Advertisement
diogoml

Untitled

Oct 21st, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.37 KB | None | 0 0
  1. ;====================================================================
  2. ; Main.asm file generated by New Project wizard
  3. ;
  4. ; Created: qua out 9 2019
  5. ; Processor: AT89C51
  6. ; Compiler: ASEM-51 (Proteus)
  7. ;====================================================================
  8.  
  9. $NOMOD51
  10. $INCLUDE (8051.MCU)
  11.  
  12. ;====================================================================
  13. ; DEFINITIONS
  14. ;====================================================================
  15.  
  16. ;====================================================================
  17. ; VARIABLES
  18. ;====================================================================
  19. SearchOK bit 20h.0
  20. Counter equ 0Eh
  21. ;====================================================================
  22. ; RESET and INTERRUPT VECTORS
  23. ;====================================================================
  24.  
  25. ; Reset Vector
  26. org 0000h
  27. jmp inicio
  28.  
  29. ;====================================================================
  30. ; CODE SEGMENT
  31. ;====================================================================
  32.  
  33. org 0100h
  34. mov a,0
  35. call convert
  36. mov p0,a
  37. inicio: call READ_KEY
  38. jnb SearchOK,inicio
  39. mov a,b
  40. call convert
  41. mov p0,a
  42. sjmp inicio
  43. convert: anl a,#0fh
  44. mov dptr,#table
  45. movc a,@a+dptr
  46. cpl a
  47. ret
  48. table:
  49. db 00111111b ;0
  50. db 00000110b ;1
  51. db 01011011b ;2
  52. db 01001111b ;3
  53. db 01100110b ;4
  54. db 01101101b ;5
  55. db 01111100b ;6
  56. db 0000011b ;7
  57. db 01111111b ;8
  58. db 01100111b ;9
  59.  
  60. READ_KEY:
  61. clr SearchOK
  62. mov P1,#0FEh
  63. mov A,P1
  64. cjne A,#0FEh,leu
  65. mov P1,#0FDh
  66. mov A,P1
  67. cjne A,#0FDh,leu
  68. mov P1,#0FBh
  69. mov A,P1
  70. cjne A,#0FBh,leu
  71. mov P1,#0F7h
  72. mov A,P1
  73. cjne A,#0F7h,leu
  74. RET
  75. leu:
  76. mov B,A
  77. mov Counter,#0
  78. mov dptr,#codigos_tec
  79. procura_codigo_lido:
  80. clr A
  81. movc A,@A+dptr
  82. jz sai
  83. cjne A,B,inc_ponteiros
  84. procura_funcao_tecla:
  85. mov dptr,#funcoes_tec
  86. mov A,Counter
  87. movc A,@A+dptr
  88. setb SearchOK
  89. mov b,a
  90. call solta_tecla
  91. sai:
  92. ret
  93. inc_ponteiros:
  94. inc dptr
  95. inc Counter
  96. sjmp procura_codigo_lido
  97. solta_tecla:
  98. mov p1,#0F0h
  99. st:
  100. mov A,P1
  101. cjne A,#0F0h,st
  102. RET
  103. codigos_tec:
  104. db 0EEh,0DEh,0BEh,7Eh
  105. db 0EDh,0DDh,0BDh,7Dh
  106. db 0EBh,0DBh,0BBh,7Bh
  107. db 0E7h,0D7h,0B7h,77h,0
  108. funcoes_tec:
  109. db '7','8','9',':'
  110. db '4','5','6',';'
  111. db '1','2','3','<'
  112. db 'o','0','>','=',0
  113. ;====================================================================
  114. END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement