Words - the Mecrisp-Stellaris Dictionary

The complete word reference in a single consistent format: word, stack comment, description. This page is the source that feeds the LSP.

Dictionary

Word

Stack Comment

Description

!

( u|n a-addr – )

Stores single number in memory

#

( ud1|d1 – ud2|d2 )

Add one digit from the double length number to output buffer

#>

( ud|d – c-addr len )

Drops double-length number and finishes pictured numeric output ready for type

#S

( ud1|d1 – 0 0 )

Add all remaining digits from the double length number to output buffer

‘ name

( - - a-addr )

Finds name in the dictionary; gives back its executable address.

(create) name

( - - )

Names a location; space may be allocated. FIG-style.

*

( u1|n1 u2|n2 – u3|n3 )

32*32 = 32 Multiplication

*/

( n1 n2 n3 – n4 )

n1 * n2 / n3 = n4

*/mod

( n1 n2 n3 – n4 n5 )

n1 * n2 / n3 = n5 remainder n4

( u1|n1 u2|n2 – u3|n3 )

Addition

+!

( u|n a-addr – )

Add to memory location

+loop

( u|n - - )

Increments the loop index by n; checks whether to continue.

,

( u|n – )

Appends a single number to dictionary

( u1|n1 u2|n2 – u3|n3 )

Subtraction

-roll

( xu-1 … x0 xu u – xu xu-1 … x0 )

Reverse rotation of the top of the stack.

-rot

( x1 x2 x3 – x3 x1 x2 )

.

( n – )

Print single number

.” Hello”

( - - )

Compiles a string and prints it when executed.

.digit

( u – char )

Converts a digit to a char

.s

( many – many )

Prints stack contents, signed

/

( n1 n2 – n3 )

n1 / n2 = n3

/mod

( n1 n2 – n3 n4 )

n1 / n2 = n4 remainder n3

0-foldable

( – )

Current word becomes foldable with zero constants

0<

( n – flag )

Negative ?

0<>

( x – flag )

0=

( x – flag )

1+

( u1|n1 – u2|n2 )

Adds one, optimized

1-

( u1|n1 – u2|n2 )

Subtracts one, optimized

1-foldable

( – )

Current word becomes foldable with one constants

12bitencoding

( x – x false | bitmask true )

Can x be encoded as 12-bit immediate ?

2!

( ud|d a-addr – )

Stores double number in memory

2*

( n1 – n2 )

Arithmetric left-shift

2+

( u1|n1 – u2|n2 )

Adds two, optimized

2-

( u1|n1 – u2|n2 )

Subtracts two, optimized

2-foldable

( – )

Current word becomes foldable with two constants

2-rot

( x1 x2 x3 x4 x5 x6 – x5 x6 x1 x2 x3 x4 )

2/

( n1 – n2 )

Arithmetric right-shift

2>r

( x1 x2 – )

(R: – x1 x2 )

2@

( a-addr – ud|d )

Fetches double number from memory

2constant name

( ud|d - - )

Makes a double constant.

2drop

( x1 x2 – )

2dup

( x1 x2 – x1 x2 x1 x2 )

2nip

( x1 x2 x3 x4 – x3 x4 )

2over

( x1 x2 x3 x4 – x1 x2 x3 x4 x1 x2 )

2r>

( – x1 x2 )

(R: x1 x2 – )

2r@

( – x1 x2 )

(R: x1 x2 – x1 x2 )

2rdrop

( – )

(R: x1 x2 – )

2rot

( x1 x2 x3 x4 x5 x6 – x3 x4 x5 x6 x1 x2 )

2swap

( x1 x2 x3 x4 – x3 x4 x1 x2 )

2tuck

( x1 x2 x3 x4 – x3 x4 x1 x2 x3 x4 )

2variable name

( ud|d - - )

Makes an initialized double variable.

3-foldable

( – )

Current word becomes foldable with 3 constants

4-foldable

( - - )

Foldable with four constant inputs; applies to d+ d- 2swap.

5-foldable

( - - )

