* WalrusIRC

You need to have 5 posts and not be part of restricted usergroups in order to use the WalrusIRC embedded shoutbox. However, you can also access our IRC channel called #CodeWalrus via EFnet.

Author Topic: Heavy Metal on TI-92 Plus  (Read 3435 times)

0 Members and 1 Guest are viewing this topic.

Offline utz

  • Full User
  • Join Date: Jun 2015
  • Location: Absurdistan
  • Posts: 150
  • Post Rating Ratio: +11/-0
  • 01000101110
    • utz82
    • utz's hp
  • WalriiPoints: 50
Re: Heavy Metal on TI-92 Plus
« Reply #15 on: April 21, 2016, 07:09:23 pm »
I'm afraid at this point even Lionel can't help me... that bit of code by itself can't be causing the problem, as in effect it does nothing at all. I'm sure the problem must be elsewhere. I mainly needed to vent my frustration, so thanks for the consolidating words @DJ Omnimaga.

I've got a hunch about what's going on by now. My guess is that those stack-based size optimizations that Lionel proposed need some modification, because in their current form they will mess up the registers when an interrupt triggers between those 2-step instructions. But that I will investigate... tomorrow, maybe.
  • Calculators owned: TI-82, TI-83, TI-83+, TI-85, TI-86, TI-92+, Sharp PC-1403

Offline Lionel Debroux

  • Full User
  • Join Date: Jan 2015
  • Location:
  • Posts: 231
  • Post Rating Ratio: +11/-0
    • debrouxl
    • 58/5891
Re: Heavy Metal on TI-92 Plus
« Reply #16 on: April 22, 2016, 11:54:57 am »
Most of the size optimizations I proposed are stack-based, yeah. But if the mere fact of switching to e.g. move.l xxx.w,xxx.w fixes the crash, then that would be a sign that your code is really unsafe, and you're just papering over the real issue.
To prevent reentrance from the same interrupt, the whole critical section of code should be executed from within the interrupt handler, i.e. before the RTE. Which means you wouldn't need to play games with the return address, either.

[EDIT: fixed typo]
« Last Edit: April 22, 2016, 02:20:20 pm by Lionel Debroux »
Member of the TI-Chess Team.
Co-maintainer of GCC4TI (GCC4TI online documentation), TIEmu and TILP.
Co-admin of TI-Planet.

Offline utz

  • Full User
  • Join Date: Jun 2015
  • Location: Absurdistan
  • Posts: 150
  • Post Rating Ratio: +11/-0
  • 01000101110
    • utz82
    • utz's hp
  • WalriiPoints: 50
Re: Heavy Metal on TI-92 Plus
« Reply #17 on: April 22, 2016, 02:15:10 pm »
Yeah, you're right. And those optimizations were not the problem, after all. Also I agree, not fiddeling with the return addresses would be nice, but I don't see how to do it without a major (unacceptable) increase in step-to-step transition noise.

So what was the problem? Well, I didn't realize that after running the timer detection loop, AUTO_INT_5 would fire immediately (ie. during TRAP #1). Which of course causes trouble when the AUTO_INT_5 vector has been modified  :banghead:

Aaaaanyway... before I package a new release, would one of you be so kind to test the TI-89 build? (upload both attached files and boot with "qed68()")
Also, updated source is available at https://github.com/utz82/qed68 for further examination.
  • Calculators owned: TI-82, TI-83, TI-83+, TI-85, TI-86, TI-92+, Sharp PC-1403

Offline Lionel Debroux

  • Full User
  • Join Date: Jan 2015
  • Location:
  • Posts: 231
  • Post Rating Ratio: +11/-0
    • debrouxl
    • 58/5891
Re: Heavy Metal on TI-92 Plus
« Reply #18 on: April 22, 2016, 03:06:10 pm »
I haven't tested your program, but I can see other optimizations:
* the branches in the rdch area should be short (smaller);
* bclr #0,($60000E); bclr #1,($60000E) should be replaced by a single and (smaller, faster).
* bra \nx[1234] should be short (smaller): unconditional branches are 10 cycles, whether they're short or word;
* in rdseq, movea.l (seqpntr),a0 should be PC-relative (smaller). This one doesn't seem to be part of an area with carefully crafted timings;

