If you have trouble logging in, try to disable JavaScript temporarily. If that doesn't work, please contact  a d m i n @ c o d e w a l r . u s  with your account nickname.

* WalrusIRC Shoutbox (Support and development thread)

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: Cross-compatible ASM CE programs  (Read 230 times)

0 Members and 1 Guest are viewing this topic.

Offline PT_

  • Full User
  • Posts: 85
  • Post Rating Ratio: +0/-0
    • View Profile
Cross-compatible ASM CE programs
« on: April 12, 2016, 09:18:47 am »
While I was a bit working on some ASM for mr womp womp's and my project, I thought of a *good* way to have 1 ASM program, while still keeping the compability with the CSE and the CE. The main difference between that too, is the 2- or 3-byte registers. So I thought of a way to detect whether it is an CE or an CSE.
Code:
Code: [Select]
21000000
23
23
01FFFF00
09
DAXXXX00
When running this on the CSE, it will be parsed as this:
Code: [Select]
ld hl, 0 \ nop
inc hl
inc hl
ld bc, $FFFF \ nop
add hl, bc
jp c, XXXX \ nop
Since 2+$FFFF > $FFFF, it will always jump to address XXXX. In the meantime, when running at the CE, it will look like this:
Code: [Select]
ld hl, 0
inc hl
inc hl
ld bc, $FFFF00
add hl, bc
jp c, XXXX00
But since 2+$FFFF00 < $FFFFFF, this code will never jump to address XXXX00, so that address may be *random*. Now let's practice. Let's say I want to display HL where HL is equal to $1234.
The code for this is
Code: [Select]
ld hl, $1234[00]
bcall(_DispHL) or call _DispHL
When compiling for the CE, this would be
Code: [Select]
21003412
CDE01E02
or something like that. For the CSE, it will look like this:
Code: [Select]
213412
EFFE44
Now let's combine this into 1 program. Our frame was this:
Code: [Select]
21000000
23
23
01FFFF00
09
DAXXXX00
Now let's expand this. Since the calc will jump when overflow, thus when executing from the CSE, the code after the jump (NOT the jump-location) should be for the CE. So it would look like this:
Code: [Select]
21000000
23
23
01FFFF00
09
DAXXXX00
21003412
CDE01E02
C9
_Lbl_XXXX:
213412
EFFE44
C9
The last task is to figure out what the address of _Lbl_XXXX is. Just count the bytes of the code for the CE, and the bytes of the frame, and at that to _UserMem, or $0BA6, if I'm right. In my case, it would be this:
XXXX = $A623. Thus, my  final code would look like this:
Code: [Select]
21000000
23
23
01FFFF00
09
DA23A600
21003412
CDE01E02
C9
213412
EFFE44
C9
Now, let's final running this on the CSE, would look like this: http://www.rafb.me/results/w8XJmL37.html
And at the CE: http://www.rafb.me/results/M1izML20.html
Note that the stuff that can crash, will never happen.

Hope that this helps to develop cross-compatible games! :D
« Last Edit: April 12, 2016, 05:50:36 pm by DJ Omnimaga »



Offline Ivoah

  • CodeWalrus Staff
  • Super User
  • Topic Management
  • Posts: 508
  • Post Rating Ratio: +5/-0
    • @NoahRosamilia
    • Ivoah
    • @UCmgDyh_AeaHALohvR7PKXIw
    • /u/Ivoah
    • Ivoah
    • 114/11421
    • View Profile
    • Codinghobbit
  • Gender: Male
  • WalriiPoints: 100
Re: Cross-compatible ASM CE programs
« Reply #1 on: April 12, 2016, 11:52:58 am »
Isn't the AsmPrgm token different on the two calculators?
  • Calculators owned: TI-86 (now broken), TI SR-56, TI-Nspire CX CAS, TI-84+ SE, TI-84+ SE, TI-85, TI-73 Explorer VS, ViewScreen, TI-84+ CSE, TI-83+ SE

Online DJ Omnimaga

  • Omni founder & CW co-founder
  • CodeWalrus Staff
  • Super User
  • Forum Maintenance
  • Original 5
  • CodeWalrus Supporter
  • *
  • Topic Management
  • Posts: 14124
  • Post Rating Ratio: +71/-7
    • dj_omnimaga
    • DJOmnimaga.music
    • @DJOmnimaga
    • dj_omnimaga
    • @DJOmnimaga
    • /u/DJ_Omnimaga
    • DJOmnimaga
    • 112/11286
    • View Profile
    • DJ Omnimaga music store
  • Gender: Male
Re: Cross-compatible ASM CE programs
« Reply #2 on: April 12, 2016, 03:33:32 pm »
I think the token automatically changes when on a different model, right?

Also nice stuff PT_ :)
  • Calculators owned: TI-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, 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)

Offline PT_

  • Full User
  • Posts: 85
  • Post Rating Ratio: +0/-0
    • View Profile
Re: Cross-compatible ASM CE programs
« Reply #3 on: April 12, 2016, 05:03:59 pm »
I think the token automatically changes when on a different model, right?

Also nice stuff PT_ :)
No, I figured out you can't run any z80 program at the CE. When you try it, it says "invalid". Then you need a second program to change the header, ie from the ez80 to the z80 would be $EF $7B -> $EF $69.

Online DJ Omnimaga

  • Omni founder & CW co-founder
  • CodeWalrus Staff
  • Super User
  • Forum Maintenance
  • Original 5
  • CodeWalrus Supporter
  • *
  • Topic Management
  • Posts: 14124
  • Post Rating Ratio: +71/-7
    • dj_omnimaga
    • DJOmnimaga.music
    • @DJOmnimaga
    • dj_omnimaga
    • @DJOmnimaga
    • /u/DJ_Omnimaga
    • DJOmnimaga
    • 112/11286
    • View Profile
    • DJ Omnimaga music store
  • Gender: Male
Re: Cross-compatible ASM CE programs
« Reply #4 on: April 12, 2016, 05:49:02 pm »
Wow, that's strange. I was 100% sure that when you sent a program that contained Asm84Cprgm to a TI-84 Plus, it changed to AsmPrgm and vice-versa and same with the CE. I mean, when you send a TI-82 program to a TI-84+, certain TI-82 commands will change automatically. I guess this is a protection TI added to prevent people from compiling unsquished ASM programs on the wrong calculator model and risking crashing their device.
  • Calculators owned: TI-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, 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