Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;====================================================================
- ; Main.asm file generated by New Project wizard
- ;
- ; Created: qua out 9 2019
- ; Processor: AT89C51
- ; Compiler: ASEM-51 (Proteus)
- ;====================================================================
- $NOMOD51
- $INCLUDE (8051.MCU)
- ;====================================================================
- ; DEFINITIONS
- ;====================================================================
- ;====================================================================
- ; VARIABLES
- ;====================================================================
- SearchOK bit 20h.0
- Counter equ 0Eh
- ;====================================================================
- ; RESET and INTERRUPT VECTORS
- ;====================================================================
- ; Reset Vector
- org 0000h
- jmp inicio
- ;====================================================================
- ; CODE SEGMENT
- ;====================================================================
- org 0100h
- mov a,0
- call convert
- mov p0,a
- inicio: call READ_KEY
- jnb SearchOK,inicio
- mov a,b
- call convert
- mov p0,a
- sjmp inicio
- convert: anl a,#0fh
- mov dptr,#table
- movc a,@a+dptr
- cpl a
- ret
- table:
- db 00111111b ;0
- db 00000110b ;1
- db 01011011b ;2
- db 01001111b ;3
- db 01100110b ;4
- db 01101101b ;5
- db 01111100b ;6
- db 0000011b ;7
- db 01111111b ;8
- db 01100111b ;9
- READ_KEY:
- clr SearchOK
- mov P1,#0FEh
- mov A,P1
- cjne A,#0FEh,leu
- mov P1,#0FDh
- mov A,P1
- cjne A,#0FDh,leu
- mov P1,#0FBh
- mov A,P1
- cjne A,#0FBh,leu
- mov P1,#0F7h
- mov A,P1
- cjne A,#0F7h,leu
- RET
- leu:
- mov B,A
- mov Counter,#0
- mov dptr,#codigos_tec
- procura_codigo_lido:
- clr A
- movc A,@A+dptr
- jz sai
- cjne A,B,inc_ponteiros
- procura_funcao_tecla:
- mov dptr,#funcoes_tec
- mov A,Counter
- movc A,@A+dptr
- setb SearchOK
- mov b,a
- call solta_tecla
- sai:
- ret
- inc_ponteiros:
- inc dptr
- inc Counter
- sjmp procura_codigo_lido
- solta_tecla:
- mov p1,#0F0h
- st:
- mov A,P1
- cjne A,#0F0h,st
- RET
- codigos_tec:
- db 0EEh,0DEh,0BEh,7Eh
- db 0EDh,0DDh,0BDh,7Dh
- db 0EBh,0DBh,0BBh,7Bh
- db 0E7h,0D7h,0B7h,77h,0
- funcoes_tec:
- db '7','8','9',':'
- db '4','5','6',';'
- db '1','2','3','<'
- db 'o','0','>','=',0
- ;====================================================================
- END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement