Re: A86: arrays


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

Re: A86: arrays




MikeT843@aol.com wrote:

> How would i create an array with Asm?

Well, a nice C array is never going to happen...
int array[20] isnt exactly something that an asm programmer can deal
with :o)
The easiest thing to do is figure out the number of elements you need
and the size that it will take, and just clear off that space at the end
of _asm_exec_ram or on RAM page 1. You may also need to write some
routines for adding and such...you could probably do it with compiler
macro's or something.
#define ARRAY_START _asm_exec_ram + 4000
#define ELEMENT_SIZE 4  ;4 bytes per element
#define array_add(X) ld hl,ARRAY_START \ ld de,X*ELEMENT_SIZE \ add
hl,de   (x is the element to point to...)

That ought to do it...tho it is certainly a primative example.

us it like this:

 array_add(4)
 ld a,(hl)

a now has the first byte of the 4th element.

hope this helps,
Chicane



Follow-Ups: References: