Re: A82: JP CR_KHAND <--???


[Prev][Next][Index][Thread]

Re: A82: JP CR_KHAND <--???




>CrASH People:
>
> I knew you can do call CR_KHAND, but had no idea that you could 'jump' 
>to that. It works really good for waiting till enter is pressed then 
>exiting. I was just wondering what other functions you can 'jump' to in 
>CrASH. This is not documented in any text files. And why does this work?

Anything that isn't called with a ROM_CALL.  Remember that CALL is the
same thing as PUSH IP \ JP whatever.  If you don't push the return
address the ret within the jumped routine will return from the calling
(jumping) function.  Look at it like this:

your_program:
        call your_routine
        ld hl,string
        ROM_CALL(D_ZT_STR)
        ret

your_routine:
        jp whatever

whatever:
        ret

string:
        .db "Hi there!",0

As you can see, the ret returns the calling routine.  CR_KHAND is no
different, other than the fact that you can't see source code.  You
can't do a ROM_CALL (note the difference between a ROM call (a routine
in ROM) and ROM_CALL (a method of calling certain ROM routines)) because
the return address of the calling function is needed to read the 2 bytes
after the CALL $whatever that the ROM_CALL does.  If you felt like it,
you could do JP CP_HL_DE if your intent is do a CP HL,DE then ret.
Think of JP when used like this as a CALL then a RET.

-- Barubary


Follow-Ups: