A85: holding a mem addr in hl and modifying it via (hl) to save memory


[Next][Index][Thread]

A85: holding a mem addr in hl and modifying it via (hl) to save memory




Hello,
	I am having some trouble with the registers hl.  First I have two
a memory locations that each store x and y coordinates.  I made a routine
that initializes these x and y locations by putting the temp mem location
of  the x temp mem into hl...

ld hl, (xmem)

	Once that happens I call another subroutine that puts the proper
x and y coordinates at the temp memory locations of (xmem) and (ymem). 
Because (ymem) proceeds (xmem) I thought that instead of using up
presious memory by manually loading the numbers in the two mem locations,
that I could load the mem location of (xmem) into hl and then load the
approprate value in.  Doing this I would have my x coord, and to get my y
coord all I would have to do is increment (hl) (the memory location of
xmem) and then I would have the address of (ymem) then I could load the
approprate y value in the (ymem) address stored in hl...

ld a, 20		; 20 is the x coord
ld (hl), a		; load 20 into the memory address of (xmem)
stored at hl
inc hl		; since (ymem) proceeds (xmem) in address number
inc hl
ld a, 40		; would give me the addr of (ymem) and I could
load 40 into
ld (hl), a		; the y position
ret

	It's not working correctly.  I know that what I discribed seems
very complex but I hope someone can help me.  It's not loading 20 and 40
into (xmem) and (ymem).  The reason that I must use hl is because I have
more then one set of (xmem) and (ymem) locations, thus it would be more
efficient to use one routine to initialize the coordinates of the three
sets of (xmem) and (ymem).  If my problem doesn't make any sence ignore
it and I will have to solve it myself.
	I am basicly trying to hold a memory location with hland load
numbers into the address stored at hl.
					- Mike

_____________________________________________________________________
You don't need to buy Internet access to use free Internet e-mail.
Get completely free e-mail from Juno at http://www.juno.com
Or call Juno at (800) 654-JUNO [654-5866]


Follow-Ups: References: