A83: using hl as a label


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

A83: using hl as a label




yo ...

Now, I have a place in memory where I strore data about several units and it 
looks like this.

#DEFINE beg 82A1h 		; 708 bytes

#DEFINE hero1 beg
#DEFINE hero2 beg+60d
#DEFINE hero3 beg+120d
#DEFINE hero4 beg+180d
#DEFINE hero5 beg+240d

#DEFINE unit1 30d
#DEFINE unit2 40d
#DEFINE unit3 50d

#DEFINE type 0
#DEFINE heroN 2
#DEFINE Nofunits 3
#DEFINE x 4
#DEFINE y 5
#DEFINE hp 6
#DEFINE stat 7
#DEFINE kind 8

So to find the hitpoints of the 3rd unit of the 2nd hero.
ld a,(hero2+unit3+hp)

At a different place in the prog I have the adress of the unit in hl
and I want to add to it the offset for hitpoints....

I tried :
ld a,(hl)+hp
ld a,(hl+hp)
ld a,((hl)+hp)
and none of them work ... The assembler takes hl for a label and says "label 
not found"

I know I can do it this way
ld d,0
ld a,(hp)
ld e,a
add hl,de
a,(hl)

but it's very long and will be using this a lot of times in the game ...

Does anybody know a way to do this ?
Ideas comments ....

thanks



______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com


Follow-Ups: