diff --git a/.Docs/Forth Words.md b/.Docs/Forth Words.md index eae2a1eb..14b0506c 100644 --- a/.Docs/Forth Words.md +++ b/.Docs/Forth Words.md @@ -51,17 +51,17 @@ The definitions are listed in ASCII alphabetical order in several groups con #### Nucleus Words - ! * */ */MOD + +! +loop - / /MOD 0< 0= 0> 1+ 1- 2+ 2- < = > >R ?DUP @ ABS AND begin C! C@ colon CMOVE constant create D+ D< DEPTH DNEGATE do does> DROP DUP else EXECUTE EXIT FILL I if J LEAVE literal loop MAX MIN MOD MOVE NEGATE NOT OR OVER PICK R> R@ repeat ROLL ROT semicolon SWAP then U* U/ until variable while XOR +! * */ */MOD + +! +loop - / /MOD 0< 0= 0> 1+ 1- 2+ 2- < = > >R ?DUP @ ABS AND begin C! C@ colon CMOVE constant create D+ D< DEPTH DNEGATE do does> DROP DUP else EXECUTE EXIT FILL I if J LEAVE literal loop MAX MIN MOD MOVE NEGATE NOT OR OVER PICK R> R@ repeat ROLL ROT semicolon SWAP then U* U/ until variable while XOR (note that lower case entries refer to just the run-time code corresponding to a compiling word.) #### Interpreter Words - # #> #S ' ( -TRAILING . 79-STANDARD <# >IN ? ABORT BASE BLK CONTEXT CONVERT COUNT CR CURRENT DECIMAL EMIT EXPECT FIND FORTH HERE HOLD KEY PAD QUERY QUIT SIGN SPACE SPACES TYPE U. WORD +# #> #S ' ( -TRAILING . 79-STANDARD <# >IN ? ABORT BASE BLK CONTEXT CONVERT COUNT CR CURRENT DECIMAL EMIT EXPECT FIND FORTH HERE HOLD KEY PAD QUERY QUIT SIGN SPACE SPACES TYPE U. WORD #### Compiler Words - +LOOP , ." : ; ALLOT BEGIN COMPILE CONSTANT CREATE DEFINITIONS DO DOES> ELSE FORGET IF IMMEDIATE LITERAL LOOP REPEAT STATE THEN UNTIL VARIABLE VOCABULARY WHILE [ [COMPILE] ] ++LOOP , ." : ; ALLOT BEGIN COMPILE CONSTANT CREATE DEFINITIONS DO DOES> ELSE FORGET IF IMMEDIATE LITERAL LOOP REPEAT STATE THEN UNTIL VARIABLE VOCABULARY WHILE [ [COMPILE] ] #### Device Words @@ -71,50 +71,50 @@ BLOCK BUFFER EMPTY-BUFFERS LIST LOAD SAVE-BUFFERS SCR UPDATE | Word | Syntax | I/C | Status | Description | Comment | |-|-|-|-|-|-| -| ! | n addr -- | | Working | Store second word at address on top | | +| ! | n addr -- | I,C | Working | Store second word at address on top | | | # | ud1 -- ud2 | | | Convert one digit of double number and add character to output string | | | #> | d -- addr n | | | Terminate output string for TYPE | | | #S | ud -- 0 0 | | | Convert all significant digits of double number to output string | | | ' | -- addr | I | | Find address of next string in dictionary | | | | -- | I | | Begin comment, terminated by | | -| * | n1 n2 -- n3 | | Working | Arithmetic product of n1 times n2 | | +| * | n1 n2 -- n3 | I,C | Working | Arithmetic product of n1 times n2 | | | */ | n1 n2 n3 -- n4 | || Multiply n1 by n2, divide result by n3 and leave quotient in n4 | | | */MOD | n1 n2 n3 -- n4 n5 | | | Multiply n1 by n2, divide result by n3 and leave remainder in n4 and quotient in n5 | | -| + | n1 n2 -- n3 | | Working | Arithmetic result of n1 plus n2 | | +| + | n1 n2 -- n3 | I,C | Working | Arithmetic result of n1 plus n2 | | | +! | n addr -- | | Working | Add second 16-bit number to contents of address | | -| +LOOP | n -- | I,C | Working | Increment index by n. Terminate loop if outside limit | | +| +LOOP | n -- | C | Working | Increment index by n. Terminate loop if outside limit | | | , | n -- | | | Allot two bytes in dictionary, storing n there | | -| - | n1 n2 -- n3 | | Working | Subtract n2 from n1 leaveing result in n3 | | +| - | n1 n2 -- n3 | I,C | Working | Subtract n2 from n1 leaveing result in n3 | | | -TRAILING | addr n1 -- addr n2 | | | Adjust char count n1 of a text string at addr to exclude trailing blank, resulting in string at addr new length on n2| | -| . | n -- | | Working | Print number | | -| ." | -- | I | Working | Print message terminated by " | | -| / | n1 n2 -- n3 | | Working | Divide n1 divide by n2, leave quotient in n3| | -| /MOD | n1 n2 -- n3 n4 | | Working | Divide n1 divide by n2, leave remainder in n3 and quotient in n4 | | -| 0< | n -- flag | | Working | True if n less than zero | | -| 0= | n -- flag | | Working | True if n zero | | -| 0> | n -- flag | | Working | True if n greater than zero | | +| . | n -- | I,C | Working | Print number | | +| ." | -- | I,C | Working | Print message terminated by " | | +| / | n1 n2 -- n3 | I,C | Working | Divide n1 divide by n2, leave quotient in n3| | +| /MOD | n1 n2 -- n3 n4 | I,C | Working | Divide n1 divide by n2, leave remainder in n3 and quotient in n4 | | +| 0< | n -- flag | I,C | Working | True if n less than zero | | +| 0= | n -- flag | I,C | Working | True if n zero | | +| 0> | n -- flag | I,C | Working | True if n greater than zero | | | 1+| n -- n+1 | | | Increment n by one | | | 1- | n -- n-1 | | | Decrement n by one | | | 2+ | n -- n+2 | | | Increment n by two | | | 2- | n -- n-2 | | | Decrement n by two| | | 79-STANDARD | | | | Returns Error if FORTH-79 Standard is not available| | -| : | -- | | Working | Begin a colon definition | | -| ; | -- | I,C | Working | End of a colon definition | | -| < | n1 n2 -- flag | | Working | True if n1 less than n2 | | +| : | -- | I | Working | Begin a colon definition | | +| ; | -- | C | Working | End of a colon definition | | +| < | n1 n2 -- flag | I,C | Working | True if n1 less than n2 | | | <# | -- | | | Initialize pictured number output | | -| = | n1 n2 -- flag | | Working | True if n1 equal to n2 | | -| > | n1 n2 -- flag | | Working | True if n1 greater than n2 | | +| = | n1 n2 -- flag | I,C | Working | True if n1 equal to n2 | | +| > | n1 n2 -- flag | I,C | Working | True if n1 greater than n2 | | | >IN | -- addr | U | | Leave addr of variable of char offset input stream {0,,1023}| | | >R | n -- | C | | Move n to return stack | | -| ? | addr -- | | Working | Print contents of address | | +| ? | addr -- | I,C | Working | Print contents of address | | | ?DUP | n -- n ( n) | | duplicate n if non-zero | | -| @ | addr -- n | | Working | Put on stack number at addr | | +| @ | addr -- n | I,C | Working | Put on stack number at addr | | | ABORT | | | Clear data and return stacks | | -| ABS | n1 -- n1 | | Working | Absolute value of n1 | | -| ALLOT | n -- | | Working | Add n bytes to parameter field of most recently defined word | | -| AND | n1 n2 -- n3 | | Working | Leave Logical bitwise AND of n1 and n2 | | +| ABS | n1 -- n1 | I,C | Working | Absolute value of n1 | | +| ALLOT | n -- | I,C | Working | Add n bytes to parameter field of most recently defined word | | +| AND | n1 n2 -- n3 | I,C | Working | Leave Logical bitwise AND of n1 and n2 | | | BASE | -- addr | U | | Leave address of variable containing current input-output number conversion base. {{2..70} | | -| BEGIN | -- | I,C | Working | Used in a colon-definition in the form:
BEGIN ... flag UNTIL or
BEGIN ... flag WHILE ... REPEAT
BEGIN marks the start of a word sequence for repetitive execution. A BEGIN-UNTIL loop will be repeated until flag is true. A BEGIN-WHILE-REPEAT loop will be repeated until flag is false. The words after UNTIL or REPEAT will be executed when either loop is finished. flag is always dropped after being tested. | | +| BEGIN | -- | C | Working | Used in a colon-definition in the form:
BEGIN ... flag UNTIL or
BEGIN ... flag WHILE ... REPEAT
BEGIN marks the start of a word sequence for repetitive execution. A BEGIN-UNTIL loop will be repeated until flag is true. A BEGIN-WHILE-REPEAT loop will be repeated until flag is false. The words after UNTIL or REPEAT will be executed when either loop is finished. flag is always dropped after being tested. | | | BLK | -- addr | U | | Leave the address of a variable containing the number of the mass storage block being interpreted as the input stream. If the content is zero, the input stream is taken from the terminal.| | | BLOCK | n -- addr | | | Return address of first byte of memory for block n. If block n is not in memory, retrieve it first | | | BUFFER | n -- addr | | | Obtain next block buffer, assign to n | | @@ -122,37 +122,37 @@ BLOCK BUFFER EMPTY-BUFFERS LIST LOAD SAVE-BUFFERS SCR UPDATE | C@ | addr -- byte | | Working | Leave on stack addr, with high bits set to 0 for 16-bit field | | | CMOVE | addr1 addr2 n -- | | | Move n bytes at addr1 to addr2 | | | COMPILE | | C | | When a word containing COMPILE executes, the 16-bit value following the compilation address of COMPILE is copied (compiled) into the dictionary. i.e., COMPILE DUP will copy the compilation address of DUP.
COMPILE [ 0 , ] will copy zero. | | -| CONSTANT | n -- | | Working | A defining word used in the form:
n CONSTANT **name**
to create a dictionary entry for **name**, leaving n in its parameter field. When **name** is later executed, n will be left on the stack. | | +| CONSTANT | n -- | I,C | Working | A defining word used in the form:
n CONSTANT **name**
to create a dictionary entry for **name**, leaving n in its parameter field. When **name** is later executed, n will be left on the stack. | | | CONTEXT | -- addr | U | | Leave the address of a variable specifying the vocabulary in which dictionary searches are to be made, during interpretation of the input stream. | | | CONVERT | d1 addr1 -- d2 addr2 | | | Convert to the equivalent stack number the text beginning at addr1+1 with regard to BASE. The new value is accumulated into double number d1, being left as d2. addr2 is the address of the first non-convertible character. | | | COUNT | addr -- addr+1 n | | | Leave the address addr+1 and the character count of text beginning at addr. The first byte at addr must contain the character count n. Range of n is {0..255}. | | -| CR | -- | | Working | Do a carriage-return | | +| CR | -- | I,C | Working | Do a carriage-return | | | CREATE | | | | A defining word used in the form:
CREATE **name**
to create a dictionary entry for , without allocating any parameter field memory. When **name** is subsequently executed, the address of the first byte of **name**'s parameter field is left on the stack. | | | CURRENT | -- addr | U | | Leave the address of a variable specifying the vocabulary into which new word definitions are to be entered. | | -| D+ | d1 d2 -- d3 | | Working | Leave arithmetic sum of d1 plus d2 | | +| D+ | d1 d2 -- d3 | I,C | Working | Leave arithmetic sum of d1 plus d2 | | | D< | d1 d2 -- flag | | | True is d1 less than d2 | | | DECIMAL | -- | | | Set input-output numeric conversation base to ten | | | DEFINITIONS | -- | | | Set current vocabulary to context vocabulary | | | DEPTH | -- n | | | Leave number of the quantity of 16-bit values contained in the data stack, before n added | | | DNEGATE | d -- -d | | | Leave the two's complement of a double number. | | -| DO | n1 n2 -- | I,C | Working | Used in a colon-definition:
DO ... LOOP or
DO ... +LOOP
Begin a loop which will terminate based on control parameters. The loop index begins at n2, and terminates based on the limit n1. At LOOP or +LOOP, the index is modified by a positive or negative value. The range of a DO-LOOP is determined by the terminating word. DO-LOOP may be nested. Capacity for three levels of nesting is specified as a minimum for standard systems. | | -| DOES | | I,C| | Define the run-time action of a word created by a high-level defining word. Used in the form:
: **name** ... CREATE ... DOES> ... ;
and then **namex name**
Marks the termination of the defining part of the defining word **name** and begins the defining of the run-time action for words that will later be defined by **name**. On execution of **namex** the sequence of words between DOES> and ; are executed, with the address of **namex**'s parameter field on the stack. | | -| DROP | n -- | | Working | Drop top number from the stack | | -| DUP | n -- n n | | Working | Duplicate top of stack | | -| ELSE | -- | I,C | Working | Used in a colon-definition in the form:
IF ... ELSE ... THEN
ELSE executes after the true part following IF. ELSE forces execution to skip till just after THEN. It has no effect on the stack. (see IF) | | -| EMIT | char -- | | Working | Transmit character to current output device | | +| DO | n1 n2 -- | C | Working | Used in a colon-definition:
DO ... LOOP or
DO ... +LOOP
Begin a loop which will terminate based on control parameters. The loop index begins at n2, and terminates based on the limit n1. At LOOP or +LOOP, the index is modified by a positive or negative value. The range of a DO-LOOP is determined by the terminating word. DO-LOOP may be nested. Capacity for three levels of nesting is specified as a minimum for standard systems. | | +| DOES | | I,C | | Define the run-time action of a word created by a high-level defining word. Used in the form:
: **name** ... CREATE ... DOES> ... ;
and then **namex name**
Marks the termination of the defining part of the defining word **name** and begins the defining of the run-time action for words that will later be defined by **name**. On execution of **namex** the sequence of words between DOES> and ; are executed, with the address of **namex**'s parameter field on the stack. | | +| DROP | n -- | I,C | Working | Drop top number from the stack | | +| DUP | n -- n n | I,C | Working | Duplicate top of stack | | +| ELSE | -- | C | Working | Used in a colon-definition in the form:
IF ... ELSE ... THEN
ELSE executes after the true part following IF. ELSE forces execution to skip till just after THEN. It has no effect on the stack. (see IF) | | +| EMIT | char -- | I,C | Working | Transmit character to current output device | | | EMPTY-BUFFERS | | | | Mark all block buffers as empty, without necessarily affecting their actual contents. UPDATEd blocks are not written to mass storage. | | | EXECUTE | addr -- | | | Execute the dictionary entry whose compilation address is on the stack. | | | EXIT | | C | | When compiled within a colon-definition, terminate execution of that definition, at that point. May not be used within a DO...LOOP. | | | EXPECT | addr n -- | | | Transfer characters from the terminal beginning at addr, upward, until a "return" or the count of n has been received. Take no action for n less than or equal to zero. One or two nulls are added at the end of text. | | -| FILL | addr n byte -- | | Working | Fill memory starting at addr with n copies of byte | | +| FILL | addr n byte -- | I,C | Working | Fill memory starting at addr with n copies of byte | | | FIND | -- addr ||| Leave the compilation address of the next word name, which is accepted from the input stream. If that word cannot be found in the dictionary after a search of CONTEXT and FORTH leave zero. | | | FORGET | -- | | | Execute in the form:
FORGET **name**
Delete from the dictionary **name** (which is in the CURRENT vocabulary) and all words added to the dictionary after **name**, regardless of their vocabulary. Failure to find **name** in CURRENT or FORTH is an error condition. | | | FORTH | -- | I | | The name of the primary vocabulary. Execution makes FORTH the CONTEXT vocabulary. New definitions become a part of the FORTH until a differing CURRENT vocabulary is established. User vocabularies conclude by 'chaining' to FORTH, so it should be considered that FORTH is 'contained' within each user's vocabulary.y | | | HERE | -- addr | | Working | Return address of next available dictionary location.| | | HOLD | char -- | | | Insert ASCII character into pictured output string. May only be used between <# and #>. | | | I | -- n | C | Working | Copy loop index on stack. May only be used in the form:
DO ... I ... LOOP or
DO ... I ... +LOOP | | -| IF | flag -- | I,C | Working | Used in a colon-definition in the form:
flag IF ... ELSE ... THEN or
flag IF ... THEN
If flag is true, the words following IF are executed and the words following ELSE are skipped. The ELSE part is optional. If flag is false, words between IF and ELSE, or between IF and THEN (when no ELSE is used), are skipped. IF-ELSE-THEN conditionals may be nested. | | +| IF | flag -- | C | Working | Used in a colon-definition in the form:
flag IF ... ELSE ... THEN or
flag IF ... THEN
If flag is true, the words following IF are executed and the words following ELSE are skipped. The ELSE part is optional. If flag is false, words between IF and ELSE, or between IF and THEN (when no ELSE is used), are skipped. IF-ELSE-THEN conditionals may be nested. | | | IMMEDIATE | | | | Marks the most recently made dictionary entry as a word which will be executed when encountered during compilation rather than compiled. | | | J | -- n | C | | Return the index of the next outer loop. May only be used within a nested DO-LOOP in the form:
DO ... DO ... J ... LOOP ... LOOP | | | KEY | -- char | | Working | Read key, put ASCII value on stack | | @@ -160,44 +160,44 @@ BLOCK BUFFER EMPTY-BUFFERS LIST LOAD SAVE-BUFFERS SCR UPDATE | LIST | n -- | | | List the ASCII symbolic contents of screen n on the current output device, setting SCR to contain n. n is unsigned. | | | LITERAL | n -- | I | | f compiling, then compile the stack value n as a 16-bit literal, which when later executed, will leave n on the stack. | | | LOAD | n -- | | | Begin interpretation of screen n by making it the input stream; preserve the locators of the present input stream (from >IN and BLK). If interpretation is not terminated explicitly it will be terminated when the input stream is exhausted. Control then returns to the input stream containing LOAD, determined by the input stream locators >IN and BLK. | | -| LOOP | -- | I,C | Working |Increment the DO-LOOP index by one, terminating the loop if the new index is equal to or greater than the limit. The limit and index are signed numbers in the range {-32,768..32,767}. | | -| MAX | n1 n2 -- n3 | | Working | Leave the greater of two numbers. | | -| MIN | n1 n2 -- n3 | | Working | Leave the lesser of two numbers. | | -| MOD | n1 n2 -- n3 | | Working | Divide n1 by n2, leaving the remainder n3, with the same sign as n1. | | +| LOOP | -- | C | Working |Increment the DO-LOOP index by one, terminating the loop if the new index is equal to or greater than the limit. The limit and index are signed numbers in the range {-32,768..32,767}. | | +| MAX | n1 n2 -- n3 | I,C | Working | Leave the greater of two numbers. | | +| MIN | n1 n2 -- n3 | I,C | Working | Leave the lesser of two numbers. | | +| MOD | n1 n2 -- n3 | I,C | Working | Divide n1 by n2, leaving the remainder n3, with the same sign as n1. | | | MOVE | addr1 addr2 n -- | | | Move the specified quantity n of 16-bit memory cells beginning at addr1 into memory at addr2. The contents of addr1 is moved first. If n is negative or zero, nothing is moved. | | | NEGATE | n -- -n | | | Leave the two's complement of a number, i.e., the difference of zero less n. | | | NOT | flag1 -- flag2 | | | Reverse the boolean value of flag1. This is identical to 0=. | | -| OR | n1 n2 -- n3 | | Working | Leave the bitwise inclusive-or of two numbers. | | -| OVER | n1 n2 -- n1 n2 n1 | | Working | Leave a copy of the second number on the stack. | | -| PAD | -- addr | | Working | The address of a scratch area used to hold character strings for intermediate processing. The minimum capacity of PAD is 64 characters (addr through addr+63). | | +| OR | n1 n2 -- n3 | I,C | Working | Leave the bitwise inclusive-or of two numbers. | | +| OVER | n1 n2 -- n1 n2 n1 | I,C | Working | Leave a copy of the second number on the stack. | | +| PAD | -- addr | I,C | Working | The address of a scratch area used to hold character strings for intermediate processing. The minimum capacity of PAD is 64 characters (addr through addr+63). | | | PICK | n1 -- n2 | | | Return the contents of the n1-th stack value, not counting n1 itself. An error condition results for n less than one.
2 PICK is equivalent to OVER. {1..n} | | | QUERY | | | | ccept input of up to 80 characters (or until a 'return') from the operator's terminal, into the terminal input buffer. WORD may be used to accept text from this buffer as the input stream, by setting >IN and BLK to zero. | | | QUIT | | | | Clear the return stack, setting execution mode, and return control to the terminal. No message is given. | | | R> | -- n | C | | Transfer n from the return stack to the data stack. | | | R@ | -- n | C | | Copy the number on top of the return stack to the data stack. | | -| REPEAT | -- | I,C | Working | Used in a colon-definition in the form:
BEGIN ... WHILE ... REPEAT
At run-time, REPEAT returns to just after the corresponding BEGIN. | | +| REPEAT | -- | C | Working | Used in a colon-definition in the form:
BEGIN ... WHILE ... REPEAT
At run-time, REPEAT returns to just after the corresponding BEGIN. | | | ROLL | n -- | | | Extract the n-th stack value to the top of the stack, not counting n itself, moving the remaining values into the vacated position. An error condition results for n less than one. {1..n}
3 ROLL = ROT
1 ROLL = null operation | | -| ROT | n1 n2 n3 -- n2 n3 n1 | | Working | Rotate the top three values, bringing the deepest to the top. | | +| ROT | n1 n2 n3 -- n2 n3 n1 | I,C | Working | Rotate the top three values, bringing the deepest to the top. | | | SAVE-BUFFERS | | | | Write all blocks to mass-storage that have been flagged as UPDATEd. An error condition results if mass-storage writing is not completed. | | | SCR | -- addr | U | | Leave the address of a variable containing the number of the screen most recently listed. | | | SIGN | n -- | C | | Insert the ASCII "-" (minus sign) into the pictured numeric output string, if n is negative. | | -| SPACE | -- |Working | Transmit an ASCII blank to the current output device. | | -| SPACES | n -- | | Working | Transmit n spaces to the current output device. Take no action for n of zero or less. | | +| SPACE | -- | I,C | Working | Transmit an ASCII blank to the current output device. | | +| SPACES | n -- | I,C | Working | Transmit n spaces to the current output device. Take no action for n of zero or less. | | | STATE | -- addr | U | | Leave the address of the variable containing the compilation state. A non-zero content indicates compilation is occurring, but the value itself may be installation dependent. | | -| SWAP | n1 n2 -- n2 n1 | | Working | Reverse top two stack items | | -| THEN | | I,C | | Used in a colon-definition in the form:
IF ... ELSE ... THEN or
IF ... THEN
THEN is the point where execution resumes after ELSE or IF (when no ELSE is present). | | +| SWAP | n1 n2 -- n2 n1 | I,C | Working | Reverse top two stack items | | +| THEN | | C | Working | Used in a colon-definition in the form:
IF ... ELSE ... THEN or
IF ... THEN
THEN is the point where execution resumes after ELSE or IF (when no ELSE is present). | | | TYPE | addr n -- | | | Transmit n characters beginning at address to the current output device. No action takes place for n less than or equal to zero. | | | U* | un1 un2 -- ud3 | | | Perform an unsigned multiplication of un1 by un2, leaving the double number product ud3. All values are unsigned. | | -| U. | un -- | | Working | Display un converted according to BASE as an unsigned number, in a free-field format, with one trailing blank. | | +| U. | un -- | I,C | Working | Display un converted according to BASE as an unsigned number, in a free-field format, with one trailing blank. | | | U/MOD | ud1 un2 -- un3 un 4 | | | Perform the unsigned division of double number ud1 by un2, leaving the remainder un3, and the quotient un4. All values are unsigned. | | | U< | un1 un2 -- flag | | | Leave the flag representing the magnitude comparison of un1 < un2 where un1 and un2 are treated as 16-bit unsigned integers. | | -| UNTIL | flag -- | I,C | Working | LWithin a colon-definition, mark the end of a BEGIN-UNTIL loop, which will terminate based on flag. If flag is true, the loop is terminated. If flag is false, execution returns to the first word after BEGIN. BEGIN-UNTIL structures may be nested. | | +| UNTIL | flag -- | C | Working | LWithin a colon-definition, mark the end of a BEGIN-UNTIL loop, which will terminate based on flag. If flag is true, the loop is terminated. If flag is false, execution returns to the first word after BEGIN. BEGIN-UNTIL structures may be nested. | | | UPDATE | | | | Mark the most recently referenced block as modified. The block will subsequently be automatically transferred to mass storage should its memory buffer be needed for storage of a different block, or upon execution of SAVE-BUFFERS. | | -| VARIABLE | n -- | | Working | A defining word executed in the form:
VARIABLE **name** to create a dictionary entry for **name** and allot two bytes for storage in the parameter field. The application must initialize the stored value. When **name** is later executed, it will place the storage address on the stack. | | +| VARIABLE | n -- | I,C | Working | A defining word executed in the form:
VARIABLE **name** to create a dictionary entry for **name** and allot two bytes for storage in the parameter field. The application must initialize the stored value. When **name** is later executed, it will place the storage address on the stack. | | | VOCABULARY | -- | | | A defining word executed in the form:
VOCABULARY **name**
to create (in the CURRENT vocabulary) a dictionary entry for **name**, which specifies a new ordered list of word definitions. Subsequent execution of **name** will make it the CONTEXT vocabulary. When **name** becomes the CURRENT vocabulary (see DEFINITIONS), new definitions will be created in that list.
In lieu of any further specification, new vocabularies 'chain' to FORTH. That is, when a dictionary search through a vocabulary is exhausted, FORTH will be searched. | | -| WHILE | flag -- | I,C | Working | Used in the form:
BEGIN ... flag WHILE ... REPEAT
Select conditional execution based on flag. On a true flag, continue execution through to REPEAT, which then returns back to just after BEGIN. On a false flag, skip execution to just after REPEAT, exiting the structure. | | +| WHILE | flag -- | C | Working | Used in the form:
BEGIN ... flag WHILE ... REPEAT
Select conditional execution based on flag. On a true flag, continue execution through to REPEAT, which then returns back to just after BEGIN. On a false flag, skip execution to just after REPEAT, exiting the structure. | | | WORD | char -- addr | | | Receive characters from the input stream until the non-zero delimiting character is encountered or the input stream is exhausted, ignoring leading delimiters. The characters are stored as a packed string with the character count in the first character position. The actual delimiter encountered (char or null) is stored at the end of the text but not included in the count. If the input stream was exhausted as WORD is called, then a zero length will result. The address of the beginning of this packed string is left on the stack. | | -| XOR | n1 n2 -- n3 | | Working | Leave the bitwise exclusive-or of two numbers. | | +| XOR | n1 n2 -- n3 | I,C | Working | Leave the bitwise exclusive-or of two numbers. | | | [ | | I | | End the compilation mode. The text from the input stream is subsequently executed. See ] | | | [COMPILE] | | I,C | | Used in a colon-definition in the form:
[COMPILE] **name**
Forces compilation of the following word. This allows compilation of an IMMEDIATE word when it would otherwise be executed. | | | ] | | | | Sets the compilation mode. The text from the input stream is subsequently compiled. See [ | | @@ -329,13 +329,13 @@ The Reference Word Set contain both Standard Word Definitions and uncontrolled | Word | Syntax | I/C | Status | Description | Comment | |-|-|-|-|-|-| -| -DUP | n -- n ? | | Working | Duplicate only if non-zero | **should be ?DUP** | +| -DUP | n -- n ? | RENAMED to ?DUP | Working | Duplicate only if non-zero | **should be ?DUP** | | R | -- n | | Working | Copy top of return stack onto stack |** really >R maybe** | -| MINUS | n -- -n | | Working | Change sign | **rename NEGATE** | -| DMINUS | d -- -d | | Working | Change sign of double-precision number | **rename DNEGATE**| +| MINUS | n -- -n | RENAMED to NEGATE | Working | Change sign | **rename NEGATE** | +| DMINUS | d -- -d |RENAMED to DNEGATE | Working | Change sign of double-precision number | **rename DNEGATE**| | ?TERMINAL | -- f | | | True if terminal break request present | | | SIGN | ( n d -- d | | | Insert sign of n to output string | | -| ENDIF | -- | | Working | End of the IF-ELSE structure | **there is no ENDIF like statement in forth, i think maybe IFs are only in loops or DOs or create word type structure so there is other "terminating" words that tell you IF is done**| +| ENDIF | -- | | RENAMED to THEN | End of the IF-ELSE structure | **there is no ENDIF like statement in forth, i think maybe IFs are only in loops or DOs or create word type structure so there is other "terminating" words that tell you IF is done**| ## License A2osX is licensed under the GNU General Pulic License | diff --git a/.Floppies/A2OSX.BOOTHD.woz b/.Floppies/A2OSX.BOOTHD.woz index d00c9a1a..51a500c0 100644 Binary files a/.Floppies/A2OSX.BOOTHD.woz and b/.Floppies/A2OSX.BOOTHD.woz differ diff --git a/.Floppies/A2OSX.BUILD.po b/.Floppies/A2OSX.BUILD.po index 361a575a..1f216567 100644 Binary files a/.Floppies/A2OSX.BUILD.po and b/.Floppies/A2OSX.BUILD.po differ diff --git a/.Floppies/A2OSX.TEST.po b/.Floppies/A2OSX.TEST.po index 013d1c4b..07cc60a1 100644 Binary files a/.Floppies/A2OSX.TEST.po and b/.Floppies/A2OSX.TEST.po differ diff --git a/BIN/ACOS.S.CODE.txt b/BIN/ACOS.S.CODE.txt index 4218f856..182bd67a 100644 --- a/BIN/ACOS.S.CODE.txt +++ b/BIN/ACOS.S.CODE.txt @@ -2,7 +2,115 @@ NEW AUTO 3,1 .LIST OFF *-------------------------------------- -CODE.PUSHINT32 ldy #3 +* ZPADDR=STR ID, New pSTR Value on stack +*-------------------------------------- +CODE.STRSET jsr CODE.PULLWS save pSTR + + ldx hStrings + jsr CODE.PUSHBI >PUSHB hSTRV + + >LDYA ZPADDR + jsr CODE.PUSHIYA >PUSHW id + + jsr CODE.PUSHWS >PUSHW str + + ldx #SYS.StrVSet + jsr CODE.SYSCALL >SYSCALL StrVSet + + rts +*-------------------------------------- +* EXP.ADDR = STR ID +* output : str to ZPStrBuf +*-------------------------------------- +CODE.STRGET ldx hStrings + jsr CODE.PUSHBI >PUSHB hSTRV + + >LDYA EXP.ADDR + jsr CODE.PUSHIYA >PUSHW id + + >LDYA ZPStrBuf + jsr CODE.PUSHIYA >PUSHW str + + ldx #SYS.StrVGet + jsr CODE.SYSCALL >SYSCALL StrVGet + + >LDYA ZPStrBuf + jsr CODE.PUSHYA + + rts +*-------------------------------------- +* ZPADDR=pInt, Int16 on Stack +*-------------------------------------- +CODE.INTSET >LDYA ZPADDR + jsr CODE.LDYAI + + ldx #0 + +.1 lda CCODE.PULLWYA,x + jsr CODE.EmitByte + inx + cpx #CCODE.PULLWYA.LEN + bne .1 + + rts +*-------------------------------------- +* EXP.ADDR=pInt +* output : Int16 on Stack +*-------------------------------------- +CODE.INTGET >LDYA EXP.ADDR + jsr CODE.LDYAI + + ldx #0 + +.1 lda CCODE.PUSHWYA,x + jsr CODE.EmitByte + inx + cpx #CCODE.PULLWYA.LEN + bne .1 + + rts +*-------------------------------------- +CODE.PULLWS ldx #0 + +.1 lda CCODE.PULLWS,x + jsr CODE.EmitByte + inx + cpx #CCODE.PULLWS.LEN + bne .1 + + rts +*-------------------------------------- +CODE.PUSHWS ldx #0 + +.1 lda CCODE.PUSHWS,x + jsr CODE.EmitByte + inx + cpx #CCODE.PUSHWS.LEN + bne .1 + + rts +*-------------------------------------- +CODE.PUSHBI lda #$A9 LDA #imm + jsr CODE.EmitByte + txa + jsr CODE.EmitByte + + jmp CODE.PUSHA +*-------------------------------------- +CODE.PUSHIYA pha + lda #$A9 LDA #imm + jsr CODE.EmitByte + pla + jsr CODE.EmitByte + jsr CODE.PUSHA + + lda #$A9 LDA #imm + jsr CODE.EmitByte + tya + jsr CODE.EmitByte + jmp CODE.PUSHA +*-------------------------------------- +CODE.PUSHINT16 ldy #1 .1 lda #$A9 LDA #imm jsr CODE.EmitByte @@ -16,34 +124,6 @@ CODE.PUSHINT32 ldy #3 rts *-------------------------------------- -CODE.PULLL2ZPADDR - >LDYA ZPADDR - jsr CODE.LDYAI - - ldx #0 - -.1 lda CCODE.PULLLYA,x - jsr CODE.EmitByte - inx - cpx #CCODE.PULLLYA.LEN - bne .1 - - rts -*-------------------------------------- -CODE.PUSHfZPADDR - >LDYA ZPADDR -CODE.PUSHfYA jsr CODE.LDYAI - - ldx #0 - -.1 lda CCODE.PUSHLYA,x - jsr CODE.EmitByte - inx - cpx #CCODE.PUSHLYA.LEN - bne .1 - - rts -*-------------------------------------- CODE.LDYAI pha lda #$A0 LDY #imm jsr CODE.EmitByte @@ -55,6 +135,10 @@ CODE.LDYAI pha pla jmp CODE.EmitByte *-------------------------------------- +CODE.PUSHYA jsr CODE.PUSHA + lda #$98 tya + jsr CODE.EmitByte +*-------------------------------------- CODE.PUSHA ldx #0 .1 lda CCODE.PUSHA,x @@ -65,6 +149,10 @@ CODE.PUSHA ldx #0 rts *-------------------------------------- +CODE.PULLYA jsr CODE.PULLA + lda #$A8 tay + jsr CODE.EmitByte +*-------------------------------------- CODE.PULLA ldx #0 .1 lda CCODE.PULLA,x @@ -85,12 +173,12 @@ CODE.FPRINTSTR ldx #0 rts *-------------------------------------- -CODE.FPRINTL ldx #0 +CODE.FPRINTINT ldx #0 -.1 lda CCODE.FPRINTL,x +.1 lda CCODE.FPRINTINT,x jsr CODE.EmitByte inx - cpx #CCODE.FPRINTL.LEN + cpx #CCODE.FPRINTINT.LEN bne .1 rts diff --git a/BIN/ACOS.S.CORE.txt b/BIN/ACOS.S.CORE.txt index 7b294aab..23bfb8f0 100644 --- a/BIN/ACOS.S.CORE.txt +++ b/BIN/ACOS.S.CORE.txt @@ -36,9 +36,22 @@ CORE.Init >LDYAI CODESEG >STA.G hVars - >LDYAI FWREF + >LDYAI STRVSEG + >SYSCALL StrVNew + bcs .9 + + sta hStrings + + >LDYAI 256 >SYSCALL GetMem bcs .9 + + >STYA ZPStrBuf + txa + >STA.G hStrBuf + + >LDYAI FWREF + >SYSCALL GetMem >STYA ZPFWRefBufPtr txa @@ -50,17 +63,27 @@ CORE.Init >LDYAI CODESEG clc .9 rts *-------------------------------------- -CORE.Quit >LDA.G hConstBuf +CORE.Quit lda hStrings beq .1 - >SYSCALL FreeMem + >SYSCALL StrVFree -.1 >LDA.G hCodeBuf - beq CORE.Cleanup +.1 ldy #hStrBuf + jsr CORE.Quit.Freemem - >SYSCALL FreeMem + ldy #hDataBuf + jsr CORE.Quit.Freemem + + ldy #hConstBuf + jsr CORE.Quit.Freemem + + ldy #hCodeBuf + jsr CORE.Quit.Freemem *-------------------------------------- -CORE.Cleanup >LDA.G hVars +CORE.Cleanup ldy #hFWRefBuf + jsr CORE.Quit.Freemem + + >LDA.G hVars beq .1 >PUSHA @@ -79,6 +102,19 @@ CORE.Cleanup >LDA.G hVars .8 clc CORE.Quit.RTS rts *-------------------------------------- +CORE.Quit.Freemem + lda (pData),y + beq .8 + + pha + lda #0 + sta (pData),y + pla + + >SYSCALL FreeMem + +.8 rts +*-------------------------------------- CORE.Compile jsr CORE.GetChar bcs CORE.Quit.RTS @@ -132,14 +168,17 @@ CORE.Compile jsr CORE.GetChar jsr EXP.Eval ZPTYPE set by CreateOrGetVar bcs .99 - ldx ZPTYPE + lda ZPTYPE + cmp EXP.TYPE + bne .91 + + tax beq .4 - - + jsr CODE.STRSET Store String in hSTRV bra .8 -.4 jsr CODE.PULLL2ZPADDR Store Int32 result in DATASEG +.4 jsr CODE.INTSET Store Int16 result in DATASEG *-------------------------------------- .8 jsr CORE.GetCharNB bcs .99 @@ -159,6 +198,10 @@ CORE.Compile jsr CORE.GetChar .90 lda #E.CSYN sec .99 rts + +.91 lda #E.TMISMATCH + sec + rts *-------------------------------------- CORE.FWREF >LDA.G hFWRefBuf >SYSCALL GetMemPtr @@ -273,7 +316,13 @@ CORE.Lookup >STYA ZPPtr1 lda (ZPInputBufPtr),y Get Src text char... beq .9 end of text - jmp CORE.IsLetterOrDigit CS=end of valid chars + cmp #'$' + bne .70 + + clc + rts + +.70 jmp CORE.IsLetterOrDigit CS=end of valid chars *-------------------------------------- CORE.IncPtr1 inc ZPPtr1 bne .8 @@ -348,28 +397,43 @@ CORE.2FWRefBuf sta (ZPFWRefBufPtr) .8 rts *-------------------------------------- CORE.CreateOrGetVar - stz ZPTYPE - >LDA.G hVars jsr CORE.GetAddr - bcc .1 + bcc .2 >LDA.G hVars jsr CORE.NewKey - bcs .9 + bcs .99 - >PUSHB.G hVars - >PUSHW ZPSID - >PUSHWI ZPDataBufPtr - >PUSHWI 3 3 bytes : ADDR + TYPE - >SYSCALL SListAddData - bcs .9 + jsr CORE.GetChar + bcs .1 + + stz ZPTYPE - lda ZPDataBufPtr + cmp #'$' + bne .1 + + sta ZPTYPE + + jsr CORE.GetNextChar skip $ + + lda STRID + sta ZPADDR + + lda STRID+1 + sta ZPADDR+1 + + inc STRID + bne .10 + + inc STRID+1 + bra .10 + +.1 lda ZPDataBufPtr sta ZPADDR -* clc - adc #4 longint + clc + adc #2 Word sta ZPDataBufPtr lda ZPDataBufPtr+1 @@ -377,16 +441,35 @@ CORE.CreateOrGetVar adc #0 sta ZPDataBufPtr+1 -.1 jsr CORE.GetChar - cmp #'$' - bne .8 +.10 >PUSHB.G hVars + >PUSHW ZPSID + >PUSHWI ZPADDR + >PUSHWI 3 3 bytes : ADDR + TYPE + >SYSCALL SListAddData + rts +*-------------------------------------- +.2 ldx #0 + + jsr CORE.GetChar + bcs .3 + + cmp #'$' + bne .3 + + tax - sta ZPTYPE jsr CORE.GetNextChar skip $ -.8 clc +.3 cpx ZPTYPE + bne .90 -.9 rts + clc + rts + +.90 lda #E.TMISMATCH + sec + +.99 rts *-------------------------------------- CORE.NewKey >PUSHA >PUSHW ZPInputBufPtr diff --git a/BIN/ACOS.S.EXP.txt b/BIN/ACOS.S.EXP.txt index 530d9bab..28e9d6b0 100644 --- a/BIN/ACOS.S.EXP.txt +++ b/BIN/ACOS.S.EXP.txt @@ -3,9 +3,11 @@ NEW .LIST OFF *-------------------------------------- * In: A = current CHAR -* Out: CC, longint on stack +* Out: CC, longint on stack or pSTR in stack *-------------------------------------- -EXP.Eval lda EXP.AOPS +EXP.Eval stz EXP.TYPE + +EXP.Eval.R lda EXP.AOPS pha lda #$FF @@ -20,14 +22,15 @@ EXP.Eval lda EXP.AOPS jsr CORE.GetNextCharNB skip ( bcs .39 - jsr EXP.Eval + jsr EXP.Eval.R bcs .39 jsr CORE.GetCharNB bcs .39 cmp #')' - bne .90 + sec + bne .39 jsr CORE.GetNextCharNB skip ) bra .41 @@ -35,10 +38,7 @@ EXP.Eval lda EXP.AOPS .12 cmp #'"' bne .20 - lda ZPTYPE - beq .90 - - jsr EXP.GetString + jsr EXP.CreateStrConst bcs .99 bra .40 @@ -48,6 +48,7 @@ EXP.Eval lda EXP.AOPS >LDYA L.ACOS.FN jsr CORE.Lookup + bcs .21 jsr EXP.FNjmpX @@ -58,15 +59,21 @@ EXP.Eval lda EXP.AOPS .21 jsr EXP.VARLookup bcs .99 - >LDYA EXP.ADDR - jsr CODE.PUSHfYA + ldx EXP.TYPE + bne .22 + + jsr CODE.INTGET + + bra .40 + +.22 jsr CODE.STRGET bra .40 *-------------------------------------- .30 jsr CORE.IsDigit10 .39 bcs .90 - jsr EXP.Int32 + jsr EXP.Int16 bcs .99 *-------------------------------------- .40 jsr CORE.GetCharNB @@ -109,9 +116,9 @@ EXP.Eval lda EXP.AOPS .99 tay Save Err code - >PULLA +.98 >PULLA tax - bpl .99 + bpl .98 sec .HS 90 BCC @@ -127,7 +134,11 @@ EXP.Eval lda EXP.AOPS EXP.FNjmpX jmp (J.ACOS.FN,x) EXP.OPjmpX jmp (J.ACOS.AOPS,x) *-------------------------------------- -EXP.GetString ldy #0 +EXP.CreateStrConst + lda #'$' + sta EXP.TYPE + + ldy #0 .1 jsr CORE.GetNextChar bcs .91 @@ -142,10 +153,12 @@ EXP.GetString ldy #0 .2 lda #0 sta (ZPConstBufPtr),y - >PUSHW ZPConstBufPtr + phy + >LDYA ZPConstBufPtr + jsr CODE.PUSHIYA - tya - clc + pla + sec for \0 adc ZPConstBufPtr sta ZPConstBufPtr bcc .3 @@ -156,8 +169,6 @@ EXP.GetString ldy #0 clc rts - -.90 .91 lda #E.ESYN * sec @@ -177,13 +188,13 @@ EXP.GetOP jsr CORE.IsAOPSChar + - * / .9 rts *-------------------------------------- -EXP.Int32 >PUSHW ZPInputBufPtr +EXP.Int16 >PUSHW ZPInputBufPtr >PUSHWI ZPInputBufPtr >PUSHBI 10 >SYSCALL StrToL bcs .9 - jsr CODE.PUSHINT32 + jsr CODE.PUSHINT16 >POP 4 @@ -209,24 +220,46 @@ EXP.VARLookup >LDA.G hVars >PUSHWI 3 3 bytes : ADDR + TYPE >PUSHWZ From Start >SYSCALL SListGetData + bcs .99 + + ldx #0 + + jsr CORE.GetChar + bcs .2 + + cmp #'$' + bne .2 + + tax + + jsr CORE.GetNextChar skip $ + +.2 cpx EXP.TYPE + bne .90 + + clc rts .9 >PULLA +.99 rts + +.90 lda #E.TMISMATCH + sec rts *-------------------------------------- -EXP.ADD ldx #FPU.ADD32 +EXP.ADD ldx #FPU.ADD16 jmp CODE.FPUCALL -EXP.SUB ldx #FPU.SUB32 +EXP.SUB ldx #FPU.SUB16 jmp CODE.FPUCALL -EXP.MUL ldx #FPU.IMUL32 +EXP.MUL ldx #FPU.IMUL16 jmp CODE.FPUCALL -EXP.DIV ldx #FPU.IDIV32 +EXP.DIV ldx #FPU.IDIV16 jmp CODE.FPUCALL -EXP.MOD ldx #FPU.IMOD32 +EXP.MOD ldx #FPU.IMOD16 jmp CODE.FPUCALL *-------------------------------------- *-------------------------------------- diff --git a/BIN/ACOS.S.FN.txt b/BIN/ACOS.S.FN.txt index ad20305e..0297a265 100644 --- a/BIN/ACOS.S.FN.txt +++ b/BIN/ACOS.S.FN.txt @@ -9,8 +9,103 @@ FN.FLAG FN.CHRd FN.INSTR FN.KEY -FN.LEN -FN.LEFTd + lda #E.CSYN + sec + rts +*-------------------------------------- +FN.LEN jsr CORE.GetCharNB + bcs .90 + + cmp #'(' + bne .90 + + jsr EXP.Eval + bcs .99 + + lda EXP.TYPE + beq .91 + + ldx #0 + +.1 lda CCODE.LEN,x + jsr CODE.EmitByte + inx + cpx #CCODE.LEN.LEN + bne .1 + + stz EXP.TYPE + + clc + rts + +.90 lda #E.CSYN + sec + rts + +.91 lda #E.TMISMATCH + sec +.99 rts +*-------------------------------------- +FN.LEFTd jsr CORE.GetCharNB + bcs .90 + + cmp #'(' + bne .90 + + jsr CORE.GetNextCharNB skip ( + bcs .90 + + jsr EXP.Eval + bcs .99 + + lda EXP.TYPE + beq .91 + + jsr CORE.GetCharNB + bcs .90 + + cmp #',' + bne .90 + + jsr CORE.GetNextCharNB skip , + bcs .90 + + jsr EXP.Eval + bcs .99 + + lda EXP.TYPE + bne .91 + + jsr CORE.GetCharNB + bcs .90 + + cmp #')' + bne .90 + + jsr CORE.GetNextCharNB skip ) + + ldx #0 + +.1 lda CCODE.LEFT,x + jsr CODE.EmitByte + inx + cpx #CCODE.LEFT.LEN + bne .1 + + lda #'$' + sta EXP.TYPE + + clc + rts + +.90 lda #E.CSYN + sec + rts + +.91 lda #E.TMISMATCH + sec +.99 rts +*-------------------------------------- FN.MIDd FN.PDL FN.PEEK @@ -22,7 +117,8 @@ FN.TIMEd FN.VAL FN.WHENd FN.WIDTH - clc + lda #E.CSYN + sec rts *-------------------------------------- MAN diff --git a/BIN/ACOS.S.KW.txt b/BIN/ACOS.S.KW.txt index 9fbc4e22..5963ce85 100644 --- a/BIN/ACOS.S.KW.txt +++ b/BIN/ACOS.S.KW.txt @@ -98,47 +98,21 @@ KW.PRINT stz hOut reset to hStdOut bcs .8 stz bFlag put ending CR - - cmp #'"' - bne .5 - - ldy #0 - -.1 jsr CORE.GetNextChar - bcs .90 - - cmp #'"' - beq .2 - - sta (ZPConstBufPtr),y - iny - bne .1 - -.2 lda #0 - sta (ZPConstBufPtr),y - iny - phy - - >LDYA ZPConstBufPtr - jsr CODE.LDYAI - jsr CODE.FPRINTSTR - - pla - clc - adc ZPConstBufPtr - sta ZPConstBufPtr - bcc .3 - - inc ZPConstBufPtr+1 - -.3 jsr CORE.GetNextCharNB skip " - bra .70 *-------------------------------------- .5 jsr EXP.Eval bcs .99 - jsr CODE.FPRINTL + lda EXP.TYPE + beq .6 + jsr CODE.PULLYA + jsr CODE.FPRINTSTR + + bra .7 + +.6 jsr CODE.PULLYA + jsr CODE.FPRINTINT +*-------------------------------------- .7 jsr CORE.GetCharNB bcs .8 diff --git a/BIN/ACOS.S.txt b/BIN/ACOS.S.txt index e25be4e0..5fe8df1d 100644 --- a/BIN/ACOS.S.txt +++ b/BIN/ACOS.S.txt @@ -8,6 +8,7 @@ NEW CODESEG .EQ 4096 CONSTSEG .EQ 1024 DATASEG .EQ 256 +STRVSEG .EQ 2048 FWREF .EQ 1024 EXP.DEPTH.MAX .EQ 16 *-------------------------------------- @@ -26,13 +27,14 @@ ZPInputBufPtr .BS 2 ZPSID .BS 2 ZPADDR .BS 2 ZPTYPE .BS 1 - .BS 1 +hStrings .BS 1 + +ZPStrBuf .BS 2 ZPPtr1 .BS 2 ZPPtr2 .BS 2 -ZPPtr3 .BS 2 -hIn .BS 1 -hOut .BS 1 +ArgIndex .BS 1 +bFlag .BS 1 ZPCodeBufPtr .BS 2 ZPConstBufPtr .BS 2 @@ -42,8 +44,10 @@ ZPFWRefBufPtr .BS 2 EXP.ADDR .BS 2 EXP.TYPE .BS 1 EXP.AOPS .BS 1 -ArgIndex .BS 1 -bFlag .BS 1 + +STRID .BS 2 +hIn .BS 1 +hOut .BS 1 ZS.END .ED *-------------------------------------- @@ -67,16 +71,18 @@ CS.START cld .DA CS.RUN .DA CS.DOEVENT .DA CS.QUIT +*-------------------------------------- L.MSG.GREETINGS .DA MSG.GREETINGS L.MSG.USAGE .DA MSG.USAGE L.MSG.ECHOCRLF .DA MSG.ECHOCRLF L.MSG.COMPILING .DA MSG.COMPILING L.MSG.DEBUG .DA MSG.DEBUG -L.MSG.ERR .DA MSG.ERR +L.MSG.TRACE .DA MSG.TRACE +L.MSG.ERROR .DA MSG.ERROR L.MSG.RUN .DA MSG.RUN L.MSG.FWREFERR .DA MSG.FWREFERR L.MSG.STR .DA MSG.STR -L.MSG.INT32 .DA MSG.INT32 +L.MSG.INT16 .DA MSG.INT16 *-------------------------------------- L.ACOS.AOPS .DA ACOS.AOPS J.ACOS.AOPS .DA EXP.ADD @@ -185,34 +191,46 @@ CS.RUN >PUSHW L.MSG.GREETINGS jsr CS.RUN.ARGS bcs CS.INIT.RTS + >LDYAI 256 + >SYSCALL GetMem + bcs CS.INIT.RTS + >STYA.G InputBufPtr + jsr CORE.Init bcs CS.INIT.RTS >PUSHW L.MSG.COMPILING - >PUSHW ZPPtr2 + >PUSHW ZPPtr2 File name >PUSHBI 2 >SYSCALL PrintF bcs CS.INIT.RTS -.1 >SLEEP +CS.RUN.LOOP >SLEEP >LDA.G bDebug bpl .2 jsr PrintDebugMsg -.2 >LDA.G bTrace +.2 jsr CS.RUN.FGetS + bcs .4 + + >LDA.G bTrace bpl .3 - >LDYA ZPInputBufPtr jsr PrintTraceMsg .3 jsr CORE.Compile - bcc .1 + bcc CS.RUN.LOOP cmp #MLI.E.EOF + beq CS.RUN.LOOP + +.4 cmp #MLI.E.EOF bne .9 + jsr CS.FClose + jsr CORE.FWREF bcs .9 @@ -220,7 +238,7 @@ CS.RUN >PUSHW L.MSG.GREETINGS bcc .8 .9 pha - jsr PrintErrMsg + jsr PrintErrorMsg pla sec rts @@ -258,25 +276,21 @@ CS.RUN.ARGS inc ArgIndex sta (pData),y bra CS.RUN.ARGS -.4 >LDA.G hFileBuf +.4 >LDA.G hFile bne .90 >LDYA ZPPtr1 - >STYA ZPPtr2 form printing later - jsr CS.RUN.LoadFile - bcs .9 + >STYA ZPPtr2 for printing later + jsr CS.RUN.FOpen + bcc CS.RUN.ARGS - >STYA ZPInputBufPtr +.9 rts - txa - >STA.G hFileBuf - bra CS.RUN.ARGS - -.7 >LDA.G hFileBuf +.7 >LDA.G hFile beq .90 clc -.9 rts + rts .90 >PUSHW L.MSG.USAGE >PUSHBI 0 @@ -286,85 +300,42 @@ CS.RUN.ARGS inc ArgIndex sec QUIT Process rts *-------------------------------------- -CS.RUN.LoadFile >SYSCALL LoadTxtFile +CS.RUN.FOpen >PUSHYA + >PUSHBI O.RDONLY + >PUSHBI S.FI.T.TXT + >PUSHWZ Aux type + >SYSCALL FOpen bcs .9 - phx - txa - >SYSCALL GetMemPtr - plx + >STA.G hFile .9 rts *-------------------------------------- +CS.RUN.FGetS >LDYA.G InputBufPtr + >STYA ZPInputBufPtr + + >INCW.G LineCounter + + >PUSHB.G hFile + >PUSHW ZPInputBufPtr + >PUSHWI 256 + >SYSCALL FGetS + + rts +*-------------------------------------- CS.DOEVENT sec rts *-------------------------------------- CS.QUIT jsr CORE.Quit - clc - rts -*-------------------------------------- -PrintErrMsg >LDA.G hFileBuf - >SYSCALL GetMemPtr - >STYA ZPPtr1 - - stz ZPPtr2 - stz ZPPtr2+1 Line counter - -.1 inc ZPPtr2 - bne .2 - inc ZPPtr2+1 - -.2 >LDYA ZPPtr1 - >STYA ZPPtr3 save line start - -.20 lda (ZPPtr1) - beq .4 EoF - - inc ZPPtr1 - bne .3 - - inc ZPPtr1+1 -.3 cmp #C.CR - bne .20 Scan until EoL - - ldx ZPPtr1 - cpx ZPInputBufPtr - lda ZPPtr1+1 - sbc ZPInputBufPtr+1 - bcc .1 not this line.... - -.4 >LDA.G bTrace - bmi .5 - - jsr PrintTraceMsg.3 - -.5 lda ZPPtr3 - cmp ZPInputBufPtr - bne .6 - - lda ZPPtr3+1 - cmp ZPInputBufPtr+1 +CS.FClose >LDA.G hFile beq .8 -.6 >PUSHBI '-' - ldy #S.PS.hStdErr - lda (pPS),y - >SYSCALL FPutC - inc ZPPtr3 - bne .5 + >SYSCALL FClose - inc ZPPtr3+1 - bra .5 - -.8 ldy #S.PS.hStdErr - lda (pPS),y - >PUSHA - >PUSHW L.MSG.ERR - >PUSHW ZPPtr2 Line counter - >PUSHBI 2 - >SYSCALL FPrintF + >STZ.G hFile +.8 clc rts *-------------------------------------- PrintDebugMsg >LDYA pStack @@ -378,56 +349,85 @@ PrintDebugMsg >LDYA pStack >SYSCALL PrintF rts *-------------------------------------- -PrintTraceMsg >STYA ZPPtr3 - -PrintTraceMsg.3 >PUSHBI '>' - ldy #S.PS.hStdErr - lda (pPS),y - >SYSCALL FPutC - - ldy #$ff - -.1 iny - lda (ZPPtr3),y - beq .8 - - cmp #C.CR - beq .8 - - phy - >PUSHA - ldy #S.PS.hStdErr - lda (pPS),y - >SYSCALL FPutC - ply - bra .1 - -.8 ldy #S.PS.hStdErr +PrintTraceMsg ldy #S.PS.hStdErr lda (pPS),y >PUSHA - >PUSHW L.MSG.ECHOCRLF - >PUSHBI 0 + >PUSHW L.MSG.TRACE + >PUSHW.G LineCounter + >PUSHW.G InputBufPtr + >PUSHBI 4 >SYSCALL FPrintF rts *-------------------------------------- -CCODE.PUSHLYA >STYA ZPADDR - ldy #3 -.1 lda (ZPADDR),y - >PUSHA - dey - bpl .1 -CCODE.PUSHLYA.LEN .EQ *-CCODE.PUSHLYA -*-------------------------------------- -CCODE.PULLLYA >STYA ZPADDR +PrintErrorMsg >LDA.G bTrace + bmi .1 + + jsr PrintTraceMsg + +.1 lda ZPInputBufPtr + + sec + >SBC.G InputBufPtr + tax + bcc * + >LDYA.G InputBufPtr + >STYA ZPInputBufPtr + + txa + beq .3 + ldy #0 -.1 >PULLA - sta (ZPADDR),y + lda #'-' + +.2 sta (ZPInputBufPtr),y iny - cpy #4 - bcc .1 -CCODE.PULLLYA.LEN .EQ *-CCODE.PULLLYA + dex + bne .2 + + txa + +.3 sta (ZPInputBufPtr),y + +.8 ldy #S.PS.hStdErr + lda (pPS),y + >PUSHA + >PUSHW L.MSG.ERROR + >PUSHW ZPInputBufPtr + >PUSHBI 2 + >SYSCALL FPrintF + rts +*-------------------------------------- +* Precompiled code +*-------------------------------------- +CCODE.PULLWS >PULLA + pha + >PULLA + pha +CCODE.PULLWS.LEN .EQ *-CCODE.PULLWS +*-------------------------------------- +CCODE.PUSHWS pla + >PUSHA + pla + >PUSHA +CCODE.PUSHWS.LEN .EQ *-CCODE.PUSHWS +*-------------------------------------- +CCODE.PUSHWYA >STYA ZPADDR + ldy #1 + lda (ZPADDR),y + >PUSHA + lda (ZPADDR) + >PUSHA +CCODE.PUSHWYA.LEN .EQ *-CCODE.PUSHWYA +*-------------------------------------- +CCODE.PULLWYA >STYA ZPADDR + >PULLA + sta (ZPADDR) + >PULLA + ldy #1 + sta (ZPADDR),y +CCODE.PULLWYA.LEN .EQ *-CCODE.PULLWYA *-------------------------------------- CCODE.PUSHA >PUSHA CCODE.PUSHA.LEN .EQ *-CCODE.PUSHA @@ -445,26 +445,54 @@ CCODE.FPRINTSTR pha >SYSCALL PrintF CCODE.FPRINTSTR.LEN .EQ *-CCODE.FPRINTSTR *-------------------------------------- -CCODE.FPRINTL >PUSHW L.MSG.INT32 - ldx #4 - ldy #5 - -.1 lda (pStack),y +CCODE.FPRINTINT pha + >PUSHW L.MSG.INT16 + pla >PUSHA - dex + tya + >PUSHA + >PUSHBI 2 + >SYSCALL PrintF +CCODE.FPRINTINT.LEN .EQ *-CCODE.FPRINTINT +*-------------------------------------- +CCODE.LEN >PULLW ZPPtr1 + + ldy #$FF + +.1 iny + lda (ZPPtr1),y bne .1 - >PUSHBI 4 - >SYSCALL PrintF - >POP 4 Discard long on stack -CCODE.FPRINTL.LEN .EQ *-CCODE.FPRINTL + >PUSHYA +CCODE.LEN.LEN .EQ *-CCODE.LEN +*-------------------------------------- +CCODE.LEFT >PULLW ZPPtr2 cnt + lda (pStack) + sta ZPPtr1 + ldy #1 + lda (pStack),y + sta ZPPtr1+1 + + ldy #0 + +.1 lda (ZPPtr1),y + beq .8 + + iny + cpy ZPPtr2 + bne .1 + + lda #0 + sta (ZPPtr1),y +.8 + +CCODE.LEFT.LEN .EQ *-CCODE.LEFT *-------------------------------------- .INB usr/src/bin/acos.s.code .INB usr/src/bin/acos.s.core .INB usr/src/bin/acos.s.exp .INB usr/src/bin/acos.s.fn .INB usr/src/bin/acos.s.kw - .INB usr/src/bin/acos.s.str *-------------------------------------- CS.END *-------------------------------------- @@ -477,11 +505,12 @@ MSG.USAGE .AS "Usage : ACOS