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:
21000000
23
23
01FFFF00
09
DAXXXX00

When running this on the CSE, it will be parsed as this:

Code:
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:
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:
ld hl, $1234[00]
bcall(_DispHL) or call _DispHL

When compiling for the CE, this would be

Code:
21003412
CDE01E02
or something like that. For the CSE, it will look like this:

Code:
213412
EFFE44

Now let's combine this into 1 program. Our frame was this:

Code:
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:
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:
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! Very Happy
I think of an easier manner:

Code:
xor a
ld a,MB        ; .db $ed,$6e   ( considered as a double-NOP on Z80-based-machines )
or a
jr z,it_s_a_Z80
And let's not forget the header is different too Smile
Very interesting! This would not be too practical for many programs, but this could be used to create something like a universal Doors installer, where the user downloads one very large program which determines the calculator and installs the correct version. Again, not too practical for most programs as they would need to be optimized for two different processors with different instruction speeds, and any values loaded into address registers would need the upper bytes to be zero. This is essentially a way of either packaging two separate programs in one, or creating small utility programs that only need to differentiate slightly. Either way, nice concept!
MateoConLechuga wrote:
And let's not forget the header is different too Smile

Yes, this damned header remains the main trouble Sad
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement