F21 Simulator/Emulator
- To: "Jeff Fox" <jfox@xxxxxxxx>
- Subject: F21 Simulator/Emulator
- From: "Mark Tillotson" <markt@xxxxxxx>
- Date: Sat, 7 Nov 1998 20:54:56 -0400
- Cc: "MISC@xxxxx rockefeller. edu" <MISC>
- Importance: Normal
- Old-Date: Sat, 7 Nov 1998 16:56:17 -0800
- ReSent-Date: Sat, 16 Jan 1999 17:57:54 -0500
- ReSent-From: Penio Penev <penev@xxxxxxx>
- ReSent-Message-ID: <Pine.SGI.4.05.9901161757540.27801@venezia.rockefeller.edu>
- ReSent-Subject: F21 Simulator/Emulator
- ReSent-To: MISC
Dear Jeff,
I am one of those people (of whom I am sure there are quite a few),
who have simply been waiting for some real working hardware before
beginning to do some real experimenting with your F21 technology.
I took the time recently, however, to download your simulator and
run the demos. I then thought that it would be interesting
to try to produce some sample code, thinking that it should be
relatively easy since I have been following the Mup21 for a long time
now (and I have the programming manual for it). It was a very
educational experience trying to produce tight code for the F21 MISC
instruction set. The algorithm which I chose to implement was an
integer square root routine. I still think that I seem to have too
many nop's in it but here it is. I am planning to start work on a
DCT routine next, and then maybe an MPEG 4 audio decoder?! (but I
probably won't find enough time for it before MPEG 5,6 or ?? comes
out since I am kept quite busy with my job and a family with four
young kids). In any case, thank you very much for the work which
you are doing to provide an alternative to the bloated direction
most of the computer industry is stampeding in. I will download
your emulator, and I am sure that it will help me in my modest
efforts.
Thanks again,
Mark
------------------------------------------------------------------
Mark Tillotson -- Mechanical Design Group Leader
CTF Systems Inc. Ph: (604) 941-8561
15-1750 McLean Ave. Fax: (604) 941-8565
Port Coquitlam, B.C. email: markt@ctf.com
Canada V3C 1M9 Web Page: http://www.ctf.com
-------------------------------------------------------------------
\ 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
com over nop nop \ -xr>r-xr
+ -if \ fr
drop 2 # nop nop \ r>1r
+ dup nop nop \ r>rr
then
drop 2/ pop a! \ r
;'
I started from this c routine which I found at:
http://www.cs.waikato.ac.nz/~rbg/sqrt/
// Integer Square Root function
// Uses bisection to find square root
unsigned long isqrt(unsigned long x)
{
unsigned long r, s, t;
r = 0;
for (t=0x40000000; t; t>>= 2)
{
s = r + t;
if (s <= x)
{
x -= s;
r = s + t;
}
r >>= 1;
}
return(r);
}