Foldable with five constant inputs.

6-foldable

( - - )

Foldable with six constant inputs.

7-foldable

( – )

Current word becomes foldable with 7 constants

: name

( - - )

Opens a new definition.

;

( – )

Finishes new definition

<

( n1 n2 – flag )

<#

( – )

Prepare pictured number output buffer

<=

( n1 n2 – flag )

Signed comparisons

<>

( x1 x2 – flag )

<builds

( - - )

Makes a dictionary header and reserves space for a special call.

=

( x1 x2 – flag )

>

( n1 n2 – flag )

><,

( u|n – )

Reverses high and low-halfword, then appends it to dictionary

>=

( n1 n2 – flag )

>in

( – addr )

Variable with current offset into source

>r

( x – )

(R: – x )

?do

( limit index - - )

Begins a loop only if index is not equal to limit.

?dup

( x – 0 | x x )

?of

( n flag - - )

Flag-of; runs up to endof when the flag is true.

@

( a-addr – u|n )

Fetches single number from memory

[

( – )

Switch to execute state

[’] name

( - - a-addr )

Tick that compiles the executable address of the found word as a literal.

[char] *

( - - char )

Compiles the code of the following character when executed.

]

( – )

Switch to compile state

abs

( n – u )

Absolute value

accept

( c-addr maxlength – length )

Read input into a string.

again

( - - )

End of a begin-again infinite loop; jumps back to begin.

align

( – )

Aligns dictionary pointer

aligned

( c-addr – a-addr )

Advances to next aligned address

allot

( n – )

Tries to advance Dictionary Pointer by n bytes Aborts, if not enough space available

and

( x1 x2 – x3 )

Bitwise AND

arshift

( x1 u – x2 )

Arithmetric right-shift of u bit-places

base

( – a-addr )

Base variable address

begin

( - - )

Marks the start of an indefinite loop.

bic

( x1 x2 - - x3 )

Bit clear; identical to ‘not and’.

bic!

( mask a-addr – )

Clear bits in word-location

binary

( – )

Sets base to 2

bis!

( mask a-addr – )

Set bits in word-location

bit@

( mask a-addr – flag )

Test bits in word-location

bl

( – 32 )

ASCII code for Space

buffer: name

( u - - )

Creates a buffer in RAM, u bytes in length.

c!

( char c-addr )

Stores byte in memory

c” Hello”

( - - cstr-addr )

Compiles a counted string; gives its address when executed.

c+!

( u|n a-addr - - )

Add to byte memory location.

c,

( char – )

Appends a byte to dictionary

c@

( c-addr – char )

Fetches byte from memory

call,

( a-addr – )

Compiles a call to a subroutine

case

( n - - n )

Begins a case structure; keeps the selector value.

cbic!

( mask c-addr – )

Clear bits in byte-location

cbis!

( mask c-addr – )

Set bits in byte-location

cbit@

( mask c-addr – flag )

Test bits in byte-location

cell+

( x – x+4 )

Add size of one cell

cells

( n – 4*n )

Calculate size of n cells

cexpect

( cstr-addr maxlength – )

Read input into a counted string.

char *

( - - char )

Gives the code of the following character.

cjump,

( Hole-for-Opcode Destination Bitmask )

Writes a conditional Jump to a-addr-Destination with the given Bitmask as Opcode into the halfword sized a-addr-Hole

clz

( x1 – u )

Count leading zeros

compare

( caddr-1 len-1 c-addr-2 len-2 – flag )

Compares two strings

compileonly

( – )

Makes current definition compileonly.

compiletoflash

( – )

Makes flash the target for compiling

compiletoram

( – )

Makes ram the target for compiling

compiletoram?

( – ? )

Currently compiling into ram ?

constant name

( u|n - - )

Makes a single constant.

count

( cstr-addr – c-addr length )

Convert counted string into addr-length string

cr

( – )

Emits line feed

create name

( - - )

Creates a definition with a default action; use <builds does> instead.

ctype

( cstr-addr – )

Prints a counted string.

current-source

( – addr )

