Hi all,

I'm working on writing some ez80 programs and I'm stuck at trying to call a subroutine from ADL mode, to Z80 mode.
I've tried using the .l and .s suffix on call and I've tried manually typing in the byte prefix to the call. I can't seem to get it to switch modes. When it reaches an RET, it crashes upon execution (it appears to be not returning to the correct address). I've fiddled with mb, both in code and via the emulator, I've manually corrected the address upon RET (via the emulator), and it still crashes. The only thing that I can get to work is a regular call Sad Does anyone have any tips? I'm using SPASM and CEmu and UM0077.pdf for reference.

I just want to get back to writing programs Sad Thanks!


_HomeUp      = 020828h
_ClrScrnFull = 020810h
_DispHL      = 021EE0h
.assume ADL=1
.db $EF,$7B
.org 0D1A881h
 call _HomeUp
 call _ClrScrnFull
 ld ix,op0
 ld a,$D1
 ld mb,a
 call.s mlt24
 ld hl,(ix+6)
 jp _DispHL
.assume ADL=0
;ix points to the first input
;ix+3 points to the second
;ix+6 points to the output
    ld c,(ix) \ ld b,(ix+3) \ mlt bc \ ld (ix+6),bc
    ld c,(ix+1) \ ld b,(ix+4) \ mlt bc \ ld (ix+8),bc
    ld c,(ix+2) \ ld b,(ix+5) \ mlt bc \ ld (ix+10),bc
    ld l,(ix+0) \ ld h,(ix+4) \ mlt hl
    ld c,(ix+1) \ ld b,(ix+3) \ mlt bc
    xor a
    add hl,bc \ ld (ix+12),hl
    ld l,(ix+1) \ ld h,(ix+5) \ mlt hl
    ld c,(ix+2) \ ld b,(ix+4) \ mlt bc   
    adc hl,bc \ ld (ix+14),hl \ jr nc,$+5 \ inc (ix+11)
    ld l,(ix) \ ld h,(ix+5) \ mlt hl
    ld c,(ix+2) \ ld b,(ix+3) \ mlt bc   
    add hl,bc
    ld bc,(ix+8)
    add hl,bc
    ld (ix+8),hl
    jr nc,+_
    ld hl,(ix+10)
    inc hl
    ld (ix+10),hl
    ld hl,(ix+12)
    ld bc,(ix+7)
    add hl,bc
    ld (ix+7),hl
    ld hl,(ix+14)
    ld bc,(ix+9)
    adc hl,bc
    ld (ix+9),hl
    ret nc
    inc (ix+11)
.echo $-mlt24
.echo $-0D1A881h
; 0112
; 1021
;  02
;  20
    .db 1,2,3
    .db 1,2,3
    .db 0,0,0,0,0,0
    .db 0,0,0,0

I'm sure I just missed some piece of documentation or misinterpreted something; I'd appreciate the help.
It goes something like this:

   ld   a,$d1
   ld   mb,a
   ld.sis   sp,$987e
   call.is   z80routine & $ffff
   ld   a,$d0
   ld   mb,a

   .assume adl=0


   .assume adl=1

Hope this helps Smile If you want to leave interrupts enabled you would need to relocate your code to saferam, which allows you to avoid changing mbase. Keep in mind the z80 routine should return with ret.l
Thanks a bunch! This totally worked Smile
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