Re: A86: simple math optimization


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

Re: A86: simple math optimization




>This assumes E<16, but I guess that is the case (else 16*D+E is a strange
>operation to make). Could be changed to support E>=16 as well, without
>losing that many T cycles.


Yes. This routine works and has no limits, only 59 cycles. Any
optimizations?

BTW I tested this out, so it actually works

-Matt
    http://www.dogtech.com/cybop/ti86/


 ; 59 T Cycles

 ;HL = (16 * d) + e
 ;      H, L, D, & A registers modified
 ;       D or E can be from 0..255 no limits

 xor a    ; 4T  | Clear A and carry flag
 ld h, a    ; 4T  | Clear H
 ld l, d    ; 4T  | HL = D

 sla l
 rl h    ; 8T  | 16-bit rotation, HL = HL * 2
 sla l
 rl h    ; 8T  | * 2
 sla l
 rl h    ; 8T  | * 2
 sla l
 rl h    ; 8T  | * 2, So HL = HL * 16

 ld d, a    ; 4T  | Clear D
 add hl, de   ; 11T | HL = HL + E



Follow-Ups: