Statement:Write assembly language program to with proper comments for the following: To display decimal decrementing counter (99 to 00) at port 05 H with delay of half seconds between .each count. Write as well the delay routine giving delay of half seconds. Operating frequency of microprocessor is 3.072 MHz. Neglect delay for the main program.
Source Program:
MVI C, 99H : Initialize counter
BACK: MOV A, C
ANI OF : Mask higher nibble
CPI OF
JNZ SKIP
MOV A, C
SUI 06 : Subtract 6 to adjust decimal count
MOV D, A
SKIP: MOV A, C
OUT 05 : send count on output port
CALL Delay : Wait for 0.5 seconds
DCR C : decrement count
MOV A, C
CPI FF
JNZ BACK : If not zero, repeat
HLT : Stop execution
Delay subroutine:
Delay: LXI D, Count
Back: DCX D : 6 T-states
MOV A, D : 4 T-states
ORA E : 4 T-states
JNZ Back : 10 T-states
RET
MVI C, 99H : Initialize counter
BACK: MOV A, C
ANI OF : Mask higher nibble
CPI OF
JNZ SKIP
MOV A, C
SUI 06 : Subtract 6 to adjust decimal count
MOV D, A
SKIP: MOV A, C
OUT 05 : send count on output port
CALL Delay : Wait for 0.5 seconds
DCR C : decrement count
MOV A, C
CPI FF
JNZ BACK : If not zero, repeat
HLT : Stop execution
Delay subroutine:
Delay: LXI D, Count
Back: DCX D : 6 T-states
MOV A, D : 4 T-states
ORA E : 4 T-states
JNZ Back : 10 T-states
RET
No comments:
Post a Comment