LZ: RE: tables


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

LZ: RE: tables



I believe that the error is in
	ld de,RandNum
If you want to put the number AT RandNum into de, use
	ld de,(RandNum)
You made that mistake in the actual code, but you had it right in the generic 
example.
--MZB
----------
From: 	owner-list-zshell@defiant.rbk.sollentuna.se on behalf of Steve Peterson
Sent: 	Thursday, July 04, 1996 3:09 PM
To: 	list-zshell@defiant.rbk.sollentuna.se
Subject: 	LZ: tables


I need to know how to set up a table that is 95 bytes long.  I need to be able 
to place a value at a specific 
element number.  I also need to be able to retrieve the value stored at any 
element number.


Here is what I have so far:


RandNum = $80E1


Place:
        CALL_(Random)
        ld hl,Table
        ld de,RandNum
        add hl,de
        ld a,1
        ld (hl),a
        ret
;----------------------------------------------------------------------------
;(Random number routine: Returns number between 0 and 95)
Random:
        ld a,r
        cp 96
        jr nc,Random
        cp 0
        jr c,Random
        ld (RandNum),a
        ret


To retrieve a value do I:?


Retrieve:
	ld hl,Table
	ld de,(Element I want to retrieve)
	add hl,de
	ld a,(hl)
	ret




As far as I can see, this should work, but for some reason it doesn't, I'm new 
so I'm sure it's something 
stupid, but if anyone can help me I'd really appreciate it, thanks


 _
(_
|_)teve
|eterson


vestige@ddt.net