Go to Triangle Digital Support Home Page TDS2020F TECHNICAL MANUAL
Forth word list
: to @TIME
Live website search
Enter key words
 

 

:                     ANS

 

'<spaces>name' -

 

Create a definition for name. Enter compilation state and start the current definition. The execution action of name is determined by the words compiled into the body of the definition. The current definition is not findable in the dictionary until it is ended or until the execution of DOES> or ;CODE .

 

INITIATION:   -      R:   - nest-sys

Save return information nest-sys about the calling definition.

 

name EXECUTION:   ?1 - ?2

Execute the definition name. The stack effects represent arguments to and from name.

 

:NONAME                    ANS

 

- xt

 

Create an execution token xt, enter compilation state and start the current definition. Append the initiation action below to the current definition. The execution action of xt will be the words compiled into the body of the definition. This definition can be executed later by using xt EXECUTE . Used to define a 'hidden' word, i.e. one without a name. See NEW FEATURES OF ANS FORTH, page 127.

 

INITIATION:   -      R: - nest-sys

Save return information nest-sys about the calling definition.

 

EXECUTION:   ?1 - ?2

Execute the definition specified by xt. The stack effects represent arguments to and from xt.

 

;                    ANS

 

COMPILATION:   -

Append run-time action below to current definition. End the current definition, allow it to be found in the dictionary and enter interpretation state.

 

RUN-TIME:   -   R:   nest-sys -

Return to the calling definition specified by nest-sys.

 

;CODE                    ANS

 

COMPILATION:   -

Append run-time action below to current definition. End the current definition, allow it to be found in the dictionary and enter interpretation state. Process source code which follows it as H8 assembler language. Used to generate defining words with fast run-time action. Used in a structure:
: name . high level Forth . ;CODE . assembler . END-CODE

 

RUN-TIME:   -   R:   nest-sys -

Replace the execution action of the most recent definition with the execution action shown below. Return to the calling definition specified by next-sys.

 

name EXECUTION:

Perform the machine code sequence that was generated following ;CODE .

 

<                     ANS

 

n1 n2 - flag

 

Flag is true if n1 is less than n2.

 

<#                    ANS

 

-

 

Initialise the pictured numeric output conversion process.

 

<>                    ANS

 

x1 x2 - flag

 

Not equal. Flag is true if n1 and n2 are unequal, and false otherwise. Opposite of = .

 

<?NUMBER>

 

ca u - d 2   or

ca u - n 1   or

ca u - 0

 

String to number conversion primitive.

 - Returns only 0 if not a number.

 - Returns n if no punctuation is present and sets DPL to -1 .

 - Returns d if number contains embedded punctuation , - . / : and sets DPL to position of rightmost punctuation, e.g. 1.23 returns DPL = 2.

This is the default action of ?NUMBER . See '?NUMBER ?NUMBER .

 

<ACCEPT>

 

ca +n - +n2

 

Receive a string of up to +n characters. Stops when cr (ASCII 13) is received. The value of n2 is the number of characters actually received, not including the cr. Editing provided by backspace (ASCII 8) and delete (ASCII 127). This is the default action of ACCEPT . See 'ACCEPT ACCEPT .

 

<EMIT>

 

x -

 

Send the lower byte of x to serial Port 1, discarding the upper byte. All bytes 0 to 255 are sent without any filtering. This is the default action of EMIT . See 'EMIT EMIT .

 

<ERROR>

 

n -

 

Display error message, if any, associated with error number n. Then clear the stack. This word is the default action of ERROR at power-up.

 

0 to -2

give no error message.

-3 to -23

give ANS error messages

 

  where implemented.

-256 to -270

give TDS2020F specific

 

  error messages.

 

All others, including all positive error numbers, display message ERROR n, where n is the error number. See ERROR CODES, page 148. Use this word after CATCH to display the error number presented by the THROW which caused the exit from CATCH . An application program should use positive error numbers.

 

<KEY>

 

- char

 

Receive one keyboard character from serial Port 1. The character is in the bottom byte and the top byte is zero. This is the default action of KEY . See 'KEY KEY .

 

<KEY?>

 

- flag

 

If a keyboard event is available from serial Port 1 return true. This is the default action of KEY? . See 'KEY? KEY? .

 

<PUT>

 

char n -

 

Puts character char at position n on LCD. E.g.

65 2 <PUT>

will place the character A (ASCII value 65) at the third from the left position on the LCD (as with other Forth counts, the left position is 0). Usually <PUT> is not used directly. At power-up PUT is vectored to <PUT> through the user variable 'PUT . The word PUT can be used as the primitive to write to the LCD. See PUT 'PUT AT .

 

<SOURCE>

 

- ca u

 

ca is the address of, and u is the number of characters in, the terminal input buffer. The word is the default action of SOURCE at power-up

 

=                     ANS

 

x1 x2 - flag

 

Flag is true if x1 is the same as x2.

 

>                     ANS

 

n1 n2 - flag

 

Flag is true if n1 is greater than n2.

 

><

 

x1 - x2

 

Swap bytes of word on top of stack.

 

>BODY                    ANS

 

xt - aa

 

aa is the aligned data-field address (parameter field address, pfa) corresponding to execution token xt, for example found with ' or ['] .

 

