<< Home | About Forth | About TurboForth | Download | Language Reference | Resources | Tutorials | YouTube >>


CODE: Search:

In Compilation Words in TurboForth Kernal

Word Name: CODE:
Type: Standard compiling word
Data Stack Signature: --
Return Stack Signature: --
Availability: V1.0  V1.1  V1.2
Description:

Begins compilation of a machine code/assembly language word.

Example:

Example (for TurboForth V1.2):

HEX CODE: PLUS A534 ;CODE DECIMAL

Creates a machine code word called PLUS which contains the following machine code:

A *R4+,*R4 ; pop top of stack and add to next number on stack
B *R12     ; call NEXT

 

To test it, try

9 100 PLUS .

Comment:

The name of the word must follow CODE: followed by a sequence of numbers representing the machine code op-codes. The numbers will be interpreted to according the current value of BASE.

CODE: writes the dictionary entry in a format suitable for machine code words (the Code Field Address (CFA) points to the machine code, instead of DOCOL) and then compiles the op-codes into consecutive addresses in memory with no translation or conversions applied.

The machine code should be terminated with ;CODE. Upon termination, ;CODE appends a B *R12 instruction to the compiled code, which (at run time) calls NEXT.

See Also: ;CODE 

<< Home | About Forth | About TurboForth | Download | Language Reference | Resources | Tutorials | YouTube >>