

Statement: Write a program to output contents of B register LSB to MSB on the SOD pin.
Source program:
MVI C, 08H : Initialize count with 8
MOV A, B
BACK: RRC : Rotate B register contents right
MOV B, A : Save contents of register B
JNC SKIP : If no carry skip
MVI A, COH
SIM : If carry, send high on SOD
JMP NEXT
SKIP: MVI A, 40H
SIM : If no carry, send low on SOD.
NEXT: CALL DELAY : Wait for specific time
DCR C : Decrement count by 1
JNZ BACK : if count = 0 Stop, if not repeat
HLT : Stop program execution
MVI C, 08H : Initialize count with 8
MOV A, B
BACK: RRC : Rotate B register contents right
MOV B, A : Save contents of register B
JNC SKIP : If no carry skip
MVI A, COH
SIM : If carry, send high on SOD
JMP NEXT
SKIP: MVI A, 40H
SIM : If no carry, send low on SOD.
NEXT: CALL DELAY : Wait for specific time
DCR C : Decrement count by 1
JNZ BACK : if count = 0 Stop, if not repeat
HLT : Stop program execution
Delay subroutine:
Delay: LXI D, Count
Back: DCX D
MOV A, D
ORA E
JNZ Back
RET
Delay: LXI D, Count
Back: DCX D
MOV A, D
ORA E
JNZ Back
RET
No comments:
Post a Comment