Re: ASM code problem
[Prev][Next][Index][Thread]
Re: ASM code problem
Thomas J. Hruska (thruska@TIR.COM) wrote:
: As you all have been noticing lately, I have been pretty active on this
: mailing list. Remember, I am the writer of the ASH <-> OShell-82
: Development Kit. I am also adding two major improvements in the next two
: versions. I need a little help with some code.
:
: push hl ; Temporarily store hl on the stack
: push de ; Temporarily store de on the stack
: ld hl,$38FA ; $38 -> l, $FA -> h
: ld de,(ROM_LOCATION) ; $00 -> e, $00 -> d
: add hl,de
: ld (FINAL_ADDR),hl
: pop de ; Retrieve de from the stack
: pop hl ; Retrieve hl from the stack
: call (FINAL_ADDR)
:
: Could someone please go through and tell me what each of the uncommented
: lines does (in terms of $38 and $FA). Also, I need to know how the call
: statement works (how it reads the value located in FINAL_ADDR).
add hl,de simply adds the contents of the 2 registers and puts the result
in hl.
ld (FINAL_ADDR),hl stores the result in memory location FINAL_ADDR
call (FINAL_ADDR) doesnt seem valid to me. The parentheses imply an
indirect call and I don't believe the Z80 can do that. CALL FINAL_ADDR
would be a valid instruction but given the logic in your code above, I
think it would probabaly crash. A way to do what seems to be implied by
that line would be CALL FINAL_ADDR-1, being sure there was a jp opcode
before FINAL_ADDR.
Call normally pushes the address of the next instruction on the stack
and branches to the address given as an immediate value. It seems that
this code is trying to determine the correct branch address and call it.
As stated above I don't believe it would work. But I'm not really a Z80
programmer and I don't know all the tricks of the assembler you're using.
Barry
References: