OpenBoot 3.x Command Reference Manual

Single-Precision Integer Arithmetic

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.