sourcelibs/Hex1000/demos/counter.xtl

1⍝!/usr/bin/env xetal 2⍝ HEX1000 counting on its outputs: three instructions in a loop, run 3⍝ for 12 instructions. First the program as it sits in the ROM, in the 4⍝ order it runs: PC steps 0, 1, 3 (the shift register's order, which 5⍝ the assembler follows), so the third instruction is at address 3. 6⍝ Then the registers after reset and after each instruction: A counts 7⍝ at IA, BR takes PC back to 0 (S is 1, so it is always taken), and O 8⍝ is A and S (bit 4, so 16 + A) as TDO left it, one IA behind. 9⍝ Run with "just demo-lib Hex1000 counter". 10ʰˣ⁼u̲se< "Hex1000" 11rom ← ʰˣa̲ssemble "loop: TDO ; A and S to the outputs\nIA ; count\nBR loop ; S is 1: always taken" 120 ʰˣl̲isting rom 13ʰˣRegNames ʰˣt̲able rom ʰˣt̲race (ʰˣReset, 0, 12)