[A83] Re: HL = A * 12 (fast)


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

[A83] Re: HL = A * 12 (fast)




I got ye beaten ;P Who does better?


ld     l,a
add    a,a     ; *2
add    a,l     ; *3
ld     l,a
ld     h,0
add    hl,hl   ; *6
add    hl,hl   ; *12



----- Original Message ----- 
From: "Darren" <qarnos@dingoblue.net.au>
To: <assembly-83@lists.ticalc.org>
Sent: Wednesday, April 24, 2002 7:35 AM
Subject: [A83] HL = A * 12 (fast)


> 
> 
> I wrote this little piece of code to calculate HL = A * 12. It seems to
> be a bit faster than anything else I could find, so maybe some of you
> could benefit from it, or prove me wrong! :)
> 
> It takes 46 T-states, and destroys A:
> 
>     add    a, a    ; A * 2
>     ld    l, a
>     add    a, a    ; A * 4
>     add    a, l    ; A * 6
>     ld    l, a
>     sbc    a, a
>     and    1
>     ld    h, a
>     add    hl, hl    ; A * 12
> 
> 
> 
> 
> 




Follow-Ups: References: