[A83] Re: Getting a value from a data table


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

[A83] Re: Getting a value from a data table




> 
> If I had a data table, and I wanted to load a value from it into any 
> register, how would I do this?
> 
> datatable:
>  .db  01,03,05,07,09       ; I'm including 0's so the table is aligned
>  .db  02,04,06,08,10
>  .db  11,13,15,17,19
   .db  24,32,43,21,31
> 
> For example, if I wanted to load the value at 4,3 into de, would I do 
> something like:
> ld   de,datatable*4+3       

Personally i'd go for
ld de, datatable + (4*5) +3  ; start table + ((4)* row length [to select 4rth 
column]) + 3 
 
this assumes 0,0 is the origin, not 1,1

> so de is now 13, which was at 4,3 in the data table
> 
> Thanks,
> Colin Hart   
> Xempest@aol.com
> 
> 
> 





References: