Appendix B

ANSI Compliance


4.1 System documentation
4.1.1 Implementation-defined options

The implementation-defined items in the following list represent characteristics and choices left to the discretion of the implementor, provided that the requirements of this Standard are met. A system shall document the values for, or behaviors of, each item.

aligned address requirements (3.1.3.3 Addresses);

MuP21 is a word addressing machine, therefore ALIGN, ALIGNED, are IMMEDIATE NOPs. There are no aligned address requirements on a word addressing machine.

behavior of 6.1.1320 EMIT for non-graphic characters;

P21Forth provides a vectored EMIT. The P21Forth serial output routine processes non-graphic characters in the same way as all others. The P21Forth video output handles four characters in unique ways. BS moves the cursor back one character position with wrap up to the upper left corner of the video screen. LF moves the cursor down one line, and scrolls the screen if the cursor is on the bottom line. FF clears the screen and moves the cursor to the upper left position. CR moves the cursor to the left most position on the current line.

character editing of 6.1.0695 ACCEPT and 6.2.1390 EXPECT;

P21Forth processes BS to remove the last received character, and terminates on the CR character. All other control characters are translated into a space.

character set (3.1.2 Character types, 6.1.1320 EMIT, 6.1.1750 KEY);

P21Forth provides a vectored EMIT and KEY. P21Forth serial I/O routines process 8 bit characters. MuP21 parallel keyboard and video output routines support 7 bit characters. MuP21 represents characters as one cell, and therefore supports I/O of 20 bit characters. Serial and video output routines use only the lower 7 or 8 bits of a cell for output.

character-aligned address requirements (3.1.3.3 Addresses);

MuP21 is a word addressing machine, therefore ALIGN, ALIGNED, are IMMEDIATE NOPs. There are no aligned address requirements on a word addressing machine.

character-set-extensions matching characteristics (3.4.2 Finding definition names);

P21Forth is case sensitive in character matching. In P21Forth the full 20 bits of a character in a cell must match.

conditions under which control characters match a space delimiter (3.4.1.1 Delimiters);

On input P21Forth processes BS to remove the last received character, and terminates on the CR character. All other control characters are translated into a space durring input. In P21Forth control characters are not treated as a space delimiter.

format of the control-flow stack (3.2.3.2 Control-flow stack);

P21Forth uses the return stack for control-flow parameters at compile time.

conversion of digits larger than thirty-five (3.2.1.2 Digit conversion);

Digits above thirty-five are supported. The P21Forth serial and video output routines only support 7 or 8 bits so characters above 127 or 255 will wrap around and be displayed improperly.

display after input terminates in 6.1.0695 ACCEPT and 6.2.1390 EXPECT;

In P21Forth each character is displayed as it is input to ACCEPT or EXPECT.

