Experiment-6
Exercises
Exercise-1
; Realize a 2-digit decimal down counter which counts down from 90 to 30 and
; then repeats. Display each count in the data field of the display for 0.5 sec.
START:
MOV A, #90H ; INITIALISE
ITER:
MOV 60H, A ; COPY DATA TO DISPLAY PLACEHOLDERS
; LCALL UPDDT ; DISPLAY PROGRAM
MOV P2, A
LCALL DELAY ; AWAIT 0.5 SECONDS
ADD A, #99H ; ADD HUNDRED'S COMPLEMENT FORM
DA A ; DECIMALLY ADJUST ACCUMULATOR
CJNE A, #29H, ITER ; REPEAT DECREMENT. TILL (30D - 1), AND IN HEX
SJMP START ; REPEAT IN A LOOP
DELAY:
; AWAIT (08H*0FAH*0FAH) MACHINE CYCLES => 0.5 SECONDS
MOV R3, #08H
UP1:
MOV R4, #0FAH
UP2:
MOV R5, #0FAH
DJNZ R4, UP2
DJNZ R3, UP1
RET ; RETURN BACK TO THE MAIN LOOP
END
Exercise-4
; Implement an 8 bit ring counter.
MOV A, #01H ; INITIALISE
ITER:
MOV 60H, A ; COPY DATA TO DISPLAY PLACEHOLDERS
LCALL UPDDT ; DISPLAY PROGRAM
LCALL DELAY ; AWAIT
RL A ; LEFT SHIFT ACCUMULATOR, WITHOUT CARRY
SJMP ITER ; REPEAT IN A LOOP
DELAY:
; AWAIT (04H*0FFH*0FFH) MACHINE CYCLES => ~0.26 SECONDS
MOV R3, #04H
UP1:
MOV R4, #0FFH
UP2:
MOV R5, #0FFH
DJNZ R4, UP2
DJNZ R3, UP1
RET ; RETURN BACK TO THE MAIN LOOP
END
Problems
Problem-1
; Implement an 8 - bit Octal up counter.
START:
MOV A, #00H ; INITIALISE
MOV R2, #08H ; FOR UPPER NIBBLE (OCTAL BASE)
ITER:
MOV R1, #08H ; FOR LOWER NIBBLE (OCTAL BASE)
L_ITER:
MOV 60H, A ; COPY DATA TO DISPLAY PLACEHOLDERS
PUSH A ; SAVE ACCUMULATOR
LCALL UPDDT ; DISPLAY PROGRAM
LCALL DELAY ; AWAIT
POP A ; RETRIEVE ACCUMULATOR
ADD A, #01H ; INCREMENT LOWER NIBBLE
DJNZ R1, L_ITER ; FOR LOWER NIBBLE UPDATES
U_ITER:
ADD A, #08H ; INCREMENT UPPER NIBBLE
DJNZ R2, ITER ; FOR UPPER NIBBLE UPDATES
SJMP START ; REPEAT IN A LOOP
DELAY:
; AWAIT (04H*0FFH*0FFH) MACHINE CYCLES => ~0.26 SECONDS
MOV R3, #04H
UP1:
MOV R4, #0FFH
UP2:
MOV R5, #0FFH
DJNZ R4, UP2
DJNZ R3, UP1
RET ; RETURN BACK TO THE MAIN LOOP
END
Problem-3
; Realize an 8-bit Johnson counter.
; LIMITATIONS: (1111 1111) AND (0000 0000) ARE REPEATED TWICE.
CLR C ; CLEAR CARRY
MOV A, #00H ; INITIALISE
ITER:
MOV 60H, A ; COPY DATA TO DISPLAY PLACEHOLDERS
PUSH A ; SAVE ACCUMULATOR
LCALL UPDDT ; DISPLAY PROGRAM
LCALL DELAY ; AWAIT
POP A ; RETRIEVE ACCUMULATOR
CPL C ; COMPLEMENT CARRY BIT
RLC A ; RIGHT SHIFT ACCUMULATOR
SJMP ITER ; REPEAT IN A LOOP
DELAY:
; AWAIT (04H*0FFH*0FFH) MACHINE CYCLES => ~0.26 SECONDS
MOV R3, #04H
UP1:
MOV R4, #0FFH
UP2:
MOV R5, #0FFH
DJNZ R4, UP2
DJNZ R3, UP1
RET ; RETURN BACK TO THE MAIN LOOP
END
Last updated