>DMY

 

n - day month year

 

Converts the number of days n since 1st Jan 1984 to three numbers representing the equivalent date. The parameter returned is 102 for the year 2002 and so on. Account is taken of leap-years. Valid to the year 2072. The word DMY> does the opposite conversion.

 

>IN                    ANS

 

- aa

 

aa is the address of a cell containing the number of characters from the start of the input buffer to the start of the parse area.

 

>NAME

 

xt - nfa

 

Converts execution token xt to name field address.

 

>NUMBER                    ANS

 

ud1 ca1 u1 - ud2 ca2 u2

 

Convert the text string, (starting at ca1 and u1 characters long) into a double number and accumulate it in ud1 to form ud2. ca2 u2 is the string beginning with the first non-convertible digit. See ?NUMBER <?NUMBER> .

 

>R                    ANS

 

EXECUTION:   x -   R:   - x

Move x to the return stack. Use should normally be balanced by R> in the same definition.

 

>SMH

 

d - secs mins hrs

 

Converts a double number representing 'ticks' since midnight to the equivalent seconds, minutes and hours as three items on the stack. Usually used after @TIME .

 

?                     ANS

 

aa -

 

Display the value stored at address aa. Its use will corrupt the transient pictured numeric output area used by  <# . #> structures.

 

?BIT

 

ca n - flag

 

Flag is true if bit n at byte address ca is set. Useful as a direct test of one parallel input line. E.g.

FF8E 6 ?BIT

returns true if bit 6 of Port 7 is at logic 1 (+5V). Port 7 is at address hex FF8E.

 

?CSP

 

-

 

Error 'INCOMPLETE' if stack changed since !CSP .

 

?DEFINED

 

- File #EXTEND.TDS needed -

 

n -

 

Error 'UNDEFINED' if n is zero.

 

?DO                    ANS

 

COMPILATION:   - 3

Append run-time action below to current definition. The action is incomplete until the following LOOP or +LOOP .

 

RUN-TIME:   u1 u2 -     R:   - n1 n2

If u1 is not equal to u2 continue execution at the following LOOP or +LOOP . Otherwise set up loop control parameters with index u2 and limit u1. Anything already on the return stack becomes unavailable until the loop control parameters are discarded.

 

?DUP                    ANS

 

x - 0    or

x - x x

 

Duplicate x if it is non-zero

 

?ERROR

 

flag err-no -

 

Test flag. If true give warning message. See ERROR CODES, page 148.

 

?NUMBER

 

ca u - d 2     or

ca u - n 1     or

ca u - 0

 

At power-up, vectored through '?NUMBER to execute <?NUMBER> but that can be changed by the application program. See <?NUMBER> '?NUMBER .

 

?STACK

 

-

 

Stack check. In case of an overflow or underflow, re-enters program after the last CATCH , within QUIT by default, giving the message 'FULL STACK' or 'EMPTY STACK'.

 

?TERMINAL

 

- File #EXTEND.TDS needed -

 

- flag

 

Return true if ctrl+C is the first character received at serial Port 1. It is a debugging aid replaced in ANS Forth by KEY? , which returns true on any key.

 

?TIME

 

- u

 

Used in a colon definition to provide the time u in microseconds taken by the words since 0TIME in the same definition. There is a maximum of 53333�s and a longer delay should either be broken into parts or it should be measured by reading the on-board clock in ticks, mins and days before and after the event. E.g.

: TEST   1000 2000

 0TIME UM* ?TIME U. 2DROP ;

Execution of TEST shows the time in microseconds taken by UM* .

 

@                     ANS

 

aa - x

 

Fetch 16-bit data x from aligned address aa.

 

@-Rx

 

-

 

An assembler word. The set of commands @-R0 to @-R7 which assemble indirect addressing through registers 0 to 7, with pre-decrement. @-R7 is the same as push to stack. E.g.

@-R7 R3 MOVO, \ Push R3 to

              \ stack

 

@DATE

 

- n

 

Gives the number of days since 1st January 1984. This date is day 0 and is the date set at power-up.

 

@ODD

 

ca - x

 

Fetch 16-bit data x from any address ca.

 

@Rx

 

-

 

An assembler word. The set of commands @R0 to @R7 which assemble indirect addressing through registers 0 to 7. An offset is needed, which can be zero. E.g.

2 @R7 R3 MOVI,

This MOVes In to register 3 the data pointed to by register R7 (the stack pointer), with an index offset of 2. In this case the next to the top 16-bit item on the stack (2 bytes into it) will be loaded to R3.

 

@Rx+

 

-

 

An assembler word. The set of commands @R0+ to @R7+ which assemble indirect addressing through registers 0 to 7, with post-increment. @R7+ is the same as pull stack:

@R7+ R2 ADD, \ Add top of

 \ stack, dropping it, to R2

 

@TIME

 

- d

 

Gives the number of 'ticks' since midnight, or power-up if time has not been set. A 'tick' is either 53.333ms and there are exactly 1125 in a minute, or a 'tick' is one second. See TICKS for detail. A double number is returned. Useful for measuring time between two events. Take the time at beginning and end, then subtract.

 

Go to Triangle Digital Support Home Page Go to top   Next page