Double-Variable which contains source

cxor!

( mask c-addr – )

Toggle bits in byte-location

d+

( ud1|d1 ud2|d2 – ud3|d3 )

Addition

d-

( ud1|d1 ud2|d2 – ud3|d3 )

Subtraction

( d – )

Print double number

d/

( d1 d2 – d3 )

d1 / d2 = d3

d/mod

( d1 d2 – d3 d4 )

d1 / d2 = d4 remainder d3

d0<

( d – flag )

d0=

( d – flag )

d2*

( d1 – d2 )

Arithmetric left-shift

d2/

( d1 – d2 )

Arithmetric right-shift

d<

( d1 d2 – flag )

d<>

( d1 d2 – flag )

d=

( d1 d2 – flag )

d>

( d1 d2 – flag )

dabs

( d – ud )

Absolute value

decimal

( – )

Sets base to 10

depth

( – +n )

Gives number of single-cell stack items.

dictionarynext

( a-addr – a-addr flag )

Scans dictionary chain and returns true if end is reached

dictionarystart

( – a-addr )

Current entry point for dictionary search

digit

( char – u true | false )

Converts a char to a digit

dint

( - - )

Disables interrupts.

dnegate

( d1 – d2 )

Negate

do

( limit index - - )

Begins a loop from index up to limit.

does>

( - - )

Executes with the address of stored data on the stack.

drop

( x – )

dshl

( ud1 – ud2 )

Logical left-shift, same as d2*

dshr

( ud1 – ud2 )

Logical right-shift

du<

( ud1 ud2 – flag )

du>

( ud1 ud2 – flag )

dup

( x – x x )

eint

( - - )

Enables interrupts.

eint?

( - - )

Are interrupts enabled?

else

( - - )

Marks the alternative branch of a conditional.

emit

( char – )

Emits a character

emit?

( – flag )

Ready to send a character ?

endcase

( n - - )

Ends the case structure; discards the selector.

endof

( - - )

Ends one alternative; jumps to endcase.

eraseflash

( - - )

Erases everything after the Flash Dictionary; clears RAM; restarts Forth.

eraseflashfrom

( a-addr - - )

Starts erasing at this address; clears RAM; restarts Forth.

evaluate

( any addr len – any )

Interpret given string

even

( u1|n1 – u2|n2 )

Makes even. Adds one if uneven.

execute

( a-addr – )

Calls subroutine

exit

( - - )

Returns from the current definition; compiles a ret opcode.

f#

( n-comma1 - - n-comma2 )

Adds one comma-digit to number output.

f#S

( n-comma1 - - n-comma2 )

Adds 32 comma-digits to number output.

f*

( df1 df2 - - df3 )

Multiplication of two fixpoint numbers.

( df - - )

Prints a fixpoint number with 32 fractional digits.

f.n

( df n - - )

Prints a fixpoint number with n fractional digits.

f/

( df1 df2 - - df3 )

Division of two fixpoint numbers.

false

( – 0 )

False flag

fill

( c-addr u c )

Fill u Bytes of Memory with value c

find

( c-addr len – a-addr flags )

Searches for a String in Dictionary.

flashpageerase

( a-addr - - )

Erases one 1k flash page only; no reset.

flashvar-here

( – a-addr )

Gives current RAM management pointer

forgetram

( – )

Forget definitions in ram without a reset

h!

( char c-addr )

Stores halfword in memory

h+!

( u|n a-addr – )

Add to halfword memory location

h,

( u|n – )

Appends a halfword to dictionary

h.s

( many – many )

Prints stack contents, unsigned, hex

h@

( c-addr – char )

Fetches halfword from memory

halign

( – )

Makes Dictionary Pointer even, if uneven.

hbic!

( mask a-addr – )

Clear bits in halfword-location

hbis!

( mask a-addr – )

Set bits in halfword-location

hbit@

( mask a-addr – flag )

Test bits in halfword-location

here

( – a-addr|c-addr )

Gives current position in Dictionary

hex

( – )

Sets base to 16

hex.

