The Fig-Forth user space has the capacity to contain additional native code fragments for the machine hardware, providing the following limitations and definitions are followed precisely. While the use of such coding is not expected to be extensive, all such code is defined as a far system call with the processor operating in a 16 bit Real Mode Configuration. Both Forth words of CODE and ;CODE initiate this far call from the internal engine with the Parameter Stack as the active element, while the Return Stack contains the call address and the Forth coding pointers. The END-CODE word manages system return and the restoration of segment registers, automatically switching to the return stack and restarting the system engine.
The following table describes the state of the processor at the moment of entry into the user code segment;
Register | Entry Contents | Comment |
AX | Offset to user code | |
BX | Offset to user code | Use this offset for local addressing but may be modified |
CX | Top Parameter Stack Item | Calling parameter |
DX | Undefined | |
BP | Return Stack offset | Should be Preserved |
SP | Parameter Stack offset | |
SI | Forth Instruction Pointer | Should be Preserved |
DI | Undefined | |
CS | User Segment | |
DS | User Segment | |
ES | User Segment | |
SS | User Segment | Should be preserved |
Note that no definition is present for the 386 extended registers, including the GS and FS segment identifiers. User code fragments may freely modify the contents of the parameter stack or the user segment, but accurate Return Stack balancing and the top three entries upon this stack should be preserved. When the user code fragment is executed the Return Stack contains the following top items;
Item # | Contents | Comments |
1 | offset to clean routine | preserve |
2 | kernel segment value | preserve |
3 | offset to internal machine | preserve |
4-N | Saved Forth IP addresses | Modify with care. |
Lastly, the CX register should always contain the top Parameter Stack item when the user fragment exits, whether modified, added to or discarded by the user code. User code should not attempt to manage the return sequence itself.
Return to Contents. Next Chapter. Previous Chapter.