The main window of TinyELF simulates the front panel of a simple ELF II computer. Each ELF computer being emulated has one of these windows associated with it. The main features of this window are illustrated below.
The hex display provides feedback while entering a program, allows you to view bytes when examining memory contents, and gives programs a way to display their results.
Programs can output bytes to the hex display using the 1802's OUT 4 (output to port 4) instruction.
One unusual feature of the 1802 is a single general-purpose bit called "Q." The state of this bit is brought out on a pin of the microprocessor, and in TinyELF is shown as a program-controlled light or LED in the display area.
Programs can turn the LED on with the SEQ (set Q) instruction, or turn it off with the REQ (reset Q) instruction. They can also test the state of the Q flag and branch or skip instructions depending upon whether or not it is set. There are six of these instructions to test Q:
All of the instructions pertaining to the Q flag are discussed in Chapter 3 of A Short Course in Programming.
Sixteen keys, 0-9 and A-F, are used to input bytes into TinyELF, using a base-16 numbering system called hexadecimal. This numbering system is still very useful for working with computers, and you can learn more about it by reading Appendix B of A Short Course in Programming.
These keys are used to input program data when the 1802 is in Load mode (with the Run switch off and the Load switch on). When the computer is in Run mode (Run switch on, Load switch off), the bytes entered with this hexpad will appear on input port 4 of the simulated 1802. Programs can then read these bytes using an INP 4 (input from port 4) instruction.
The Run and Load switches are used in combination to set the mode of the simulated 1802 microprocessor. This gives four basic modes of operation:
For more information on using TinyELF's mode control switches, read Chapter 2 of A Short Course in Programming.
Turning the Memory Protect switch on has two effects: first, a running program may not modify memory; second, bytes entered in Load mode will not modify memory, allowing you to examine memory byte-by-byte with each press of the Input key.
Note that not all programs will run correctly with the Memory Protect switch turned on, because they depend on writing values into memory. The only memory that an 1802 program can write to, however, is its own; it can never write to the memory of any other program on your Mac.
Also note that TinyELF's Memory Contents editor, available from the Debug menu, allows memory to be changed regardless of whether or not the Memory Protect switch is set.Chapter 2 of A Short Course in Programming discusses the use of the Memory Protect switch.
Use the Input key, labeled "I" on the keypad, to input bytes into memory in Load mode, or to step through and examine memory when Load mode is used while the Memory Protect switch is on. In Run mode, pressing the Input key turns on a signal to the simulated 1802 called External Flag 4, or EF4 for short. 1802 programs can test the condition of this flag and take different actions depending on whether or not it is set.
The instructions that test the state of EF4 are B4 (branch if EF4 is on) and BN4 (branch if EF4 is off), both of which are discussed in Chapter 3 of A Short Course in Programming. Information on using the Input key to load or examine programs may be found in Chapter 2.
An ASCII (alphanumeric) keyboard was available for real ELF II computers. An ELF II so equipped would then have two physical keyboards: the hex keypad and the ASCII keyboard.
Your Mac has only one physical keyboard, so TinyELF provides a control to allow it to act as either the hexpad or an ASCII keyboard.
When Hexpad is selected, the hexadecimal digits "0-F" simulate clicking the "0-F" buttons on the displayed hexpad. Additionally, the "R" key toggles the Run switch, "L" toggles Load, "M" toggles the Memory Protect switch, and the Enter or "I" key clicks the Input button.
When ASCII is selected, characters from your Mac's keyboard are fed into input port 7 of the 1802, and the 1802's External Flag 3 (EF3) signal is momentarily raised to let it know there is a character to process. An 1802 program can test the state of EF3 using the B3 (branch if EF3 is on) and BN3 (branch if EF3 is off) instructions, and read the character from the input port using an INP 7 (input from port 7) instruction.