( u – )

Prints 32 bit unsigned in hex base, needs emit only.

hflash!

( u|n a-addr - - )

Writes a halfword to flash.

hold

( char – )

Adds character to pictured number output buffer from the front.

hold<

( char - - )

Adds character to pictured number output buffer from behind.

hook-emit

( – a-addr )

hook-emit?

( – a-addr )

Hooks for redirecting

hook-key

( – a-addr )

on the fly

hook-key?

( – a-addr )

terminal IO

hook-pause

( – a-addr )

Hook for a multitasker

hook-quit

( – a-addr )

Hook for changing the inner quit loop

hxor!

( mask a-addr – )

Toggle bits in halfword-location

i

( - - u|n )

Gives the innermost loop index.

if

( flag - - )

Begins a conditional; consumes a flag.

immediate

( – )

Makes current definition immediate.

inline

( – )

Makes current definition inlineable.

inline,

( a-addr – )

Inlines the choosen subroutine

interpret

( any – any )

Execute, compile, fold, optimize…

ipsr

( - - ipsr )

Interrupt program status register.

irq-collection

( - - a-addr )

Collection of all unhandled interrupts.

irq-fault

( - - a-addr )

Memory location for all fault IRQ hooks.

irq-systick

( - - a-addr )

Memory location for the systick IRQ hook.

j

( - - u|n )

Gives the second loop index.

jump,

( Hole-for-Opcode Destination )

Writes an unconditional Jump to a-addr-Destination with the given Bitmask as Opcode into the halfword sized a-addr-Hole

k

( - - u|n )

Gives the third loop index.

key

( – char )

Waits for and fetches the pressed key

key?

( – flag )

Checks if a key is waiting

leave

( - - )

Leaves the current innermost loop promptly.

list

( - - )

Prints all defined words.

literal,

( u|n – )

Compiles a literal with runtime

loop

( - - )

Increments the loop index by one; checks whether to continue.

lshift

( x1 u – x2 )

Logical left-shift of u bit-places

m*

( n1 n2 – d )

n1 * n2 = d

m/mod

( d n1 – n2 n3 )

d / n1 = n3 remainder n2

max

( n1 n2 – n1|n2 )

Keeps greater of top two items

min

( n1 n2 – n1|n2 )

Keeps smaller of top two items

mod

( n1 n2 – n3 )

n1 / n2 = remainder n3

move

( c-addr1 c-addr2 u – )

Moves u Bytes in Memory

movwmovt,

( x Register – )

Generate a movw/movt-Sequence to get x into any given Register. M3/M4 only

negate

( n1 – n2 )

Negate

nip

( x1 x2 – x2 )

nop

( - - )

No operation; hook for unused handlers.

not

( x1 – x2 )

Invert all bits

number

( c-addr length - - 0 | n 1 | n-low n-high 2 )

Tries to convert a string to a number; 0 = failed, 1 = single, 2 = double.

nvariable name

( n1*u|n n1 - - )

Makes an initialized variable with a specified size; maximum 15 words.

of

( m - - )

Compares m with the selector; runs up to endof if equal.

or

( x1 x2 – x3 )

Bitwise OR

over

( x1 x2 – x1 x2 x1 )

parse

( char – c-addr len )

Cuts anything delimited by char out of input buffer

pause

( – )

Task switch, none for default

pick

( … xi+1 xi … x1 x0 i – … x1 x0 xi )

Picks one element from deep below

postpone

( - - )

Postpones a word so it compiles rather than executes.

query

( – )

Fetches user input to input buffer

quit

( many – )

(R: many – ) Resets Stacks

r>

( – x )

(R: x – )

r@

( – x )

(R: x – x )

rdepth

( – +n )

Gives number of return stack items.

rdrop

( – )

(R: x – )

recurse

( – )

Lets the current definition call itself

registerliteral,

( x Register – )

Generate shortest possible sequence to get x into given low Register.

repeat

( - - )

End of a begin-while-repeat loop; jumps back to begin.

reset

( - - )

Reset on hardware level.

