Bug in my F21 integer square root routine
- To: "Jeff Fox" <jfox@xxxxxxxx>
- Subject: Bug in my F21 integer square root routine
- From: "Mark Tillotson" <markt@xxxxxxx>
- Date: Tue, 10 Nov 1998 02:35:26 -0400
- Cc: "MISC@xxxxx rockefeller. edu" <MISC>
- Importance: Normal
- Old-Date: Mon, 9 Nov 1998 22:37:00 -0800
- ReSent-Date: Sat, 16 Jan 1999 17:58:01 -0500
- ReSent-From: Penio Penev <penev@xxxxxxx>
- ReSent-Message-ID: <Pine.SGI.4.05.9901161758010.27801@venezia.rockefeller.edu>
- ReSent-Subject: Bug in my F21 integer square root routine
- ReSent-To: MISC
Dear Jeff,
I found a ?minor? bug in my integer square root routine.
I mistakenly used com and thought negate. The corrected
routine follows.
Sorry about that,
Mark
P.S. The new emulator is very nice, but you should
mention that it needs EMS memory enabled (not the default
on my WindowsNT machine). It took me awhile to figure this
out since the window disapears too quickly to read the error
message.
\ F21 20 bit Integer Square Root
': sqi ( xr --- xr |a=t )
dup com A nop \ xxr>-xxr>t-xxr
+ -if \ fxr
push over pop nop \ xr|f>rxr|f>frxr|
+ -if \ fxr
com push drop A \ x'xr>xr|x'>r|x'>tr|x'
2* nop nop nop \ tr|x'
+ pop dup nop \ r'|x'>x'r'>x'x'r'
then
then
drop push 2/ pop \ xr>r|x>r|x>xr
A 2/ 2/ A! \ txr>txr>txr>xr
;'
': isqrt ( x --- x )
a push 40000 # a! \ ax>x|a>tx|a>x|a
push 0 # pop nop \ |xa>r|xa>xr|a
sqi
sqi
sqi
sqi
sqi
sqi
sqi
sqi
sqi
over com nop nop \ -xr>r-xr >>> was: com over nop nop
+ com nop nop \ -fr>fr >>> was: + -if
-if \ fr >>> new: line
drop 2 # nop nop \ r>2r
+ dup nop nop \ r>rr
then
drop 2/ pop a! \ r
;'----