exception abort sequence (as in 6.1.0680 ABORT");

In P21Forth ABORT" compiles the abort primitive and a string. The abort" primitive uses -2 THROW to perform the abort.

input line terminator (3.2.4.1 User input device);

P21Forth uses CR to terminate an input line.

maximum size of a counted string, in characters (3.1.3.4 Counted strings, 6.1.2450 WORD);

P21Forth uses a cell to hold the count of a counted string. This makes the maximum size of a counted string FFFFF in hex.

maximum size of a parsed string (3.4.1 Parsing);

P21Forth uses a cell to hold the count of a counted string. This makes the maximum size of a counted string FFFFF in hex.

maximum size of a definition name, in characters (3.3.1.2 Definition names);

P21Forth uses a cell to hold the count of a counted string, or a name in the name dictionary. IMMEDIATE and COMPILE-ONLY flag bits are stored in a separte locatation which makes the full 20 bits available for string count. This makes the maximum size of a definition name FFFFF in hex.

maximum string length for 6.1.1345 ENVIRONMENT?, in characters;

P21Forth stores strings for ENVIRONMENT? in the name dictionary. The maximum size of a definition name FFFFF in hex.

method of selecting 3.2.4.1 User input device;

P21Forth uses vectored input. The variable `?KEY holds the execution vector for ?KEY. ' ?RX '?KEY ! will set the user input device to the parallel without a multitasking pause. ' P?RX '?KEY ! will set the user input device to the parallel keyboard with a multitasking pause. ' ?RS '?KEY ! will set the user input device to the serial keyboard. ' both '?RX ! will enable both serial and parallel keyboards at the same time. PARALLEL is an alternate way to set the input vector to the parallel keyboard. SERIAL is an alternate way to set the input vector to the serial keyboard, and BOTH is an alternate way to enable both keyboards.

method of selecting 3.2.4.2 User output device;

P21Forth uses vectored output. The variable 'EMIT holds the execution vector for EMIT. ' TX!EMIT ! will set the user output device to the MuP21 video output. ' TS! 'EMIT ! will set the user output device to the serial port.

methods of dictionary compilation (3.3 The Forth dictionary);

P21Forth uses separate spaces for names and code. P21Forth uses HEAD, to compile headers into the name dictionary. :NONAME compiles the code to begin a headerless colon definition. : uses HEAD, and :NONAME to create a colon defintion. CREATE, CONSTANT, VARIABLE, and USER create headers in the name dictionary, and code in the code dictionary.

number of bits in one address unit (3.1.3.3 Addresses);

MuP21 is a word addressing machine, and MuP21 words are 20 bits.

number representation and arithmetic (3.2.1.1 Internal number representation);

P21Forth uses 20 bit numbers with two's compelent arithmetic.

ranges for n, +n, u, d, +d, ud (3.1.3 Single-cell types, 3.1.4 Cell-pair types);

   decimal                       hex
n  -524288 to 524287             80000h  to  7FFFFh
+n 0 to 524287                   0h to 7FFFFh
u  0 to 1048575                  0h to FFFFFh
d  -549755813888 to 549755813887 8000000000h to 7FFFFFFFFFh
+d 0 to 549755813887             0h to 7FFFFFFFFFh
ud 0 to 1099511627775            0h to FFFFFFFFFFh
read-only data-space regions (3.3.3 Data space);

P21Forth provides access to the 8 bit wide ROM/SRAM/PCMCIA memory space with the words CARD@, CARD!, MOVE>C, and MOVEC>. This memory space can only hold 8 bit numbers, and may or may not be read only.

size of buffer at 6.1.2450 WORD (3.3.3.6 Other transient regions);

WORD moves the parsed word from the input stream to HERE. This provides 80 words between HERE and PAD as a transient area.

size of one cell in address units (3.1.3 Single-cell types);

MuP21 is a word addressing machine, and MuP21 words are 20 bits.

size of one character in address units (3.1.2 Character types);

MuP21 is a word addressing machine, and MuP21 words are 20 bits. Characters use one word each, or one address unit per character.

size of the keyboard terminal input buffer (3.3.3.5 Input buffers);

P21Forth provides a 256 word terminal input buffer at address 3F00h.

size of the pictured numeric output string buffer (3.3.3.6 Other transient regions);

P21Forth provides an 80 word region to buffer build pictured numeric output strings.

size of the scratch area whose address is returned by 6.2.2000 PAD (3.3.3.6 Other transient regions);

In P21Forth PAD returns the address 80 words above HERE.

system case-sensitivity characteristics (3.4.2 Finding definition names);

P21Forth is case sensitive for definition names. All 20 bits of a character in a name must match to find a defined name.

system prompt (3.4 The Forth text interpreter, 6.1.2050 QUIT);

P21Forth uses the traditional `ok' prompt.

type of division rounding (3.2.2.1 Integer division, 6.1.0100 */,6.1.0110 */MOD, 6.1.0230/,6.1.0240 /MOD, 6.1.1890 MOD);

P21Forth uses UM/MOD in division. SM/REM is also provided and may be substituted for UM/MOD if symetric vs floored division is prefered.

values of 6.1.2250 STATE when true;

P21Forth has two true values for STATE. STATE is set to -1 when compiling. STATE is set to 1 as an alternate interpreter for [IF], [ELSE], [THEN].

values returned after arithmetic overflow (3.2.2.2 Other integer operations);

The least significant 20 bits are returned from single precision operations, and the least significant 40 bits are returned from double precision operations. Overflow will not change the bits that are returned.

whether the current definition can be found after 6.1.1250 DOES> (6.1.0450 :).

In P21Forth the current definition cannot be found after a DOES> is used. DOES> is not an immediate word in P21Forth, and is compiled into definitions like all other NON-IMMEDIATE words. In P21Forth DOES> is COMPILE-ONLY. A defined name cannot be found until the end of the definition, or the word REVEAL has been executed.

4.1.2 Ambiguous conditions

A system shall document the system action taken upon each of the general or specific ambiguous conditions identified in this Standard. See 3.4.4 Possible actions on an ambiguous condition. The following specific ambiguous conditions, indicated by an asterisk, are noted in the glossary entries ofthe relevant words. The following general ambiguous conditions could occur because of a combination of factors:

a name is neither a valid definition name nor a valid number during text interpretation (3.4 The Forth text interpreter);

P21Forth will echo the input stream up to the invalid word, and print the error message ?(-13).

a definition name exceeded the maximum length allowed (3.3.1.2 Definition names);

P21Forth permits definition names as large as the entire DRAM addressing space in MuP21. Therefore it is not possible for definition names to exceed this length.

addressing a region not listed in 3.3.3 Data Space;

MuP21 does not separate code and data spaces. P21Forth uses 20 bit numbers, and the entire 20 bit DRAM addressing space may contain data or code. It is not possible in P21Forth to create an address outside of data space.

argument type incompatible with specified input parameter, e.g.,passing a flag to a word expecting an n (3.1 Data types);

P21Forth uses -1 for TRUE and 0 for FALSE. Logic flags would appear as 0 or a 20 bit -1 to a word expecting a number.

attempting to obtain the execution token, (e.g., with 6.1.0070 ',6.1.1550 FIND, etc.) of a definition with undefined interpretation semantics;

P21Forth may ' or FIND any word in the dictionary. The execution token will be returned even for COMPILE-ONLY words.

dividing by zero (6.1.0100 */, 6.1.0110 */MOD, 6.1.0230 /, 6.1.0240 /MOD, 6.1.1561 FM/MOD 6.1.1890 MOD, 6.1.2214 SM/REM, 6.1.2370 UM/MOD, 8.6.1.1820 M*/);

  Divide by zero in P21Forth is valid operation.
    1 2 0 */       returns -1
    1 2 0 */MOD    returns -1
    1 0 /          returns -1
    1 0 /MOD       returns 1 -1
    1 0 0 FM/MOD   returns 1 -1
    1 0 MOD        returns 1
    1 0 0 SM/REM   returns 1 -1
    1 0 0 UM/MOD   returns 1 -1
    1 0 1 0 M*/    returns -1 -1
insufficient data-stack space or return-stack space (stack overflow);

In P21Forth data-stack overflow will overwrite the USER variables, and then the return-stack locations. In P21Forth data-stack overflow will overwrite code. Stack overflow will not be trapped and can crash the system.

insufficient space for loop-control parameters;

Insufficient space on the return stack will overwrite code and could crash the system.

insufficient space in the dictionary;

In P21Forth the code dictionary builds up from 2000h towards the region containing the video buffer at AAAAAh. If the video memory is overwritten with CPU code the system could crash. The name dictionary builds down from FFFFF towards the BLOCK BUFFERS and video memory. If the name dictionary extends down below C07FFh it will overwrite the BLOCK BUFFERS and then the video memory, and could crash the system.

interpretating a word with undefined interpretation semantics;

If a word is declared COMPILE-ONLY then the interpreter will not interpret it and will return the error message "compile?". If a word is not declared COMPILE-ONLY and has undefined interpretation semantics in P21Forth and is interpreted it will most likely crash the system.

modifying the contents of the input buffer or a string literal (3.3.3.4 Text-literal regions, 3.3.3.5 Input buffers);

There is nothing illegal in these operations in P21Forth.

overflow of a pictured numeric output string;

There is sufficient room in P21Forth to build a pictured numeric output string for a double number in binary. If a format is used that exceeds the room available code could be overwritten and the system could crash.

parsed string overflow;

P21Forth permits strings to be as large as memory permits. Overflow cannot occur when a string is parsed, but an error may occur if a parsed string is too large to fit into the name dictionary.

producing a result out of range, e.g., multiplication (using *) results in a value too big to be represented by a single-cell integer (6.1.0090 *,6.1.0100 */, 6.1.0110 */MOD, 6.1.0570 >NUMBER,6.1.1561 FM/MOD, 6.1.2214 SM/REM, 6.1.2370 UM/MOD, 6.2.0970 CONVERT, 8.6.1.1820 M*/);

The least significant 20 bits are returned from single precision operations, and the least significant 40 bits are returned from double precision operations. Overflow will not change the bits that are returned.

reading from an empty data stack or return stack (stack underflow);

In P21Forth reading from the data stack when it is empty will result in the contents of the cell below the data stack being returned, and in the error message "depth?" being displayed. Reading from an empty return stack could cause the system to crash.

unexpected end of input buffer, resulting in an attempt to use a zero-length string as a name;

P21Forth will return the error message "?(-10)" if no name string is provided to words that require a name from the input stream.

>IN greater than size of input buffer (3.4.1 Parsing);

P21Forth will parse past the end of the input buffer is >IN is greater than the size provided in the buffer.

6.1.2120 RECURSE appears after 6.1.1250 DOES>;

In P21Forth DOES> in a NON-IMMEDIATE word, so RECURSE could be used after DOES> in a defintion. In this case RECURSE would compile a reference to the word containing the DOES>.

argument input source different than current input source for 6.2.2148 RESTORE-INPUT;

RESTORE-INPUT will return the error message "error cannot restore" if the number of arguments given to RESTORE-INPUT does not match the number expected. The source of the input may change between SAVE-INPUT and RESTORE-INPUT and should be restored properly when the first argument containing the number of arguments to restore is correct.

data space containing definitions is de-allocated (3.3.3.2 Contiguous regions);

In P21Forth the data space containing definitions is contiguous and is neither allocated or de-allocated.

data space read/write with incorrect alignment (3.3.3.1 Address alignment);

No alignment is need on a word addressing machines. Incorrect alignment of addresses cannot occur in P21Forth.

data-space pointer not properly aligned (6.1.0150 ,, 6.1.0860 C,);

No alignment is need on a word addressing machines. Incorrect alignment of addresses cannot occur in P21Forth.

less than u+2 stack items (6.2.2030 PICK, 6.2.2150 ROLL);*

These operations will treat will treat the area below the stack pointer as part of the stack. A PICK from this area will not cause any problems, but a ROLL into the memory below that data stack could crash the system.

loop-control parameters not available (6.1.0140 +LOOP, 6.1.1680 I, 6.1.1730 J, 6.1.1760 LEAVE, 6.1.1800 LOOP, 6.1.2380 UNLOOP);

P21Forth places loop-control parameters on the return stack, and if the proper arguments are not there these operations could cause a system crash.

most recent definition does not have a name (6.1.1710 IMMEDIATE);

IMMEDIATE will make the compiled word with a name into an IMMEDIATE word. If the most recent definition does not have a name then IMMEDIATE will operate on the most recent definition that does have a name.

name not defined by 6.2.2405 VALUE used by 6.2.2295 TO;

Using TO on a word that is not a VALUE could cause a system crash. TO can be used on CONSTANTS.

name not found(6.1.0070 ', 6.1.2033 POSTPONE, 6.1.2510 ['], 6.2.2530 [COMPILE]);

If a name is not found an error is generated and the input stream up to the word that was not found is displayed followe by the error message "?(-D)".

parameters are not of the same type (6.1.1240 DO, 6.2.0620 ?DO, 6.2.2440 WITHIN);

MuP21 is a word addressing machine. Flags, characters, and single cell numbers all occupy one cell.

6.1.2033 POSTPONE or 6.2.2530 [COMPILE] applied to 6.2.2295 TO;

POSTPONE and [COMPILE] should not be applied to TO because TO will take an argument from the input stream. TO is immediate and expects the next word in the input stream to be an argument.

string longer than a counted string returned by 6.1.2450 WORD;

In P21Forth counted strings may be as large as the full memory space. Since WORD moves a string to HERE there will be a limit to the size of a string that can be moved to HERE without causing something to be overwritten.

u greater than or equal to the number of bits in a cell ( 6.1.1805 LSHIFT, 6.1.2162 RSHIFT);

The least significant 20 bits are returned from single precision operations. Overflow will not change the bits that are returned.

word not defined via 6.1.1000 CREATE (6.1.0550 >BODY, 6.1.1250 DOES>);

In P21Forth >BODY returns the address 5 cells above the start of the code of a word, this may not be valid if the word was not created by CREATE, CONSTANT, VARIABLE, or VALUE. DOES> will modifiy the code created by CREATE. The results of performing this modification to a word that was not created by CREATE, CONSTANT or VARIABLE is unpredictable, and could cause a system crash.

words improperly used outside 6.1.0490 <# and 6.1.0040 #> (6.1.0030 #, 6.1.0050 #S,6.1.1670 HOLD, 6.1.2210 SIGN).

P21Forth room for the way these words are used within the system. Proper use of these words in an application must consider the size of the area used to construct pictured numeric output strings.

4.1.3 Other system documentation. A system shall provide the following information:

list of non-standard words using 6.2.2000 PAD (3.3.3.6 Other transient regions);

P21Forth has no non-standard words using this region.

operator's terminal facilities available;

Three words from the FACILITY wordset are implemented in P21Forth. AT-XY, PAGE, and MS are available. AT-XY works only with video output, and care should be taken to not give AT-XY invalid arguments as it will accept values that would correspond to locations that are off the screen. If characters are written to some off screen locations the video output could be corrupted. The word PAGE simply emits a FormFeed character to the screen or to the serial output device.

program data space available, in address units;

The word UNUSED returns the total of the space in cells from the top of the code dictionary (growing upward in memory) to the bottom of the video memory, and the space from the top of the BLOCK BUFFERS to the bottom of the name dictionary (growing downward in memory). UNUSED reports 942,591 words of unused memory. There is no distiction between code, name, and data space in P21Forth.

return stack space available, in cells;

P21Forth boots up with 64 cells in the return stack. Stack space allocated for background tasks is specified in the word HAT and may be as large as available memory permits.

stack space available, in cells;

P21Forth boots up with 58 cells in the data stack. Stack space allocated for background tasks is specified in the word HAT and may be as large as available memory permits.

system dictionary space required, in address units.

P21Forth code and name dictionaries require a total of about 10K words of memory. With about 1% of the memory used by P21Forth, and 6% of the memory used for a video buffer, 93% is available as code/data/name space.

7.4 Additional documentation requirements

7.4.1 System documentation

7.4.1.1 Implementation-defined options

the format used for display by 7.6.2.1770 LIST (if implemented);

The format normally used by LIST is 44 columns by 24 rows. This requires that the video window be set to 48 columns by 24 rows.

the length of a line affected by 7.6.2.2535 \ (if implemented).

The length of the line in blocks is assumed to be 48 cells.

7.4.1.2 Ambiguous conditions

Correct block read was not possible;

Block reads are always possible on the 8 bit UVPROM/RAM/PCMCIA interface even when no media is present. Block addressing on the media will wrap so that if a block beyond the addressable range of the media is addressed then the block in the media that matches the decoded lower order address bits on the media. Blocks 1 through n are available on media with n kbytes. Attempted access of blocks above n will result in access of block n MOD. Media of up to 1 Mbyte is supported directly in MuP21 hardware.

I/O exception in block transfer;

P21Forth will perform a read even if there is no media in the 8 bit wide ROM/RAM/PCMCIA memory space. P21Forth will attempt to perform a write to the media even if there is no media in the 8 bit wide ROM/RAM/PCMCIA memory space.

Invalid block number (7.6.1.0800 BLOCK, 7.6.1.0820 BUFFER, 7.6.1.1790 LOAD);

P21Forth will accept any number as a valid block number. If the secondary storage media has n blocks, and an attempt is made to access a block greater than n, then block n MOD will be accessed.

A program directly alters the contents of 7.6.1.0790 BLK;

In P21Forth if a program modifies the contents of BLK the system may no longer be able to distinguish the correct source of input.

No current block buffer for 7.6.1.2400 UPDATE.

UPDATE will not update anything if there is no current block buffer.

7.4.1.3 Other system documentation

any restrictions a multiprogramming system places on the use of buffer addresses;

In P21Forth background tasks should not use BLOCK or BUFFER or assume that the regions of memory returned from these words will remain constant or may be modified without problems. BLOCK and BUFFER should not be used in background tasks in P21Forth.

the number of blocks available for source text and data.

1024 blocks are available on a 1 Megabyte sized media (UVPROM/RAM/PCMCIA). If P21Forth is placed to boot on a 64 kilobyte UVPROM the 16 kiloword P21Forth boot image will use 48 blocks, and 16 blocks will be available for source text and data.

16.4.1 System documentation

16.4.1.1 Implementation-defined options

maximum number of word lists in the search order (16.3.3 Finding definition names,16.6.1.2197 SET-ORDER);

P21Forth provides a default of a maximum number of word lists in the search order of 8 word lists.

minimum search order (16.6.1.2197 SET-ORDER, 16.6.2.1965 ONLY).

The minimum search order in P21Forth is one wordlist, FORTH. The minimum search order is selected by ONLY or -1 SET-ORDER.

16.4.1.2 Ambiguous conditions

* changing the compilation word list (16.3.3 Finding definition names);

If a program changes the compilation word list during the compilation of a definition or before modification of the behavior of the most recently compiled definition with ;CODE, DOES>, or IMMEDIATE then these words may not function properly.

* search order empty (16.6.2.2037 PREVIOUS);

If there is only one FORTH and PREVIOUS is executed the system will respond ?(-D) and will no longer be able to find any words

* too many word lists in search order (16.6.2.0715 ALSO).

If there are 8 wordlists in the search order and ALSO is executed P21Forth will respond with an echo of the input stream up to the ALSO and with the error message "?(-31)".


End of Appendix B

Return to Table of Contents

Appendix A

Appendix C