Advertisement
Guest User

Untitled

a guest
Jul 15th, 2019
735
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; Assembly code for printing from 0 to 99 in double segment display
  2.  
  3. ORG 00H                 ; Set origin to 00H
  4.  
  5. MOV DPTR, #300H         ; Moving Data pointer to 300H
  6. MOV R0, #10D            ; Loop 10 times
  7. MOV R7, #0D             ; Loop variable will increment
  8.  
  9. LOOP1:                  ; Loop of printing [0-9] of right digit
  10.     ; Loop 1 : loops to the position where the next value is present
  11.     MOV DPTR, #300H
  12.     MOV A, R7
  13.     MOV R6, A
  14.     MOV A, R7
  15.  
  16.     JZ PASS             ; Jump if value of A (which is R7) is zero
  17.     LOOP3:
  18.         INC DPTR
  19.         DJNZ R6, LOOP3         
  20.     PASS:
  21.  
  22.     ; Passing value of DPTR in output pin P2 (for left segment)
  23.     INC R7
  24.     MOV A, #00H
  25.     MOVC A, @ A+DPTR
  26.     MOV P2, A
  27.    
  28.     ; Loop 2 : loops to the position [0-9]
  29.     MOV R1, #10D
  30.     MOV DPTR, #300H
  31.     LOOP2:
  32.         MOV A, #00H
  33.         MOVC A, @ A+DPTR
  34.         MOV P0, A           ; Passing output to right segment
  35.         LCALL DELAY         ; Note that P0 has segment pins from
  36.         INC DPTR            ; higher to lower order
  37.         DJNZ R1, LOOP2
  38.          
  39.     ;INC DPTR
  40.     DJNZ R0, LOOP1
  41.  
  42. DELAY:                               ; Delay procedure
  43.     MOV R2, #10
  44.     RAI:
  45.         MOV R3, #255
  46.     RA:
  47.         MOV R4, #255
  48.     JA:
  49.         DJNZ R4, JA
  50.         DJNZ R3, RA
  51.         DJNZ R2, RAI
  52.     RET
  53.  
  54. ORG 300H
  55. DB 0C0H  ; digit drive pattern for 0
  56. DB 0F9H  ; digit drive pattern for 1
  57. DB 0A4H  ; digit drive pattern for 2
  58. DB 0B0H  ; digit drive pattern for 3
  59. DB 099H  ; digit drive pattern for 4
  60. DB 092H  ; digit drive pattern for 5
  61. DB 082H  ; digit drive pattern for 6
  62. DB 0F8H  ; digit drive pattern for 7
  63. DB 080H  ; digit drive pattern for 8
  64. DB 090H  ;digit drive pattern for 9
  65. END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement