//----------------------------------- // Initialise the register variables //----------------------------------- 0000 mvi c,FF // Set direction = right 0EFF = 0000 1110 // 0 is left, 0xFF is right 1111 1111 0002 mvi d,1 // Set position = 1 1601 = 0001 0110 0000 0001 :loop //----------------------------------------- // Move the recorded position of the light //----------------------------------------- 0004 mov a,d // Load Position into Accumulator 7A = 0111 1010 0005 cpi 128 FE80 = 1111 1110 1000 0000 0007 jz switchDirection // Position = 128? CA0F00 = 1100 1010 0000 1111 0000 0000 000A cpi 1 FE01 = 1111 1110 0000 0001 000C jnz movePosition // Position != 1? C21200 = 1100 0010 0001 0010 0000 0000 // Switch the direction of the light :switchDirection 000F mov a,c // Load Direction into Accumulator 79 = 0111 1001 0010 cma // Compliment the accumulator 2F = 0010 1111 0011 mov c,a // Store result back in the Direction 4F = 0100 1111 :movePosition 0012 mov a,c // Load Direction into Accumulator 79 = 0111 1001 0013 cpi 0 // Direction != left? FE00 = 1111 1110 0000 0000 0015 jnz moveRight C21E00 = 1100 0010 0001 1110 0000 0000 // Move position Left 0018 mov a,d // Load Position into Accumulator 7A = 0111 1010 0019 ral // Rotate left 17 = 0001 0111 001A mov d,a // Store result back in the Position 57 = 0101 0111 001B jmp outputLight C32100 = 1100 0011 0010 0001 0000 0000 // Move position Right :moveRight 001E mov a,d // Load Position into Accumulator 7A = 0111 1010 001F rar // Rotate right 1F = 0001 1111 0020 mov d,a // Store result back in Position 57 = 0101 0111 //----------------------------------------------- // Output the light to PROGRAMMED OUTPUT display //----------------------------------------------- :outputLight 0021 mov a,d // Load Position into Accumulator 7A = 0111 1010 0022 cma // Compliment Accumulator due 2F = 0010 1111 // to way PROGRAMMED OUTPUT works 0023 out FF // Output to PROGRAMMED OUTPUT D3FF = 1101 0011 1111 1111 //----------------------- // User controlled Delay //----------------------- 0025 in FF // User delay from PROGRAMMED INPUT DBFF = 1101 1011 // port 0xFF 1111 1111 0027 inr a // Make sure 0 is minimum delay 3C = 0011 1100 :delayOuter 0028 mvi b, 02 // Set register B loop delay to 2 0602 = 0000 0110 0000 0010 :delayInner1 002A mvi e, FF // Set register E loop delay to 255 1EFF = 0001 1110 1111 1111 :delayInner2 002C dcr e // Decrement Register E 1D = 0001 1101 002D jnz delayInner2 // Loop until Register E = 0 C22C00 = 1100 0010 0010 1100 0000 0000 0030 dcr b // Decrement Register B 05 = 0000 0101 0031 jnz delayInner1 // Loop until Register B = 0 C22A00 = 1100 0010 0010 1010 0000 0000 0034 dcr a // Decrement Accumulator 3D = 0011 1101 0035 jnz delayOuter // Loop until Register A = 0 C22800 = 1100 0010 0010 1000 0000 0000 //------------------- // Loop indefinitely //------------------- 0038 jmp loop C30400 = 1100 0011 0000 0100 0000 0000