All stack elements are 16-bit unsigned integers.
Duplicates the top element of the stack.
Adds the top two elements of the stack.
Subtracts the top element of the stack from the one immediately before it.
Bitwise and
of the top two elements of the stack.
Bitwise or
of the top two elements of the stack.
Bitwise xor
of the top two elements of the stack.
Left shift of the top element of the stack.
Right shift of the top element of the stack.
Drop the top element of the stack.
Swap the top two elements of the stack.
Push the second-top element of the stack onto the top of the stack.
Increment the top element of the stack.
Decrement the top element of the stack.
Increment the top element of the stack by 2.
Decrement the top element of the stack by 2.
Increment the top element of the stack by 4.
Decrement the top element of the stack by 4.
F_HIDDEN
Non-blocking form of KEY
.
Print the character with the ASCII code form the top of the stack.
Pop the top element from the stack and print it.
Print the value pointed to by addr
.
Block until a key that corresponds to a printable ASCII character is given, then push that value onto the stack.
Convert a value given by KEY
to the corresponding ASCII character code.
Multiply the top two elements on the stack.
Carriage return.
Print a NUL-delimited string.
Print a NUL-delimited string followed by a carriage return.
Get characters from the user until [ENTER]
is pressed, storing the
result in the memory locationBUF
.
Get the next character from BUF
.
Unget the last character from BUF
.
Read a full, space-delimited word from BUF
and push the address of
WBUF
followed by the length of the word onto the stack.
Given a pointer returned from FIND
, return whether or not the word
is marked IMMEDIATE
. Follows boolean convention.
Mark the last word (or currently-being-defined word) as IMMEDIATE
.
Given a FIND
-returned pointer, return the address of the start of
the word's name string.
Given a FIND
-returned pointer, return the address of the start of
the word's Code Field Address (CFA).
Given two addresses of NUL-terminated string, check whether they are equal character-by-character.
Given the address of a word string and its length, return a FIND
pointer to the word in the dictionary. Return 0
if the word is not
found.
Writeback the (possibly) modified contents from data_start
to data_end
.
Writes the three bytes corresponding to call docol
to the memory
location pointed to by HERE
.
Created by DOES>
, or can be called as well. Sets the call
destination of the LATEST
word's Code Field Address to the address
directly after DOES>
, which is the instruction pointer at the time
DOES>
is invoked. See DOES>
for more information.
Used in words that can create new words. See the following example:
: CONSTANT
WORD CREATE DOCOL_H ,
DOES> @
;
The word CONSTANT
in the example reads a word, creates the link and
name header, followed by three bytes corresponding to call docol
,
followed by the top element of the stack. DOES>
denotes the end of
CONSTANT
's action and the start of the action of what the word
created by CONSTANT
will do. In other words, we can use it like
this:
31415 CONSTANT PI
PI . \ => 31415
The words following DOES>
are executed on the same stack, but with
the top element of the stack begin the address of the word defined by
CONSTANT
's children. That's why we can just deference the pointer
with @
and thus get the constant value out.
What's happening is that DOES>
is an immediate word that compiles
(DOES>)
followed by the 3 bytes representing call dodoes
to the
current word being defined (i.e. CONSTANT
). When CONSTANT
is
invoked, the invocation of (DOES>)
sets the destination address of
the call
instruction in the new word (whatever it may be) being
defined (in this case, PI
) to the byte after (DOES>)
, so that
the new word starts its Code Field Address with call XXXX
,
where XXXX
is the address after the location of (DOES>)
in
CONSTANT
. Then, (DOES>)
acts like EXIT
, resuming execution.
This means you can share the same body code between words created by a
word using DOES>
, reducing wasted space.
Clear the screen.
HIDDEN
?HIDDEN ( fptr -- b )
Given a FIND
pointer, return whether or not the word is hidden.
Tucks the top element two locations prior.
Sound emit. Play the "frequency" with the duration. The convention is that the lower the frequency number the higher it actually is in real life.
Exit the program.
Returns how many bytes have been used (starting from H0
).