RE: A82: ASM code problem
[Prev][Next][Index][Thread]
RE: A82: ASM code problem
On Monday, July 07, 1997 6:02 PM, Thomas J. Hruska[SMTP:thruska@tir.com] wrote:
> push hl ; Temporarily store hl on the stack
> push de ; Temporarily store de on the stack
> ld hl,$38FA ; $38 -> l, $FA -> h
Well... not quite, $38 goes to H, and $FA goes to L ( you got it reversed :)
> ld de,(ROM_LOCATION) ; $00 -> e, $00 -> d
> add hl,de
This line adds DE -- what was at the address 'ROM_LOCATION' -- to $38FA, and stores it back in HL.
> ld (FINAL_ADDR),hl
This stores the result of that addition into the memory place that 'FINAL_ADDR' points to.
> pop de ; Retrieve de from the stack
> pop hl ; Retrieve hl from the stack
> call (FINAL_ADDR)
Well... CALL (FINAL_ADDR) should mean call the address that's stored at 'FINAL_ADDR', but that's not an instruction in Z80 assembly language, so I'm assuming it's supposed to be CALL_(FINAL_ADDR), which is the Zshell/Ash/Oshell-82 defines for calling even though the program will be at another place.
The function is that it pushes the current address of execution (the Program Counter (PC) is it's name), so that the function can call will be able to execute a RET, which pops the value off the stack, and returns execution to that place.
Hope this helps!
Sam
--
Sam Davies <sdavies@mail.trilogy.net>
Follow-Ups: