Quartus Forth Manual

Table of Contents - Quartus Forth Home Page - How to Register

Data Types

Forth has been called an 'untyped' language.  This is incorrect; there are a number of data types in Forth, but only limited type-checking.  Stack-diagrams used to annotate Forth programs make frequent reference to data types.

The following table lists the data types commonly encountered in Quartus Forth:

Symbol Data Type Cells on Stack
? or flag Boolean flag

1

true True flag

1

false False flag

1

char Character

1

n Signed number

1

+n Non-negative number

1

u Unsigned number

1

n|u Number

1

x Unspecified cell

1

xt Execution token

1

addr Address in dataspace

1

a-addr Aligned address in dataspace

1

c-addr Character-aligned address in dataspace

1

d Double-cell signed number

2

+d Double-cell non-negative number

2

ud Double-cell unsigned number

2

d|ud Double-cell number

2

xd Unspecified pair

2

colon-sys Definition compilation

1

do-sys Do-loop structures

1

case-sys CASE structures

1

of-sys OF structures

1

orig Control-flow origins

1

dest Control-flow destinations

1

loop-sys Loop-control parameters

3 (Return stack)

nest-sys Definition calls

2 (Return stack)

i*x, j*x, k*x Any data type

0 or more

Examples of additional punctuation used in stack diagrams in Quartus Forth applications:
name. Double-cell value (called 'name')

2

&name Pointer to a data structure (called 'name')

1

&name. 32-bit (double-cell) pointer to a data structure (called 'name')

2

L.&name Pointer to a double-cell signed number (called 'name')

1

U&name Pointer to a single-cell unsigned number (called 'name')

1

name[>byte] Parameter (called 'name') must be left-shifted 8 bits before passing

1

A Note on the values of TRUE and FALSE

A properly-formed TRUE flag consists of a cell with all bits set to 1, which can be represented in Quartus as the number -1.  A FALSE flag is a cell with all bits set to 0.  For the purposes of IF, WHILE, and UNTIL, any non-zero value found on the stack is considered true.

To convert a cell to a properly formed TRUE flag, use the code sequence 0= 0=:

The value of a properly-formed TRUE flag is binary 1111111111111111, which is the same as -1 in decimal representation.

The first 0= will convert a 0 to TRUE, non-zero to FALSE (0000000000000000). The second 0= inverts the resulting flag.

This means that

1 0= 0= -> TRUE (1111111111111111)
2 0= 0= -> TRUE (1111111111111111)
-17 0= 0= -> TRUE (1111111111111111)
432 0= 0= -> TRUE (1111111111111111) (you get the idea)

0 0= 0= -> FALSE (0000000000000000)

Therefore 0= 0= will convert any value to a properly formed TRUE flag.


Table of Contents - Quartus Forth Home Page
© 1998, 1999 Neal Bridges. All rights reserved.