[A83] Re: call, stack adresses and free space


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

[A83] Re: call, stack adresses and free space




No, that's not what I'm talking about.  Sure, "jp (hl)" is faster than
pushing and returning, but and so would storing the jump address in HL, but
then you can't use HL in the code block.

A note: "jp (hl)" would make more sense as "jp hl", since it jumps to the
address stored in HL, not the address stored at the address pointed to by HL
(it's direct, not indirect).

I was refering to something like the code below.  Yes, you could use "jp
(hl)" here, but not if you use HL.  I think I did something like that in
Zelda 86 somewhere, but no way I'd find it just glancing through source code
(13000 lines, almost 50 files, have fun).

 ld hl,MoveDone
 push hl

; read keys from ports

 rra
 jr nc,MoveDown
 rra
 jr nc,MoveLeft
; ...and so on...

MoveDown:
; ...do stuff...
 ret                     ; go to MoveDone, 1 byte
MoveLeft:
; ...more stuff...
 ret                     ; again, 1 byte

MoveDone:

> In case of HL it would of course be better to use
>
>   jp  (hl)
>
> instead of
>
>   push hl
>   ret
>
> It's a byte shorter and a lot faster






References: