Panasonic_HHC_Programmers_Manual
Panasonic_HHC_Programmers_Manual
NIIIIIP.
TABLE OF CONTENTS
INTRODUCTION
THE KEYBOARD
THE LCD
4-13 FLAME-ON
4-13 Vectored I/O; (EMIT)
4-15 BLIPS
4-16 BEEPS AND SQUEAKS
SAMPLE PROGRAMS
9-2 OVERVIEW
9-4 THE ASSEMBLY PROCESS
9-4 The Assembler Does Not Work In Compile Mode
9-5 Getting In and Out Of the Assembler Vocabulary
9-6 OPCODES
9-8 OPERANDS
9-8 Addressing Modes
9-10 FLOW OF CONTROL
9-10 IF . . . ELSE . . . ENDIF
9-10 The Condition Specifier
9-10 The UNTIL Loop
9-11 The WHILE Loop
9-11 The AGAIN Loop
9-12 HHC CALLING CONVENTIONS
9-12 SETUP
9-12 Low Level Procedures
9-12 Jumping To CODE Words
9-13 Return to Caller From a CODE Word
9-13 Leaving a CODE Word
9-13 Calling a SNAP Word From a CODE Word
9-14 (Assembling Low Level Procedures Outside SNAP)
9-15 HHC CODING CONVENTIONS
9-15 Using the Parameter Stack
9-16 Using the Return Stack
INDEX
HHC ARCHITECTURE
The Hardware
4000-7FFF Capsule and I/O bank space. ROM capsules are read from
this space. Contents of this space is controlled by
bank switching; the space may be filled by any two of
the 3 capsule sockets on the back of the HHC, and/or
sockets in a ROM expander. Bank switching also permits
access to the HHC's memory-mapped I/O hardware.
FIGURE 1-1
MEMORY MAP
The Software
The items listed above constitute the NUCLEUS, that is, the
intrinsic portion of the operating system.
device's I/O driver into the HHC's address space when I/O to that
device is requested.
A A A A I A
i 1 i I I
i 1 1 I I
1 I i
V V
I I I 'Peripheral
Peripheral I/O I/O inter-
drivers 'face; inter- I I File
I I I Irupt handler; system Menu
timer driver
1
Intrinsic1<---- < WW1 OEM MI=
I/0 drvrsl
SNAP interoreter
FIGURE 1-2
SNAP source files use a variable length line. This means that
you can increase the legibility of your programs by using as much
white space as you want without suffering any oenaity from wasted
storage. The system improves storage efficiency further by
Summary
emulated
P,M.P.s* &
ROM capsules SNAP
0 emulator
File editor (displaces
x & utilties FORTH)
x (run under FORTH)
source
files, etc.
file :
0 FORTH interpreter
system:
X
Figure 1-3
Overall Structure
of the Development System
source files
0 File editor
x
x •
ANNOMINIP.111111.M.M
emulated
P.M.P.s* & Copying utility
ROM capsules
0
x
x
"LOAD"
V •
Use
Memo pad "SNAP capsule"
editor to debug
Figure 1-4
Using the Development System
to Test a Program
THE GLOSSARIES
1. HHC words. Most of the words that you can use in a SNAP
program are described here. This includes both executable
words (e.g., OVER, DUP, DROP) and compile-time words (e.g.,
';', and 1 ( 1 ).
2. Emulator control words. These are words you can use to
control the operation of the emulator, but would NOT use in a
program.
3. FORTH system words. These are words you can use in the
development system's FORTH environment, but cannot use in
the emulator or in a SNAP program.
4. Object time words. These are words in the HHC's vocabulary
that are generated by the compiler, but are never written
in source programs. They implement program control
structures and literal constants.
Glossary Notation
(Glossary Format)
OVER
The word being described.
( X Y--- X Y X)
Shows stack input to the left of the hyphens, and
stack output to the right. This example shows that the
word expects two items on the stack, and leaves three.
N an integer.
U an unsigned integer.
if B is FALSE.
( A L --- A L' )
note
Notes explain how this word fits into the HHC system.
none
If an entry in the HHC glossary has no note, the
implication is that the word is a colon definition in
the target dictionary (i.e., on the HHC), and works
identically in the HHC and the emulator.
In other glossaries, "no note" has no particular
implication. (Observe that it would be absurd for "no
note" to have the same implication in the FORTH
glossary, for example, as in the HHC glossary! A word
in the FORTH glossary is, ipso facto, not in the
target dictionary.)
S
The word is a symbolic constant. It may return the
address of some fixed data item in RAM or ROM. More
commonly it returns a scalar constant, such as the
number of dot columns in the LCD, or the binary value
that represents a particular ASCII character.
Dn
The word is a data item. It returns the address of
data at a fixed location in RAM. "n" is the length of
the data in bytes.
C
Control word. This word is used in a target colon
definition and compiles to target code, but does NOT
compile one-for-one to a corresponding SNAP tag. An
example is the word LITERAL, which takes one word
from the stack at compile time and compiles to a CLIT
or LIT followed by a one- or two-byte constant, the
constant's value being the value taken from the
stack
L
Label. Returns an address on the stack AT COMPILE
TIME. This address is most often the entry point to a
subroutine that is called from low-level words, using
the standard 6302 calling linkage rather than the
SNAP (high-level) linkage.
NOTE
There is something else to note about this word. See
the following description.
(Text Format)
x y OVER x y z
OVER copies the second word on the stack to
the top of the stack.
MEMORY MAP
DATA REPRESENTATION
16-bit integer:
in memory: HHHHHHHHLLLLLLLL
adr+1 adr
on stack: HHHHHHHHLLLLLLLL
32-bit integer:
in memory: HHHHHHHH3333333322222222LLLLLLLL
adr+3 adr+2 adr+1 adr
HERE
S"
== cccc
What a Tag Is
The tag table that the interpreter used to execute UPDATE might
look like this:
tag
address contents represented meaning
1800 OS** 00
1986
• OFF3 C3 (address of TOTAL)
1988 15C3 C4 (address of TODAY)
In fact, the HHC uses certain tag values (01H through 08H) as
"escape tags" which mean, "use the following byte as an index
into another tag table, and execute the word pointed to by the
appropriate entry in that table."
For all practical purposes, we can treat a tag 01H to 07H,
followed by another byte, as a single LONG TAG. We will
distinguish an "ordinary" tag (value OOH or 03H to OFFH) by
calling it a SHORT TAG.
OC 02 15 07 03 SF
The HHC uses several tag tables to execute SNAP code. These
tables are:
* The SHORT INTRINSIC TABLE, used for tags OUR through OBFH.
This table is in intrinsic ROM; its entries represent short
tags that are part of the HHC's intrinsic software (nucleus,
device routines, and intrinsic applications).
* TABLE #1, containing long tags that begin with 01H. This
table is in intrinsic ROM; its entries represent long tags
that are part of the HHC's intrinsic software.
* The SHORT EXTRINSIC TABLE, used for tags OCOH through OFFH.
This table is in an extrinsic program (i.e., in a ROM capsule
or a SNAP program in a virtual file). Its entries represent
short tags that are part of the extrinsic program.
memory
address banK
short
I intrinsic
short 81 table
extrinsic
1 80
2 81 CAPSULE #1
memory bank 1
3 84 - - :
program long
(empty) header 1 table #1
(empty)
short
(empty) extrinsic
(empty) long table
#2
(empty)
CAPSULE #2
memory bank 4
program
header
long table
#3
FIGURE 2-1
The second word in the long table should initialize the tag
table vector to point to the short tag table, and to any
additional long tag tables the program may need, whether in this
capsule or in some other. The mother word should call this word
before executing any word that is not in the (primary) long tag
table.
table.
FIGURE 2-2
Header For an Application Program
The Mother Word and the Tag Table Vector Initializatin Word
Recall that the second tag in the long tag table ,is
initialize the tag table vector to point to the snort extrinsic
table, and to any additional long tables that the program uses;
and the mother word must execute the second tag before using any
of those tables.
Figure 2-3 shows how the mother word and the second word
could be set up, assuming a header like the one in Figure 2-2.
The second line stacks the number of the long tag table, and
multiplies it by 3, giving the offset of the tag table vector
entry that represents the long tag table.
The third line fetches the first byte from the tag table
vector entry that represents the long tag table. This contains
the bank ID of this capsule (which applies to both the long
extrinsic table and the short extrinsic table).
FIGURE 2-3
A Tag Table Vector Initialization Word
and a Mother Word
A long tag table may be over 256 entries long. If it is, you
must initialize anotner tag taole vector entry for eacn
additional segment of up to 256 entries. This consists simply of
storing a segment's address and bank ID in the proper entry in
the vector.
For example, suppose you define a tag table with 520 entries,
and specify that the first tag is to be number 200H (and you set
ROMEXT to 2). The nucleus will initialize tag table vector entry
#2 for the part of the to table that contains tags 200H through
2FFH. You must include code in the tag table vector
initialization word to initialize tag table vector entry #3 for
the part of the table that contains tags 300H through 3FFH, and
tag tale vector entry #4 for the part of the table that contains
tags 400H through 407H.
FIGURE 2-4
Initializing the Tag Table Vector
For a Second Tag Table
The master capsule must initialize the tag table(s) for the
SLAVE capsule(s). Assuming a slave capsule has a standard-format
capsule header, you can initialize the vector in the following
way:
If you find the capsule you want, fetch its tag table
address (kept at ROMVECT in the header) and its taole
number (one byte long, kept at ROMEXT). Store its address
and bank ID in the appropriate tag table vector entry.
IMPORTANT: when you store the bank ID in the tag table
vector entry, turn on the 80's bit to indicate that the
bank ID refers to a ROM bank. If you do not do this, the
HHC will think the capsule is in a RAM bank.
If the slave capsule has more than one tag table, you can
call a word in the slave capsule itself to initialize the
vector for additional tables. Alternatively, you can set up a
convention of your own which enables the master capsule to find
additional tables in the slave.
ROM capsules come in sizes of 2K, 4K, 8K, and 16K bytes. All
but the largest size use FAST ROM, which can be read any time the
HHC wants to access it. The 16K capsules must use SLOW ROM, which
cannot be accessed for several milliseconds after it is bank-
switched into the address space. If your program is to be stored
in a slow ROM capsule, you must signal that limitation to the
HHC's software by turning on another bit in the header flag byte.
LONG name
SHORT name
If you have a long-tag word that is called only once, you can
save a byte in your program by defining it with ':C' instead of
1 :1. This is a useful trick if your program is just barely too
big to fit in a ROM capsule, and every byte counts.
If you define a word with :C, the definition of the word is
compiled, but the word is NOT assigned a tag. Any reference to
the word in another colon definition will compile to the short
tag '(CALL)', followed by the 2-byte address of the word's
definition.
CONSTANTS
Symbolic Constants
64 == BFR.LEN
BFR 64 ERASE
: BFR.LEN 64 ;
: 64 64 ;
DEFINITION REFERENCE
CONSUMES CONSUMES
To use a TSA, you must' (1) define it at compile time, and (2)
allocate it at run time.
You define a TSA at compile time with the AREA word. AREA is
followed by another word which becomes the name of a word which
AREA defines; you may execute this word to allocate the TSA. AREA
is followed by variable definitions, and then ENDAREA. (See the
example below.) You must compile this sequence before any code
which allocates or refers to the TSA.
An Example
This example shows how you could define and allocate a TSA.
WURD (S )
TSAWURD NOTIF ALLOC TSA & TEST SUCCESS.
." NO SPACE!" ENDIF
.. •
Here are the words that may be used to allocate RAM in a TSA.
yaw-
CVAR coo
defines a one-byte variable named "ccc".
n CVECTOR ccc
Defines an array named "ccc" containing "n" byte elements.
DVAR ccc
Defines a two-word variable named "ccc".
FVAR ccc
Defines a floating point (8 byte) variable named "ccc".
n STRING ccc
Defines a character string variable with room for "n"
characters, named "ccc".
VAR ccc
Defines a one-word variable named "ccc".
n VECTOR ccc
Defines an array named "ccc" containing "n" word elements.
Releasing 7SA's
LETGO
LETGO releases the TSA most recently allocated and not yet
released. In other words, it acts like a DROP that applies to the
temporary stack, dropping one whole TSA at a time.
2.
n GRAB [adr] b
n ?ROOM b
AVAIL n
RAM as you could, leaving 500 bytes free for virtual files. You
could do so like this:
LABEL EXTAB
HEX 00 C, 4A C, 25 C,
HERE
00 C, 4A C, 25 C,
33 C, 21 C,
== EXTAB
RESTARTING A PROGRAM
Pressing the CLEAR key ONCE makes the system perform a SOFT
CLEAR. A soft clear consists of the following functions:
Ending a Program
LATCH BYTE
HARDWARE ARCHITECTURE
ENTER
Performs tne function more commonly called CARRIAGE
RETURN. An "ordinary" character key; generates an ASCII
code.
Cursor up, down, left, and right (I, r, <-, ->)
These keys are labelled with arrows oointing in the
appropriate directions. They are ordinary keys.
A program may use the cursor control keys for any purpose,
but they have two conventional meanings. First, if a
program uses cursor control on the video display (or on a
"virtual CRT" windowed by the LCD), it uses these keys to
move the cursor. Second, if a program uses a menu which
the user advances one step at a time, "down" is used to
advance the menu, and "up" is used to back it up. "Right"
and "left" may be used to advance and back up a subsidiary
menu. The paradigm is a page of a book, which is read top-
to-bottom and left-to-right.
ON and OFF
Turn the HHC on and off. Both are immediate keys.
Note that the effects of these keys are programmed; the
keys do not actually turn the power on and off.
SECOND SHIFT
A shift key to shift the keyboard into a third case (in
addition to lower and upper case). All punctuation,
special characters, Pr. c., are in this case.
A hidden key.
HELP
Waits for the next keystroke, interprets that keystroke as
a command, and displays an explanation of the command. (It
does not execute the command.)
Note that HELP is asynchronous with the application
program and totally transparent to it.
DELETE
Used by the memo pad to delete characters from LCD. Other
programs may use this key for any purpose.
INSERT
Used by the memo pad to insert characters on LCD. Other
programs may use this key for any purpose.
SEARCH
Used by the memo pad to search for a character string.
Other programs may use this key for any purpose.
ROTATE
Customarily used by applications to control rotation of
the display, but may be used for any purpose.
Keyboard Codes
For example, suppose the user presses the key in the lower
left corner of the keyboard (the 'Cl' key). This key generates a
raw keyboard code of 31H. The HHC places the contents of byte
number 31H of the current keyboard translation table (where the
first byte in the table is "number 0") in the keyboard buffer. If
the user presses the same key, but in a shifted state, the raw
keyboard code is 71H, and the HHC places the contents of byte
number 71H in the buffer.
HEX
LABEL your-keybd
00 C, -V KEYBD CODE 00 IS NOT GENERATED.
4A C,-V KEYBD CODE 01 GENERATES 4A.
2C C,-V KEYBD CODE 02 GENERATES 2C.
\ AND SO FORTH.
: ADOPT-KBD
your-keybd KBVECT \ ADOPT NEW KEYBD TABLE.
KBSET KBVECT I
-01- -02- -03- -04- -OS- -06- -07- -08- -09- -OA- -uB- -0C- -OD-
! 21 " 22 4 23 s 24 % 25 & 26 ' 27 ( 28 ) 29 _ 5F HELP ^ I/O
1 31 2 32 3 33 4 34 5 33 6 36 7 37 -- -- -- 14 80 -n-,....
1 31 2 32 3 33 4 34 3 33 6 36 7 37 8 38 9 39 0 33
-11- -12- -13- -14- -15- -16- -17- -18- -19- -1A- -18- -1C- -1D-
% 25 + 28 - 2D x 92 T 91 = 3D <- stop ->
Q 51 W 57 E 45 R 52 T 54 Y 59 U 55 I 49 0 4F P 50 81 /spd 82
q 71 w 77 e 65 r 72 t 74 y 79 u 75 i 69 o 6F p 70 OE
-21- -22- -23- -24- -23- -26- -27- -28- -29- -2A- -2B- -2C- -2D-
\ 5C t 7B 1 7D [ 5B I 5D < 3C > 3E Fl
.10 OM
SRCH * ROT
A 41 S 53 D 44 F 46 G 47 H 48 J 4A K 4B L 4C 15 89 83 07
a 61 s 73 d 64 f 66 g 67 h 68 j 6A k 6B 1 6C
-39- -3A- -3B- -3C- -30- -20- -10- -33- -OE- -1E- -2E- -3E- -38-
^ 5E - 7E 60 @ 40 I 7C * 2A ; 38 : 3A F2 INSRT DEL LOCK
Z SA X 58 C 43 V 56 B 42 N 4E M 4D -- 16 84 85 86
z 7A x 78 c 63 v 76 b 62 n 6E m 6D , 2C . 2E
FIGURE 3-1
For keys where shift and second-shift are not significant, the
second line shows the ASCII code or key function and the third line
shows the input value, character code.
adr len init initc eol mode EXPECT adr len' eolchar mode'
adr
Address of the buffer where EXPECT is to deposit the line it
reads. The operating system provides a buffer named &LBUF
which you may for this purpose.
len
Length of the buffer indicated by 'adr'. The maximum allowed
length is 256. (The length of &LBUF is 80.)
initc
Initial position of cursor.
eol
Address of a word written to detect the end-of-line (EOL)
character.
EXPECT calls this EOL word each time a character is read from
the keyboard. EXPECT finishes editing the line when the EOL
word finds an EOL character.
The linkage to the EOL word is:
(C B)
where C is a character that has been read from the keyboard,
and B is TRUE iff the character is an EOL character.
mode
The initial editing mode EXPECT should operate in. The
following symbolic constants represent the possible modes:
%OVR Overstrike. This is EXPECT's "normal" mode.
Each input character replaces the character under
the cursor, and causes the cursor to move right.
If the cursor is at end-of-line, each input
character is appended to the line.
The left- and right-cursor keys move the cursor; but
an attempt to move the cursor past the beginning or
end of the text will not succeed, and will make the
HHC beep.
%INSERT Insert. Each input character is inserted just before
the character under the cursor. All following
characters are bumped one position to the right.
EXPECT returns to overstrike mode after receiving
one character.
The normal cursor is replaced by an "insert" cursor,
which looks like a filled-in rectangle with
alternate dots on and off.
If the cursor is at end-of-line, each input
character is appended to the line.
%DELETE Delete. The "cursor left" key deletes the character
to the left of the cursor; the "cursor right" key
deletes the character under the cursor. Any other
key is considered an error, and causes EXPECT to
beep.
The normal cursor is replaced by a "delete" cursor,
which looks like an outline of a rectangle, with the
interior clear,
mode'
Editing mode that applied to the last character received from
the keyboard.
EXPECT Modes
Example 1
HERE
: EOLWD (S C B )
&CR = ;
(P TRUE IFF C IS A CARRIAGE RETURN.)
== A(EOLWD) \ ADR OF EOLWD.
BEGIN
REPETITIVE-TASK
?KEY UNTIL
•••
"sec" and "ticks" are the number of seconds and ticks (256 ths of
a second) the HHC is to nap.
If a keystroke becomes available before the specified
interval expires, the nap ends immediately. "c", the value of the
keystroke, is stacked; "b" is TRUE.
BEGIN
REPETITIVE-TASK
0 27 NAP
UNTIL \ AT EXIT, CHARACTER IS ON STACK.
C B A KQ
KQI
KQO
HGFEDCJI KQ
T KQI
I KQO
For example, if you push a '2', then a 'G' into the buffer,
the buffer looks like tnis:
2 G ......_ PKQ
PKCT = 2
The next KEY or LOCKKEY will get the 'G'; the one after that
will get the '2':
2PKQ
..... _ .....
PKCT = 1
..................M.....P
PKQ
PKCT = 0 (empty)
Function Keys
OFFSET FROM
FUNDEF CONTENTS
When you "type" a function key in this way, your program will
read it before any of the characters in the keyboard buffer or the
pushkey buffer.
I/O WORDS
EMIT
C@ \ THE CHARACTER.
CNEG \ INVERSE VIDEO FLAG.
SQUISH EMIT \ COMBINE & OUTPUT.
You can store characters in the buffers with the aid of the
CHARBUF and CTRLBUF words:
n CHARBUF adr
n CTRLBUF adr
C@ \ THE CHARACTER
18 CHARBUF C! \ STORE IT IN CHARACTER BUFFER
3 CNEG OR \ THE CONTROL BYTE
18 CTRLBUF C! \ STORE IT IN CONTROL BUFFER
UPDISP \ UPDATE DISPLAY
Note that you can find out what is on the LCD by FETCHING
from the addresses given by CHARBUF and CTRLBUF. For example, to
capitalize the character in position #0:
Graphics Output
You can manipulate the LCD buffer, and thus the dots, with
the word DMOVE. DMOVE works like MOVE, but performs special
processing necessary to move information into and out of the LCD
display buffer. Its linkage is:
Note that you can use DMOVE to read the contents of the LCD,
as well as to write it. Simply specify a "from" address that is
in the LCD buffer, and a "to" address that is elsewhere.
CAUTION: before starting to use DMOVE, clear the LCD b y
executing the following code:
off the LCD. With the cursor in this position, dot columns 156-
158 are NOT available for your use. This is necessary because (1)
'gm. an HHC bug makes it impossible to write to dot columns under the
cursor, and (2) it is impossible to move the cursor entirely off
the LCD.
Program-defined Blips
The HHC allows you to define your own character set for
displaying characters on the LCD, To define your own character
set, you must (1) create a character translation table containing
a dot-pattern definition for each displayable character, and (2)
inform the HHC of its location.
Each byte consists of one bit for each dot that makes up the
column being defined. The bits, from high-order to low-order,
represent the dots from bottom to top.
For example, consider the standard character set used in the
simulator as of this writing. Entry #20H, representing "space,"
is all zero. The following 5-byte entry, representing 'I', is
00000
o**oo
o**oo
o**oo
00 DE DE 00 00 , producing: o**oo
oocoo
o**oo
o**oo
o*oo*
o*oo*
vivo 82 FE 92 92 6C , producing: 0***0
o*oo*
o*oo*
****o
Notice that the top row of dots is not used for ordinary
characters in the standard character set; it is reserved for
accent signs.
The standard baseline (the line the letters appear to rest
on) is at the bottom row of dots. "Lower case letters" are
actually small caps, so none of the standard characters have
descenders.
HEX
00 00 00 00 00 ,CHAR \ SPACE
00 DE DE 00 00 ,CHAR '•
00 06 00 06 00 ,CHAR "
• • •
CHAR.DOT.PATTERN CHVECT1 !
The accent table has the same structure as the character set
table, except that it has a maximum of 16 entries. Each entry
defines a character that will be superimposed on a text character
when that text character is displayed with the appropriate accent
bits turned on in the high-order byte.
Although there is no default floating accent table, there is
a set of standard meanings for the accent-character bit values:
0 no accent
1 accent agout
2 accent grave
3 umlaut
4 circumflex
3 inverted circumflex
6 tilde
7 bar
YOUR-CURSOR-DEFINITION ^ CURSOR 1
The alternate cursor pattern will become visible tne next time a
high-level I/O operation is done on the LCD.
To restore the standard cursor oattern, store CURDOTS in
CURSOR:
CURDOTS CURSOR 1
Again, the cursor pattern will become visible the next time a
ROTATION MODE
You can change the way in which the LCD responds to overflow
(EMITing a character when the cursor is past the last character
position) by storing a value into the byte at (ROTMODE).
10 1 (slowest setting)
9 2
8
7 4
6
5 6
4 7
3 8
2 9
1 0 (fastest setting)
0 faster than fastest STOP/SPEED setting
FLAME-ON
The technique makes use of the words (EMIT) and 'EMIT. (EMIT)
is the HHC's "inner EMIT" word, which performs all the functions
normally associated with EMIT. 'EMIT is the "EMIT vector"
variable, which normally contains the tag of (EMIT).
BLIPS
Value
Word (hex) Meaning
The HHC has a small built-in speaker which it may use to make
various kinds of noise.
The virtual file system can store any number of files. A file
may contain up to 8K characters (counting storage-format
overhead) and an unlimited number of records, subject to the
limit of the amount of memory that is available. Any record may
be any length from 0 to 255 characters. (The 8K limit is imposed
by the size of a Programmable Memory Peripheral, not by the file
system's data structure. At some point in the future the limit
will increase to 16K.)
Each file begins with a HEADER which contains the file name
and various housekeeping information such as the length of the
file. This is followed by the data held in the file.
FILE TYPES
The fourth type a file can have is the TEXT type. A text file
is divided into records (lines), each of which is 0-255
characters long. (Details of file format are given below.) The
lines are generally expected to consist of ASCII text. The file
editor permits the user to edit a text file; it does not Permit
him to execute any other kind of file, except for record 4-1
(which contains the file name).
The HHC allows I/O to only one virtual file at a time. At any
time, the file that virtual I/O words will access is called the
CURRENT FILE.
"adr len" are the address and length of a file name. "b" is TRUE
if the file was opened successfully, and FALSE if not.
"adr len" are the address and length of a file name. "b" is TRUE
if the file was created and selected successfully, and FALSE if
not.
You fetch a record from the current file with READ. The
linkage is:
"adr len" are the address and length of a buffer where READ is to
deposit the record. "recnum" is the number of the record being
requested.
If READ is successful, "len" is the length of record as it
was deposited in the buffer. If the record is no longer than
"len," then the whole record is moved to "adr," and "len" is the
length of the record. If the record is longer than "len," then it
is truncated to length "len," and "len'" equals "len." You get no
warning that the record has been truncated.
"adr len" are the address and length of the record to be written.
(Note, it may be any length up to 255 characters; it may be
longer than the record it replaces.) "recnum" is the number of
the record to be replaced.
You insert a new record in the current file with INSERT. The
linkage is:
REC-CNT n
You delete a record from the current file with DELETE. The
linkage is:
recnum DELETE b
Here, "adr len" are the address and length of the file's name.
If the file exists, "adr" is the address of the first byte in
its header, and "b" is TRUE. If the file does not exist, "adr'"
is absent and "b" is FALSE.
4 + COUNT
Once you have got the ceiling of the file header, you must
allocate enough file space for the data. You do this with REVISE.
The format of REVISE is:
If REVISE succeeds, you can place data in the file with MOVE
or any other appropriate method.
filenum DELETE-FILE b
You can fetch the file number of the current file with CFILE:
CFILE filenum
Renaming a File
Every file has a "record #-1 (number minus 1)" which contains
its name. To rename a file, simply change the contents of this
record. You can do this from the file editor or from your own
program.
You need not create record #-1 in a new file; the system creates
it automatically.
You can test and set the type of the current file by storing
a byte at the address given by GET-TYPE. The linkage is:
GET-TYPE adr
%BASIC
For a Microsoft Basic program file. (Basic source
programs are stored in tokenized form rather than as
pure ASCII text.)
%EXECUTABLE
For "executable." The file contains an executable SNAP
program.
%TEMPORARY
For "temporary," In a future version of the HHC system,
the file will be deleted at the next hard CLEAR. (Note
that a non-temporary file will also be deleted at CLEAR
if it contains no records, or if it contains no non-
null records.)
%TEXT
For "text." The file contains text. This is the only
tyoe of file that the file editor will ocerate on
(except for the renaming operation; see below). Notice
%INVISIBLE GET-TYPE C!
You can OR them into the value of GET-TYPE to add a new type to
those already set:
Executing '0 GET-TYPE C!' resets ALL the types; that is, it
makes the current file non-invisible, non-temporary, non-
executable, and non-text.
You can get the name of the n'th file in the current file
space with LOOKUP. The linkage is:
n LOOKUP (al b
Note that when you call EDIT-FILE you can specify your own
end-of-line and end-of-edit characters. This lets you modify the
behavior of EDIT-FILE to fit situations where RETURN as an end-
of-line character would not make sense.
bytes contents
.....___
0-1 Length of this file in bytes (including this field).
2 Type code (set by GET-TYPE C!).
3 Length of file name (not including length byte
itself).
4-xx File name (1 to 255 characters long).
xx+1 + Records. Each record consists of a length byte giving
the length of the record (not including the length
byte itself) , followed by the data.
records.
bytes contents
0-1 Length of this file in bytes (including this field).
2 Type code (set wih GET-TYPE).
3 Length of file name.
4-xx File name (1 to 255 characters long). Note that
executable and non-executable files have the same
structure up to this point.
xx+1 + Data.
The format is very similar to that of a ROM capsule,
except that there is no header containing address of
tag table, copyright notice, etc.
&EXTRINSIC ( )
Indicates whether the current file space is the extrinsic
or the intrinsic file space. 3=TRUE -> extrinsic, B=FALSE
-> intrinsic.
FSPACE ( ADR )
Returns the address of the beginning of the first file in
the current file space.
FILELEN ( --- LEN )
Returns the length of the current file space.
AVAIL ( N )
Returns the number of free bytes in the current file
space.
FILEORG ( ADR )
Returns the address of the first free location in the
current file space.
FILESPACE ( ADR )
Returns the address of the beginning of intrinsic file
space. (The extrinsic file space, if present, always
begins at location 4000H; but it is NOT bank-switched into
the address space except when needed.)
TP ADR )
Returns the address of a two-byte area which contains the
address of the end of intrinsic file space, i.e., the
address of the lowest byte currently occupied by the
temporary stack.
?ROOM ( N B )
Returns TRUE if N bytes of space is available in the
current file space, and FALSE if not.
operations. This is the main use for them on the HHC. ECBs can
have other functions, though; they are useful wherever one
process needs to wait for an asynchronous EVEN: .7_0 occur. The
completion of an I/O operation is one kind of event.
1. The wait bit. This is the first (80's) bit of the first
byte.
byte.bit contents
return
code (hex) meaning
00 Successful operation.
01 Invalid logical device number (not 0-7) (I/0 onlv).
Using ECBs
We recommend that you not try to share space between ECBs and
other program elements; if you make errors in keeping the uses
separate, they are likely to be hard to debug.
Also, do not use the same ECB for two or more types of
operations, even on the same device. If two operations should
happen concurrently on the same ECB, the results are
unpredictable (and generally unpleasant).
Software: Architecture
Software: In General
returns to the word after the RIP or ROP or whatever. The program
can continue executing, if that is logically possible, while the
7 /0 operation is going forward. We say that the I/O operation is
ASYNCHRONOUS because its progress is not synchronized with the
execution of the program that initiated it.
ecb WAIT
We have stated that RIP reads from the system input device
(normally the keyboard), and the ROP writes to the system output
device (normally the LCD). The KEY word also reads from the
system input device, and the EMIT word writes to the system
output device. What is the relationship between these two sets of
words?
The relationship is this: KEY does a RIP with logical unit
#0, and EMIT does a ROP with logical unit #1. If these logical
units are reassigned, KEY and EMIT will send their output to
different devices, just as RIP and ROP will.
The only important differences between KEY/EMIT and RIP/ROP
is that KEY and EMIT belong to a larger group of words which do
I/O only on logical units #0 and #1, but which support a greater
range of operations on those devices than RIP and ROP do. For
example, the LOCK-KEY word is similar to KEY, but will return the
same character over and over while the LOCK key is in effect.
Outside the context of peripheral I/O, we say that words like
KEY read from the keyboard, and words like EMIT write to the LCD.
What we really mean is that words like KEY read from logical unit
#0, which is normally the keyboard, and words like EMIT write to
logical unit #1, which is normally the LCD. Keep this in mind as
you deal with those words!
Opening and closing are two I/O operations which you must
perform for some devices.
OPENING means preparing the device for I/O, after attaching
it but before doing the first RIP or ROP.
CLOSING means "cleaning up" after the last ROP, e.g., writing
out the last record to a record-oriented device, etc.
A device may be opened and closed with the ROPEN and RCLOSE
words, respectively:
NOTE: do not press any key on the HHC's keyboard which LUN #0
is attached to a peripheral device. If you do so, the HHC may
"freeze up" and execute only one Basic statement each time you
press a keyboard key. If this happens, the HHC will remain
"frozen" until you do a hard CLEAR or reattach LUN #0 to the
keyboard.
PARAMETER VALUES
input output
code code device
41H LCD
31H keyboard
82H 42H modem
43H video
44H Micro Printer
85H 45H reserved for expansion
86H 46H Serial Interface Adaptor
47H speech synthesizer (not yet avail.)
88H 48H reserved for expansion
89H 49H reserved for expansion
4AH reserved for expansion
8BH reserved for expansion
The 20's bit through the l's bit are used to distinguish
device types. The 80's and 40's bit are used to indicate whether
the device may be used for input or output. If the 86's bit is
on, the device may be used for input; if the 40's bit is on, the
device may be used for output.
code meaning
0 Successful operation.
1 Logical device number invalid (not 0-7).
2 Logical device number not assigned.
3 Invalid device type code.
4 Device control ROM absent, or contents invalid.
5 Operation already pending on this device.
6 No RAM available for device (ROPEN).
CONTROL CHARACTERS
SYMBOLIC
CONSTANT HEX MEANING
&BSP 08 backspace
&LF OA line feed
OC form feed
&CR OD carriage return
&ESC 1B escape (starts escape control sequences, below)
80 cursor up
81 cursor left
82 cursor right
83 cursor down
ESCWB Set Word Break. The data byte defines the word break
character that can trigger automatic word wrap. (This
means that when an output line becomes longer than a
device's line length, the device automatically starts a
new line and moves the last word of the old line to the
start of the new line so that the word will not straddle
a line break.)
cases.
The Keyboard
The LCD
(Technical Information)
I/O OPERATIONS:
ROPEN Unneeded.
RIP Not applicable.
ROP Outputs the character stored in byte I (origin-0) of
the ECB.
RCTL Not applicable.
RCLOSE Unneeded.
(General Information)
(Technical Information)
I/O OPERATIONS:
07 Bell; ignored.
08 Backspace. Moves the printer buffer pointer left one
character and deletes the last character in the
buffer.
OA Line feed. The printer treats this code as a no-op.
(Carriage return causes an automatic line feed.
OC Form feed. Writes and empties the printer buffer and
advances the paper 5 lines.
OD Carriage return. Makes the printer print an accumulated
line of output and do a line feed.(Note that tne line
feed character is NOT supported.) After the or inter
has printed the contents of the buffer, the buffer is
reset to all-blanks.
13 Escape. Marks the beginning of an escape control
sequence.
80 Cursor Up. Displays as 'I"
81 Cursor Left. Moves the printer buffer pointer left one
character. The last character in the buffer is not
deleted, but will be overwritten by the next output
character.
82 Cursor Right. Moves the printer buffer pointer right
one character without changing the contents of the
buffer.
83 Cursor Down. Displays as 'V.
Video Interface
(General Information)
(Technical Information)
Modem
(General Information)
(Technical Information)
ECB LENGTH: 4 bytes for RCTL; 2 bytes for input & output
I/O OPERATIONS:
RCLOSE No function.
(Device Initialization)
The modem must be initialized before you can begin doing I/O
on it. Initialization sets hardware options such as data rate,
parity, etc., to values compatible with the host system.
(Initialization Call)
RCTL:
(General Information)
(Technical Information)
ECB LENGTH: 4 bytes for RCTL; 2 bytes for input & output
I/O OPERATIONS:
RCTL Used to initialize the modem for I/O, and to modify and
query its status.
RCLOSE No function.
*NW
(Device Initialization)
(Initialization)
SYMBOLIC
BYTE BIT CONSTANT Meaning for call to RCTL
0 Unused.
1 Function code. Use the symbolic
constant CTLPCA.
2 80 PWRON 1->device power on, 0->off.
40 BRKBIT 1->use breaktone; 0-> don't.
20 unused.
10-08 DTBT Character length in bits. 00-> 5 bits;
01-> 6 bits; 10-> 7 bits; 11-> 8
bits.
04 NOPTY 1->suppress parity check; 0->don't.
02 EVENPTY 1->even parity; 0->odd.
01 STBT Number of stop bits; 1-> 2 bits; 0-> 1
bit.
SYMBOLIC
BYTE BIT CONSTANT Meaning for return from RCTL
.1.1 ...a Nap.
(POKE Call)
SYMBOLIC
BYTE BIT CONSTANT Meaning for call to RCTL
0 Unused.
1 Function code. Use the symbolic
constant CTLPOKE.
2 Offset of PCA field to be POKEd. See
the description of PEEK for useful
offsets.
3 Value to POKE.
SYMBOLIC
BYTE BIT CONSTANT Meaning for return from RCTL
Now
0 Traffic bit & return code.
1-3 Unchanged.
(PEEK Call)
SYMBOLIC
BYTE BIT CONSTANT Meaning for call to RCTL
.11=11,01.0.11=5.110
0 Unused.
3 Unused.
SYMBOLIC
BYTE BIT CONSTANT Meaning for return from RCTL
SYMBOLIC
BYTE BIT CONSTANT Meaning for call to RCTL
0 Unused.
1 Function code. Use the symbolic
constant CTLSTATUS.
2 -3 Unused.
SYMBOLIC
BYTE BIT CONSTANT Meaning for return from RCTL
-- .10
2-3 Unused.
1.1111IP
TIMER SERVICES
INTERNAL STORAGE
byte.bit contents
value meaning
0 ZERO. The numeric value 0.0.
Arithmetic operations which produce 0 always set the
sign bit to 0 (positive). The user may push a
negative 0 on the stack if he wishes; the software
will treat it the same as a positive 0.
The ASCII representation of ZERO is '0'.
1 UNDERFLOW; 10 - -1024 > result > O. An underflow
converted to ASCII is represented as
2 OVERFLOW; result > 110**1023. An overflow converted to
ASCII is represented as 'V'.
3 COMPLEX NUMBER; occurs when an attempt is made to
take the square root of a negative number, or when a
complex number is used in a calculation. A complex
number converted to ASCII is represented as
4 ZERO DIVIDE; occurs wnen a number, overflow, or
underflow is divided by a 0 or by a zero divide. A
zero divide converted to ASCII is represented as
3 ENIGMA; any undecidable result not covered above,
e.g., the result of converting your name to a
floating point number. A zero divide converted to
ASCII is represented as
below.
HEX
: FNEGATE ( --- FPI' )
80 XOR ;
DECIMAL
HEX
: FP>SC (S FP N FP' )
007F AND >T 0F80 AND T> OR ;
(P FP = A FLOATING POINT NUMBER; N = DESIRED SPECIAL
CASE CODE DESIRED; FP' = FP TURNED INTO THE SPECIAL
CASE.)
DECIMAL
: FSC (S N --- FP )
007F AND 0 0 0 ;
(P N IS THE SPECIAL CASE CODE DESIRED; FP IS THE
SPECIAL CASE VALUE.)
HERE-V
0 ,-V 0 ,-V 0 ,-V F53F ,-V == FP0.5
: BLXFLT ( --- )
•• •
FLIT [ 0 ,-V 0 ,-V 0 ,-V F53F ,-V ]
• ' •
The non-checking words are not in the HHC's tag table. If you
want to use them, your program must define words that locate them
by referring to near-by words that are in the tag table. (You
cannot safely code a non-checking word's address into your
program, since the address may change from one version of the HHC
to another. A change in the address of an intrinsic word does not
force application programs to be recompiled, so long as the tag
table does not change.)
CODEC (F+)
'X FNEGATE >< FF AND 2*
IDICT SHINT 2* + + DUP
LDA,
1+ LDY,
LABEL (FIETS)
N 10 + STA,
DEY,
N 11 + STY,
FE # LDY,
N 10 + )y LDA,
N 12 + STA,
INY,
N 10 + )Y LDA,
N 13 + STA,
N 12 + ) JMP,
CODEC (F*)
'X F/ >< FF AND 2*
LDA,
1+ LDY,
(FIETS) BNE,
CODEC (F/)
'X FROUND >< FF AND 2*
IDICT SHINT 2* + + DUP
LDA,
1+ LDY,
(FIETS) BNE,
CODEC LEGAL?
TOP 1+ LDA,
F # AND,
0= IF,
TOP LDA,
0= NOT IF,
ILL,QUAN # LDA,
>EXROR JMP,
THEN,
8 # LDY,
BEGIN,
TOP STA,
INX,
DEY,
0= UNTIL,
TXA,
8 1- 4 SBC,
TAX,
THEN,
IDICT ( 'X EXIT )
) JMP,
GLOSSARY
F! ( FP ADR --- )
A. Stores a floating point number.
FIt ( FP N --- FP N )
A word used by FP>ASC to assist in formatting the ASCII
representation of a floating point number.
F@ ( ADR --- FP )
Fetchs a floating point number.
F. ( FP NDIGITS --- N )
Displays a floating point number in standard notation (not
exponential notation).
F.EXT ( N M --- )
Used after F. to extend a floating point number to a
specified length.
FDROP ( FP --- )
Drops four words (one floating point number) from the
stack.
FDUP ( FP --- FP FP )
Duplicates the floating point number (four words) on the
top of stack.
FLIT ( --- FP )
"Floating point literal." Places the next four words after
this tag on the stack, and passes control around the
words.
At run time, FLIT works like the run-time words LIT (which
stacks a word literal) and CLIT (which stacks a character
literal). FLIT is listed here as well as with the run-time
words because the compiler currently cannot generate it
automatically from a floating point constant.
To use FLIT to compile a floating point number, use the
following words:
FLIT [ nl , -V n2 ,-V n3 , -V n4 , -V
where nl to n4 are the values of the four words that make
up the floating point constant, FP.
FVAR ( )
A defining word. Used in a TSA to reserve 8 bytes of
storage for a floating point variable. For example:
FVAR ERRVAL
Use (Technical)
(Inventory File)
The HHC must have an INVENTORY FILE in its virtual file space
cetore the order entry program may be used. This rile aerines the
items the customer will be able to order. The name of the file
must be '0:E.INW.
There are two ways you can create the inventory file: by
running a separate program from the capsule's main menu, or by
using the file editor.
The separate program in the capsule's main menu is titled
something like - create order entry tile." This program creates an
inventory file containing three hard-coded records, for
- binocular bump pads," "titfin guns," and - nypnogiyphs."
If you want to create a larger or more realistic file (e.g.,
for demonstrating the HHC at a trade show), use the tile edizor
and follow the file format explained in the next section.
The inventory file contains one record per item. The order of
the records is unimportant, except that it aetermines the oraer
name-of-item\qty-price\qty-priceX...\qty-price
The HHC must have an ORDER FILE in its virtual file space in
which to record orders. Unlike the inventory file, the order file
need not be prepared beforehand; the program will create i:
automatically if it does not exist.
The name of the order file is '0.E.ORDER'.
Each record group begins with one record containing the name
and address of the person making the order. This is followed oy
name\adr-line-1\adr-line-2\...\adr-line-n
For example:
3 15 2000
When the order file is nearly full (less than 100 bytes
remaining in the file space), an attempt to start the inventory
program will produce a warning message like this on the LCD:
The two lines of the warning will appear alternately until the
someone presses CLEAR. The "salesman" should copy the order file
to a Programmable Memory Peripheral if he wants to keep it; then
he should delete it. (The program specs state that the salesman
will use an "upload" function to send the order file to a host
system, where orders would be processed. To date the upload
function has not been implemented, because the modem was not
ready for use the last time the program was modified.)
When you start the order entry program, it gives you a menu
with 3 options: "take an order," "print last order," and uorint
summary of orders." Select "take an order."
Next the program prompts you for your name and address. If
the address has fewer than 5 lines, enter a null line after the
last line of the address.
The program then displays the name of the first item in the
inventory file. You can scroll the inventory file forward with
the V key, and backward with the I key. The file is circular;
i.e. the record after the last is the first, and the record
before the first is the last. The program displays a warning
message before wrapping in either direction.
You can order any item by entering the desired quantity while
that item is being displayed, and pressing ENTER. Alternatively,
you can just press ENTER. Then the program displays the first
quantity-price range and the associated price. You can scroll the
quantity-price ranges with the K- and -> keys. Again, you can
order an item by entering the desired quantity and pressing
ENTER; or you can just press ENTER, in which case the program
orompts you for a quantity.
When you are done looking at the extended price, you may
return to the inventory menu by pressing any key.
When you are done entering the order, press the E (for "end")
key. The program displays the total, sales tax (at 6%), and sum
of total and tax.
feed" feature. But there has been talk of making making the
program go to a new page by doing a form feed instead of by
.. counting carriage returns. This is because at trade shows, the
demonstrators tended to alternate this application with others,
and when they used the printer the forms got out of alignment.
Check to see if the program has been modified to do form feeds
before trying to use a printer that does not support that
feature.
Program Structure
111110,-
primary menu
/ \
/ \
/ \
I application menu I
/ \
.1.1.111
I order entry I
i function menu
i I
Figure 6-1
(The Header)
We specify that the mother word, MAIN.MAN, and the tag table
vector initialization word, CAP.INIT, will be represented by long
tags. The first and second tags in the long tag table,
respectively, are reserved for them.
3. Change the names of the tag table and the strings. Ordinarily
none of these names are referred to, so changing them will
have no ripple effect.
(Utilities)
The words defined in this section are ones that are likely to
be useful in other applications.
(I/O Words)
When tne customer presses the -> key, the program calls FIND to
move the pointer forward to the next backslash; then it moves the
pointer one byte further to the beginning of the following field.
INVKEY, which reads a key from the keyboard and acts on it while
the customer is looking at inventory information and ordering
items.
(Function Menu)
Use
When you run SKETCH, you get a function menu with the
following entries:
MAKE NEW PICTURE lets you enter the name of a file in which
SKETCH will save the picture you create. SKETCH creates this file
and makes it the current file, and places you in edit mode so
that you can create a picture.
MODIFY EXISTING PICTURE lets you enter the name of an
existing picture file. SKETCH makes this file the current file,
reads the file, and displays the file on the LCD. Then it places
you in edit mode so that you can modify the picture.
CONTINUE W/ SAME PICTURE enters edit mode without changing
the current file.
SAVE THE PICTURE saves the current picture file, including
any modifications you have made to it. After editing a picture
and returning to the program's menu, you save the edited cicture
(Safety Features)
SKETCH also stops you from running any functions that do not
make sense. For example, you cannot MAKE NEW PICTURE with the
same name as an existing picture; nor can you CONTINUE WITH SAME
PICTURE after DELETE SAVED PICTURE (because the current file is
the one just deleted).
(Edit Mode)
You can change the state of SKETCH with the following keys:
Program Design
(Data)
Note: the last 3 columns of the LCD are not used because of a
bug in the HHC's cursor handling code. Although SKETCH makes the
cursor invisible, the HHC insists that the cursor is present
somewhere in the LCD, and will not allow any dots to be turned on
in that position. SKETCH puts the cursor in position 26 of the
LCD, of which only 3 dot columns are visible, because this is the
last objectionable place for the bug to appear.
The current picture file is kept in PICBUF, a "string"
variable in the TSA. BUF>LCD copies it from there directly to the
LCD buffer, with !DISPLAY. Editing is actually done on the data
in the LCD buffer, using @DISPLAY to fetch the contents of a byte
(i.e., a column of dots) and !DISPLAY to store one. The contents
of the LCD buffer is moved back to PICBUF just before SKETCH
leaves edit mode (see EXEC.KEY).
The variable FNAME holds the name of the current file; the
variable L'NAME holds the length of the name.
The variable PICSTAT holds a code indicating the current
contents of the picture file buffer:
(The Program)
DRAW is the word that implements edit mode. Each of the words
that puts SKETCH into edit mode does so by executing DRAW.
DRAW consists of a loop that Processes one keystroke per
iteration. Each keystroke is passed to EXEC.KEY for processing.
DRAW and EXEC.KEY maintain all relevent state variables on
the stack. Working from the root toward the tip, they are:
X
X-co-ordinate of cursor (0 to 135).
Y
Y-co-ordinate of cursor. This is expressed as a bit
mask which maybe applied to a byte in the picture file
Use
Program Design
OK
hex OK [puts you in base 16.}
string" 1200." asc1200 OK (defines an ASCII constant.}
asc12 00 count asc> fp 2drop OK {converts it to FP. }
. . 0 0 0 1244 OK [types it.}
Notice that ". . ." types the floating point value from the
stack tip word first, which is the reverse of the way you would
use it in a program. For example, the dialog above tells you that
to define a floating point constant with the value 1200.0, you
should code:
HEX HERE
1244 , 0 , 0 , 0 == NAME-OF-THE-CONSTANT
In the TSA, the three variables I.TX, I.RX and I.PX indicate
whether the time, rate, and principal amount have been entered
vet. The variables I.T, I.R and I.P contain the time in months,
the annual rate, and the principal amount, when they have been
entered. I.MR contains the monthly rate, calculated from the
annual rate.
NEW
All*
Friends Amis, Inc. SKETCH/INFL 09-SEP-81 PAGE 1
***********************************
DECIMAL
53
59
5C
****** MISCELLANEOUS ROUTINES *****
: ?EOL (S C )
&CR = ;
(P END-OF-LINE-CHARACTER ROUTINE FOR
EXPECT.)
Friends Am is , Inc . SKETCH/INFL 09-SEP-81 PAGE 2
?EOL == 'EOL
•Y/N (S B)
BEGIN KEY L>U
%Y CASE 1 1 ELSE
%N CASE 0 1 ELSE
DROP 0 ENDIF ENDIF
UNTIL ;
(P PROMPT USER FOR A 'Y' OR 'N )
: 0! (S ADR )
0 SWAP ! ;
(P STORES 0 IN THE WORD AT ADR. )
•• •.
. I, •
••
(P WRITES COLON-SPACE TO LCD. )
: PRO (S a•O
"
KEY DROP
BEGIN ?KEY WHILE KEY DROP REPEAT
(P PROMPT USER TO PRESS ANY KEY TO
PROCEED WITH INSTRUCTIONS. )
: LASTKEY (S C )
KEY
BEGIN ?KEY WHILE DROP KEY REPEAT
HEX
: DIGIT (S C [N] B )
7F AND 30 —
DUP BASE C@ U< IF
1
ELSE DROP 0 ENDIF ;
DECIMAL
: (D.CHK) (S W D W D' )
0 MAX OVER 1— MIN ;
(P INT.L WORD FOR N>ASC CONVERSION.
FORCES 0<=D<=W-1.)
HEX
DECIMAL
: .FP(N) (S FP N --- )
>R
14 R 1+ MINUS FROUND
F.
R> F.EXT ;
(P DISPLAYS FP WITH N DIGITS RIGHT OF THE DECIMAL POINT.)
Friends kmis, Inc. SKETCH/INFL 09-SEP-81 PAGE 5
*************************************
AREA SK.AREA
ENDAREA
: SK.INIT (S )
PICBUF L'LCD ERASE
FNAME L'FNAME &BL FILL
0 L'NAME ! 0 PICSTAT C, •
(P INITIALIZE PROGRAM. )
FILE.NAME (S [A L] B )
CR ." ENTER PICTURE FILE NAME."
FNAME L'FNAME ADR MAXLEN
L'NAME @ DUP \ A ML INITL INITL
'EOL %OVR \ A ML IL IL EOL M
EXPECT 2DROP \ A L
DUP L'NAME ! \ UPDATE NAME LEN.
DUP IF \ALI
ELSE 2DROP 0 ENDIF ; 0
(P DISPLAY LAST-ENTERED FILE NAME &
PROMPT USER FOR NEW FILENAME. )
: .FILE.NAME (S )
%" EMIT FNAME L'NAME @ TYPE %" EMIT SPACE
(P TYPE FILE NAME ENCLOSED IN QUOTES.
: @DISPLAY (S CN F )
DSPLY + PICCOL 1 DMOVE PICCOL C@ ;
(P STACK COL. IMAGE F FROM LCD COLUMN BUFFER.
: !DISPLAY (S F CN )
SWAP PICCOL C!
DSPLY + PICCOL SWAP 1 DMOVE ;
(P PUT COLUMN IMAGE F INTO LCD COLUMN BUFFER.)
: BUF>LCD (S )
PICBUF DSPLY L'LCD DMOVE ;
(P REFRESH LCD FROM PICTURE BUFFER.)
: LCD>BUF (S )
DSPLY PICBUF L'LCD DMOVE ;
(P REFRESH PICTURE BUFFER FROM LCD.)
ERASE .LCD (S )
PICBUF L'LCD ERASE BUF>LCD ;
(P ERASE THE BUFFER & CLEAR THE LCD.)
DRAW (S )
LCD.CR BUF>LCD STOP. CURSOR
26 BUFPOSN C! \ JOHN FORKER'S BUG
L'LCD 2/ 16 1 \ INITIAL X Y MODE
BEGIN
WAIT.KEY \ WAIT FOR KEY
EXEC .KEY \ PROCESS THE KEY
UNTIL 'E' KEY ENDS FTN.
LCD.CR START. CURSOR
(P "DRAW" FUNCTION. )
Friends Amis, Inc. SKETCH/INFL 09-SEP-81 PAGE 8
HEX
: ?PICLOAD (S B )
PICSTAT C@ 1 AND ;
(P DETERMINES IF A PICTURE IS LOADED. )
: !PICMOD (S )
PICSTAT C@ 3 OR PICSTAT C! ;
(P FLAGS PICTURE BUFFER AS LOADED &
MODIFIED. )
: !PICUNMOD (S )
PICSTAT C@ FD AND PICSTAT C! ;
(P FLAGS PICTURE AS UNMODIFIED. )
: !PICUNLOAD (S )
PICSTAT C@ FC AND PICSTAT C! ;
(P FLAGS PIC. AS UNLOADED & UNMODIFIED. )
DECIMAL
: CONT.PIC (S )
?PICLOAD NOTIF
CR .NOFILE EXIT ENDIF
!PICMOD DRAW ;
(P CONTINUE DRAWING A PICTURE ALREADY IN
THE BUFFER.)
SAVE.PIC (S )
?PICLOAD NOTIF
CR .NOFILE EXIT ENDIF
!PICUNMOD
0 DELETE DROP
PICBUF L' LCD 0 INSERT DROP
CR .FILE .NAME ." SAVED" ;
(P SAVE A PICTURE FROM THE LCD BUFFER TO
THE CURRENT FILE. NOTE, THIS IS CALLED
BY 1 ?SAVEFIRSTT AS WELL AS BY THE MENU
DRIVER. )
?SAVEFIRST (S )
PICSTAT C@ 2 AND IF
CR ." SAVE " .FILE.NAME ." FIRST?"
Y/1\1 IF
SAVE.PIC ENDIF
ENDIF
!PICUNLOAD
(P PROMPTS USER TO SAVE CURRENT PICTURE
IF IT IS FLAGGED AS MODIFIED. IT UNLOADS
THE FILE EVEN IF IT DOESN'T SAVE, SINCE
ITS CALLER IS GOING TO DESTROY THE
CONTENTS OF THE FILE NAME BUFFER. )
Friends Amis, Inc. SKETCH/INFL 09-SEP-81 PAGE 9
MAKE.PIC (S )
?SAVEFIRST !PICUNLOAD
FILE.NAME IF \ GET FNAME.
2DUP OPEN NOT IF \ SHOULDN'T FIND IT.
MAKE IF SHOULD MAKE IT.
PICBUF L'LCD 0 INSERT \ ENUF SPACE?
IF !PICMOD ERASE .LCD DRAW \ YES.
\ FOLLOWING ARE ERROR CONDITIONS.
ELSE CR ." NO ROOM TOMAKE FILE"
CFILE DELETE-FILE ENDIF
ELSE CR ." CAN'T MAKE FILE"
ENDIF
ELSE CR ." FILE ALREADY EXISTS"
2DROP ENDIF
ENDIF ;
(P MAKE A NEW PICTURE FILE [SHOULD NOT
ALREADY EXIST]. )
DEL. PIC (S )
?SAVEF IRST
FILE.NAME IF ASK NAME.
OPEN IF \ TRY OPEN.
!PICUNLOAD
CFILE DELETE-FILE \ IT WORKED
CR .FILE.NAME ." DELETED"
ELSE
CR .NOFIND ENDIF
ENDIF ;
(P DELETE A PICTURE FILE. )
HERE
Friends Amis, Inc. SKETCH/INFL 09-SEP-81 PAGE 10
: SK.KEY
IF.ITS 0 MAKE.PIC ENDIF
IF.ITS 1 GET.PIC ENDIF
IF.ITS 2 CONT.PIC ENDIF
IF 3 SAVE.PIC ENDIF
IF.ITS 4 DEL.PIC ENDIF
DROP FALSE ;
SK.DS ( N )
SK.MLIST @SA TYPE ;
SK.MTXT ( N )
5 <IF [ 'X SK.DS ] LITERAL TRUE
ELSE FALSE ENDIF ;
SK.MENU (
SK.INIT
BEGIN
1 [ 'X SK.KEY ] LITERAL
( 'X SK.MTXT ] LITERAL
MENU-DRIVER
AGAIN ;
(P EVERYTHING EXCEPT INITIALIZATION.)
HEX
: SKETCH
SK.AREA ?ENOUGH-ROOM
[ 'X SK.MENU LITERAL FLEE
DECIMAL
Friends Amis, Inc. SKETCH/INFL 09-SEP-81 PAGE 11
\ *****************************************
\ * INFLATION CALCULATOR DEMO PROGRAM *
* J SAC HS 4 JUN 81 *
\ *****************************************
HEX
HOST
HERE 3140 , 20 , 0 , 0 , == FP1200
HERE 0 , 0 , 0 , 0 , == FPO
HERE 0140 , 0 , 0 , 0 , == FP1
SNAP
DECIMAL
AREA I.TSA
CVAR I.TX \ TIME ENTERED?
CVAR I.RX \ RATE ENTERED?
CVAR I. PX \ PRICE ENTERED?
VAR I.T \ TIME (MONTHS)
FVAR I.R \ ANNUAL RATE.
FVAR I.MR \ COMP. MONTHLY %
FVAR I.P \ PRICE
ENDAREA
Friends Amis, Inc. SKETCH/INF L 09-SEP-81 PAGE 12
: ........
(S --- ) . 11 .........11
;
(P TYPES A DOUBLE HYPHEN. )
: I. INVKEY (S --- )
CR . " THAT'S AN INVALID KEY. " ;
(P TYPES "THAT'S AN INVALID KEY. " )
: I. ERR (S --- )
CR ." THAT ISN'T VALID." ;
(P TYPES "THAT ISN'T VALID. )
Friends Amis, Inc. SKETCH/INFL 09-SEP-81 PAGE 13
I. RE VU (S )
CR ." PRICE = "
I.PX C@ IF %$ EMIT I.P F@ 2 .FP(N)
ELSE .-- ENDIF
CR ." RATE _
I.RX C@ IF I.R F@ 2 .FP(N) %% EMIT
ELSE .-- ENDIF
CR ." TIME _
I.TX C@ IF I.T @ . ." MONTHS"
ELSE .-- ENDIF ;
(P REVIEWS FACTORS SET SO FAR.)
: I. TIME (S )
.: SPACE
READINBUF \ READ KEYBD.
?DUP NOTIF DROP EXIT ENDIF LL-> QUIT
2DUP + >R ASC>N R> N END' END
<IF I.ERR DROP EXIT ENDIF \ VALID?
DUP 0< IF I.ERR DROP EXIT ENDIF N<0?
DUP 9999 > IF I.ERR DROP EXIT ENDIF
I.T ! 1 I.TX C! ;
(P ACCEPTS & VALIDATES TIME IN MONTHS.)
I.DATA? (S B )
I.PX C@ I.RX C@ I.TX C@ AND AND
DUP NOTIF
CR ." CAN'T COMPUTE RESULT"
CR ." BECAUSE"
I.PX C@ NOTIF
CR PRICE " H.N.B.E. ENDIF
I.RX C@ MOTIF
CR ." RATE H.N.B.E. ENDIF
I.TX C@ NOTIF
CR . n TIME " H.N.B.E. ENDIF
ENDIF ;
(P ENSURES THAT ALL 3 FACTORS HAVE BEEN
ENTERED BEFORE COMPUTING INFLATION. )
I. PRICE (S )
: I. RATE (S --- )
READINBUF
?DUP MOTIF DROP EXIT ENDIF \ NULL?
2DUP --1- >EZ
ASC>FP DROP
R> < IF I.ERR FDROP
ELSE FDUP I.R F! FP1200 F@ F/
I.MR F! 1 I.RX C!
ENDIF ;
(P ACCEPTS & SAVES ANNUAL INTEREST RATE;
COMPUTES & SAVES MONTHLY COMPOUND INTER-
EST RATE.)
: I.COMP (S --- )
I.DATA? IF
CR ." FINAL PRICE = $"
I.MR F@ FP1 F@ F+ I.P F@
I.T @ 0 DO
FOVER F*
LOOP
2 .FP(N) SPACE FDROP
LASTKEY DROP
ENDIF ;
(P COMPUTES & PRINTS INFLATED PRICE. )
Friends Amis, Inc. SKETCH/INFL 09-SEP-81 PAGE 15
: I.MKEY (S N --- 0 )
IF.ITS 0 I. PRICE ENDIF
IF.ITS 1 I.RATE ENDIF
IF.ITS 2 I.TIME ENDIF
IF.ITS 3 I.REVU ENDIF
IF.ITS 4 I.COMP ENDIF
DROP FALSE ;
HERE
S" ENTER INITIAL PRICE"
S" ENTER ANNUAL INFL. RATE"
S" ENTER TIME IN MONTHS"
S" DISPLAY INPUT"
S" COMPUTE RESULT"
== I.MLIST
: I.DS (S N --- )
I.MLIST @SA TYPE ;
: I.MTXT (S N --- )
5 <IF [ 'X I.DS ] LITERAL TRUE
ELSE FALSE ENDIF ;
: I.INIT (S --- )
FLAME. ON
0 I.PX C! 0 I.TX C! 0 I.RX C!
(P INITIALIZES THE PROGRAM. )
: I.MENU (S ........... )
I. INIT
BEGIN
1 [ 'X I.MKEY ] LITERAL
[ 'X I.MTXT ] LITERAL
MENU-DRIVER
AGAIN ;
(P EVERYTHING EXCEPT INITIALIZATION.)
: INFLATION (S --- )
I.TSA ?ENOUGH-ROOM
[ 'X I.MENU ] LITERAL SOFTAG
I.MENU ;
(P MOTHER WORD.)
Friends Amis, Inc. SKETCH/INFL 09-SEP-81 PAGE 16
\ *****************************************x********
\ * TRAILER & MAIN MENU FOR DEMONSTRATION PROGRAMS *
\ * SKETCH - INFLATION *
\ **************************************************
HEX
: ESKEY (S N --- B )
IF.ITS 0 INFLATION ENDIF
IF.ITS 1 SKETCH ENDIF
DROP FALSE ; \ CONTINUE
DECIMAL
: ESDSP (S N --- )
2 <IF [ 'X .ES ] LITERAL TRUE
ELSE FALSE ENDIF
\ ***********************************
\ * HEADER & COMMON CODE *
\ * FOR SNAP DEMONSTRATION PROGRAMS *
\ * J SACHS -- 23 JUN 81 *
\ ***********************************
HEX
ROMADDR SETORG \ CAPSULE SPACE
ROMID TO DP-V
S" ORDER ENTRY DEMO"
LABEL MY.TAGTABLE
SHINT 040 200 088 TAG. TABLE TABLE.OF.TAGS
MY.TAGTABLE 80 + ROMVECT !-V
2 ROMEXT C!-V
80 CSPEED C!-V
LONG MAIN. MAN \ ENTRY POINT
LONG CAP.INIT \ CAPSULE INITIALIZATION: SET UP SHORT TAG TABLE
DEC IMAL
HEX
1A == ^Z
22 == %"
24 == %$
25 == %%
2E == &.
45 == %E
4E == %N
53 == %S
59 == %Y
5C == &\
DEC IMAL
: ?EOL (S C --- B )
&CR = ;
(P END-OF-LINE-CHARACTER ROUTINE FOR
EXPECT. )
•Y/N (S --- B)
BEGIN KEY L>U
%Y CASE 1 1 ELSE
,40.. %N CASE 0 1 ELSE
DROP 0 ENDIF ENDIF
Friends Amis, Inc. 0.E-EXAMPLE 09-SEP-81 PAGE 2
UNTIL ;
(P PROMPT USER FOR A 'Y' OR 'N'.)
: 0! (S ADR --- )
0 SWAP ! ;
(P STORES 0 IN THE WORD AT ADR.)
II II
: ;
(P WRITES COLON-SPACE TO LCD.)
: PRO
.1I ....... > II
KEY DROP
BEGIN ?KEY WHILE KEY DROP REPEAT
(P PROMPT USER TO PRESS ANY KEY TO
PROCEED WITH INSTRUCTIONS.)
: LASTKEY (S --- C )
KEY
BEGIN ?KEY WHILE DROP KEY REPEAT
HEX
: GETDIGIT (S C [N] B )
7F AND 30 -
DUP BASE C@ U< IF
1
ELSE DROP 0 ENDIF ;
DECIMAL
: (D.CHK) (S W D W D' )
0 MAX OVER 1- MIN ;
(P INT.L WORD FOR N>ASC CONVERSION.
FORCES. 0<=D<=W-1.)
HEX
DECIMAL
: .FP(N) (S FP N )
>R
14 R 1+ MINUS FROUND
F.
R> F.EXT ;
(P DISPLAYS FP WITH N DIGITS RIGHT OF THE DECIMAL POINT.)
Friends Amis, Inc. 0.E-EXAMPLE 09-SEP-81 PAGE 5
************************************
HEX
AREA 0.TSA
\ PRINTER VARIABLES
VAR LINE# VAR PAGELEN
VAR COL# VAR LINELEN
ENDAREA
•0.INBUF 0.INBUF# 1+
DECIMAL
: OPEN.L ( --- B )
PTR.D# PTR.U# ATTACH IF \ TRY ATTACH.
PTR.ECB PTR.U# ROPEN \ TRY OPEN.
ELSE FALSE ENDIF ;
(P "OPEN" EPSON PRINTER.)
: EMIT.L ( C --- )
1 COL# +1
5C CASE 2F ENDIF
PTR.ECB WAIT PTR.ECB 1+ C!
PTR.ECB PTR.U# ROP DROP ;
(P EMIT CHARACTER TO EPSON PRINTER.)
: TYPE.L ( A L --- )
OVER + SWAP ?DO I C@ EMIT.L LOOP ;
(P "TYPE" A STRING TO EPSON PRINTER.)
: CR.L ( --- )
&CR EMIT.L
COL# 0! 1 LINE# +!
: SPACES.L ( N --- )
0 ?DO &BL EMIT.L LOOP ;
DECIMAL
Friends Amis, Inc. 0.E-EXAMPLE 09-SEP-81 PAGE 7
: . AT
OPEN.INV ( )
O.INV COUNT OPEN NOTIF
CR ." NO INVENTORY FILE!" ENDIF
PROMPT>OUTBUF (S B )
O.OUTBUF COUNT SWAP OVER + LN CL
0.L'OUTBUF ROT - \ CL LEN-REMAIN
&LBUF SWAP CL &LBUF LEN-REMAIN
0 0 'EOL %OVR EXPECT \ CL +A +L E' K M
2DROP \ CL +A +L
>R SWAP R CMOVE R> \ MOVE IT; +L
0.0UTBUF +C! 1 ; INCR LENBYTE
(P READS A STRING FROM KEYBD & APPENDS
IT TO 0.0UTBUF.)
: +OUTBUF (S C )
0.0UTBUF COUNT + C! 1 0.0UTBUF +C! ;
(P APPENDS A CHARACTER TO 0.0UTBUF.)
HEX
HERE
S" PRESS '5' KEY TO START."
S" FOR NEXT ITEM PRESS X." \ UPARROW
-2 ALLOT-V 33 C, &. C,
S" FOR LAST ITEM PRESS X." DOWNARROW
-2 ALLOT-V 80 C, &. C,
S" FOR NEXT PRICE PRESS XXX." ->
'4110,
-4 ALLOT-V &ESC C, ESCDC C, 82 C, &. C,
S" FOR LAST PRICE PRESS XXX." <-
Friends Amis, Inc. 0.E-EXAMPLE 09-SEP-81 PAGE 8
: 0.HELP ( --- )
O.HLST BEGIN
DUP C@ NOTIF DROP 0.HLST ENDIF
COUNT 2DUP CR TYPE
+
?KEY IF KEY L>U %S = ELSE 0 ENDIF
UNTIL DROP
(P ROTATE THROUGH 0.HLST UNTIL USER
PRESSES 'S'.)
: INIT. ORDER (S - )
0 0 0.TOTAL 2!
0.CURITM 0! 0.CURFLD 0!
0.INBUF# 0!
LINE4 0! COL# 0!
66 PAGELEN ! 35 LINELEN !
(P INITIALIZATION FOR AN ORDER.)
Friends Amis, Inc. 0.E-EXAMPLE 09-S EP-81 PAGE 9
: N>OUTBUF (S N )
S>D <# # #S #> STR>OUTBUF ;
(P CONVERTS A NUMBER TO ASCII & APPENDS
IT TO 0.0UTBUF.)
: D. $&C (S DN )
&. HOLD 2DUP OR IF \ .
#S ENDIF &$ HOLD #> TYPE ; $
(P INTERPRETS N AS A NUMBER OF CENTS &
PRINTS A PRICE IN THE FORM 1 $DD.CC 1 .)
: PROMPT.NAME (S )
OPEN. ORDER
REC-CNT 0.NAME
0 0.0UTBUF C! &\ +OUTBUF
CR ." YOUR NAME: "
PROMPT>OUTBUF DROP &\ +OUTBUF
CR ." HOUSE ADDRESS:
PROMPT>OUTBUF DROP &\ +OUTBUF
CR ." CITY, STATE ZIPCODE:
PROMPT>OUTBUF DROP
O.OUTBUF COUNT REC-CNT INSERT DROP ;
(P PROMPTS FOR NAME & ADDRESS AT START
OF AN ORDER.)
HEX
: FETCH .PRICE (S N )
0.INBUF 1+ \FIND \ SKIP NAME FLD
BEGIN \ SEARCH QTY/$S
DUP 7F ASC>N SWAP DROP \ AMIN AMAX-1
1+ 7F ASC>N DROP \ A-MIN MAX
Friends Amis, Inc. 0.E-EXAMPLE 09-SEP-81 PAGE 10
RECORD.ITEM (S
0 0.0UTBUF C! \ NULL >OUTPUT.
0.CURITM @ N>OUTBUF ITEM# >OUTPUT
20 +OUTBUF \ BLANK >OUTPUT
0.QTY @ N>OUTBUF \ QTY >OUTPUT
20 +OUTBUF \ BLANK >OUTPUT
0.PRICE @ N>OUTBUF \ UNIT PRICE
OPEN. ORDER
0.0UTBUF COUNT REC-CNT INSERT DROP
OPEN.INV ;
(P WRITES AN ORDERED ITEM TO THE ORDER
FILE.)
DEC IMAL
: WRAPMSG (S )
CR ." YOU HAVE REACHED THE
DUP 0< IF ." START" ELSE • END"
ENDIF
CR ." OF THE INVENTORY LIST."
CR ." THE NEXT ITEM YOU SEE"
CR ." WILL BE THE "
DUP 0< IF
." LAST." ELSE ." FIRST." ENDIF
0 > IF
CR ." PRESS 'E' TO END ORDER."
ENDIF ;
(P INVENTORY LIST WRAP MESSAGE. 3=1 ->
WRAP FROM END TO START; 8=-1 -> WRAP
FROM BEGINNING TO END.)
: INVREAD (S )
OPEN.INV \ OPEN INV. FILE.
0.INBUF 0.L'INBUF \ READ CUR. RCD.
0.CURITM @ READ DROP
0.INBUF 0 SWAP C! \ PUT NUL AT END.
0.INBUF 0.CURFLD ! ; \ SET FIELD ADR.
(P READS CURRENT RECORD FROM INVENTORY
FILE INTO INBUF.)
Friends Amis, Inc. 0.E-EXAMPLE 09-SEP-81 PAGE 11
INVDISP (S )
0.CURFLD @ DUP &\ \ A A '\'
FIND NOTIF \ A A' (A('\')).
DUP 0 FIND DROP ENDIF
OVER \ A L
CR TYPE ; \ TYPE IT.
(P DISPLAYS CURRENT FIELD OF CURRENT
RECORD.)
: MOVEDN (S )
OPEN.INV 0.CURITM @ 1+ \ ITEM #.
DUP REC-CNT < NOTIF > MAX.?
1 WRAPMSG DROP 0 ENDIF \ YES; WRAP.
0.CURITM ! \ STORE #.
INVREAD ; \ READ RCD.
(P MOVE DOWN TO NEXT INVENTORY ITEM.)
MOVEUP (S )
OPEN. INV 0.CURITM @ 1- \ ITEM #.
DUP 0< IF < 0?
-1 WRAPMSG DROP \ YES; WRAP.
DROP REC-CNT 1-
ENDIF
0.CURITM ! \ STORE #.
INVREAD ; \ READ RCD.
(P MOVE UP TO PREVIOUS INVENTORY ITEM.)
MOVEL (S )
O.CURFLD @ 2- \ A(LAST CHR) PRV FLD.
DUP C@ NOTIF \ IS THERE ONE?
DROP \ NO.
0.INBUF 0 FIND DROP 1- \ C(RCD)-1.
ENDIF
&\ -FIND IF 1+ \ GO BACK TO
ELSE 0.INBUF ENDIF \ TO START IF NONE.
0.CURFLD ! ; \ SET A(FIELD).
(P MOVE LEFT 1 FIELD IN CURRENT INVENTORY RECORD.)
: MOVER (S )
0.CURFLD @ &\ FIND IF
1+ A(NEXT FIELD).
ELSE 0.INBUF ENDIF \ NONE; USE STRT
0.CURFLD ! ; \ SET A(FIELD).
(P MOVE RIGHT 1 FIELD IN CURRENT INVENT-
ORY RECORD.)
ORDER. ITEM (S C )
&LBUF C! \ SAVE 1ST CH
CR ." ENTER QUANTITY: "
&LBUF 10 OVER C@ IF 1 2 ELSE 0 0 ENDIF
'EOL %OVR EXPECT 2DROP \ READ ++
2DUP fi >R ASC>N CVT ->N UM
R> = IF VALID?
DUP O. QTY ! \ YES; SAVE
Friends Amis, Inc. 0.E-EXAMPLE 09-S EP-81 PAGE 12
INVKEY (S B )
KEY L>U
IF.ITS &< MOVEL 1 ENDIF MOVE LEFT
IF.ITS &> MOVER 1 ENDIF MOVE RIGHT
IF.ITS &U MOVE UP 1 ENDIF MOVE UP
IF.ITS &D MOVEDN 1 ENDIF \ MOVE DOWN
IF.ITS &CR
0 ORDER.ITEM 1 ENDIF ENTER
DUP GETDIGIT IF \ A DIGIT.
DROP DUP ORDER.ITEM 1 ENDIF
IF.ITS %a 0 ENDIF \ END.
SWAPDROP ;
(P PROCESS USER RESPONSE.)
: SUMMARY.NAME (S A L )
1- SWAP 1+ SWAP TYPE.L CR.L ;
(P PRINT A NAME RECORD IN THE QUEUE
SUMMARY.)
SUMMARY .ITEM (S A L )
RETRIEVE.ITEM \ FORMAT RECORD.
0.QTY a S>D 5 0 DN>ASC(W,D) 1-
TYPE.L 2 SPACES.L
>R R TYPE.L
28 R> - 1 MAX SPACES.L
].PRICE @ S>D 6 2 DN>ASC(W,D) TYPE.L
3 SPACES.L
0.PRICE @ S>D 0.QTY @ SD*
3 2 DN>ASC(W,D) TYPE.L CR.L
(P PRINT AN ITEM RECORD IN THE QUEUE
SUMMARY.)
Friends Amis, Inc. (LE-EXAMPLE 09-SEP-81 PAGE 14
HEX
PRINT .SUMMARY (S )
INIT.ORDER
80 PTR.ECB C!
OPEN. ORDER CR.L
REC-CNT 0 ?DO
OPEN.ORDER
0.INBUF DUP 0.L'INBUF I READ DROP
OVER C@ &\ =
IF SUMMARY.NAME
ELSE SUMMARY.ITEM
ENDIF
LOOP
CR ;
(P PRINT A SUMMARY OF THE ORDER QUEUE.)
DECIMAL
: PROMPT .ORDER (S )
OPEN. ORDER
REC-CNT 0.1STITEM ! \ START WRITE HERE
INVREAD \ READ 1ST INV RCD
BEGIN INVDISP INVKEY WHILE REPEAT ;
(P PROMPT USER FOR HIS ORDER; CONTINUE
UNTIL INVKEY RETURNS 0, INDICATING LAST
ITEM ENTERED.)
REVIEW.ORDER (S )
CR ." SUMMARY OF YOUR ORDER:"
OPEN. ORDER
REC-CNT 0.1STITEM =a ?DO FOR EACH RCD
OPEN. ORDER
0.INBUF DUP 0.L'INBUF READ,
I READ DROP TYPE NAME,
RETRIEVE .ITEM CR TYPE \ GET DATA,
.: SPACE 0.QTY @ . .AT \ TYPE QTY,
0.PRICE @ S>D D.S&C \ PRICE, ":"
0.PRICE @ S>D \ EXTENDED
0.QTY @ SD* D. $&C PRICE.
LOOP ;
(P REVIEWS THE ORDER AFTER LAST ITEM HAS
BEEN ENTERED)
•SHOW .TOTALS (S )
CR ." TOTAL IS " 0. TOTAL 2@ D. $&C
O. TOTAL 2@ 6 SD* 100 UM/ SWAP DROP S>D
CR ." SALES TAX a 6% IS " 2DUP D. $&C
0.TOTAL 2@
CR ." TOTAL TAX IS " D.$&C
(P SHOWS TOTAL, TAX, & TOTAL+TAX.)
: ACCEPT, ORDER? (S )
CR ." TAKE ORDER AS SHOWN (Y/N)?"
Y/N IF
Friends Amis, Inc. 0.E-EXAMPLE 09-SEP-81 PAGE 15
: FORM.FEED (S
BEGIN
CR. L \ DO CR'S
LINE# a PAGELEN \ UNTIL END
< WHILE REPEAT
LINE# 0! ; \ OF PAGE.
(P DO "FORM FEED" ON EPSON PRINTER BY
CR'S UNTIL LINE#=PAGELEN.)
•SKIP.TO.LINE
DUP LINE; @ > IF \ ANY WORK TO DO?
DUP PAGELEN @ > \ YES; TOO MUCH?
IF DROP FORM.FEED \ YES; FF.
ELSE \ NO; EMIT
LINE# N-LINE#
DO CR.L LOOP \ CR'S.
Friends Amis, Inc. 0.E-EXAMPLE 09-S EP-81 PAGE 17
ENDIF
ELSE DROP \ NO WORK TO DO.
ENDIF ;
(P SKIP TO LINE N ON EPSON PRINTER. )
HEX
PR .CUST (S )
OPEN. ORDER
O. INBUF DUP O. L INBUF
O. NAME @ READ DROP \ GET NAM , ADR
OVER + SC SWAP C! \ TERMINATE
1+ \ SKIP 1ST BACKSLASH
3 0 DO *** RISKY
DUP \FIND
SWAP 2DUP - 1- \ CIEL OLD CIEL-OLD
OC SKIP.TO.COLUMN
TYPE.L CR.L \ LINE OF CUST
LOOP DROP ;
(P PRINT A CUSTOMER'S ORDER.)
DEC IMAL
HERE
S" THE PANASONIC HAND HELD COMPUTER"
== THE.HHC
HERE
S" ORDER ENTRY DEMONSTRATION PROGRAM"
== 0.E.D.P.
: PR.0.1 (S )
6 SKIP.TO.LINE
12 SKIP.TO.COLUMN
THE.HHC COUNT TYPE.L CR.L
12 SKIP.TO.COLUMN
0.E.D.P. COUNT TYPE.L CR.L
13 SKIP.TO.LINE
PR. OUST ;
(P PRINTS HEADING & NAME ON AN ORDER
FORM.)
PR.0.2 (S )
24 SKIP.TO.LINE
OPEN. ORDER
REC-CNT 0.1STITEM @ ?DO
OPEN. ORDER
0.INBUF DUP 0.L'INBUF I READ DROP
RETRIEVE.ITEM
0.QTY @ S>D 5 0 DN>ASC(W,D)
1- 5 1 RTYP.L
O.CURITM @ 230 +
S>D 4 0 DN>ASC(W,D) 1-
4 21 RTYP.L OVER C@ EMIT.L
30 SKIP.TO.COLUMN TYPE.L
0.PRICE @ S>D
7 DN>$&C 8 60 RTYP.L
0.PRICE @ S>D
0.QTY @ SD* 2DUP
0.TOTAL 2@ D+ 0.TOTAL 2!
7 DN>S&C EX.PR CR.L
LOOP ;
(P PRINTS THE ITEMS-ORDERED PART OF AN
ORDER FORM.)
PR.0.3 (S )
58 SKIP.TO.LINE
0.TOTAL 2@
7 DN>S&C EX.PR
61 SKIP.TO.LINE
0.TOTAL 2@ 5 SD*
100 UM/ SWAP DROP S>D
2DUP 7 DN>S&C EX.PR
64 SKIP.TO.LINE
O.TOTAL 2@ 0+
7 DN>S&C EX.PR CR.L ;
(P PRINT TOTALS PART OF AN ORDER FORM.)
Friends Amis, Inc. 0.E—EXAMPLE 09—SEP-81 PAGE 19
HEX
: PRINT.ORDER (S --- )
80 PTR.ECB C!
INIT. ORDER
PR.0.1 PR.0.2 PR.0.3
FORM .FEED ;
(P PRINT AN ORDER.)
DECIMAL
•0.PGMS
IF.ITS 0 TAKE .ORDER ENDIF
IF.ITS 1 PRINT.ORDER ENDIF
IF.ITS 2 PRINT .SUMMARY ENDIF
DROP FALSE ;
HERE
S" TAKE AN ORDER"
,nor S" PRINT LAST ORDER"
S" PRINT SUMMARY OF ORDERS"
== 0.MSGLST
: O. MSG
0.MSGLST @SA TYPE ;
•0.MSGS
3 <IF [ 'X 0.MSG ] LITERAL TRUE
ELSE FALSE ENDIF ;
•ORDER. MENU
INIT.ORDER \ INITIALIZATION!
100 ?ROOM NOTIF
BEGIN
. " FILE SPACE LOW" CR
. " PLEASE NOTIFY A SALESMAN" CR
AGAIN
ENDIF
BEGIN
1 [ 'X 0.PGMS ] LITERAL
[ 'X 0.MSGS ] LITERAL
MENU—DRIVER
AGAIN ;
(P WHOLE PROGRAM EXCEPT INITIALIZATION. 'FLEE'
GOES HERE, & CONTROL RETURNS HERE ,THEN 'CLEAR'
IS PRESSED.)
Friends Amis, Inc. 0.E-EXAMPLE 09-SEP-81 PAGE 20
HEX
•ORDER. ENTRY
0.TSA ?ENOUGH-ROOM
80 PTR.ECB C!
80 POZECB C!
0.1STITEM 0! 0.NAME 0!
OPEN. L
[ 'X ORDER.MENU ] LITERAL SOFTAG !
ORDER.MENU ;
(P MOTHER WORD FOR ORDER ENTRY.)
DECIMAL
Friends Amis, Inc. 0.E-EXAMPLE 09-SEP-81 PAGE 21
\ ****************************************
\ * BUILD INVENTORY FILE FOR ORDER ENTRY *
\ * J SAC HS 4 JUN 81 *
\ ****************************************
HERE
S" BINOCULAR BUMP PADS\1-5 .50\6-10 .40\11+ .35"
S" TIFFIN GUNS\1-3 55.00\4-8 40.00\9+ 30.00"
S" HYPNOGLYPHS\1-9 10.00\10+ 8.00"
HOST 0 , SNAP
== LINES
: PUT.IT.OUT ( --- )
0.INV COUNT MAKE DROP
%TEXT GET-TYPE C!
LINES BEGIN
DUP COUNT REC-CNT INSERT DROP
COUNT +
DUP C@ WHILE REPEAT
DROP ;
Friends Amis, Inc. 0.E-EXAMPLE 09-SEP-81 PAGE 22
\ **************************************************
\up
\ * TRAILER & MAIN MENU FOR DEMONSTRATION PROGRAMS *
\ * ORDER ENTRY *
\ **************************************************
: ESKEY (S N --- B )
IF.ITS 0 PUT.IT.OUT ENDIF
IF.ITS 1 ORDER. ENTRY ENDIF
DROP FALSE ; \ CONTINUE
: ESDSP (S N --- )
2 <IF ( 'X .ES ] LITERAL TRUE
ELSE FALSE ENDIF
;
\ SET UP TAG TABLE VECTORS
: CAP. INIT \ CALL BY SNAP INTERPRETER AND OTHERS TO SEI
MY.TAGTABLE TVECTO ! \ TABLES AND OTHER INITIALIZATION WITH
( TVECTO 8 + ] LITERAL C@ \ WITHOUT ENTERING THE MAIN ROUTINE -....
( TVECTO 2 + 3 LITERAL C! ;
: MAIN.MAN (S --- )
CAP. INIT
BEGIN
1 'X ESKEY
'X ESDSP
MENU-DRIVER
AGAIN ;
DECIMAL
THE SNAP ASSEMBLER
OVERVIEW
I. The word definition begins with CODE and the name of the word
being defined, and ends with ENDCODE; this is analogous to a
high level definition beginning with I:I and the name of the
word, and ending with
...t2
Two Types of Routines
The word CODE creates a tag table entry for an assembler word
definition, and also initiates the assembly process. We will call
a word defined by CODE a CODE DEFINITION or a CODE WORD.
The assembly process consists of interpreting code with the
context vocabulary set to ASSEMBLER.
The ASSEMBLER vocabulary contains definitions of the words
that make up assembler programs (e.g., it contains the 6502
opcodes). The primary function of these words is to deposit
machine code in the target address space.
If the SNAP interpreter fails to find a word in the ASSEMBLER
vocabulary, it goes on to search the current vocabulary (if any),
then the SNAP or ULTRA vocabulary; then it tries to interpret the
word as a number; then it gives an "undefined word" error. Note
that these are exactly the same rules that the SNAP interpreter
follows at other times!
N 2+ )Y STA,
OPCODES
Figure 7-1 shows the 6502 opcodes in the forms that they are
recognized by the SNAP assembler.
One-mode Opcodes
Multi-mode Opcodes
FIGURE 7-1
6502 SNAP ASSEMBLER OPCODES
OPERANDS
Addressing Modes
.A accumulator none
immediate 3 bits only
,X indexed X z-page or absolute
,Y indexed Y z-page or absolute
X) indexed indirect X z-page
)Y indirect indexed Y z-page
indirect absolute
none memory z-page or absolute
Figure 7-2(a)
.A ROL, ROL A
1 # LDY, LDY #1
,X N ,X STA, STA N,X
,y N ,Y CMP, CMP N,Y
X) 6 X) ADC, ADC (06,X)
)Y N )Y STA, STA (N) ,Y
N 2+ ) JMP, JMP (N+2)
none NEXT JMP, JMP NEXT
Figure 7-2(b)
FLOW OF CONTROL
IF . . . ELSE • . ENDIF
N LDA,
0= IF, N 1+ ADD,
ELSE, N 2+ ADD,
ENDIF,
SPECIFIER PROCESSOR
WORD STATUS TEST NATURE OF TEST
BEGIN,
TOP LDA, N ,Y STA,
INX, INY, N 1- CPY,
0= UNTIL,
BEGIN,
TOP LDA, N ,Y STA,
0= WHILE,
INX, INY, N 1- CPY,
REPEAT,
BEGIN,
CALLED-PROCEDURE-1 JSR, 0= IF, NEXT JMP, ENDIF,
CALLED-PROCEDURE-2 JSR, 0= IF, NEXT JMP, ENDIF,
CALLED-PROCEDURE-3 JSR, 0= IF, NEXT JMP, ENDIF,
•• •
AGAIN,
SETUP
The HHC has a low level procedure named SETUP which pops
input values off the parameter stack and stores them in a
workarea in RAM.
On entry to SETUP, the accumulator should contain the number
of 16-bit values to be popped. This number may be in the range 1
to 8.
When you define a low level procedure, you must identify its
entry point with a LABEL. You can do this with the LABEL word.
For example:
HEX
LABEL CKCPYRT
OiC EDY,
BEGIN,
ROMADDR ,Y LDA,
CPYRTMSG ,Y CMP,
0= NOT IF, RTS, ENDIF,
DEY,
0= UNTIL, RTS,
CKCPYRT JSR,
CODE DROP
INX, INX, UN BX BSP,
NEXT JMP,
NEXT JMP,
(:P)
SNAP words go here..
(;P)
•
•
CAUTION!: the symbols that begin and end the high level code
are '] [1 , not 1 []'. This oddity is due to the fact that the
symbols 1 1] 1 were originally intended to escape FROM compile mode
in order to execute some statements (e.g., to compute tne value
of a svmbol at compile time). Here they are being used to escaPe
INTO compile mode, so their order must be reversed.
PUSH Pushes a new entry on the stack. The low byte of the
entry contains the value in the accumulator. The
high byte contains the tip byte of the return stack.
The tip byte of the return stack (NOT a whole entry)
is dropped.
PUSHOA Pushes a new entry on the stack. The low byte of the
entry contains the value in the accumulator. The
high byte contains zero.
PUT Drops the tip entry on the stack, th.,n does a PUSH.
Temporary Storage
The HHC has several storage areas in page-0 RAM that are
available for use by low level code.
SECURITY
1. The parameter stack must have the same depth at the end of a
definition as it had at the beginning.
EXAMPLES
law
Below are several examples of CODE words and low level
procedures to help you become familiar with the SNAP assembler
and the techniques of writing low level code for the HHC.
Example 1: SETUP
Example 2: U*
0 HEX
1 CODE U* ( U1 U2 --- DU )
2 SEC LDA, N STA, SEC STY,
3 SEC 1+ LDA, N 1+ STA, SEC 1+ STY,
4 10 # LDY,
5 BEGIN,
6 TOP 2+ ASL,
7 TOP 3 + ROL, TOP ROL, TOP 1+ ROL,
8 CS IF,
9 CLC,
10 N LDA, TOP 2+ ADC, TOP 2+ STA,
11 N 1+ LDA, TOP 3 + ADC, TOP 3+ STA,
12 CS IF,
13 TOP INC,
14 0= IF,
15 TOP 1+ INC,
16 ENDIF,
17 ENDIF,
18 ENDIF,
19 DEY,
20 0= UNTIL
21 NEXT JMP,
22 ENDCODE
SO S1
•
\
i
1 U2L U2H 1 UlL U1H
1 I
UIL U1H
SO S1
1 i 1
I U2L U2H I 0 0 I
i 1 .
. 1
I<---tip of stack high memory --->
Next U* begins a loop♦ The loop shifts the tip 4 bytes of the
stack (SO/S1) left one bit. A 0 goes into the lowest bit of Si,
and the highest bit of SO goes into the carry flag, C. Then, if C
is set (i.e., if the bit shifted out of SO was 1) it adds Ul to
Si.
The loop is executed 16 times, once for each bit in U2. When
it is done, U2 has been shifted out of existence, and SO/S1
contains the product, DU.
ya•- 5-7. The loop begins. The 32-bit unit SO/S1 is shifted left
one bit. Notice how S1 is addressed as 'TOP 2+ and 'TOP
3 +', rather than 'SEC' and 'SEC 1+'. This makes no
difference in the assembled code, but it emphasizes that
we are treaing S1 as an extension of SO, and not as a.
separate 16-bit parameter.
8-11. If C (the bit just shifted out of SO) is 1, we add Ui to
Si.
Example 3: SHIFT
The word loads NS's high byte (NSH) into A. It uses the
"negative" or "sign" flag to choose a left shift (N=0) or a right
shift (N=1). Then it executes one of two loops to shift X the
proper number of bits in the proper direction.
HHC WORDS
( X A --- )
Stores X at A. Pronounced "store" or "bang."
( ND1 ND2 )
Used to convert binary numbers to ASCII. See description
of <# for details.
( ND --- A L )
Used to convert binary numbers to ASCII. See description
of <# for details.
#DECB ( A )
(Stacks address of DECB, a timer ECB used by the LCD
display routines. #DECB is a short tag; thus you should
use #DECB instead of DECB to save a byte in your code.)
4S ( ND1 ND2 )
Used to convert binary numbers to ASCII. See description
of <# for details.
%DELETE ( N)
"Delete mode" mask for EXPECT's mode parameter. See EXPECT
for details.
%EXECUTE ( N )
%INSERT (--- N) .
"Insert mode" mask for EXPECT's mode parameter. See EXPECT
for details.
%INVISIBLE ( --- N )
File-type mask used with GET-TYPE to designate the
"invisible" attribute.
%LD ( ___ N )
"Lock-delete mode" mask for EXPECT's mode parameter. See
EXPECT for details.
%LI ( --- N )
"Lock-insert mode" mask for EXPECT's mode parameter. See
EXPECT for details.
%OVR ( m N)
"Overstrike mode" mask for EXPECT's mode parameter. See
EXPECT for details.
%TEMPORARY ( --- N )
File-type mask used with GET-TYPE to designate the
"temporary" attribute. (Not presently used.)
%TEXT ( --- N )
File-type mask used with GET-TYPE to designate the "text"
attribute.
&2SH ( --- c )
(The binary value input by the 2nd SHIFT key. Application
programs never get to see this keystroke; it is filtered
out by the I/O routines in the nucleus.
(Note that the 2nd SFT key normally is processed by the
keyboard handling routines in the nucleus, so that an
application program never sees it.)
&< ( ___ C )
The binary value input by the "cursor left" key.
&> ( m c )
The binary value input by the "cursor right" key.
&APS ( --- A ) V6
A 6-byte area in page 0 which is available for use by
application programs. This area is not used by any part of
the HHC*I s operating system. It is destroyed only by a hard
clear.
&BL ( )
The binary value input by the "space" key. The name stands
for "blank."
See the description of 20H.
&BSP ( )
The binary value input representing the ASCII character
"backspace" (not represented on the HHC keyboard).
&C1 ( )
&C2 ( )
&C3 ( )
&C4 ( )
The binary values input by the HHC keys "Cl," "C2," "C3,"
and "C4."
&CFILE ( A) V2
Pointer to the currently open virtual file. If no file has
been opened since the most recent soft or hard clear, the
pointer is zero.
&CR ( )
The binary value input by the ENTER key. It represents the
ASCII control character RETURN. Sent to an output device,
performs a carriage return; sending this character to the
LCD is equivalent to doing a CR.
&CSR ( )
The binary value input by the "search" key.
&D ( )
The binary value input by the "cursor down" key.
&ESC ( )
The binary value representing the ASCII control character
ESCAPE. Not represented on the HHC keyboard. Sen to an
output device, it begins an escape control sequence.
&EXTRINSIC ( --- A ) V1
Indicates whether the current virtual file space is the
extrinsic or the intrinsic file space (i.e., in a
Programmable Memory Peripheral or in intrinsic RAM). A
zero value means intrinsic. A non-zero value indicates
extrinsic; the value is the number of the RAM bank
currently selected.
&FP ( A) V6
A temporary storage area used by floating point code
words. It is safe for application programs to use, but its
contents may be destroyed by the execution of any floating
point word.
&HLP ( )
The binary value input by the HELP key.
&I ( )
The binary value input by the INSERT key.
&IO ( )
The binary value input by the I/O key.
&K ( )
The binary value input by the DELETE key.
&KL ( N)
("Delete line" keyboard code. Not used in the current
version of the HHC.)
&LBUF ( A) V80
An 80-character area which you may use as an input buffer
for EXPECT.
&LF ( )
The value of the ASCII control character LINE FEED (not
represented on the HHC keyboard).
&LK ( )
(The binary value input by the LOCK key. Application
programs never get to see this keystroke; it is filtered
out by the I/O routines in the nucleus.
&LOCK ( --- FL ) V1
(A byte used by EXPECT to implement its handling of the
LOCK key.)
&MEM ( A ) V8
(Used by the intrinsic calculator for "memory." Do not use
this area; if you do, you will destroy the contents of the
calculator's memory. HHC specs state that the memory
persists across hard clears.)
&MODE ( --- FL ) V1
(A byte used by EXPECT to implement its handling of the
INSERT and DELETE keys.)
&R ( )
The binary value input by the ROTATE key.
&SLEN ( A) V1
A data area available to application programs for any
purpose.
(Search pattern length. Used by the SEARCH key function in
the intrinsic file editor.)
&SH ( )
(The binary value input by the SHIFT key. Application
programs never get to see this keystroke; it is filtered
out by the I/O routines in the nucleus.)
&SPAT ( A) V12
A data area available to application programs for any
purpose.
(Search pattern. Used by the SEARCH key function in the
intrinsic file editor.)
&STP ( )
The binary value input by the STOP/SPEED key.
&U ( )
The binary value input by the "cursor up" key.
'C ( ___ A ) I
Compiles code to stack the address of the entry point to a
colon definition, i.e., the address of the first tag
following the BREAK instruction that begins the colon
definition. For example, to stack the address of the entry
point to the colon definition MENU-DRIVER:
'C MENU-DRIVER
'C may be used to stack the address of a word that is to
be executed by (CALL) later in the program.
'EMIT ( ___ A ) V2
An area containing the tag of a word which EMIT will call
to do all of its processing. This area normally contains
the tag of (EMIT), and is reset to that tag by a soft
clear.
You can "redefine" EMIT for your application by repointing
'EMIT to another word of your choice.
The following code illustrates the use of 'EMIT. After it
is executed, EMIT will execute FOOBAR instead (EMIT). It
will continue to do so until 'EMIT is changed again, or
until the next soft clear.
: FOOBAR . . .
: INITIALIZATION-WORD
4 • •
'FILE-COND ( --- A ) V2
An area used to store the tag of a file-selecting word
that the menu driver is to use to determine which files
are to be listed in a menu.
The linkage to the file-selecting word must be:
( A B )
'FILEORG ( N )
Stacks the tag of the word (FILEORG).
'KEY ___ A ) V2
An area containing the tag of a word which KEY will call
to do all of its processing. This area normally contains
the tag of (KEY), and is reset to that tag by a soft
clear.
You can redefine KEY's function by writing your own char-
acter processing routine and storing its definition tag at
'KEY.
See 'EMIT for linkage details.
( A ) I
Compiles code to stack the address of the BREAK instruc-
tion that begins the following colon definition. For
example, to stack the address of the colon definition
MENU-DRIVER:
'V MENU-DRIVER
See also 'C.
( )
Begins a comment. The comment will be ended by the first
encountered (whether or not surrounded by blanks).
Note, is not a vocabulary word; it is just a character
that 'C scans for.
See also '\'.
(D.) ( DN --- A L )
Formats a double integer in ASCII, using the current base
(see BASE). A L point to the ASCII formatted number.
(EMIT) (C )
Performs the entire character output function of EMIT. The
address of (EMIT) is normally stored at 'EMIT.
You can redefine EMIT's function by writing your own
character processing routine and storing its tag at 'EMIT.
(FILEORG) ( --- A )
Stacks address of the current virtual file space. See
FILESPACE.
(FREEZE) ( A) V1
Number of the first character position of LCD that
participates in rotation. The normal value is 0, causing
the entire LCD to rotate. You can "freeze" the left part
of the LCD by setting (FREEZE) to a non-zero value.
(KEY) .1=111MMOINIP C )
(P ( ) COMP,NOTE
Begins a documentary comment. The comment is ended by the
first encountered, just as a 'C comment is.
(P is used after the definition of a word, to provide a
text description of the word. For example:
: 2SWAPDROP (S DX DY DY )
2SWAP 2DROP ;
(P DROPS SECOND DOUBLE WORD ON THE STACK.)
(ROTMODE) ( --- A ) V1
A variable that controls how the LCD will be rotated when
the cursor is past the last character column and another
character is written with EMIT. Meaningful values are:
0: fill mode
1: rotate mode (the normal setting)
2: rotate and fill mode
Note that (ROTMODE) is not reset by a hard clear.
For details of use, see the discussion of "Rotation Mode"
in the chapter on the LCD.
(S ( ) I,NOTE
Begins a documentary comment. The comment is ended by the
first encountered, just as a 'C comment is.
'(S' is used within a colon definition (customarily after
the defining word and name), to describe the things that
the word expects and leaves on the parameter stack. See
the description of (P for an example.
( N1 N2 --- N3 )
N3 = N1 * N2.
*/MOD ( N1 N2 N3 --- N4 N5 )
N4 = remainder of (N1*N2)/N3.
N5 = quotient of (Nl*N2)/N3.
Intermediate result is a double number.
+ ( N1 N2 --- N3 ) C
N3 = N1 + N2.
+! ( N A --- ) C
Adds N to the word found at A and stores the sum back at
A. Pronounced "plus-store." Equivalent to
SWAP OVER @ + SWAP !
+C! ( N A --- ) C
Adds N to the byte found at A and stores the sum back at
A. Pronounced "plus-C-store." Equivalent to
SWAP OVER C@ + SWAP C!
+USED ( N --- )
(Internal word used by the file system.)
I ( N --- ) COMP
A synonym for ',-V'.
- ( N1 N2 --- N3 ) C
N3 = N1 - N2.
-1 0 1 2 3 4 5 6 7 8 9 ( --- N) C,NOTE
These small numbers are used so often that they are
defined by name in the dictionary as constants.
. ( N --- )
Display a number (16-bit two's complement notation) in
ASCII, according to the current BASE. A trailing space
follows the number. Pronounced "dot."
.n ( --- ) NOTE
Prints a string constant. The constant is the text
following ." and one blank, up to the next "".
If used in a colon definition, ." compiles to the (.")
word, a two-byte pointer to the end of the string
constant, and the string constant.
Here is an example of how .II is used in a program:
." two words"
The string constant is accompanied by a call to a routine
which will print the string at run time.
If used in immediate mode, prints the string immediately.
The maximum number of characters that may appear in the
string is 255.
NOTE: I ." compiles to '(.") 1 followed by the constant to be
printed.
." compiles to '(.")'.
.R ( N1 N2 --- )
Display N1 (16-bit two's complement notation) in ASCII,
according to the current BASE. The number is right-aligned
in a field N2 positions wide.
If the "natural" width of the number exceeds N2, no
truncation occurs, and no leading spaces are printed.
/ ( N1 N2 --- N3 )
N3 = N1 / N2. Remainder is dropped.
If N2=0 and Ni<0 then N3=1. If N2=0 and Nl>=0 then N3=-1.
/MOD ( N1 N2 --- N3 N4 )
N3 = remainder of N1/N2.
N4 = quotient of N1/N2.
0< (N F) C
Test if N < 0.
0= (N B)
Test if N = 0.
1+ (N N' )
N' = N + 1.
1 (N - - N' )
N' = N - 1.
10EXP (N EXP )
Extracts the unbiased exponent from a floating point
number that is on the stack.
N is the position of the floating point number, relative
to the tip of the stack. If the number is immediately
below N, then N should be 1 (since N itself occupies
position 0!). If the number is below N and one other
floating point number, then N should be 5, and so forth.
EXP is the unbiased exponent from the number.
2! ( X Y A --- )
Stores X at A+2 and Y at A. (The reverse order of storage
reflects the 6502's convention of orienting the low-order part
of a number toward the low end of memory.)
2* ( N N' )
N' = N + N.
2+ ( N N' )
N' = N + 2.
2- ( N N' )
N' = N - 2.
2/ ( N N' )
N' = N / 2. Note that the result is truncated downward,
not toward zero; thus, for example, "-3 2/" leaves -2, and
"-1 2/" leaves -1.
20H ( N ) NOTE
Stacks the value 20H.
NOTE: 20H produces the same result as &BL: it stacks the
numeric value 20H (which is also the ASCII character
"blank"). 20H generates a short tag (one byte of code);
&BL generates a CLIT followed by 20H (two bytes of code).
2@ ( A --- X Y )
Fetches X was at A+2 and Y was at A.
2DROP ( XD ) C
Drops top double entry on stack.
2DUP ( XD XD XD )
Copies top double entry on stack.
20VER ( XD YD XD YD XD )
Copies 2nd double entry on stack.
2PICK ( XDy XD3 XD2 XD1 y XDy XD3 XD2 XD1 XDy )
Copies y'th double entry on stack to the top.
2ROT ( XD YD ZD YD ZD XD )
Moves 3rd double entry on stack to top.
2 SWAP ( XD YD --- YD XD )
Exchanges top 2 double entries on stack.
30H ( ___ N )
Stacks the value 30H.
80H ( ____ N )
Stacks the value 80H.
( ___ ) DEF
Used to begin a colon definition. Used in the form
: cccc dddddddd... ;
creates a dictionary entry defining word "cccc" with
definition "ddddddd..."
(Compiling is done by the text interpreter as long as
STATE is non-zero. The CONTEXT vocabulary is set to the
CURRENT vocabulary. Words with the precedence bit set are
executed rather than compiled.)
:C ( --- ) DEF
Used like 1 :1 , but defines a word without creating an
entry for it in any tag table. When the compiler
encounters such a word, it compiles the tag of '(CALL)',
followed by the address of the word. This makes your
program one byte shorter if you refer to the word only
once in your program.
If you refer to a word before you define it, the compiler
assumes that the word will be defined later as a :C word.
If the word is later defined as a :C word, the compiler
gives you an advisory message and patches the definition's
address into the reference(s) it has already compiled.
If the word is never defined, OR if it is later defined as
an ordinary colon word, the compiler cannot resolve the
forward reference. It gives an error message at the end of
the compilation which identifies the word as unresolved.
If you want to make a forward reference to a colon
definition word, "predefine" the word by declaring it with
LONG or SHORT before the first reference to it.
:0 ( --- ) DEF
(Like 1 :1 , but does not add the defined word to the cross-
compiler's symbol table. The word is thus an "internal
word," not available for use by application programs. :0
:P ( ) DEF
Defines a passage of high level code that is callable by a
JSR from a low level routine. It is used like this:
:P high-level-name
snap words go here . • •
;P
•
LABEL any-label
( ) CTRL
Used to terminate a colon definition. See I:I.
;P ( ) CTRL
Terminates a passage of high level code that is callable
from low level code. See ':P' for details and example of
use.
( N1 N2 --- B )
Test if 'NI <N2'.
<# - )
Used to convert a number from binary to ASCII. Associated
words are # , #S , SIGN , and #> .
The conversion process uses the text output buffer.
<# performs setup for conversion.
<> ( N1 N2 B)
Test if 'N1 <> N2' (N1 not equal to N2).
( N1 N2 --- B )
vsw Test if 'N1 = N2'.
= = ( X --- ) DEF
Defines a symbolic constant. Used like this:
5 == TBCDONE
TBCDONE is defined as a compile time symbol with the value
5. Wherever TBCDONE appears in the source program, the
value 5 is compiled into the object code.
== is used to name values in order to make code more
understandable. It is the SNAP equivalent of an assembler
equate. It is the most efficient way of defining a
constant (equal in run-time efficiency to a literal
constant), but is less compact than a "constant" defined
with a colon definition.
=IF ( X Y ) CTRL
Executes the following code, up to ELSE or ENDIF, if X=Y.
Equivalent to '= IF'.
( N1 N2 --- B )
Test if 'N1 > N2'.
>R ( X --- )
Pushes X onto the top of the return stack.
?ENOUGH-ROOM ( B )
Use ?ENOUGH-ROOM after ?ROOM to give a stubborn error
message if there is not enough room in the intrinsic file
space to allocate a TSA.
If enough room exists, B is TRUE and ?ENOUGH-ROOM does
nothing.
If not enough room exists, B is FALSE and ?ENOUGH-ROOM
presents the user with a menu of non-invisible tiles. The
user may choose to delete any one of these files. If he
selects a file to delete, the HHC will clear itself after
deleting the file.
If the user does not select a file to delete, the only way
for him to escape from the ?ENOUGH-ROOM menu is to clear
the HHC himself.
?FILE ( A L [A'] B )
Given the name of a virtual file, returns its address.
A L are the address and length of the file's name. If the
file exists in the current file space, A' is the address
of its header, and B is TRUE. If the file does not exist
in the current file space, A' is absent and B is FALSE.
?KEY ( B )
Return TRUE if a keystroke is available for KEY, else
return FALSE.
?KEY-HIT ( B )
If a keystroke is waiting to be read, reads the keystroke,
?ROOM (N B)
Determines whether there is enough room in intrinsic RAM
to allocate N bytes of storage. If there is enough room, B
is TRUE; else B is FALSE.
?SF ( A --- B )
Given the address of a file (i.e., of the file-length
word), determines whether the file is an executable SNAP
file.
( A --- X )
Stacks the word stored at A.
HERE
S" STRING ARRAY ELEMENT #0"
S" STRING ARRAY ELEMENT #1"
S" STRING ARRAY ELEMENT #2"
5" STRING ARRAY ELEMENT #3"
== EXAMPLE.STRING.ARRAY
Example:
A
A>B ( C --- N )
Performs ASCII character to binary conversion according to
the following rules:
'0' through '9' are converted to 0 through 9.
'A' through 'Z' and 'a' through 'z' are converted to 10
through 36.
All other input values are converted to binary zero.
A>B is convenient for interpreting a cnaracter indicating
the user's selection from a menu.
ABORT ( ___ ) C
The word normally executed when a serious error occurs.
See 'ABORT for more information.
(JSR's to the label BREAK. BREAK displays the message
"RESET" and then performs a nard clear.)
ACVECT ( ____ A ) V2
Stacks the address of the address of the current LCD
accent table. You may give the HHC a new LCD accent table
by changing the contents of ACVECT.
ALL-EMIT ( C --- ) C
(Sends a character to the LCD and to all attached periph-
eral devices. FLAME-ON stores the tag of this word in
'EMIT. See 'EMIT.)
ALRMBLIP ( --- N )
A mask for the "alarm" blip. See ANDBLIP for aetalls.
AND ( X Y --- Z ) C
Bitwise logical AND.
ANDBLIP ( N --- ) C
ANDs the low-order byte of N into the LCD blip byte. If a
bit is i in N, the corresponding blip is unchanged; if a
bit is 0 in N, the corresponding blip is turned otf.
AOECB ( m A) V6
A 6-byte area containing a timer ECB used by the auto-off
function.
AOENB ( --- FL )
A flag in FLAG3 that controls the auto-off feature. 1 ->
the feature is enabled; 0 -> the feature is disabled.
AOTOKE ( --- FL ) =
A flag in FLAG3 that is used by the auto-off feature. 1 ->
an event has occurred that warrants resetting the auto off
timer; 0 -> no such event has occurred. The bit is
checked, and the timer may be reset, every 30 seconds. The
timer is set to a 10 minute interval; if it reaches the
AP ( A) V2
A variable which points to the ceiling of the current TSA.
AREA ( ) DEF
Used to define and temporary storage area (TSA) at compile
time, and allocate it at run time.
The user may create his own variables within the TSA with
words such as VAR, DVAR, CVAR, and VECTOR.
The area is terminated by the word ENDAREA.
See the section on TSA's in "General Technical
Information" for details.
ASSEMBLER ( ) COMP
Name of a vocabulary containing an assembler that
assembles into the host machine's address space. See the
chapter on "The SNAP Assembler" for details.
ASSEMBLER-V ( ) COMP
Name of a vocabulary containing an assembler that
assembles into the target machine's address space.
AVAIL ( N)
Returns the number of free bytes in the current file
space. If the intrinsic file space is current, N is
reduced by a safety factor to allow room for numeric
conversions between the temporary stack and the tiles.
For the total number of bytes in the current file space,
see FILELEN.
B>A ( C --- N )
Performs binary to ASCII character conversion according to
the following rules:
0 through 9 are converted to '0' through '9'.
10 through 36 are converted to 'A' through 'Z'. 37 is
converted to 1 [ 1 (the next ASCII character after 'Z'), 38
is converted to '\', and so on.
B>A is the inverse of A>B.
BASE ( ____ A ) V1
The current number base used for input and output
conversion. Initial value is 10.
BEEP ( --- )
Produces a "beep" on the HHC's noise maker. Equivalent to
sending 07H (ASCII "bell" code) to the LCD.
If LCD output is redirected to another device (by changing
the value of 'EMIT, for example), BEEP is redirected too.
BEEPER ( ___. N ) .
A mask which may be ANDed into the system control byte to
isolate the squeaker bit. It the bit is 1, a DC-high
voltage is placed on the squeaker. If the bit is 0, a DC-
low voltage is placed on the squeaker. A program can make
sounds by switching the bit on and off.
BLANKS (AN )
Deposits N blanks in RAM, beginning at address A.
maw Equivalent to '32 FILL'.
BUFPOSN ( A ) V1
Gives the cursor's current character position in the
display, i.e., the position where the next character
EMITed will appear. The left-most position is #0.
Application programs may move the cursor by changing this
variable via the word POSN.
C! ( C A --- ) C
Stores C at address A. Pronounced "C-store."
C@ ( A --- C ) C
Fetches the character stored at address A.
CALC ( --- )
Executes the intrinsic calculator.
CALL ( A --- )
Executes the definition at address 'A'. 'A' points to the
first tag in the definition to be executed.
CALT ( --- N )
A mask for the "alternate character set" bit in the high-
order byte of an EMIT parameter. If the bit is on, EMIT
displays a character from the alternate character set. If
the bit is off, EMIT displays a character from the
standard character set.
CAN.LIST ( A C B --- )
Cancels one or more ECB's.
A is the address of a list of ECB addresses; each address
points to an ECB to be cancelled or preserved (see B,
below).
C is the length of the ECB list, in words.
B=FALSE means "cancel every ECB in the list." B=TRUE means
"preserve every ECB in the list, but cancel every other
ECB."
CANCEL ( ECBADR )
Post ECB as completed, regardless of whether the
associated event has occurred.
CAPON ( N)
A mask which may be ANDed into the system control byte to
isolate the capsule-power bit. If the bit is 1, the
hardware is giving the capsules power. If the bit is 0,
the hardware is not giving the capsules power.
CASE-ESC ( )
(A jump table used by LCD support routines to process
escape codes.)
CBIT --- FL )
(A flag bit in FLAG2 used to indicate whether the cursor
is on. As the cursor flashes, this bit is toggled on and
off. Tested by >ENCODE.)
CEMIT (C )
(Emits a character to the video and LCD. Usable only in
the calculator, which binds the video.)
CFILE ( A)
Returns the address of the current virtual file. After a
clear and before any file has been opened, the address is
zero. CFILE is used to identify the file in various I/O
operations, most importantly in DELETE-FILE.
CGRTN ( --- ) C
(Internal word used by EMIT to trap and process the
carriage return character.)
CH ( ___ A ) V2
(Internal word used by the keyboard decoding routine.)
CHESAV ( ___ A ) V2
(Address of the current I/O ECB. Used internally by I/O
routines.)
CHSAV ( --- A ) V1
(Character being output to a BINDed peripheral. Used
internally by I/O routines.)
CHVECT1 ( _ 4_ A ) V2
Stacks the address of the address of the current LCD
primary character set table. You can change the HHC's
primary character set by changing the contents of CHVECT1.
CHVECT2 (--- A) V2
Stacks the address of the address of the current LCD
alternate character set table. You can change the HHC's
alternate character set by changing the contents of
CHVECT2.
CLEAR ( --- ) C
Simulates the effect of the user pressing the CLEAR key
once. This effect is a hard clear if this is the second
CLEAR (from software or keyboard) since any other keyboard
key was pressed; otherwise it is a soft clear.
See also SOFT.CLR and HARD.CLR.
CLR.BITS ( A X --- )
Changes the value of the word at A by turning off each bit
that corresponds to a bit that is on in X. See also TOGGLE
and SET.BITS.
CNEG ( --- N )
A mask for the "negative" bit in the high-order byte of an
EMIT parameter. If the bit is on, EMIT displays a
character in inverse video. If the bit is off, EMIT
displays a character in the usual way.
CPUON ( ____ N ) =
A mask which may be ANDed into the system
control byte to isolate the CPU-on bit. It the bit is 1,
CQMK ( m N )
A mask for the "flash/question-mark" bit in the high-order
byte of an EMIT parameter. If the bit is on, EMIT
displays a character alternating with a 'V. If the bit is
off, EMIT displays a character in the usual way.
CR ( )
---
If the the most recent keystroke was input after the most
recent LCD character was displayed, CR causes an immediate
carriage return.
If the most recent LCD character was displayed after the
most recent keystroke was input, CR works by turning on a
flag which is later tested by the LCD output routines. The
next time a character is sent to the LCD, the routines
test this flag to see if a carriage return is pending; if
so, they do the carriage return (and reset the flag)
before writing the character.
In addition, each time a character is written to the LCD,
a timer is set; and if user writes a CR and then another
character before the timer expires, the routines wait
until the timer expires before doing the carriage return.
This gives the user a guaranteed minimum length of time to
look at a line on the LCD after it is completely displayed
and before it is erased.
CRBIT ( --- FL ) .
(Bit in FLAG2. 1 -> an LCD carriage return is pending.)
CRESTORE ( --- )
Pops two words from the return stack to the parameter
stack, then stores the low character of the first word at
the address indicated by the second word. See SAVE.
CSBIT ( --- N )
A mask for the byte in a ROM capsule at the address given
by CSPEED. If the bit is on, this ROM capsule has slow
ROM. If the bit is off, this ROM capsule has fast ROM.
CSPEED ( ___ A ) K1
CTEXT ( A) K1,NOTE
Tag table number of the primary external tag table of an
application in a control ROM.
Note that the value of the "constant" will vary depending
v~~ on what control ROM is currently in the address space.
CTRFLAG2 ( --- A ) K1
(Control ROM byte containing complex I/O flags.)
CTRFLAGS ( --- A ) Kl
(Control ROM byte containing the peripheral's hardware
device type code.)
CTRID ( A) Kl
The address in a control ROM where the name of the device
the ROM is for (e.g., 'MODEM') is stored in count format.
CTROM ( A)
Stacks the address of the part of the address space where
device control ROMs go.
CURBIT ( --- FL )
(A bit in FLAG2. 1 -> turn the cursor on.)
CURCTL ( A) V1
CURRAM ( A) V1
Bank ID of the RAM bank currently switched into the
extrinsic RAM space.
CURROM ( A) V1
Bank ID of the ROM bank currently switched into the ROM
capsule space.
CVAR ( ) DEF
Used in a TSA to reserve one byte of storage for a
variable. For example:
CVAR ERRFLG
This reserves a one byte for a variable named ERRFLG.
CVECTOR ( N ) DEF
Used in a TSA to reserve N bytes of storage for an array
of byte-length values. For example:
CVECTOR ERRCODES
D.R ( DN N )
Display DN in ASCII, according to the current BASE. The
number is right-aligned in a field N positions wide.
If the "natural" width of the number exceeds N, no
truncation occurs, and no leading spaces are printed.
D= ( ND1 ND2 B)
Compares two double numbers. B is TRUE iff ND1 = ND2.
DBUF A) V27
Character buffer for the LCD. Contains ASCII cnaracters
representing the 27 character positions of the LCD. (Only
the first half of the 27th position is aisplayed.)
DBUF is used internally to manage LCD display. It is not
normally used by applications.
DBUF1 ( A) V27
Control buffer for the LCD. Each byte contains bit flags
that control whether the character in the corresponding
byte of DBUF is displayed with blink, flashing, etc. The
control byte normally is deposited in DBUF1 by EMIT, which
gets it from the high-order byte of its parameter.
See also DBUF and UPDISP.
DBUFL ( N )
The length of the LCD in characters (27).
DECB ( A) V6
(A timer ECB used by the LCD control routines. See #DECB.)
DEL.CH.R (N )
Shifts the right part of the LCD display left one
character. the character in position N+1 is shifted to
position N; all following characters are shifted after it.
The contents of the last position is not disturbed; the
original contents of position N is lost. SEE ALSO
INS.CH.R.
DELETE (N B)
Deletes the N'th record in the current virtual file; B is
TRUE. If the N'th record does not exist, B is false.
DELETE-FILE ( A --- )
Deletes a file. A is the address of the first byte of the
file to be deleted.
Use ?FILE to find the address of the first byte of the
file, given its name.
DISP.CH (N N' )
(Used internally by (EMIT) to display a character. Given
buffer position of cursor before display, returns buffer
position of cursor after display.)
DISPON ( N)
A mask which may be ANDed into the system control byte to
isolate the LCD display bit. If the bit is 1, the LCD
display is on. If the bit is 0, the LCD display is off.
DLITERAL ( DX --- )
At compile time, takes a 32-bit value from the stack and
compiles it into the code. At execution time, this 32-bit
value is treated in whatever way its context dictates.
DMODE ( ........ A ) VI
Stacks the address of a byte containing the current
default display mode, i.e., the mode in which EMIT will
display a character if the high byte of the parameter word
is zero. The value of DMODE is interpreted the same as the
value of the high byte of an EMIT parameter.
DP ( ___ A ) COMP
A synonym for DP-V.
DROP ( X --- ) C
Drops the top entry from stack.
DSIZE ( ___ N ) =
Size of LCD in characters (the value is 26).
DSPFLAG ( --- FL )
(Bit in the HDT byte 0; 1 -> this HDT is for the LCD.)
DSPLY ( ____ A )
Address of the 159-byte memory mapped LCD I/O area. You
can read from and write to the LCD at the dot level by
moving data to and froom this area with DMOVE.
DUP ( X --- X X ) C
Duplicates X.
DVCON ( --- FL ) =
(Bit in the HDT byte 1; 1 -> this device is on, or will be
turned on the next time DVCSET is called. See DVCSET.)
DVCSET ( --- ) C
(Scans the HDT's and turns all devices on or off,
depending on the value of the DVCON bit.)
DVSAV ( ____ A ) V1
(Page 0 location used by I/O routines to store the on/off
status of a device during an I/O operation.)
EMIT (C )
Send character C to display.
The high-order byte of C is normally zero, but may be set
to other values to display the character in unusual ways.
For example, the CNEG bit may be set to display the
character in inverse video. See the text description of
EMIT for more information.
ENCODE ( )
Used internally to manage LCD display. Not normally used
15y applications.
(Converts ASCII character to LCD dots.)
ENDAREA (--- ) COMP
Used to terminate a TSA. All of the VAR's etc., defined
between AREA and ENDAREA are allocated in the TSA.
ENDIF ( ) CTRL
Used to terminate an IF construction or a CASE
construction.
Used in the form:
IF tttt... ELSE eeee... ENDIF or
IF tttt... ENDIF or
a CASE aaaa... ELSE
b CASE bbbb... ELSE
c CASE cccc... ELSE
xxxx...
ENDIF ENDIF ENDIF
Note, in the last form there must be one ENDIF matching
each CASE.
(At compile time, the form is "A N ---". A is the address
of the space reserved for a branch past the ENDIF by ELSE
or IF. ENDIF inserts HERE at A. N is used for error
checking.)
vo. EOL ( C B )
ESCCC ( ___ N ) =
Escape control sequence opcode "Set Control Character
Mode." If the data byte is TRUE, subsequent control
characters sent to the device will be displayed, not
executed; if FALSE, subsequent control characters sent to
the device will be executed, not displayed.
ESCDC ( --- N ) =
Escape control sequence opcode "Display Character." The
next data character will be displayed, even if it is a
control character that would normally be executed. For
example, if the next character is OAF (carriage return)
and it would normally cause a physical end-of-line on the
device, it causes no carriage end-of-line, but is written
as an inverse J.
ESCDR ( --- N ) =
Escape control sequence opcode "Delete Right." The
character under the cursor is deleted; following
characters on the line are moved left. The data byte is
used as a fill character at the end of the line.
ESCFL ( m N ) =
Escape control sequence opcode "Flush I/O Buffer."
Characters in the device's I/O buffer are read or written,
emptying the buffer. (This operation is generally applied
only to output devices that write a line of data at a
time. Writing a line would normally be triggered by a CR
character.)
ESCHM ( _____ N ) =
Escape control sequence opcode "Home Cursor." This
normally returns the cursor to the upper left corner of a
device with a two-dimensional display.
ESCIR ( m N ) =
ESCSF ( ....... N )
Escape control sequence opcode "Set Flash Mode."
Subsequent output will be displayed in flashing
characters. Reverses the effect of ESCUF.
ESCSI ( ___ N )
Escape control sequence opcode "Set Inverse Mode."
Subsequent output is displayed in inverse. Reverses the
effect of ESCUI.
ESCUF ( --- N )
Escape control sequence opcode "Set Unflash Mode." All
subsequent output is displayed in non-flashing characters,
until the mode is changed by ESCSF. Reverses the effect of
ESCSF.
ESCUI ( ____ N )
Escape control sequence opcode "Set Uninverse Mode."
Subsequent output will be displayed normally ( non-
inverse). Reverses the effect of ESCSI.
ESCUN ( ____ N )
Escape control sequence opcode "LCD unescape." On the LCD,
the data byte is written normally. On all other devices,
it is ignored.
ESCWB ( ___ N )
Escape control sequence opcode "Set Word Break." The data
byte defines the word break character that can trigger
automatic word wrap. (This means that when an output line
becomes longer than a device's line length, the device
automatically starts a new line and moves the last word of
the old line to the start of the new line so that the word
will not straddle a line break.)
The word break character is initially blank (20H) in all
cases.
Setting the word break character to OFFH turns automatic
word breaking off.
EVECT ( ___ A )
(Stacks address of a JMP instruction used by the inner
EVFLAG ( _p.m._ A ) In
(Event processor service flag. 1 -> call event processor
the next time the inner loop is executed. 0 -> do not call
event processor.
(This byte may not have any value except 0 or 1. It is
changed with increment and decrement instructions, so that
an interrupt cannot occur while it is being updated.)
EVFLAG1 ( --- A ) V1
(Event processor service flag. 1 -> an event is being
processed. This flag prevents the HHC from re-entering the
event processor when an event occurs while another event
is being processed.)
: YOUR-TOP-WORD ...
'X YOUR-TOP-WORD EXECUTE
EXIT ( --- ) C
Used inside a colon definition, terminates execution of
that colon definition, returning control immediately to
its caller. The contents of the parameter stack is not
disturbed.
NOTE: do NOT use ;S in this context, as you would in
FigFORTH.
NOTE: do NOT use EXIT inside a DO loop. It will produce
random results, since DO uses the return stack to store
the loop index and limit.
F! ( FP A --- )
Stores a floating point number.
F# ( FP N --- FP N )
Used by FP>ASC to assist in formatting the ASCII
representation of a floating point number.
(Used between <# and #> to put a digit of the mantissa in
the TOB. To format the entire mantissa, FP>ASC executes a
loop for N from number of significant digits desired minus
1, to 0. For each digit, if the digit is not a trailing 0,
F# converts the digit to ASCII, deposits it at the address
indicated by HLD, and decrements HLD by 1.)
F. ( FP NDIGITS N)
Displays a floating point number in standard notation (not
exponential notation).
FP is the number to display. NDIGITS is the number of
significant digits to display. N is the number of digits
displayed after the decimal point.
In the case where FP can be displayed exactly in fewer
than NDIGITS digits, the result is padded to NDIGITS
digits with zeroes to the right of the decimal point.
In the case where the integer part of FP cannot be
displayed in NDIGITS digits, the result includes whatever
number of trailing zeroes is necessary to display a
correct (rounded) result. These zeroes are not considered
"significant."
To display a number in exponential notation, use FP>ASC
and TYPE.
F.EXT ( N M --- )
Used after 'F.' to extend a floating point number to a
specified length.
N is the length of a floating point number just displayed.
(It is the value left on the stack by 'F.'.) M is the
desired length. F.EXT extends the number to the desired
length by displaying M-N zeroes.
F@ ( A --- FP )
Fetches a floating point number.
FALSE ( m B ) =
Pushes a FALSE onto the stack. The binary value of FALSE
is 0. FALSE is a synonym for 0.
FAST.CR ( --- )
Performs a carriage return on the LCD immediately.
Distinguish FAST.CR from CR, which sets flags which will
cause a carriage return to occur at some future time.
FDROP ( FP --- )
Drops four words (one floating point number).
FDUP ( FP --- FP FP )
Duplicates the floating point number (four words) on the
top of stack.
FECB ( m A) V6
(A timer ECB used by the LCD control routines to control
cursor flashing.)
FFFF ( N )
Stacks the value OFFFFH (-1). Note that FFFF is actually a
synonym for the colon word -1.
FILEORG ( A)
Address of the origin of the current virtual file space
(i.e., of the intrinsic or extrinsic file space).
FILESPACE ( --- A ) V
An internal word in the virtual file system.
(Stacks address where the intrinsic virtual file space
begins.)
FILL ( A LEN C )
Fill an area in memory at address A, length LEN, with the
byte value C.
FLAG1 ( A)
(A byte of flags relating to keyboard status.)
FLAG2 ( A) V1
A byte of flags relating to keyboard and LCD status. It
controls the function of the function keys, the functions
of the SHIFT, 2nd SFT and LOCK keys, and the LCD rotat-
ion/carriage return delay, among other things. See FUNBIT
and PASSRAW.
FLAG3 ( A) V1
A byte of flags relating to various functions of timer
interrupts. It controls the auto-off feature, among other
things. See AOTOKE and AOENB.
FLAME.ON ( )
Attaches all available output devices and binds them to
the LCD. Use this word if you want your application to
echo the LCD's display on anything that happens to be
available, e.g., the video.
Once the available devices are bound to the LCD, they
remain so until the next soft clear.
FLEE.CAP ( )
Executes the mother tag of the external tag table in the
capsule currently switched into the capsule address space.
FLEE.CROM ( DEVCODE )
FLEEs to the application program, if any, stored in the
control ROM for the peripheral with the specified software
device code.
FLIM ( A )
Returns the address of the first free byte in the current
virtual file space.
FLIT ( --- FP )
"Floating point literal." Places the next four words after
this tag on the stack, and passes control around the
words.
At run time, FLIT works like the run-time words LIT (which
FP ( A) V2
The address of the first free byte in in the current file
space. Maintained by the file system.
FSPACE ( A )
Returns the address of the first file in the current file
space. If the file space is empty, returns the address
where the first file will go.
FUNBIT ( --- FL )
A flag in FLAG2 which controls operation of the function
keys. 1 -> the keys are processed normally. 0 -> the keys
are ignored; they do not have their normal "macro"
functions, nor are they passed through the keyboard buffer
as distinct characters.
FVAR ) DEF
Used in a TSA to reserve 8 bytes of storage for a floating
point variable. For example:
FVAR ERRVAL
This reserves a 8 bytes for a variable named ERRVAL.
GET-TYPE ( --- A )
Returns the address of the file-type byte for the current
virtual file. You can read the file-type byte with C@ and
set it with C!.
The value of the file-type byte is the logical OR of the
file-type attributes that apply to this file. The symbolic
constants defining the file-type attributes are:
%INVISIBLE: file will not be displayed in file selection
menus.
%TEMPORARY: file will be deleted automatically at next
CLEAR. (Auto-delete support not currently
implemented.)
%EXECUTABLE: file contains executable SNAP code.
(Execution support not currently
implemented.)
%TEXT: file contains ASCII text. (This is the only
type of file that may be edited. Note that
%TEXT and %EXECUTABLE are logically
incompatible.)
%BASIC file contains a Microsoft Basic program. The
program is stored in ASCII except for Basic
keywords, which are represented by one-byte
binary codes. NOTE: the symbol %BASIC is not
pre-defined. If you need it, assign it the
value 10H.
NOTE: this word compiles into TWO tags, representing the
words &CFILE and 2+.
GMT ( ____ A ) V4
Time of century of the next timer interrupt, in seconds.
GMT points one byte past GMTF; that is, GMT points to the
2nd byte of the 5-byte area at GMTF.
GMTF ( A ) V5
Time of century of the next timer interrupt, in clock
ticks.
GMTF may be used to get a time of century that is more
accurate than that obtainable with GET.GMT, the usual
choice for getting time of century. GET.GMT is accurate
only as of the most recent interrupt.
To get an accurate time of century, do a SET.DELAY for a
short time period (e.g., 0.1 second). Immediately after
setting the delay, check to see that the delay has not yet
expired (i.e., the associated ECB is not yet posted). If
not, get the time with GMTF; it is in the future by no
more than the duration of the delay that you set.
GROUND.MENU ( --- A )
(A list of count-format strings used by the menu driver to
display the names of the intrinsic applications in the
primary menu.)
H: ( ) COMP
"Host definition." Used like defines a word that is
to be available during compilation (by the simulator or
cross-compiler) but not during execution (by the simulator
or the HHC). The equivalent of a macro definition in
conventional assembled or compiled languages.
HARD.CLR ( )
Performs a hard clear, as though the user had pressed the
CLEAR key twice in succession.
HDTSAV ( A)
(An internal word used by the I/O routines.)
HDTSZ ( N )
(The size of an HDT in bytes (6).)
HERE ( A) COMP
A synonym for HERE-V.
HEX ( ) COMP,NOTE
Sets BASE to 16. This causes output words such as 1.1 and
'R.', and conversion words such as '<# #S #>', to display
numbers in base 16.
NOTE: use HEX only outside colon definitions, to set the
compile time base. In SNAPPLE, HEX is defined in the
target vocabulary, and functions as a normal target
definition; but in the cross-compiler, HEX is an immediate
word.
HINTFLAG ( --- FL )
(An unused bit flag mask.)
HOLD (C )
Used to insert an ASCII character into an ASCII number
being created by "<# #S #>". May be used to insert a
decimal point, for example. See "<#" for details.
I ( N)
Used in a DO loop to copy the loop index onto the stack.
I/O ( A)
(Address of the "I/O page," a memory mapped region used by
device drivers and intrinsic I/O routines. Note that the
so-called I/O page does not begin on a 6502 page boundary.
IDICT ( A)
Stacks the address of the short intrinsic tag table.
You can stack the entry point of a word represented by a
short intrinsic tag (OOH to OBFH) by loading the word at
the following address, where "tn" represents the tag
number:
IDICT tn 2* +
You can stack the entry point of a word represented by a
long intrinsic tag (100H to 1FFH) by loading the word at
the following address, where "tn" represents the tag
number:
HEX
IDICT SHINT + SHINT +
tn 100 - 2*
IF (B ) CTRL
Used to begin an IF construction.
Used in the form:
IF tttt... ELSE eeee... ENDIF or
IF tttt... ENDIF
If B is TRUE, "tttt..." is executed and "eeee..." (if any)
is skipped. If B is false, "tttt..." is skipped and
"eeee..." (if any) is executed.
(At compile time, the form is "--- A N". IF compiles a
OBRANCH and reserves 2 bytes after it where ELSE or ENDIF
can insert the offset to branch to if B is FALSE. A is the
addres of the reserved space; N is used for error
checking.)
See also LONG.IF.
IF.ITS ( N N ) CTRL
A CASE-like statement used to make a choice based on a
numeric value. IF.ITS is useful where clarity or
compactness is more important than etticiency, and where
the possible values are scattered. It is most often used
to execute code based on a menu selection.
The word is used like this:
X @ \ VALUE TO CHOOSE WITH.
IF.ITS 1 code-for-choice-1 ENDIF
IF.ITS 2 code-for-choice-2 ENDIF
IF.ITS 3 code-for-choice-3 ENDIF
INS.CH.R (N )
Shifts the right part of the LCD display right one
character. the character in position N is shifted to
position N+1; all following characters are shifted after
it. The original contents of the last position is lost;
the contents of position N is not disturbed. SEE ALSO
DE.CH.R.
INSERT ( A L N B )
Inserts a new record before the N'th record of the current
virtual file. The new record consists of the data at
address A, length L. B is TRUE.
To add a record to the end of the tile, use N = the number
of records in the file (one greater than the record number
of the last record). The word REC-CNT returns this value.
If N is greater than the number of records in the file
(i.e., if record N-1 does not exist), no record is
inserted and B is FALSE.
INTFLAG ( --- FL )
(A flag in PCA byte 3. 0 -> an interrupt is being
requested from this peripheral; 1 -> no interrupt is being
requested.)
IOSAV ( A) V1
(Used internally by I/O routines to hold a code identify-
IPBANK ( ___ A ) V1
(Bank ID of the memory bank the tag now being interpreted
is in.)
IPBIT ( --- FL ) =
(A bit in FLAG2. 1 -> the HHC is in input mode; i.e., a
keystroke has been encountered since the list EMIT was
executed.)
IRQVECT ( --- A ) =
Address of a JMP instruction that jumps to the entry point
of a user IRQ routine. The normal user IRQ routine is a
null routine; that is, it just returns to its caller. You
can intercept IRQ's by changing IRQVECT to jump to your
own IRQ handler.
IRQX ( ___ A ) V1
(Area where the nucleus saves the X register before
calling the IRQ handler in a peripheral control ROM. The X
register always points to the PCA in this context.
(See also IRQY.)
IRQXV ( ___ A ) =
(Address of a JMP instruction that jumps to the entry
point of the IRQ routine in the peripheral controller ROM
currently switched into the address space.)
IRQY ( ___ A ) V1
(Area where the nucleus saves the Y register before
calling the IRQ handler in a peripheral control ROM. The Y
register always points to the HDT in this context.
(See also IRQX.)
IVECT1 ( ___ A ) V1
(Used internally by inner loop to decode tags.)
IVECT2 ( ___ A ) V1
(Used internally by inner loop to decode tags.)
J ( N) C,NOTE
Copies the value of the index of the second outer nested
DO loop onto the stack.
JUMP-TAB ( N ) DEF
Defines a "jump table" that can be used to execute one of
several words depending on the value of a word on the
stack.
4 JUMP-TAB FOUR.WORDS
WORD1
WORD2
WORD3
WORD4
This example defines a jump table with 4 entries, named
FOUR.WORDS. The entries in the jump table are four words
(defined elsewhere, with tags) named WORD1, WORD2, WORD3,
and WORD4.
: JUMPING.LIZARDS ( )
JUMP.TO.ME @ FOUR.WORDS
KB ( ___ A ) =
(Address of the keyboard's hardware I/O area. When the
user presses a key, a binary value is stored somewhere in
this area. The "raw keyboard code" is derived from the
value that is stored and the address of the byte that the
value is stored in.)
KBFLAG ( --- FL ) =
(A flag in HDT byte 0. 1 -> this HDT represents the
keyboard.)
KBSET ( _a_ A ) K2
The standard keyboard translation table. To make the
standard table the current table, execute:
KBSET KBVECT !
KBVECT ( ___ A ) V2
Address of the current keyboard translation table. You can
change the HHC's current keyboard translation table by
changing the contents of KBVECT.
KECB ( --- A ) V2
(An ECB used by the keyboard input routines.)
KQ ( --- A ) V8
The keyboard buffer. This is a ring buffer with KQI
pointing to input (from keyboard) and KQO pointing to
output (to KEY).
KQHI ( ____ N ) =
Length of the keyboard buffer in characters. This is the
maximum number of characters that the HHC can buffer
between keyboard input and program processing. The current
value is 8.
KQI ( A) V1
The keyboard buffer input pointer. Contains the aisplace-
ment of the byte in the keyboard buffer where the next
character read from the keyboard will be stored. Note that
keys are stored backwards, e.g., the value of KQI is
initially 7, then becomes 6, 5, 4, .— 0, 7, ...
See also KQ, KQO.
KQO ( A) V1
The keyboard buffer output pointer. Contains the displace-
ment of the byte in the keyboard buffer from which the
next character passed to KEY will be tetched.
The buffer is empty when KQO and KQI (the input pointer)
are equal.
See also KQ, KQI.
L>U (C C' )
Converts a lower case character to upper case. L>U has no
effect on characters which are not lower case.
LASTFLAG ( --- FL )
(A flag in HDT byte 0. 1 -> this is the last HDT in the
HDT list.)
LATCH ( A ) V1,NOTE
(Stacks address of the LATCH, a special one-byte segment
of the address space whose bit settings control various
aspects of the HHC's hardware status. Symbolic constants
defining the functions of the bits in LATCH are:
VALUE
WORD (HEX) MEANING
n/a 1 Indicate which intrinsic capsule
n/a 2 capsule socket (if any) is currently bank-
switched into the address space. Values
00B, 01B, and 10B represent sockets 0, 1,
and 2. Value 11B has no meaning.
CAPON 4 1-> an intrinsic capsule socket is bank-
switched into the address space. 0 -> a
capsule socket in a ROM expander is bank-
switched into the address space.
DISPON 8 1-> HHC is turned on, 0-> off.
SLOMEM 10 1-> addressing slow ROM, 0-> normal.
BEEPER 20 High/low DC to speaker. Software can toggle
this bit to generate audio.
CPUON 40 1-> CPU power on, 0-> off.
DMASK 80 Selects function of memory mapped area for
keyboard/LCD functions. 1-> LCD control,
0->keyboard control.
(Note that the latch is write-only. To interrogate the
latch's status you must read LATCHS, below.)
411,0. LATCHS ( A) Vi
LATSAV ( --- A ) V1
(A byte in N used internally by I/O routines to save latch
byte settings.)
LCD.CR ( --- ) C
(A word used internally by LCD I/O routines to perform the
function of the "carriage return" character.)
LEAVE ( ___ ) C
Used to force early termination of iteration in a DO loop.
LEAVE sets the loop limit equal to the current value of
the index. This causes termination of the loop at the end
of the current iteration. NOTE, it does NOT cause
immediate termination of the loop.
LETGO ( --- )
Releases the TSA most recently allocated and not yet
released. This permits you to use variables defined in the
first-allocated remaining TSA. You may also re-use the
space in the released TSA (by allocating a new TSA, for
example).
LOBAT ( A ) V1
(A byte whose 80's bit is turned on to indicate the
"battery low" condition.)
LOC.NXT.CAP ( B)
Searches through ROM ID's for the next available ROM
capsule after the one now switched into the capsule
address space.
LOCK.IT ( --- FL )
(A flag in FLAG1. 1 -> LOCK key is in effect, 0 -> not.)
LOCKED? ( --- FL )
(A flag in FLAG1. 1 -> we're locked in SHIFT or 2nd SFT
mode, 0 -> we're not. Meaningful only when SHIFT? is
true.)
LONG ( .11.1.000.111M )
COMP
Instructs the compiler to reserve a long tag number for a
specific word, and assign that tag number to the word
regardless of whether it is assigning long or short tags
to other words when the word is defined. LONG is used like
this:
LONG word
It must be used BEFORE the word in question is defined.
Use LONG before the first colon definition in your program
to identify the word that is to be the program's entry
point. This works because SNAP uses the first tag in the
program's long tag table vector to be the entry point.
LONG.IF B ) CTRL
Use LONG.IF, LONG.ELSE and LONG.ENDIF in place of IF, ELSE
and ENDIF when the code between IF and ELSE or between ELSE
400. and ENDIF is more than 255 bytes long. These words generate
jumps with two-byte displacements, rather than the one-byte
displacements generated by IF, ELSE and ENDIF.
When you need to use LONG.IF, etc., the compiler will
inform you by giving you an error message in response to
IF, ELSE, and ENDIF.
LONG.REPEAT ( ) CTRL
See LONG.WHILE.
LONG.TAGS ( ) COMP
Instructs the compiler to compile defining words into long
tags until further notice. LONG.TAGS is the opposite of
SHORT. TAGS.
LONG.WHILE ( B ) CTRL
Use LONG.WHILE and LONG.REPEAT in place of WHILE and REPEAT
when the code between WHILE and REPEAT or between BEGIN and
REPEAT is more than 255 bytes long. These words generate
jumps with two-byte displacements, rather than the one-byte
displacements generated by IF, ELSE and ENDIF.
When you need to use LONG.WHILE and LONG.REPEAT the
compiler will inform you by giving you an error message in
response to WHILE and REPEAT.
Note that there is no LONG.BEGIN word; BEGIN serves both
the short and long forms of the WHILE loop.
LOOKUP ( N [A] B )
Returns the address of the N'th file in the current file
space.
If file N exists, A is the address of the file (i.e., of
the "length of file" field) and B is TRUE. If file N does
not exist, A is absent and B is FALSE.
LOOP ( ) CTRL
Used to terminate a DO loop.
The index is incremented by 1. If the new index value <
limit, control returns to the first word after the
corresponding DO. If the new index value >= limit, the
LP ( A ) 171
(Displacement of the first free byte on the loop stack
from the beginning of page 1. Add 100H to this value to
get the address of the first free byte on the loop stack.
(If the address of the base of the loop stack is given by
LSTK; thus, if the value of LP is equal to LSTK, the loop
stack is empty.)
LSTK ( A )
(The address of the base of the loop stack.)
M* ( N1 N2 --- ND )
ND = N1 * N2.
M/ ( ND N1 --- N2 N3 )
N2 = signed remainder of ND/N1. (The remainder takes its
sign from the dividend.)
N3 = signed quotient of ND/N1.
MAKE (AL B)
Creates a new virtual file.
A and L are the address and length of the file name. B is
TRUE if the file can be created; FALSE if it already
exists or if there is no space for it.
MAX ( N1 N2 --- N3 )
N3 = the greater of N1,N2.
MAXBANK ( N)
(The maximum number of RAM and ROM banks that the HHC may
support at one time. The current value is 64.)
MAXDEV N )
The maximum logical unit number that the HHC can support;
one greater than the highest valid logical unit number.
The current value is 16.
( N --- B )
If N is a valid option number, the word displays the text
(not including the leading number) of the option message;
B is TRUE. If N is not a valid option number, the word
displays nothing; B is FALSE.
MIN ( N1 N2 --- N3 )
N3 = the lesser of Ni,N2.
MOD ( N1 N2 --- N3 )
N3 = N1 modulo N2 (remainder of N1/N2). Sign of N3 is same
as Ni.
MOVE ( Al A2 L --- )
Move data from Al to A2, length L. The move is managed so
that the data cannot overlay itself, no matter what values
of Al, A2, and L are used. This allows overlapping source
and destination areas to be MOVEd successfully.
NATTACH ( A) VI
(A counter used internally by BIND.)
NEGATE (N N' ) C
N' = -1 * N.
NEXT ( A) V3
(Address of a JMP instruction that points to the SNAP
inner loop. Changed by the HHC's nucleus to handle certain
types of interrupt conditions.)
NEXTV ( A) V1
(Address of a variable used to repoint NEXT to bank
switching code when SNAP must execute a tag defined in
another memory bank.)
NFILES ( A)
Stacks the address of a word containing the number of
files existing in the current file space.
NMIVECT ( A) V2
(Non-maskable interrupt vector. May be changed to point to
a low level NMI processing routine. The default NMI
processing routine is a null routine; is returns control
immediately to the caller.)
NREC ( N --- [A L] B )
An internal word in the virtual file system.
(Finds a record in the current virtual file. N is the
number of the record. If the record is found, A L are its
address and length; B is TRUE. If the record is not found,
A L are absent; B is FALSE.
ONFLAG ( A) V1
(A byte used to turn the CPU on and off. The 80's bit
controls the on/off status.)
OPEN (AL B)
Opens an existing virtual file.
A and L are the address and length of the file name. B is
TRUE if the file is found; FALSE if not.
OPEN-FILE (N )
(Opens the N'th file in the current file space. Used
internally by OPEN.)
OP FLAG ( --- FL )
(A flag in HDT byte 1. 1 -> this HDT represents a device
capable of output.)
OR (XY Z) C
Performs a bitwise logical OR.
ORBLIP (N )
ORs the low-order byte of N into the LCD blip mask. If a
bit is 1 in N, the corresponding blip is turned on; if a
bit is 0 in N, the corresponding blip is unchanged.
For a list of symbolic constants that may be used to
designate the bits, see ANDBLIP.
OVER ( X Y --- X Y X ) C
Copies 2nd entry on stack.
PASSRAW ( --- FL )
A bit in FLAG2 which controls the operation of the SHIFT,
2nd SFT, and LOCK keys. 1 -> the keys have their normal
functions. 0 -> the keys place binary codes in the
keyboard buffer, like ordinary character keys.
PATLEN ( ....... L )
(Length of the "pattern" used to re-initialize several
I/O-related vectors, such as the address of the keyboard
translation table, during a clear.)
PCASAV ( ___ A ) V1
(A byte in N used internally by I/O routines to save the
displacement of the current PCA.)
PCH ( A) V1
(Value of the previous raw keyboard character code. Used
internally by keyboard debouncing routines.)
PENDFLAG ( --- FL )
(A flag in HDT type 1. 1 -> I/O operation is pending on
this device.)
PICK Xy X3 X2 X1 y Xy ... X3 X2 X1 Xy )
Copies y'th entry on stack to the top.
PIPFLAG ( --- FL )
(A flag in PCA byte 0. 1 -> this PCA represents a device
capable of doing input.)
PKCT ( A ) V1
The pushkey buffer pointer. Contains the number of char-
acters currently in the pushkey buffer, PKQ. If the value
is 0, the buffer is empty, and the next character in the
input stream will come from the keyboard buffer. If the
value is 4, the pushkey buffer is full.
See also PKQ.
PKEY ( A) VI
(A location in which input characters are deposited when a
RIP is done on the keyboard.)
PKQ ( A) V4
The pushkey buffer. This is a 4-byte stack containing
characters "pushed" into the keyboard input stream by the
program.
The stack grows upward; thus the first character pushed
into the buffer goes at PKQ, and the 4th (and last) char-
acter pushed into the buffer goes at PKQ+3.
See also PKCT.
POSN ( N )
Used internally to manage LCD display. Not normally used
by applications.
(Positions cursor in character position N. The next EMIT
or -EMIT will put a character where the cursor then is.
POZECB ( ___ A ) V6
The timer ECB used by NAP. In synchronous routines it is
safe to use this ECB for any purpose such that NAP cannot
be executed while it is in use. (This means mainly words
that perform a waiting function similar to NAP.)
PROGBIT ( ___ F ) =
A bit mask for CSPEED. See CSPEED for details.
PSECB ( ____ A ) V6
(Timer ECB used by the clock controller. If any clock
controller alarms are defined, this ECB is in the timer
queue, and contains the time of the next alarm to come
due. If no alarms are defined, this ECB is all-zero and is
not in the timer queue.
When the timer represented by this ECB is exhausted the
HHC issues its trumpet fanfare and resets the timer for
now plus 10 minutes. When the clock controller cancels the
alarm that has come due, it also adjusts the ECB to
reflect the next remaining alarm in the queue (if any).
PUSHKEY ( C --- ) C
Pushes a character into the pushkey buffer. See PKQ, PKCT.
R ( )
Copies X from top of return stack.
R> ( )
Pops X from top of return stack.
RAM.N (N B )
Given the relative bank ID of a RAM bank, N, tries to
switch the RAM bank into the extrinsic RAM address space.
Available RAM banks are numbered consecutively from 1.
If the RAM bank exists, RAM.N switches it in and returns
B=TRUE. If not, RAM.N returns B=FALSE.
RAMADDR ( A )
Address of the beginning of the extrinsic RAM address
space (8000H).
RAMS IT ( --- FL )
(A bit in FLAG3 indicating whether to do a hard clear when
exiting from the I/O key processor. 1 -> do a hard clear;
0 -> do no clear.
RAMEXFLAG ( --- FL )
(A flag in PCA byte 0. 1 -> the PCA represents a program-
mable memory peripheral.)
RCSAV ( A)
(A byte in N used internally by I/O routines to save an
REC-CNT ( --- N )
Returns number of records in the current virtual file.
This may be used to add a record to the end of the file,
like this:
adr len REC-CNT INSERT drop
REFRESH ( --- ) C
Used internally to manage the LCD display. Not normally
used by applications.
(Checks contents of LCD display buffer; ensures that all
characters that are marked "flash on" in the control
vow buffer are, in fact, flashing.)
REST.KEY ( )
(Restores variables indicating status of keyboard from
values saved on the return stack. See SAVE.KEY.)
RESTORE ( )
Restores a word in memory, stored by SAVE. Note, does not
leave the address on the stack. See SAVE.
RESTORE .RAM ( )
(Switches the current RAM bank into the address space.
Used by the I/O key to restore the current RAM bank atter
switching in each available bank while displaying the I/O
menu.)
RESTORE .TASK ( )
Restores variables indicating HHC status that are saved by
SAVE.TASK. See SAVE.TASK.
REVISE (AN B)
Adds or deletes space within non-text virtual files. (Also
used internally by the file system to insert and delete
records in text files.)
ROLLBIT ( --- FL )
(A flag in FLAG1 used by the keyboard decoding routine to
support keyboard rollover.)
ROMADDR ( A )
Stacks the location at which ROM capsules begin in the HHC
address space. Used in a capsule header like this
ROMADDR SETORG
ROMEXFLAG ( --- FL )
A flag in the PCA byte 0. 1 -> this PCA represents a ROM
extender.
ROME XT ( A ) K1
The location in a ROM capsule header which contains the
number (2 through 7) of the capsule's primary long tag
table. See ROMVECT for more information.
ROMID ( A ) K1
The location in a ROM capsule header where a string
containing the ROM capsule's name should begin. Used like
this•
ROMID TO DP-V
to store that address into the virtual dictionary pointer
ROMVECT ( A ) K2
The location in the header of a ROM capsule which contains
the address of the capsule's primary long tag table. When
the HHC executes the program in the capsule, it stores
this address in the proper entry of the tag table vector.
The proper entry is the one indicated by ROMEXT.
RP! ( )
Empties the return stack.
RP @ ( A)
Stacks the current value of the return stack pointer,
i.e., the address of the current tip entry on the return
stack. May be used with caution to fetch data from the
return stack.
RSTK ( A )
(Address of the base of the return stack.)
RUNBIT ( --- FL )
S" ( ) I,NOTE
Begins the definition of a count format string constant
(i.e., a constant consisting of a one-byte length field
followed by an ASCII value). Used like this:
S" TEXT OF THE MESSAGE"
The value of the constant begins with the first character
after S" and one blank. It is terminated by the next "
character in the input stream.
Used outside a colon definition, S" simply deposits a
string value in the target address space. To get the
address of the string (at compile time), stack HERE before
defining the string. Here is an example which defines a
table consisting of 3 strings, terminated by a null
string, with the label C-TABLE representing the target
address of the first string:
HERE
S" FIRST STRING"
5" SECOND STRING"
S" THIRD STRING"
"
== C-TABLE
To define a single string constant, the word STRING" is
preferred.
Used inside a colon definition, S" defines a string value,
and also generates code to branch around the value and
stack its address. Use S" in this way only when you have a
good reason to do so. It is generally better practice to
define a separate, labelled string constant and refer to
it by name, since the same value can then be used in more
than once place.
NOTE: a bug in the current version of the development
system causes multiple blanks in a file to be compressed
to single blanks, even when they appear in an S" value. As
a result, values containing multiple blanks, or a single
leading blank, will be stored incorrectly. (A single
leading blank will be combined with the preceding blank
that delimits S", and so will disappear.)
NOTE: a bug in the current version of the development
system makes it impossible to represent a null string
value with 'S" If you try to do so, the compiler will
ignore the second and begin looking for the string
delimiter with the first following character (presumably
another blank). This can make a large section of a program
fail to compile for no apparent reason.
S.T ( )
Shows a date and time in the format used by the clock
controller's "time" function. Does not update the time.
Before executing S.T, you must store the time you wish to
display in the 39th and 40th words of &LBUF. The time
should be time of century in seconds. For example, to
display the current time:
GET. GMT DROP &LBUF 39 + 2! S.T
S= ( Al Ll A2 L2 --- B )
Compares the string defined by Al/Li to the string defined
by A2/L2. B is TRUE iff the two strings are equal.
S>D ( N --- ND )
N is converted to a double integer.
SAVE ( A --- )
Saves address A and the contents of the word at address A
on the temporary stack. The contents of the word may be
restored to memory by RESTORE.
SAVE.KEY ( )
(Saves variables indicating status of keyboard on the
return stack. See REST.KEY.)
SAVE .TASK ( )
(Saves the a number of variables that determine attributes
of the HHC's status.
(Saved variables include (ROTMODE) and (FREEZE); 'KEY and
'EMIT; characters displayed on the LCD (but not their
display attributes, e.g., reverse image); cursor position;
SCROLL ( )
Used internally to manage LCD display. Not normally used
by applications.
(Rotates the LCD display left by 1 character. Matching dot
columns at the right end of the display are cleared. The
display output pointer, BUFPOSN, is shifted left with the
display.)
SCROLR )
Used internally to manage LCD display. Not normally used
by applications.
(Same as SCROLL, but scrolls right.)
SDT ( A)
Stacks the address of the system device table (SDT). The
SDT contains one one-byte entry per logical unit number
(LUN), stored in LUN order.
Each entry is the displacement from the beginning of the
hardware device table (HDT) area to the HDT for the device
connected to this LUN. A value of 0 indicates the
keyboard; 6 represents the LCD; OCH, 12H, 18H, ...
represent peripherals; OFFH represents an unattached LUN.
SECS N )
Puts the HHC to sleep for N seconds.
SET-BLIPS ( )
(An internal word used by EXPECT to refresh the INSERT and
DELETE blips.)
SET.BITS ( A X --- )
Changes the value of the word at A by turning on each bit
that corresponds to a bit that is on in X. See also TOGGLE
and CLR.BITS.
SET.CONSTANT N DEF
SET.FLSH ( )
Causes any following EMIT with zero in the character
parameter's high byte to display a flashing character. SEE
ALSO UNSET.INV and SET.INV.
SET.INV
Causes any following EMIT with zero in the character
parameter's high byte to display a character in inverse
image form. SEE ALSO UNSET.INV and SET.FLSH.
SET.RP ( -- ) C
(Empties the return stack.)
SET.SP ( X --- ) C
Sets the parameter stack pointer to the address indicated
by the low-order byte of X (relative to the start of page
1). This may be used WITH CAUTION to empty the stack to a
predetermined level, regardless of how many entries have
since been pushed onto it.
To get a value of X, use SP@. For example, in the
following piece of code:
SP@ SDEPTH 1
.
.
.
SDEPTH @ SET.SP
SET.SP@ sets the stack to the depth that it had immed-
iately before SP@ was executed.
CAUTION: if SET.SP moves the stack pointer AWAY from the
root of the stack, effectively adding entries to the
stack, the added entries will be meaningless.
SETBANKS ( X --- )
The two bytes of X are interpreted as bank ID's. The high-
order byte is used to switch a ROM bank into the ROM
capsule address space. The low-order byte is used to
switch a RAM bank into the extrinsic RAM address space.
SHIFT? ( --- FL )
(A bit in FLAG1. 1 -> we're in SHIFT or 2nd SFT mode; 0 ->
we're not. If SHIFT? is TRUE, WHICH? tells which mode
we're in.
See also WHICH? and LOCKED?
SHINT ( N)
A symbol giving the number of the first short tag that is
free for use in the short extrinsic tag table. Used with
TAG.TABLE to set up a ROM capsule header that contains a
short extrinsic tag table.
SHORT ( ) COMP
Informs the compiler that a word, to be defined later, is
to be assigned a short tag. The compiler reserves the next
available entry in the short tag table for the specified
word at the time when SHORT is processed.
SHORT.TAGS ( ) COMP
Causes the cross-compiler to begin using short tags to
compile definitions (assuming space for short tags remains
in the current tag table). This is the cross-compiler's
initial mode of operation.
SHOW.TIME ( ) NOTE
Shows the current time in the format used by the clock
controller's "time" function; updates the time each
second.
SIGN (ND D)
SIZERAM ( N) C
(Used by the CLEAR key to determine the size of a RAM.)
SL ( A) V1
"Stack limit." The displacement from the beginning of page
1 to the first word below the limit of the parameter
stack. (Recall that the parameter stack grows down from
the top of page 1.)
In base 16,
SL C@ 100 + 2+
SLPFLG ( A) V1
(A byte used to control "sleep," i.e., the turning off of
the CPU.)
SMART-POSN ( N )
Moves the LCD cursor to character position N. SMART-POSN
functions by EMITing a string of <-'s or ->'s.
SNAP-FILE ( )
(Implements the "run SNAP programs" option from the
primary menu.)
SOFT.CLR
Performs a soft clear, as though the user had pressed the
CLEAR key once.
SOFT. EMIT ( C )
Same function as EMIT, but treats all control characters
SOFTAG ) V2
The tag that was executed when the current application was
entered. Set by FLEE.
This tag will be re-executed if the application is re-
started by a soft clear.
SOFTAG may be changed directly, or by another FLEE.
See also SOFTROM, SOFTCTL, and SOFTVECT.
SOFTCTL ( A ) V1
Bank ID of the peripheral control ROM that was selected
when the current application was entered. Set by FLEE.
This control ROM will be re-selected if the application is
restarted by a soft clear.
SOFTCTL may be changed directly by the application
program.
See also SOFTROM, SOFTVECT, and SOFTAG.
SOFTFLAG ( A ) V1
A location whose contents determines whether the next
clear will be a soft clear or a hard clear.
If the contents of SOFTFLAG is 5AH, the next clear will be
hard. If the contents of SOFTFLAG is anything else, the
next clear will be soft.
A soft clear set SOFTFLAG to 5AH; any other keystroke sets
it to 0.
An application can prevent hard clears from taking place
by resetting SOFTFLAG as soon as the restart word indicat-
ed by SOFTAG is executed. (CAUTION: this violates the
HHC's customary user interface design, and forces the user
to take drastic steps, such as unplugging a program
capsule, if the program malfunctions or he forgets how to
use it.)
SOFTROM V1
Bank ID of the capsule ROM that was selected when the
SP@ ( A ) C
Returns the address of the tip of the parameter stack,
i.e., of the lowest entry on the stack.
SPACE ( )
Displays a space on the current output device (normally
the LCD).
SPACES (N )
Displays N spaces on the current output device (normally
the LCD).
SPEED ( A) VI
mow A number that controls speed of EMIT, CR, menu rotation,
etc.
The value of SPEED is set by the STOP/SPEED key like this:
value STOP/SPEED setting
10 1 (slowest setting)
9 2
SPINIT ( A)
Stacks the address of the root of the parameter stack. To
empty the stack, execute the following code:
SPINIT SET.SP
START.CURSOR ( )
Enables flashing cursor (makes it visible).
STKBIT ( --- FL )
(A bit in FLAG1 that indicates HHC status is on the return
stack.)
STM ( )
Performs the entire "set time" function of the clock
controller. It returns control to its caller when the user
presses ENTER (if he wants to set the time) or gives up
control to a soft clear (if he wants to escape from the
word without setting the time).
Application programs may call this word to let the user
set the HHC's clock without going to the clock controller.
STOP.CURSOR ( )
Disables flashing cursor (makes it invisible).
STRING (N ) DEF
Used in a TSA to reserve storage for a string.
The word reserves N bytes. By convention, this is space
for a string up to N-1 bytes long, preceded by a count
byte containing the string's actual length. For example:
24 STRING ERRMSG
This reserves 24 bytes for a string named ERRMSG.
STRING" ( ) DEF
Defines a string constant. Input up to the next double
quote is prefixed with a length byte and moved to virtual
memory. The next word is defined to be the string's name.
For example:
STRING" PLEASE WAIT..." WAITMSG
When the string's name is referenced at run time, the
string's address (the address of the count byte) is placed
on the stack.
SWAP ( X Y Y X ) C
Exchanges top 2 entries on the stack.
SWAPDROP ( X Y Y )
Drops the second entry on the stack.
T! ( )
Initializes (empties) the temporary stack. NOTE:
application programs should NOT use this word.
T: ( ) DEF
"Target colon." When a word defined by T: appears in a
colon definition, it is executed (not compiled into the
colon definition). This is useful for defining a "compile
time macro" that compiles more than one tag, or compiles
data into a colon definition.
Here is an example of a T: from the HHC nucleus. It
defines the word GET-TYPE, which compiles to two tags: the
tag for CFILE, and the tag for 2+:
T: GET-TYPE ( --- A )
COMPILE-V CFILE COMPILE-V 2+ T;
T: is also useful for creating an "alias" for a word; that
is, for specifying that a certain word in the source
program is to be compiled to another word. Here is an
example of this sort of use:
T: NOT COMPILE 0= T;
This code makes NOT an alias for 0=. Wherever NOT appears
in the source program, the tag for 0= will be compiled
into the target.
T; ) COMP ,NOTE
Used to terminate a T: definition. See T: for details.
TO ( m A) V1
T1 ( --- A ) V1
T2 ( ___ A ) V1
T3 ( --- A ) V1
T4 ( m A) Vi
T5 ( A) V1
T6 ( m A) V1
T7 ( --- A ) V1
T8 ( m A) V1
(Work space used by low level nucleus routines to maintain
the HHC's time of century clock. Hands off!)
TABLE (N ) DEF
Used to create a word-element table in ROM. The table must
be initialized by storing data into it, for example:
4 TABLE TRIBBLE
3 I 2 I 1 I 0 I
TDKFLAG ( --- FL )
(A flag in HDT byte 0: 1 -> this HDT belongs to the LCD or
keyboard.)
THEN ( ) CTRL
A synonym for ENDIF.
THI ( A )
(High order byte of the hardware timer. See TLO, TMID.)
TIMEFLAG ( --- FL )
(A bit in FLAG2 used by the HHC nucleus to help support
timer updating.
TLO ( A )
(Low order byte of the hardware timer. See THI, TMID.)
TMID ( )
(Middle order byte of the hardware timer. See THI, TLO.)
TOGGLE ( A X --- )
Changes the value of the word at A by reversing each bit
that corresponds to a bit that is on in X. See also
SET.BITS and CLR.BITS.
TP ( A ) V2
An internal variable in the virtual file system.
(Ceiling of the last virtual file in the intrinsic virtual
file space. 'TP @' stacks the ceiling of the last virtual
file, i.e., the address of the first free byte of
intrinsic virtual file space.)
I see a conflict within my notes, which give both this
definition and "address of the tip of the temporary
stack." Which is correct, and what variable gives the
other value?
TPSAFE? ( N--- A I 0 )
Determines if there is enough space in intrinsic RAM to
allocate N bytes of storage space. If there is, A is the
address of the space; if there is not, 0 is returned.
Note that TPSAFE? does not allocate the space; it merely
returns the address at which space WILL be allocated, if
TQUEUE ( A) V12
Timer queue. Consists of 6 2-byte entries, each containing
the address of a timer ECB or 0.
Each unexpired timer ECB in the system is represented in
this queue. Whenever a timer interrupt occurs, the queue
is searched for expired ECB's; if any are found, they are
posted and removed from the queue. Each unexpired ECB is
updated to reflect the amount of time remaining until it
expires.
TURN .OFF ( )
(Turns the HHC off as if the OFF key had been pressed.
Applications should not use this word; it will cause the
HHC to execute the word pointed to by 'ABORT. See 'ABORT,
ABORT.)
TVECTO ( A ) V24
Stacks the address of the first entry in the tag table
vector (the entry representing the short extrinsic tag
table).
The table consists of 8 entries: #0 for the short
extrinsic tag table, #1 for the long intrinsic tag table,
and #2 through #7 for long extrinsic tag tables. For
further details, see the discussion of tag tables in the
chapter on "General Technical Information."
Each entry in the tag table is 3 bytes long:
byte bit contents
0 80 l->tag table is in ROM, 0->in RAM.
40-01 Bank ID of memory bank containing the tag
table.
1-2 Address of the tag table.
TYPE (AL )
Displays characters from memory, starting at address A,
for length L.
Control characters may be included in the character string
to perform control functions on the TV adapter if the
No. adapter is bound to the display. These control codes have
no effect on the LCD.
TYPEDROP ( X A L )
Types the string at address A, length L, and drops X.
U* ( Ul U2 UD )
UD = Ul * U2.
U< ( Ul U2 --- B )
Tests if Ul < U2.
UM/ ( UD Ul --- U2 U3 )
U2 = unsigned remainder of UD/U1.
U3 = unsigned quotient of UD/U1.
UNPACK ( DN --- SEC MIN HOUR AMPM YEAR DAY MONTH) NOTE
Given a time of century in seconds, "unpacks" it into a
date and time in standard form.
All of the results are short integers.
HOUR is the hour on a 12-hour clock.
AMPM is a boolean; it is FALSE for "AM", and "TRUE" for
PM.
YEAR is origin-1980 (i.e., 1980 is year 0, 1981 is year 1
. . . 2000 is year 20 . . . 2079 is year 99).
NOTE: UNPACK is a tagless word. It must be executed with
(CALL). To locate its entry point, add 3 to the address of
the entry point of the word represented by tag 0A1H. The
following word may be used to call UNPACK:
HEX
: UNPACK (S DN --- SEC MIN HR AMPM YR DAY MO )
\ ADR OF TAG TABLE ENTRY FOR WORD 0A1H.
IDICT OA1 + ()Al + ] LITERAL
A(ENTRY PT) FOR WORD W/TAG 0A1H.
3 + A(ENTRY PT) FOR UNPACK.
UNSET.FLSH ( )
Reverses the effect of a preceding SET.FLSH, if any.
UNSET.INV ( )
Reverses the effect of a preceding SET.INV, if any.
UNTIL (N ) CTRL
Ends a BEGIN loop in a colon definition.
Occurs in a colon definition in the form
BEGIN ... UNTIL
BEGIN ... UNTIL loops until UNTIL finds a 1 on the stack.
Then it passes control to the next word after UNTIL.
(At compile time, the format is "A N ---". UNTIL compiles
(OBRANCH) and an offset from A to HERE. N is an error
checking code.)
UPDISP
Updates the LCD after the contents of the LCD character
buffer or the LCD control buffer has been modified.
USED ( A)
Stacks the address of a 2-byte area containing the number
of bytes used in the current file space.
For the number of bytes free in the current file space,
see AVAIL.
VAR DEF
Used in a TSA to reserve one word of storage for a
variable. For example:
VAR ERRCODE
This reserves a word for a variable named ERRMSG.
7 ERRTBL
would stack the address of the 7th (and last) element of
maw the vector, ERRTBL.
WHICH? ( --- FL ) .
(A flag in FLAG1. If SHIFT? is TRUE, indicating that the
HHC is in SHIFT or 2nd SFT mode, WHICH? indicates which
mode it is in: 1 -> SHIFT mode, 0 -> 2nd SFT mode.)
WRITE ( A L N --- B )
Replaces record #N of the current virtual file with the
data at address A, length L.
If record #N already exists, B is true. If record #N does
not already exist, the new record is NOT WRITTEN and B is
false.
To write a record where none exists, use INSERT.
X1SAV ( A) V1
(Used by peripheral I/O routines to save the X register.)
XOR (XY Z) C
Bitwise logical exclusive OR.
XSAVE ( A) V1
A one-byte area set aside for storing the X register. A
CODE word or low level procedure may use it for any
purpose. But note that any lower level routine may destroy
its contents; if your code calls a lower level routine
that is not part of your own program, assume that XSAVE
will be destroyed by the call, even if it currently
appears to be preserved.
YOFF ( A )
(Address of a location in the I/O page. A store into this
address causes the Y-driver to stop asserting IRQ.)
Z ( A ) V9
(Work space in low RAM, used by IRQ processing routines.)
( --- ) I
Switches SNAP from compile mode to execute mode. This word
has two uses. One is to execute some words while
compiling. This is most commonly done to resolve the value
of an expression at compile time. For example:
HEX
80 == ALL.DONE
40 == PART.DONE
: FOOBAR ( xxxxxxxx... )
...
FLAGBYTE C@ [ ALL.DONE PART.DONE OR ] LIT AND IF
...
\ ( ___ ) I
Makes the rest of this source screen line a comment.
Example:
2DUP + 1- \ POINT TO THE LAST BYTE.
'\' must be followed by a blank. No terminating delimiter
is needed.
( --- ) COMP
Switches SNAP from execute mode to compile mode. Used with
ip to switch SNAP from compile mode to execute mode, then
back to compile mode; or from execute mode to compile
mode, then back to execute mode. See description of 'P.
-CURSOR ( ___ A ) V2
Stacks the address of the address of the current cursor
image definition. You can define a new cursor image by
executing the following words:
YOUR-CURSOR-DEFINITION -CURSOR !
where YOUR-CURSOR-DEFINITION stacks the address of a 5-
byte cursor image definition block.
The address of the HHC's standard cursor definition is
given by CURDOTS. -CURSOR is reset to CURDOTS by a hard
clear.
-HDT ( ___ A ) V2
Address of the first HDT.
OBJECT-TIME WORDS
(+LOOP) ( N --- ) C
Compiled from +LOOP. Increments loop index by N and tests
for loop completion.
(.") ( --- ) C
Compiled from 1 ." (dot-quote). Displays the COUNT format
string that follows (.") in the program; passes control
around the string.
(;P) (--- ) C
Compiled from ';'. Pops IP from the return stack and goes
to NEXT.
(<IF) ( N1 N2 --- ) C
Compiled from <I F. If Nl<N2, executes the following code.
If Nl>=N2, passes control around the following code to the
point representing the matching ELSE or ENDIF.
(=IF) ( N1 N2 --- ) C
Compiled from =IF. If N1=N2, executes the following code.
If Nl<>N2, passes control around the following code to the
point representing the matching ELSE or ENDIF.
(?DO) ( N1 N2 --- ) C
Compiled from ?DO.
(AGAIN) ( --- ) C
Compiled from REPEAT and AGAIN. Followed by a one-byte
unsigned displacement which is subtracted from the address
of the displacement to get the address of the correspond-
ing BEGIN.
(CASE) ( B --- ) C
Compiled from CASE. If B is TRUE, executes the following
code. If B is FALSE, branches around the following code to
the point representing the next CASE, the matching ELSE,
or the matching ENDIF.
(CALL) ( m ) C
Compiled from any reference to a colon definition that was
defined with ':C' instead of 1 :1 . Interprets the next two
bytes as an address, and "calls" the colon definition
beginning at that address.
(DO) ( N1 N2 --- ) C
Compiled from DO. Moves loop control parameters to the
return stack.
(ELSE) C
Compiled from ELSE. Followed by a one-byte unsigned number
giving the displacement from the displacement byte to the
ENDIF.
(IF) ( B --- ) C
Compiled from IF. Followed by a one-byte unsigned number
giving the displacement from the displacement byte to the
ELSE (if any) or ENDIF.
If B is FALSE, does nothing. If B is TRUE, passes control
to the point representing the matching ELSE or ENDIF.
(IF.ITS) ( N --- N ) C
Compiled from IF.ITS. If N is equal to the constant
compiled after IF.ITS, passes control to the code
following the constant. If N is not equal to the constant,
passes control to the point representing the matching
ENDIF.
yew
(LOOP) ( --- ) C
Compiled from LOOP. Increments loop index and tests for
loop completion.
(NOTIF) ( B --- ) C
Compiled from NOTIF. Followed by a one-byte unsigned
number giving the displacement from the displacement byte
to the ELSE (if any) or ENDIF.
If B is TRUE, does nothing. If B is FALSE, passes control
to the point representing the matching ELSE or ENDIF.
(UNTIL) ( B --- ) C
Compiled from UNTIL. Followed by a one-byte unsigned
displacement. If B is TRUE, passes control back to the
corresponding BEGIN, which is at the address of the
displacement minus the value of the displacement. If B is
FALSE, passes control to the address of the displacement
+1.
<JUMP-TAB> ( N --- ) C
'`' Compiled from JUMP-TAB. Executes the N'th word in the jump
table.
?JUMP ( B --- ) C
Compiled from LONG.IF and LONG.WHILE. Followed by a 2-byte
signed displacement.
If B is TRUE, passes control to the address of the dis-
placement plus the value of the displacement. If B is
FALSE, passes control to the address of the displacement
+2.
CLIT ( m c ) C
Compiled from a literal with a value in the range O-OFFH.
Followed by one byte giving the value of the literal. At
run time, CLIT stacks the contents of the next byte, left-
padded with a zero byte.
CLIT2 ( --- N ) C
Compiled from a literal with a value in the range 200H-
2FFH. Followed by one byte giving the value of the literal
minus 200H.
CLIT3 ( --- N ) C
Compiled from a literal with a value in the range 300H-
3FFH. Followed by one byte giving the value of the literal
minus 300H.
FLIT ( --- FP ) C
"Floating point literal." At run time, FLIT works like the
run-time words LIT (which stacks a word literal) and CLIT
(which stacks a character literal). However, the compiler
currently cannot generate it automatically from a floating
point constant.
To use FLIT to compile a floating point number, use the
following words:
FLIT [ nl ,-V n2 ,-V n3 ,-V n4 ,-V ]
where nl to n4 are the values of the four words that make
up the floating point constant, FP.
JUMP ( --- ) C
A run time support word generated by LONG.ELSE and
LONG.REPEAT. Followed by a 2-byte signed displacement.
(Transfers control to the address of the displacement plus
the value of the displacement.
(This word may also be used to patch compiled high-level
LIT ( _a_ N ) C
Compiled from a literal that cannot be compiled to a CLIT,
CLIT2, or CLIT3. Followed by two bytes giving the value of
the literal. At run time, LIT stacks the contents of the
next two bytes.
ASSEMBLER GLOSSARY
1. Opcodes.
2. SNAP compile-time words used in address calculations, such
as 2+.
"Sn" refers to the "n"th entry on the stack. For example, the
tip entry is "SO;" the next-to-tip entry is "Sl."
"NEXT" Words
These words pass control directly to NEXT when they are done
executing. Call them with a ',IMP,' instruction.
(2POP)
Pops the top 2 words off the stack.
(POP)
Pops the tip word off the stack.
(POPPUT)
Pops the tip word of the stack; replaces the second word
on the stack. The replacement value is constructed from
AC (high byte) and one byte popped off the return stack
(low byte).
(PUSH)
Pushes a word onto the stack. The word is constructed from
the contents of the accumulator (high byte) and one byte
popped off the return stack (low byte).
(PUSHOA)
Pushes a word onto the stack. The word is constructed from
a zero (high byte) and AC (low byte).
(PUT)
Replaces the tip word on the stack. The replacement value
is constructed from AC (high byte) and one byte popped off
the return stack (low byte).
(PUTOA)
Replaces the tip word on the stack. The replacement value
is constructed from a zero (high byte) and AC (low byte).
(PUTFLS)
Replaces the tip word on the stack. The replacement value
is FALSE (zero).
(PUTTRU)
Replaces the tip word on the stack. The replacement value
is TRUE (1).
(SLEEP)
Puts the HHC to sleep the next interrupt (from the timer,
keyboard, etc.) will wake it up.
"RTS" Words
(SCOMP)
Performs a signed algebraic comparison of the two words on
the tip of the stack.
On return, the words are still on the stack, but their
signs are reversed.
On return, the CPU flags are set as follows:
tip word = 2nd word Z=1
tip word > 2nd word Z=0, C=0
tip word < 2nd word Z=O, C=1
For unsigned comparison, see (UCOMP).
(SETUP)
Pops a variable number of input values off the parameter
stack and stores them in the workarea N.
(UCOMP)
Performs an unsigned algebraic comparison of the two words
on the tip of the stack.
On return, the words are still on the stack, and are
unchanged.
On return, the CPU flags are set as follows:
tip word = 2nd word Z=1
tip word > 2nd word Z=0, C=0
tip word < 2nd word Z=O, C=1
For signed comparison, see (SCOMP).
GETMEM
(A subroutine formerly used by peripheral controller
routines to allocate space from the bottom of the param-
eter stack area in page 1. Peripheral controller routines
now use GETMEMT to get space from the temporary stack
instead.
(On entry, AC contains the number of bytes required.
(On return, AC contains the address of the space if the
space was available, or zero if not.)
GETMEMT
A subroutine used by peripheral controller routines to
allocate space from the temporary stack.
On entry, AC contains the number of bytes required.
On return, AC contains the address of the space if the
space was available, or zero if not.
GETMEMT is intended for use by peripheral controller
routines. Application programs should allocate a TSA, or
use the high level word GRAB if a TSA is inappropriate.
POSTECB
Posts an ECB for an I/O operation.
On entry, Y contains the address of the HDT associated
with the device. AC contains the return code to post in
Other Words
# ( ___ )
Addressing mode specifier for "immediate" mode.
) ( ___ )
Addressing mode specifier for absolute mode.
YY ( ___ )
Addressing mode specifier for "indirect indexed Y" mode.
,x
Addressing mode specifier for "indexed X" mode.
,Y
Addressing mode specifier for "indexed Y" mode.
.A
Addressing mode specifier for "accumulator" mode.
0<
Condition specifier for processor status N=1 ("byte less
than zero)."
0=
Condition specifier for processor status Z=1 ("byte equals
zero").
AGAIN,
Used in a CODE word in the form:
BEGIN, . . . AGAIN,
ASSEMBLER
Name of the ASSEMBLER vocabulary. Using this word makes
ASSEMBLER the context vocabulary.
Use ASSEMBLER to begin assembling code without making an
entry in the tag table, i.e., to assemble a low level
procedure which CODE words can call with a JSR,.
BEGIN,
Used in a CODE word in the form:
BEGIN, . . . cc UNTIL,
or
BEGIN, . . . cc WHILE, . . . REPEAT,
or
BEGIN, . . . AGAIN,
marks the beginning of a loop that will be executed
iteratively (a) until condition specifier "cc" before
UNTIL, is satisfied, (b) until the condition specifier
"cc" before WHILE, is not satisfied, or (c) indefinitely,
if AGAIN, is used.
BEGIN, does not assemble any machine instructions; its
sole function is to mark the target of a jump from UNTIL,
REPEAT, or AGAIN,.
CODE
A defining word used in the form:
CODE <name> . . . ENDCODE
Creates a tag table entry for <name> and makes the
ASSEMBLER vocabulary the context vocabulary.
CS
Condition specifier for processor status C=1 ("test carry
set").
ELSE,
Used in a CODE word in the form:
cc IF, . . . ELSE, . . . ENDIF,
marks the end of a section of code to be executed if
condition specifier "cc" is satisfied, and the beginning
of a section of code to be executed if "cc" is not
satisfied."
ELSE, assembles to an unconditional jump to the code
following ENDIF,.
110111.-
ENDCODE
Ends a CODE definition (begun by the word CODE), just as
';' ends a colon definition (begun by th word 1 :1 ).
Performs error checking to make sure that all conditionals
are properly paired and that the stack is the same depth
as when the CODE word began; resets the context vocabulary
to be the same as the current vocabulary.
ENDIF,
Used in a CODE word in the form:
cc IF, . . . ELSE, . . . ENDIF, or
cc IF, . . . ENDIF,
marks the end of a conditional-execution section of code.
In the first case, the code between IF, and ELSE, is
executed if condition specifier "cc" is satisfied, and the
code between ELSE, and ENDIF, is executed if not. In the
second case, the code between IF, and ENDIF, is executed
if "cc" is satisfied, and no code is executed if not.
ENDIF, does not assemble to any code; its function is to
mark the target for an unconditional jump from ELSE,.
IF,
Used in a CODE word in the form:
cc IF, . . . ELSE, . . . ENDIF, or
cc IF, . . . ENDIF,
marks the beginning of a section of code to be executed if
condition specifier "cc" is satisfied.
IF, assembles to a conditional jump instruction to the
code after ELSE, or ENDIF,; the condition used depends on
the preceding "cc."
IP
Stacks the address of a two-byte area in low RAM which
contains the address of the lowest level colon definition
tag currently being executed.
LABEL
Defines a "label" whose value is the current value of the
dictionary pointer. It is used like this:
Nimp. LABEL symbol
N
Stacks the address of a 20-byte area which a CODE word or
low level procedure may use for any purpose. Its customary
use is to hold parameters popped off the stack. See
(SETUP).
A procedure may not safely assume that N will be preserved
across any call to a lower-level routine.
NEXT
A label representing a JMP, to the entry point of the SNAP
inner interpreter. A CODE word must return control to SNAP
by jumping to NEXT:
NEXT JMP,
NOT
Reverses the condition specified by the preceding
condition specifier. May be applied to any condition
specifier. For example,
0= IF, N STA, ENDIF,
executes the STA, if the "equal to zero" condition is
satisfied;
0= NOT IF, N STA, ENDIF,
executes the STA, if the "equal to zero" condition is NOT
satisfied.
REPEAT,
Used in a CODE word in the form:
SEC
Same as TOP, but addresses the second (next-to-tip) entry
on the parameter stack. See TOP.
TOP
Addresses the low byte of the tip entry of the parameter
stack by stacking a zero address and setting the
addressing mode to "indexed indirect X." (By convention, X
points to the tip entry of the parameter stack.) For
example,
TOP LDA,
is equivalent to
0 X) LDA,
mip, and loads the low byte of the tip entry into AC.
TOPDEC
Subtracts 1 from the signed value of SO. Returns to
caller.
TOPINC
Adds 1 to the signed value of SO. Returns to caller.
UCOMP
Compares SO and S1 as unsigned numbers. The result is
turned in the Z and C flags. The meanings of the flags are
the same as for SCOMP.
Returns to caller.
UNTIL,
Used in a CODE word in the form:
BEGIN, . . . cc UNTIL,
marks the end of a loop that will be executed iteratively
until condition specifier "cc" is satisfied.
WHILE,
Used in a CODE word in the form:
BEGIN, . . . cc WHILE, . . . REPEAT,
marks the termination test in a loop that will be executed
iteratively until condition specifier "cc" fails to be
satisfied.
WHILE, assembles to a conditional jump to the point marked
by REPEAT,; the condition used depends on "cc."
X)
Addressing mode specifier for "indexed indirect X" mode.
XSAVE
A one-byte area set aside for storing the X register. A
CODE word or low level procedure may use it for any
purpose. But note that any lower level routine may destroy
its contents; if your code calls a lower level routine
that is not part of your own program, assume that XSAVE
will be destroyed by the call, even if it currently
appears to be preserved.
HHC ASCII
value notes name name
0 NUL, Null
1 SOH, Start of heading
2 STX, Start of text
3 ETX, End of text
4 EOT, End of transmission
5 ENQ, Enquiry
6 ACK, Acknowledge
7 Rotate; Bell BEL, Bell
0 inverse-image @
1 inverse-image A
2 inverse-image B
3 inverse-image C
4 inverse-image D
5 inverse-image E
6 inverse-image F
7 Rotate inverse-image G "beep"
8 inverse-image H Backspace cursor; erase character
under cursor after backspace.
9 inverse-image I
10 inverse-image J
11 I/O inverse-image K
12 inverse-image L
13 Enter inverse-image M Erase LCD; move cursor to left edge.
14 Stop/Speedl inverse-image N
15 inverse-image 0
16 inverse-image P
17 inverse-image Q
18 inverse-image R
19 inverse-image S
20 Help inverse-image T
21 F11- inverse-image U
22 F21 inverse-image V
23 F31 inverse-image w
24 inverse-image X
25 inverse-image Y
26 inverse-image Z
27 inverse-image [ Begins an escape control sequence.
28 inverse-image
29 inverse-image 1
30 inverse-image
31 inverse-image
Displayable Characters
HHC keybd
value character name
20 space
21 exclamation mark
22 quotation mark
23 pound sign
24 $ dollar sign
25 % percent sign
26 & ampersand
27 i apostrophe
28 ( left parenthesis
29 ) right parenthesis
2A * asterisk, star, or "times" sign
2B + plus sign
2C , comma
2D - hyphen, dash, or minus sign
2E . period
2F / slash
30 0
31 1
32 2
33 3
34 4
35 5
36 6
37 7
38
39 9
3A • colon
33 • semicolon
44 D
45 E
46 F
47 G
48 H
49 I
4A J
4B K
4C L
4D M
4E N
4F 0
50 P
51 Q
52 R
53 S
54 T
55 U
56 V
57 w
58 X
59 Y
5A Z
5B [ left bracket
SC \ backslash
5D j right bracket
SE caret
SF underscore
.
60 grave
61 a
62 b
63 c
64 d
65 e
-
66 f
67 g
68 h
69 i
6A j
6B k
6C 1
6D m
6E n
OF o
70 p
71 g
72 r
73 s
74 t
75 u
76 v
77 w
78 x
79 y
7A z
7B t left brace
7C 1 vertical bar
70 } right brace
7E tilde
Additional Characters
7F "insert"
cursor
80 up arrow I T
81 left 4 4 Backspaces cursor; does not
arrow disturb character under cursor
after move.
82 right * Advances cursor; does not
arrow disturb character that was
under cursor before move.
83 down 17 t
arrow
34 "AM" INSERT a
m
symbol
85 "PM" DELETE o
rn
symbol
36 H super- LOCK M
script M
87 division
sign
88 "times" x
sign
89 block SEARCH 1
cursor
8B "a" with Cl a
umlaut
8C "o" with C2
umlaut
8D "u" with C3
umlaut
8E "n" with C4 n
tilde
8F H second
shift
'EMIT
Vectored I/O and, 4-13
(EMIT) , 4-13
(ROTMODE) , 4-11
:C definition, 2-19
?KEY, 3-14
?LOCK, 3-5
?ROOM, 2-26
B
Bank switching, 2-17, 10-70, 10-71
Programmable Memory Peripheral, 3-11
Tag table vector controls, 2-16
BASIC file type, 5-8
Battery
Conserving, 3-14
Beep, 4-16
BIND, 4-9
Blips, 4-15
Last 3 columns of LCD, 4-5
BREAK instruction, 2-8
C
C1/C2/C3/C4 keys, 3-4
Capsule
Memory map, 2-1
Character
Displayable character set, A-4
Numeric representation, 2-4
Character control buffer, 4-3
Character display buffer, 4-3
Character translation table, 3-6
LCD, 4-6
CLEAR, 10-25
&APS destroyed by, 10-3
Does not reset rotation mode, 4-11
Hard, 2-30, 2-31, 10-49
Soft, 2-30, 2-31, 10-72
CLEAR key, 2-30, 2-31, 3-3, 5-10, 6-7
Restarting an application, 2-30
CLEAR stack, 2-30
Clock, 6-33
Clock tick, 6-33
CODE
Definition, 9-4
Word, 9-4
Code structure of SNAP, 2-5
CODE word, 9-2
Complex number, 7-2
Condition specifier, 9-10
Constant, 2-20
Control byte
Peripheral, 6-10
Control characters
Peripheral, 6-16
Control key, 3-1
Cross-compiler, 1-10, 1-13
CSLOW, 2-17
CSPEED, 2-11, 2-17
Current file, 5-3
Cursor
Alternate character pattern, 4-9
Image definition, 10-61, 10-86
LCD, 4-1
LCD graphics and, 4-4
Cursor control keys, 3-2
D
Data capsule, 2-17
Decompiler, 10-87
Delete cursor, 3-10
DELETE key, 3-4, 3-11
Development system, 1-13
DMOVE
Use with EMIT, 4-5
Dots in LCD, 4-1
Double word
Representation of, 2-3
Down-loader, 1-13
DP-V, 2-11
DSPLY, 4-3
Dynamic allocation of RAM, 2-26
Floating point
Numeric representation, 2-3
Representation of, 7-1
Special case, 7-2
Forward reference, 2-19
Function key
Defining a, 3-18
Precedence over keyboard & pushkey buffers, 3-19
Typing from program, 3-19
Function vs. program, 8-5
Glossary
Format of, 1-17
GRAB, 2-26
Graphics
EXPECT and, 4-5
LCD, 4-3, 10-30
Ground state, 2-30
I
I/O
Drivers, 1 -6
intrinsic, 1-3
Peripheral drivers, 1-6
I/O bank, 1-5
I/O key, 3-3
Immediate keys, 3-2
Insert cursor, 3-10
INSERT key, 3-4, 3-11
Integer
Representation of, 2-3
Interrupt, 6-1, 6-6
Interrupts, 1-9
In 1-3
Applications, 1-6
RAM, 2-1, 2-24
Rom, 2-2
Virtual file abace, 5-11
Intrinsic I/O, 1-3
Inverse d? splay, 6-17
KBVECT, 3-6
KEY, 3-5
RIP and, 6-8
Keyboard, 3-1, 6-12, see also names of individual keys
Additional characters, A-7
Character translation table, 3-6
Displayable character set, A-4
Hardware of, 3-2
Hidden and immediate keys, 3-2
Input with EXPECT, 3-9
Keyboard buffer, 3-16
Logical unit number 0, 6-7
Raw keyboard code, 3-6, 3-8
RIP versus KEY, 6-8
Label, 9-12
Latch, 10-54
Latch byte, 2-32
LCD, 4-1
Additional characters, A-7
As a peripheral, 6-18
Blips, 4-15
Character control buffer, 4-3
Character display buffer, 4-3
Character translation table, 4-6
Cursor, 4-1, 4-9
Display buffer, 4-3
Displayable character set, A-4
Displaying accent marks, 4-8
Graphics, 4-3
Logical unit number 1, 6-7
ROP versus EMIT, 6-8
Slaving peripherals to, 4-13
STOP/SPEED control, 4-12
Used as data buffer, 3-16
LCD buffer, 10-30
LCD graphics, 10-30
L7TGO, 2-24
Liquid crystal display, see LCD
LOCK key, 3-3
LOCK-KEY, 3-3, 6-9
Logical unit number, 6-5, 6-7, 6-13
LONG, 2-13, 2-19
Long tag, 2-6
How executed, 2-8
LONG,TAGS, 2-18
Loop stack
Size of, 2-1
NAP, 3-14
No-text file, 5-8
Non-text file, 5-6
Format of, 5-13
Nucleus, 1-6
SDT
Addresses in, 6-12
SEARCH key, 3-4
SECOND SHIFT key, 3-1, 3-4
Serial Interface Adaptor, 6-25
Name of initialization file, 6-27
Servicing an interrupt, 6-1
SETORG, 2-10
SHIFT bit, 3-5
ltior SHIFT key, 3-1, 3-3, 3-5, 3-6
T
Tag, 1-11
SNAP code structure , 7-5
Tag table, 2-5, 8-7
41, 2-7
2 through f8, 2-7
Initializing, 2-1U
Master capsule, 2-16
Overflow of, 2-18
Short extrinsic, 2-7
Slave capsule, 2-16
Structure of, 2-7
vector, 2-3, 10-78
TAG.TABLE, 2-11
Target system, 1-10
Temporary file, 10-48
TEMPORARY file type, 5-2, 5-8
Temporary stack, 5-11, see Temporary storage area
Used by Micro Printer, 6-19
Temporary storage area, 2-22
Test cabsule, 1-13
Text file, 10-48
TEXT file tote, 5-2, 5-8
WAIT, 6-2
Wait bit, 6-2, 6-4
WAITM, 6-11
Word
Representation of, 2-3
Word break character, 6-17
XCN/XOFF crotocol
1odem, 0-22, 6-24
Zero divide
Floating point, 7-2