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


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

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




Optimized.  Two bytes for redundancy elimination, one for register use.  And
incidentally, you have d and e mixed up.  You'd almost get points for
preserving de.

; ld a,(datatable+(d*5)+e)

 ld h,0
 ld l,d
 ld b,h
 ld c,l
 ld d,h
 add hl,hl
 add hl,hl
 add hl,bc
 add hl,de
 ld bc,datatable
 add hl,bc
 ld a,(hl)

> ld h,0
> ld l,e
> ld b,0
> ld c,e
> add hl,hl
> add hl,hl
> add hl,bc
> ld b,0
> ld c,d
> add hl,bc
> ld de,datatable
> add hl,de






Follow-Ups: References: