bytes, you still have 224 bytes available for your own programs.
Keyboard Systems. Adding a hex keyboard would make your Elf microcomputer even easier to use, with 16 keys labelled 0 through F, you would have to press only two keys for each byte you want to store in memory. In the second article, we described a circuit for monitoring the status of 16 switches or keys. (See POPULAR ELECTRONICS, Sept. 1976, page 38, Fig.3). If you add this circuit and a 16-key hex keyboard, you can use Program 2--EHOPS-256 (Elf Hex OPerating System for 256-byte memory). This program requires 74 bytes of RAM so you still have 182 bytes left for your own programs. You can also use the hex keyboard subroutine as part of your program if desired.
PROGRAM 1--ETOPS-256 0000 F8 20 A1 R1.0 = work 03 E1 X=1 04 6C 64 21 D = toggles 07 3F 07 Wait for IN on 09 37 09 Wait for IN off 0B 32 1D M(1D) if D=00 0D F6 33 11 M(11) if D=01 10 7B Q=1 11 6C A1 R1.0 = toggles 13 3F 13 Wait for IN on 15 37 15 Wait for IN off 17 39 1A M(1A) if Q=0 19 6C M1 = toggles 1A 64 Show M1, R1 + 1 1B 30 13 Repeat M(13) 1D 6C A3 R3.0 = toggles 1F D3 P=3 20 00 Work area 21 User programs from M(21) to M(FF)
After loading EHOPS in memory, you can use it as follows. To load a byte into any memory location from the hex keyboard, set the toggles to 02 and flip the RUN switch up. The 02 toggles tell EHOPS that you want to store bytes in memory. On the hex keyboard, press the most significant digit of a memory address followed by the least-significant digit. This address byte will be displayed and tells EHOPS where you want to start loading bytes in memory. You can now load a sequence of bytes into memory via the hex keyboard. Just press the two digits (most significant first) of each byte you want to load and they will be stored sequentially in memory starting at the selected location.
PROGRAM 2--EHOPS-256 0000 F8 FF A2 R2.0 = work 03 F8 23 A5 R5.0 = BSUB 06 F8 33 A6 R6.0 = HSUB 09 F8 0D A3 R3.0 = M(0D) 0C D3 P=3 0D D5 A1 BSUB, R1.0=D 0F 6C D, M2 = toggles 10 3A 14 M(14) if D != 00 (Note: != means 'not equal') 12 81 A3 R3.0 = R1.0 14 F6 3B 1C M(1C) if D=02 17 D5 E1 BSUB, X=1 19 64 Show M1, R1+1 1A 30 17 Repeat M(17) 1C D5 E1 BSUB, X=1 1E 51 64 M1=D, show M1, R1+1 20 30 1C Repeat M(1C) 22 D3 P=3 (return) BSUB 23 D6 HSUB 24 FE FE D left x 2 26 FE FE D left x 2 28 A0 D6 R1=D, HSUB 2A 80 F1 52 M2=R1 or M2 2D 64 22 Show M2 2F 30 22 Go to M(22) 31 F0 D5 D=M2, P=5 HSUB 33 E2 FC 01 X=2, D+1 36 FA 0F 52 M2=D and 0F 39 62 22 Select key M2 3B 3D 33 M(33) if key off 3D 7B F8 09 Q=1, D=09 40 B4 R4.1=09 41 24 94 R4-1 43 3A 41 M(41) if R4.1 != 00 45 7A Q=0 46 35 46 Wait for key off 48 30 31 Go to M(31)
To examine any memory location (without changing its contents), set the toggles to 01 before you flip the RUN switch up. Using the hex keyboard, enter the one-byte starting address of the sequence of memory locations you want to examine. Press any hex key twice to step through memory and display the stored bytes.
To run a program you've loaded using EHOPS, set the toggles to 00 before flipping the RUN switch up. Using the hex keyboard, enter the one-byte starting address of your program. It will begin running with R3 as the program counter.
PROGRAM 3 0050 F8 FF A1 R1.0 = work 53 F8 00 51 M1=00 56 E1 64 21 Show M1 59 F0 FC 01 51 M1+1 5D F8 10 B2 R2.1 = delay 60 22 R2-1 61 92 3A 60 M(60) if R2.1 != 00 64 30 56 Repeat M(56)
EHOPS controls the hex keyboard with two subroutines called BSUB and HSUB. BSUB calls HSUB by changing the program counter to R6 with a D6 instruction. HSUB continuously scans all 16 hex keyswitches until one is pressed. It provides a switch debounce delay and waits until the key has been released. It then returns control to BSUB with the value of the pressed key in the least-significant digit of the byte in D and M2.
BSUB is called by changing the program counter to R5 with a D5 instruction. It waits until two hex keys have been pressed before returning control to the calling program with the values of the two keys in the two digits of the byte in D and M2. The most-significant digit represents the first key pressed. Any program you write with R3 as the program counter can call BSUB to obtain a byte from the hex keyboard. If you drive a speaker with the Q lines as described in the September article, you will hear an audible click each time a hex key is pressed.
Program 3 can be loaded and run us-[65}