[A83] Re: square


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

[A83] Re: square




You're better off just multiplying.  But for multiplying/dividing by powers 
of 2, add a,a and rra+and %xxxxxxxx can't be beat.

To square a number:

ld a,4
ld l,a
ld h,a
bcall (_htimesl)
(hl = 4^2)


AVOID using sla whenever possible.  Use add a,a instead.  (use sla when 
working with a different register)

Same for srl: use rra, and if more than once, AND away only what bits you 
want to keep afterwards.

SLA = 2 bytes.  add a,a = 1 byte.
SRL = 2 bytes.  rla = 1 byte, and = 2 bytes.


>From: "Jan (belgacom)" <jandebeule@belgacom.net>
>Reply-To: assembly-83@lists.ticalc.org
>To: "TI-83 assembly-83" <assembly-83@lists.ticalc.org>
>Subject: [A83] square
>Date: Wed, 25 Apr 2001 20:13:47 +0200
>
>Does anybody know how to square numbers (number^2) using bit-level
>instructions (like sla or sra)?
>
>
>
>

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com