ret,

( – )

Compiles a ret opcode

rol

( x1 – x2 )

Logical left-rotation of one bit-place

roll

( xu xu-1 … x0 u – xu-1 … x0 xu )

Remove u; rotate u+1 items on the top of the stack.

ror

( x1 – x2 )

Logical right-rotation of one bit-place

rot

( x1 x2 x3 – x2 x3 x1 )

rp!

( a-addr – )

Store return stack pointer

rp@

( – a-addr )

Fetch return stack pointer

rpick

( i – xi )

R: ( … xi … x0 – … xi … x0 )

rshift

( x1 u – x2 )

Logical right-shift of u bit-places

s” Hello”

( - - c-addr length )

Compiles a string; gives address and length when executed.

s>d

( n – d )

Makes a signed single number double length

serial-emit

( char – )

serial-emit?

( – flag )

Serial interface

serial-key

( – char )

as default communications

serial-key?

( – flag )

terminal routines

setflags

( char – )

Sets Flags with a mask.

setsource

( c-addr len – )

Change source

shl

( x1 – x2 )

Logical left-shift of one bit-place

shr

( x1 – x2 )

Logical right-shift of one bit-place

sign

( n – )

Add a minus sign to pictured number output buffer, if n is negative

skipstring

( cstr-addr – a-addr )

Increases the pointer to the aligned end of the string.

smudge

( – )

Makes current definition visible, burns collected flags to flash and takes care of proper ending

source

( – c-addr len )

Current source

sp!

( a-addr – )

Store data stack pointer

sp@

( – a-addr )

Fetch data stack pointer

space

( – )

Emits space

spaces

( n – )

Emits n spaces if n is positive

state

( – a-addr )

Address of state variable

string,

( c-addr len – )

Inserts a string of maximum 255 characters without runtime

swap

( x1 x2 – x2 x1 )

then

( - - )

Ends a conditional; the paths merge here.

tib

( – cstr-addr )

Input buffer

token

( – c-addr len )

Cuts one token out of input buffer

true

( – -1 )

True flag

tsource

( c-addr len - - )

Change source.

tuck

( x1 x2 – x2 x1 x2 )

type

( c-addr length – )

Prints a string.

u*/

( u1 u2 u3 – u4 )

u1 * u2 / u3 = u4

u*/mod

( u1 u2 u3 – u4 u5 )

u1 * u2 / u3 = u5 remainder u4

( u – )

Print unsigned single number

u.s

( many – many )

Prints stack contents, unsigned

u/mod

( u1 u2 – u3 u4 )

32/32 = 32 rem 32 Division

u<

( u1 u2 – flag )

u<=

( u1 u2 – flag )

Unsigned comparisons

u>

( u1 u2 – flag )

u>=

( u1 u2 – flag )

ud*

( ud1|d1 ud2|d2 – ud3|d3 )

64*64 = 64 Multiplication

ud.

( ud – )

Print unsigned double number

ud/mod

( ud1 ud2 – ud3 ud4 )

64/64 = 64 rem 64 Division

udm*

( ud1 ud2 – ud3-Low ud4-High )

64*64=128 Multiplication

um*

( u1 u2 – ud )

32*32 = 64 Multiplication

um/mod

( ud u1 – u2 u3 )

ud / u1 = u3 remainder u2

umax

( u1 u2 – u1|u2 )

Keeps unsigned greater

umin

( u1 u2 – u1|u2 )

Keeps unsigned smaller

unhandled

( - - )

Message for unhandled interrupts.

unloop

( R: old-limit old-index - - )

Drops the innermost loop structure; restores old loop values.

until

( flag - - )

Ends a begin loop; repeats while the flag is false.

unused

( – u )

Get current amount of free memory

variable name

( u|n - - )

Makes an initialized single variable.

while

( flag - - )

Checks a flag mid-loop; exits if false.

words

( – )

Prints list of defined words.

xor

( x1 x2 – x3 )

Bitwise Exclusive-OR

xor!

( mask a-addr – )

Toggle bits in word-location