The commands listed in Table 4-5 perform single-precision arithmetic.
Table 4-5 Single-Precision Arithmetic Functions
Command |
Stack Diagram |
Description |
---|---|---|
+ |
( nu1 nu2 -- sum ) |
Adds nu1 + nu2. |
- |
( nu1 nu2 -- diff ) |
Subtracts nu1 - nu2. |
* |
( nu1 nu2 -- prod ) |
Multiplies nu1 times nu2. |
*/ |
( n1 n2 n3 -- quot ) |
Calculates nu1 * nu2 / n3. Inputs, outputs and intermediate products are all one cell. |
/ |
( n1 n2 -- quot ) |
Divides n1 by n2; remainder is discarded. |
1+ |
( nu1 -- nu2 ) |
Adds one. |
1- |
( nu1 -- nu2 ) |
Subtracts one. |
2+ |
( nu1 -- nu2 ) |
Adds two. |
2- |
( nu1 -- nu2 ) |
Subtracts two. |
abs |
( n -- u ) |
Absolute value. |
bounds |
( start len -- len+start start ) |
Converts start,len to end,start for do or ?do loop. |
even |
( n -- n | n+1 ) |
Round to nearest even integer >= n. |
max |
( n1 n2 -- n3 ) |
n3 is maximum of n1 and n2 |
min |
( n1 n2 -- n3 ) |
n3 is minimum of n1 and n2 |
mod |
( n1 n2 -- rem ) |
Remainder of n1 / n2. |
*/mod |
( n1 n2 n3 -- rem quot ) |
Remainder, quotient of n1 * n2 / n3. |
/mod |
( n1 n2 -- rem quot ) |
Remainder, quotient of n1 / n2. |
negate |
( n1 -- n2 ) |
Change the sign of n1. |
u* |
(u1 u2 -- uprod ) |
Multiply 2 unsigned numbers yielding an unsigned product. |
u/mod |
( u1 u2 -- urem uquot ) |
Divide unsigned one-cell number by an unsigned one-cell number; yield one-cell remainder and quotient. |
<< |
( x1 u -- x2 ) |
Synonym for lshift. |
>> |
( x1 u -- x2 ) |
Synonym for rshift. |
2* |
( x1 -- x2 ) |
Multiply by 2. |
2/ |
( x1 -- x2 ) |
Divide by 2. |
>>a |
( x1 u -- x2 ) |
Arithmetic right-shift x1 by u bits. |
and |
( x1 x2 -- x3 ) |
Bitwise logical AND. |
invert |
( x1 -- x2 ) |
Invert all bits of x1. |
lshift |
( x1 u -- x2 ) |
Left-shift x1 by u bits. Zero-fill low bits. |
not |
( x1 -- x2 ) |
Synonym for invert. |
or |
( x1 x2 -- x3 ) |
Bitwise logical OR. |
rshift |
( x1 u -- x2 ) |
Right-shift x1 by u bits. Zero-fill high bits. |
u2/ |
( x1 -- x2 ) |
Logical right shift 1 bit; zero shifted into high bit. |
xor |
( x1 x2 -- x3 ) |
Bitwise exclusive OR. |
The commands listed in Table 4-6 perform double number arithmetic.
Table 4-6 Double Number Arithmetic Functions
Command |
Stack Diagram |
Description |
---|---|---|
d+ |
( d1 d2 -- d.sum ) |
Add d1 to d2 yielding double number d.sum. |
d- |
( d1 d2 --d.diff ) |
Subtract d2 from d1 yielding double number d.diff. |
fm/mod |
( d n -- rem quot ) |
Divide d by n. |
m* |
( n1 n2 -- d ) |
Signed multiply with double-number product. |
s>d |
( n1 -- d1 ) |
Convert a number to a double number. |
sm/rem |
( d n -- rem quot ) |
Divide d by n, symmetric division. |
um* |
( u1 u2 -- ud ) |
Unsigned multiply yielding unsigned double number product. |
um/mod |
( ud u -- urem uprod ) |
Divide ud by u. |
The commands listed in Table 4-7 perform data type conversion.
Table 4-7 32-Bit Data Type Conversion Functions
Command |
Stack Diagram |
Description |
---|---|---|
bljoin |
( b.low b2 b3 b.hi -- quad ) |
Join four bytes to form a quadlet |
bwjoin |
( b.low b.hi -- word ) |
Join two bytes to form a doublet. |
lbflip |
( quad1 -- quad2 ) |
Reverse the bytes in a quadlet |
lbsplit |
( quad -- b.low b2 b3 b.hi ) |
Split a quadlet into four bytes. |
lwflip |
( quad1 -- quad2 ) |
Swap the doublets in a quadlet. |
lwsplit |
( quad -- w.low w.hi ) |
Split a quadlet into two doublets. |
wbflip |
( word1 -- word2 ) |
Swap the bytes in a doublet. |
wbsplit |
( word -- b.low b.hi ) |
Split a doublet into two bytes. |
wljoin |
( w.low w.hi -- quad ) |
Join two doublets to form a quadlet. |
The data type conversion commands listed in Table 4-8 are available only on 64-bit OpenBoot implementations.
Table 4-8 64-Bit Data Type Conversion Functions
Command |
Stack Diagram |
Description |
---|---|---|
bxjoin |
( b.lo b.2 b.3 b.4 b.5 b.6 b.7 b.hi -- o ) |
Join eight bytes to form an octlet. |
lxjoin |
( quad.lo quad.hi -- o ) |
Join two quadlets to form an octlet. |
wxjoin |
( w.lo w.2 w.3 w.hi -- o ) |
Join four doublets to form an octlet. |
xbflip |
( oct1 -- oct2 ) |
Reverse the bytes in an octlet. |
xbsplit |
( o -- b.lo b.2 b.3 b.4 b.5 b.6 b.7 b.hi ) |
Split an octlet into eight bytes. |
xlflip |
( oct1 -- oct2 ) |
Reverse the quadlets in an octlet. The bytes in each quadlet are not reversed. |
xlsplit |
( o -- quad.lo quad.hi ) |
Split on octlet into two quadlets. |
xwflip |
( oct1 -- oct2 ) |
Reverse the doublets in an octlet. The bytes in each doublet are not reversed. |
xwsplit |
( o -- w.lo w.2 w.3 w.hi ) |
Split an octlet into four doublets. |
The commands listed in Table 4-9 perform address arithmetic.
Table 4-9 Address Arithmetic Functions
Command |
Stack Diagram |
Description |
---|---|---|
aligned |
( n1 -- n1 | a-addr) |
Increase n1 if necessary to yield a variable aligned address. |
/c |
( -- n ) |
The number of address units to a byte: 1. |
/c* |
( nu1 -- nu2 ) |
Synonym for chars. |
ca+ |
( addr1 index -- addr2 ) |
Increment addr1 by index times the value of /c. |
ca1+ |
( addr1 -- addr2 ) |
Synonym for char+. |
cell+ |
( addr1 -- addr2 ) |
Increment addr1 by the value of /n. |
cells |
( nu1 -- nu2 ) |
Multiply nu1 by the value of /n. |
char+ |
( addr1 -- addr2 ) |
Increment addr1 by the value of /c. |
chars |
( nu1 -- nu2 ) |
Multiply nu1 by the value of /c. |
/l |
( -- n ) |
Number of address units to a quadlet; typically 4. |
/l* |
( nu1 -- nu2 ) |
Multiply nu1 by the value of /l. |
la+ |
( addr1 index -- addr2 ) |
Increment addr1 by index times the value of /l. |
la1+ |
( addr1 -- addr2 ) |
Increment addr1 by the value of /l. |
/n |
( -- n ) |
Number of address units in a cell. |
/n* |
( nu1 -- nu2 ) |
Synonym for cells. |
na+ |
( addr1 index -- addr2 ) |
Increment addr1 by index times the value of /n. |
na1+ |
( addr1 -- addr2 ) |
Synonym for cell+. |
/w |
( -- n ) |
Number of address units to a doublet; typically 2. |
/w* |
( nu1 -- nu2 ) |
Multiply nu1 by the value of /w. |
wa+ |
( addr1 index -- addr2 ) |
Increment addr1 by index times the value of /w. |
wa1+ |
( addr1 -- addr2 ) |
Increment addr1 by the value of /w. |
The address arithmetic commands listed in Table 4-10 are available only on 64-bit OpenBoot implementations.
Table 4-10 64-Bit Address Arithmetic Functions
Command |
Stack Diagram |
Description |
---|---|---|
/x |
( -- n ) |
Number of address units in an octlet, typically eight. |
/x* |
( nu1 -- nu2 ) |
Multiply nu1 by the value of /x. |
xa+ |
( addr1 index -- addr2 ) |
Increment addr1 by index times the value of /x. |
xa1+ |
( addr1 -- addr2 ) |
Increment addr1 by the value of /x. |