|
A few simple programs to exercise the COSMAC Elf.
Program: Blinky Mem Comment: Scans through memory, displaying each byte with a delay for visibility. For suitably random memory contents, displays some suitably random blinking lights. Also blinks the Q LED as the scan passes through 0 mod 256. Source: bh (2011 Aug) Registers: 0: PC 1: delay counter 2: pointer into mem Addr Mem Label Instr Comment ---- --- ------- --------------- --------------------------- 0 E2 Start SEX 2 X refs R2 1 F8 LDI 0 0 -> R2 2 00 3 A2 PLO 2 4 B2 PHI 2 5 82 Loop GLO 2 Check low bits of pointer 6 CE LSZ for 0. 7 7A REQ And display Q appropriately. 8 38 SKP 9 7B SEQ A 64 OUT 4 Display mem, increment pointer. B F8 delay LDI 8 Delay is 256*num. C 08 D B1 PHI 1 Load delay into high bits. E 21 DlyLp DEC 1 Count down F 91 GHI 1 10 3A BNZ DlyLp until 0. 11 0E 12 30 BR Loop Loop for next mem location. 13 05
Program: Walking Bit Comment: A simple blinky-light program to rotate a bit around the 8 display LEDs. Source: bh (2011 Aug) Registers: 0: PC 1: delay counter 2: pointer to bit pattern Addr Mem Label Instr Comment ---- --- ------- --------------- --------------------------- 0 E2 Start SEX 2 X refs R2 1 F8 LDI BitPtrn R2 refs BitPtrn 2 17 3 A2 PLO 2 4 F8 LDI 0 5 00 6 B2 PHI 2 7 FD SDI 0 Set DF to 1 to start bit pattern. 8 00 9 52 WalkLp STR 2 Save bit pattern. A 64 OUT 4 Display bit pattern B 22 DEC 2 and undo increment from OUT. C F8 delay LDI 8 Delay is 256*num. D 08 E B1 PHI 1 Load delay into high bits. F 21 DlyLoop DEC 1 Count down. 10 91 GHI 1 11 3A BNZ DlyLoop Loop until 0. 12 0F 13 02 LDN 2 Rotate BitPtrn 14 76 RSHR to right. 15 30 BR WalkLp Loop to display. 16 09 17 - BitPtrn - the bit pattern
Program: Q Toggle (Blink) Comment: Toggle the Q Bit and so blink the Q LED. Source: Popular Electronics Sep 1976 Elf article Registers: 0: PC 1: delay counter Addr Mem Label Instr Comment ---- --- ------- --------------- --------------------------- 0 7A REQ Q off 1 F8 Delay LDI 16 Delay will be 256*num 2 10 3 B1 PHI 1 Load delay into high bits of R1 4 21 DlyLoop DEC 1 --R(1) 5 91 GHI 1 R(1).1 -> D 6 3A BNZ DlyLoop Loop until 0 7 04 8 31 BQ 0 If Q is on go turn it off. 9 00 10 7B SEQ Turn Q on. 11 30 BR Delay Go delay. 12 01
Program: Tone Generator Comment: Toggles Q at a rate determined by the data switches. With Q connected appropriately to a speaker, tones of different frequencies will be generated. Source: bh (2011 Aug) Registers: 0: PC 1: delay counter 2: dummy pointer for IN Addr Mem Label Instr Comment ---- --- ------- --------------- --------------------------- 0 E2 Start SEX 2 X refs R2. 1 F8 LDI 0 Init R2 to point to dummy. 2 00 3 B2 PHI 2 4 F8 LDI dummy IN will need location to load into. 5 12 6 A2 PLO 2 7 7A QOff REQ Turn Q off. 8 6C Delay IN 4 Get delay count from switches. 9 FF DelayLp SMI 1 Count down A 01 B 3A BNZ DlyLp until 0. C 09 D 31 BQ QOff If Q is on go turn it off. E 07 F 7B SEQ Turn Q on. 10 30 BR Delay Go delay. 11 08 12 - dummy - Dummy location for IN.
1802 Instructions
| Programs
| Log
COSMAC Elf |
bhilpert 2011 Aug |