PROGRAM NAME: Walkingbit
DATE: August 2011
BY: Unknown
COMMENT: This short program turn on the most significant LED, delays and then rotates (walks) one LED to the right. Once all eight LEDs are walked through, the program repeats forever.
REGISTERS USED:
R0 Program counter.
R1 Delay counter.
R2 Memory pointer to current bit pattern.
0000 E2START: SEX R2 ; Set X to point at R2.
0001 F8 17 LDI PATTERN ; R2 points at RAM location with the PATTERN.
0003 A2 PLO R2
0004 F8 00 LDI 00h
0006 B2 PHI R2
0007 FD 00 SDI 00h ; Set the DF to 1 for start pattern.
0009 52 WALK: STR R2 ; Save the current bit pattern.
000A 64 OUT 4 ; Display the pattern.
000B 22 DEC R2 ; Undo the increment from the OUT command.
000C F8 08 DELAY: LDI 08h ; Set delay in R1 to 8 x 256 = 2048.
000E B1 PHI R1
000F 21 DLOOP: DEC R1 ; Decrement delay count in R1.
0010 91 GHI R1 ; If not done with delay do another round.
0011 3A 0F BNZ DLOOP
0013 02 LDN R2 ; Rotate the pattern one bit to the right.
0014 76 RSHR
0015 30 09 BR WALK ; Do it all again forever.
0017 00 PATTERN: DB 0 ; RAM location of the pattern byte.