Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; Assembly code for printing from 0 to 99 in double segment display
- ORG 00H ; Set origin to 00H
- MOV DPTR, #300H ; Moving Data pointer to 300H
- MOV R0, #10D ; Loop 10 times
- MOV R7, #0D ; Loop variable will increment
- LOOP1: ; Loop of printing [0-9] of right digit
- ; Loop 1 : loops to the position where the next value is present
- MOV DPTR, #300H
- MOV A, R7
- MOV R6, A
- MOV A, R7
- JZ PASS ; Jump if value of A (which is R7) is zero
- LOOP3:
- INC DPTR
- DJNZ R6, LOOP3
- PASS:
- ; Passing value of DPTR in output pin P2 (for left segment)
- INC R7
- MOV A, #00H
- MOVC A, @ A+DPTR
- MOV P2, A
- ; Loop 2 : loops to the position [0-9]
- MOV R1, #10D
- MOV DPTR, #300H
- LOOP2:
- MOV A, #00H
- MOVC A, @ A+DPTR
- MOV P0, A ; Passing output to right segment
- LCALL DELAY ; Note that P0 has segment pins from
- INC DPTR ; higher to lower order
- DJNZ R1, LOOP2
- ;INC DPTR
- DJNZ R0, LOOP1
- DELAY: ; Delay procedure
- MOV R2, #10
- RAI:
- MOV R3, #255
- RA:
- MOV R4, #255
- JA:
- DJNZ R4, JA
- DJNZ R3, RA
- DJNZ R2, RAI
- RET
- ORG 300H
- DB 0C0H ; digit drive pattern for 0
- DB 0F9H ; digit drive pattern for 1
- DB 0A4H ; digit drive pattern for 2
- DB 0B0H ; digit drive pattern for 3
- DB 099H ; digit drive pattern for 4
- DB 092H ; digit drive pattern for 5
- DB 082H ; digit drive pattern for 6
- DB 0F8H ; digit drive pattern for 7
- DB 080H ; digit drive pattern for 8
- DB 090H ;digit drive pattern for 9
- END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement