| Computers Forum Index » Computer Architecture - Arithmetic » * and / using same step operation!!... |
|
Page 1 of 1 |
|
| Author |
Message |
| jacko... |
Posted: Thu Jan 08, 2009 12:41 am |
|
|
|
Guest
|
hi
some forth code for demonstration of ringfield number theory applied
to reducing the size of divide multiply operations.
c*/ is the basic operation which both will do divide and multiply ...
( ringfield demo )
Code dont ( exit no restore for /step )
RI RI FE BA
End-Code
: /step >r 2* r at (no spam) + cskip dont r at (no spam) negate u+ r> BA ;
: c*/ /step /step /step /step /step /step /step /step drop ;
\ character mul div support, safe to 7 bit, and most 8 bit sets
: c* ( c1 c2 -- c1*c2 )
$8000 + swap invert u2*8 swap c*/ ;
: c/ ( c1 c2 -- rem*256+quot )
negate clc u2*8 1+ c*/ ;
: udont RI 2r> ;
: u/step 2>r d2* 2r at (no spam) d+ cskip udont 2r at (no spam) dnegate d+ 2r> ;
: (um*/) u/step u/step u/step u/step u/step u/step u/step u/step ;
: um*/ (um*/) (um*/) 2drop ;
: um* 0 -rot swap invert swap $8000 um*/ ;
: um/mod 0 swap 1 swap negate um*/ ; |
|
|
| Back to top |
|
|
|
|