Advertisement
Guest User

Untitled

a guest
Mar 19th, 2019
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.09 KB | None | 0 0
  1. ORG 0
  2.  
  3. MOV R0,#30h
  4. MOV R1,#40h
  5. MOV R2,#4
  6. LCALL IRAMtoIRAM
  7.  
  8.  
  9. MOV DPTR, #100h
  10. MOV R0, #50h
  11. MOV R2, #1h
  12. LCALL IRAMtoXRAM
  13. SJMP $
  14.  
  15. ;--------------------------------------------------
  16. ; Returns:
  17. ; R0 - read key
  18. ;--------------------------------------------------
  19. read_key:
  20. PUSH ACC
  21. SETB P5.7
  22. MOV 20H, P.7
  23. JB 20H.3, pressed_1
  24. JB 20H.2, pressed_2
  25. JB 20H.1, pressed_3
  26. JB 20H.0, pressed_A
  27.  
  28. CLR P5.7
  29. SETB P5.6
  30. MOV 20H, P.7
  31. JB 20H.3, pressed_4
  32. JB 20H.2, pressed_5
  33. JB 20H.1, pressed_6
  34. JB 20H.0, pressed_B
  35.  
  36. CLR P5.6
  37. SETB P5.5
  38. MOV 20H, P.7
  39. JB 20H.3, pressed_7
  40. JB 20H.2, pressed_8
  41. JB 20H.1, pressed_9
  42. JB 20H.0, pressed_C
  43.  
  44. CLR P5.5
  45. MOV 20H, P.7
  46. JB 20H.3, pressed_asterix
  47. JB 20H.2, pressed_0
  48. JB 20H.1, pressed_hash
  49. JB 20H.0, pressed_D
  50. JMP pressed_none
  51.  
  52. pressed_1:
  53. MOV R0, '1'
  54. JMP key_read
  55.  
  56. pressed_2:
  57. MOV R0, '2'
  58. JMP key_read
  59.  
  60. pressed_3:
  61. MOV R0, '3'
  62. JMP key_read
  63.  
  64. pressed_A:
  65. MOV R0, 'A'
  66. JMP key_read
  67.  
  68. pressed_4:
  69. MOV R0, '4'
  70. JMP key_read
  71.  
  72. pressed_5:
  73. MOV R0, '5'
  74. JMP key_read
  75.  
  76. pressed_6:
  77. MOV R0, '6'
  78. JMP key_read
  79.  
  80. pressed_B:
  81. MOV R0, 'B'
  82. JMP key_read
  83.  
  84. pressed_7:
  85. MOV R0, '7'
  86. JMP key_read
  87.  
  88. pressed_8:
  89. MOV R0, '8'
  90. JMP key_read
  91.  
  92. pressed_9:
  93. MOV R0, '9'
  94. JMP key_read
  95.  
  96. pressed_C:
  97. MOV R0, 'C'
  98. JMP key_read
  99.  
  100. pressed_asterix:
  101. MOV R0, '*'
  102. JMP key_read
  103.  
  104. pressed_0:
  105. MOV R0, '0'
  106. JMP key_read
  107.  
  108. pressed_hash:
  109. MOV R0, '#'
  110. JMP key_read
  111.  
  112. pressed_D:
  113. MOV R0, 'D'
  114. JMP key_read
  115.  
  116. pressed_none:
  117. MOV R0, 'X'
  118.  
  119. key_read:
  120. POP ACC
  121. RET
  122.  
  123. ;--------------------------------------------------
  124. ; R0 - source adress
  125. ; R1 - destination address
  126. ; R2 - size
  127. ;--------------------------------------------------
  128. IRAMtoIRAM:
  129. MOV A, @R0
  130. MOV @R1, A
  131. INC R0
  132. INC R1
  133. DJNZ R2, IRAMtoIRAM
  134. RET
  135.  
  136.  
  137.  
  138. ;--------------------------------------------------
  139. ; R0 - source adress
  140. ; DPTR - destination address
  141. ; R2 - size
  142. ;--------------------------------------------------
  143. IRAMtoXRAM:
  144. MOV A, @R0
  145. MOVX @DPTR, A
  146. INC R0
  147. INC DPTR
  148. DJNZ R2, IRAMtoXRAM
  149. RET
  150.  
  151.  
  152. END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement