MATHEMATICAL OPERATIONS
These are abbreviated details from the section WORD
LIST grouped here for convenience, see that section for notation definition.
Only integer mathematics in the Forth ROM is shown, see below for a summary
of integer extensions, floating point and other methods.
*

( n1 n2  n1*n2 )


*/

( n1 n2 n3  n4 )

Scale n1 by ratio n2/n3

*/MOD

( n1 n2 n3  n4 n5 )

Leave quotient n5 and remainder
n4 of operation n1*n2/n3

+

( n1 n2 
n1+n2 )


+!

( n addr
 )

Add n to value at address

+

( n1 n2 
n3 )

Apply sign of n2 to n1, which is left as n3



( n1 n2 
n1n2 )


/

( n1 n2 
n1/n2 )


/MOD

( n1 n2 
rem quot )

Leave remainder and signed quotient n1/n2

0<

( n  f )

True if number less than zero

0=0=

( n  f )

f=1 if n not zero, f=0 if n is zero

0=

( n  f )

True if number equal to zero

0>

( n  f )

True if number greater than zero

1+

( n  n+1 )


1

( n  n1 )


2*

( n  n*2 )


2+

( n  n+2 )


2

( n  n2 )


2/

( n  n/2 )


<

( n1 n2 
f )

True if n1 less than n2

<>

( n1 n2 
f )

True if n1 not equal to n2

=

( n1 n2 
f )

True if n1 equal to n2

>

( n1 n2 
f )

True if n1 greater than n2

ABS

( n  u )

Leave absolute value u of number n

C+!

( b a  )

Add lower byte of second item on the stack to byte at
addr

D*/

( d1 n1 n2
 d2 )

Scale double number d1 by ratio n1/n2

D*S

( d1 n 
d2 )

d2 = d1 * n

D+

( d1 d2 
d1+d2 )


D+

( d1 n 
d2 )

Apply sign of n to d1, which is left as d2

D

( d1 d2 
d1d2 )


D/

( d1 d2 
n )

n = d1 / d2

D/S

( d1 n 
d2 )

d2 = d1 / n

D0=

( d  f )

True if double number equal to zero

D<

( d1 d2 
f )

True if d1 less than d2

D=

( d1 d2 
f )

True if d1 equal to d2

DABS

( d  ud )

Leave absolute value ud of double number d

DMINUS

( d1  d2 )

d2 = d1

M*

( n1 n2 
d )

d = n1 * n2

M+

( d1 n 
d2 )

d2 = d1 + n

M/

( d n  n2
n3 )

Leave remainder n2 and quot. n3 of d/n

M/MOD

( ud1 u2
 u3 ud4 )

Leave remainder u3 and quotient ud4 of ud1/u2

MAX

( n1 n2 
n3 )

n3 is the greater of n1 and n2

MIN

( n1 n2 
n3 )

n3 is the lesser of n1 and n2

MINUS

( n1  n2 )

n2 = n1

MOD

( n1 n2 
n3 )

n3 is the remainder of n1/n2

S>D

( n  d )

Sign extend single number n to form double number d

T*

( ud u 
ut )

ud * u giving 48bit product

T/

( ut u 
ud )

ut / u 48bit integer divided by single to give double
integer

U*

( u1 u2 
ud )

ud = u1 * u2

U*/

( ud1 u1 u2  ud2 )

Scale unsigned double number
ud1 by ratio u1/u2

U/

( ud u1  u2 u3 )

Leave remainder u2 and
quotient u3 of ud/u1

U<

( u1 u2 
f )

True if u1 less than u2

INTEGER TYPES (Forth ROM and _MATH.TDS)
Use integer (16bit) or doubleinteger (32bit) where possible
because you get the best speed. Scaling the input and output to fit in the range
�2,000,000,000 generally allows this.
Integer functions in the Forth ROM are shown above but in the
file _MATH.TDS there is a wide range of others available including 48bit arithmetic,
logarithms and exponentials.
FIXED POINT (_FIXED.TDS)
Uses 32bit integer arithmetic for speed and accuracy but has
fixed decimal point for input and output. You can choose between 0 and 4 decimal
places.
FRACTIONAL ARITHMETIC (Forth ROM
and _SQRT.TDS)
This u ses 16bit integer
arithmetic for speed. You scale input and output to the range �2.000 before
using the mathematical operations. Apart from the main four functions and conversion
words, sine, cosine, logarithms, exponentials and square roots are provided.
FLOATING POINT (TDSFLOAT  optional extra)
DESCRIPTION
The package TDSFLOAT is a fullyfeatured floating point and
extended string handling package for the TDS9092. It is available as an option.
Use the parts of it you need in your application code.
However be sure you really need floating point. Floating point
arithmetic enables very small numbers (like 0.0000000001) to very large numbers
(like 3000000000000) to be handled at the same time. This is very rarely needed
and the extensive 32bit double number arithmetic routines in the TDS9092 cater
for most needs. These can handle from 0 to �2000000000, or 0.00000 to �20000.00000
for example.
Occasions do arise where floating point would be useful. TDSFLOAT
is available in source code on a PC format disk. Apart from normal calculator
functions, a full range of trigonometrical and log/exponential functions is
included with accuracy 8 to 10 decimal digits. There are also string extensions
to give Forth equivalents of the string handling words in BASIC. A manual with
a printed source listing is provided.
TYPICAL PERFORMANCE
Floating point multiply F*

8ms

Floating point divide
F/

53ms

Floating point add
F+

10ms

Floating point sine FSIN

270ms

FLOATING POINT PRINCIPAL WORDS
1/PI

10^X

D!

D*

D>F

D@

DEG>RAD

DIM

DINT

E

E#

E.

E^X

F!

F#

F*

F+

F

F.

F/

F/MOD

F10*

F<

F<0

F=0

F>0

F@

FABS

FACOS

FALN

FALOG

FASIN

FATAN

FCONSTANT

FCOS

FDROP

FDUP

FINT

FLITERAL

FLN

FLOAT

FLOG

FMAX

FMIN

FMINUS

FMOD

FOVER

FROT

FSIGN

FSIN

FSQR

FSWAP

FTAN

FVARIABLE

FX^N

FX^Y

PI

RAD>DEG

S>D

S>F

SINT





STRING FUNCTION PRINCIPAL WORDS
$!

$+

$.

$@

$DIM

$DROP

$DUP

$INPUT

$SWAP

$VARFILL

$VARIABLE

ASC

E.$

E.N

F.$

F.N

FASC

FLEN

INPUT

LEFT$

LEN

MID$

RIGHT$

STR$

VAL

