Interp Code Samples

1. List CLI Argument Information

The argtest function uses the print iterator and System Constants ("K") 24, 25, and 26 to show the complete content of the unix/Linux command line. See it in action here.

2. Write Image Format File

Load this file last to write out your function definitions in the Interp Image Format (IIF.) Applications stored in this format are easier to distribute as turn-key solutions.

3. Debug Macros

These seven macros are a good starting point for ideas about developing your own debugging tools for interp scripts.

4. Byte-by-Byte Memory Dump

This function uses the print iterator and prints 256 bytes of memory in hex, as 16 rows of 16 bytes with ASCII equivalents.

5. Big-Endian Memory Dump

This function prints 256 bytes of memory in hex, as 16 rows of 4 32-bit values with ASCII equivalents. It works properly on Big-Endian CPUs.

6. Little-Endian Memory Dump

This function prints 256 bytes of memory in hex, as 16 rows of 4 32-bit values with ASCII equivalents. It works properly on Little-Endian CPUs.

7. Example 17

Example 17 (from the User Manual) expects a memory address on top of the stack, uses the print iterator, and prints 256 bytes of memory in hex, as 16 rows of eight 16-bit values.

8. Example 18

Example 18 (from the User Manual) is an expanded version of Example 17, with the print iterator and local functions called as macros. Compare this example with Code Sample 6 (above) to see just how much simpler your code can be when you switch to the print iterator.

9. Dump the System Constants

This function displays the value of every System Constant.

10. Version 2 of Dump the System Constants

This function uses the the print iterator and displays the value of every System Constant. Compare this example with Code Sample 9 to see how much "cleaner" your code looks when you use the print iterator.

11. Original print iterator tests for QUOTE

This script tests the new print iterator meta-characters and modifiers in the QUOTE operator.

12. Original print iterator tests for M-QUOTE

This script tests the new print iterator meta-characters and modifiers in the M-QUOTE operator.

13. Original IIF tests for 0xA0, 0xA1, and 0xB1

This script tests the new IIF loader opcodes by creating an in-memory IIF image containing one global function record, one local function record, and one End-of-Data record. There is one optional argument for this script that, when present, will add an auto-start string to the End-of-Data record. The MEMORY-MACRO ("m@") operator is used to execute the image and load the two function definitions into their corresponding tables. If auto-start is requested, you will see the output from the two functions after they execute. If auto-start is not requested, the function names are listed to show they were added to the tables.

14. Default Macro Definitions

Load this file to restore the default macro definitions. This has been superceeded by the "#restore" outer-interpreter directive, but it is still a good example of a script file that does nothing other than define macros for interactive use.