For maintainability, you should have used appropriately named macros, instead of open-coding so many
* or.l d0,d0
* move.l (a7),-(a7); addq.l #4,a7
* move.l 1(a<n>),a<n> immediately followed by bra \nx(<n-1>) (I have noticed the occasional move in-between, for timing purposes).
* cmp.b (a<n>),d0 immediately followed by beq \resetsmp<n-1>;
* the 4 5-instruction sequences at the beginning of every core* subroutine, unless writing to the link port requires otherwise;
* the 6-instruction sequence at every \nx4 label, only core2[234] seem to be different due to writing to the link port.

A pessimization: disabling vector table protection only for short periods of time, when you're actually modifying its contents, instead of disabling it for the whole duration of your program :)
« Last Edit: April 22, 2016, 03:10:09 pm by Lionel Debroux »
Member of the TI-Chess Team.
Co-maintainer of GCC4TI (GCC4TI online documentation), TIEmu and TILP.
Co-admin of TI-Planet.

Offline utz

  • Full User
  • Join Date: Jun 2015
  • Location: Absurdistan
  • Posts: 150
  • Post Rating Ratio: +11/-0
  • 01000101110
    • utz82
    • utz's hp
  • WalriiPoints: 50
Re: Heavy Metal on TI-92 Plus
« Reply #19 on: April 22, 2016, 04:00:51 pm »
Thanks Lionel, I'll look into these.

Branches are auto-optimized via the .tpr, so they should always be short. But I can add the .s to make the code more portable. Forgot about re-enabling vector table protection, will take care of that.

I very much dislike macros. I do see why others find them convenient, but for me, they decrease readability of the code too much.  So since I'm the one who has to maintain this code, I prefer to keep the text bloat, sorry.

Edit: Changes done, latest test build for TI-89 attached.
« Last Edit: April 22, 2016, 06:52:47 pm by utz »
  • Calculators owned: TI-82, TI-83, TI-83+, TI-85, TI-86, TI-92+, Sharp PC-1403

Offline xlibman

  • Omni founder & CW co-founder
  • Super User
  • Original 5
  • CodeWalrus Supporter
  • *
  • Join Date: Nov 2014
  • Location: Quebec, Canada
  • Posts: 18902
  • Post Rating Ratio: +100/-5
    • dj_omnimaga
    • DJOmnimaga.music
    • @DJOmnimaga
    • dj_omnimaga
    • @DJOmnimaga
    • /u/DJ_Omnimaga
    • DJOmnimaga
    • 112/11286
    • @djomnimaga
    • @DJOmnimaga
    • DJ Omnimaga music store
  • Gender: Male
Re: Heavy Metal on TI-92 Plus
« Reply #20 on: April 22, 2016, 09:50:52 pm »
I'll give this a try on a calculator later if I can find my adapter and some batteries. :)
  • Calculators owned: TI-57, 73, TI-80 (broken), TI-81, TI-82, TI-83, TI-83+ (broken), TI-83+ (broken), TI-83+SE (broken), TI-84+, TI-84+CSE, TI-84+CE, TI-85, TI-86, TI-89T, TI-92, TI-Nspire, TI-Nspire CX (semi-broken), HP 39gII, HP Prime, Casio fx-7000G, fx-7400G+, fx-7700GE, fx-9750G+, fx-9750GII, fx-9860G, cfx-9850G, FX-1.0+, fx-CG10, fx-CP400
  • Consoles, mobile devices and vintage computers owned: Samsung i5510, Nexus 5, Atari 2600, Lynx, SMS, Game Gear, Genesis, Dreamcast, NES, SNES, N64, GCN, Wii, Wii U, GBA, DS, 3DS, PS2, PS3, PS4, PSP, PSVita, XBox 360, XBOne

Bandcamp|Reverbnation|Facebook|Youtube|Twitter
Retired Omnimaga admin (2001-11) and editor (2012-14)

 


You can also use the following HTML or bulletin board code to share it on your page or forum signature!


Also do not forget to check our affiliates below.
Planet Casio TI-Planet Calc.news BroniesQC BosaikNet Velocity Games