Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ORG 0
- MOV R0,#30h
- MOV R1,#40h
- MOV R2,#4
- LCALL IRAMtoIRAM
- MOV DPTR, #100h
- MOV R0, #50h
- MOV R2, #1h
- LCALL IRAMtoXRAM
- SJMP $
- ;--------------------------------------------------
- ; Returns:
- ; R0 - read key
- ;--------------------------------------------------
- read_key:
- PUSH ACC
- SETB P5.7
- MOV 20H, P.7
- JB 20H.3, pressed_1
- JB 20H.2, pressed_2
- JB 20H.1, pressed_3
- JB 20H.0, pressed_A
- CLR P5.7
- SETB P5.6
- MOV 20H, P.7
- JB 20H.3, pressed_4
- JB 20H.2, pressed_5
- JB 20H.1, pressed_6
- JB 20H.0, pressed_B
- CLR P5.6
- SETB P5.5
- MOV 20H, P.7
- JB 20H.3, pressed_7
- JB 20H.2, pressed_8
- JB 20H.1, pressed_9
- JB 20H.0, pressed_C
- CLR P5.5
- MOV 20H, P.7
- JB 20H.3, pressed_asterix
- JB 20H.2, pressed_0
- JB 20H.1, pressed_hash
- JB 20H.0, pressed_D
- JMP pressed_none
- pressed_1:
- MOV R0, '1'
- JMP key_read
- pressed_2:
- MOV R0, '2'
- JMP key_read
- pressed_3:
- MOV R0, '3'
- JMP key_read
- pressed_A:
- MOV R0, 'A'
- JMP key_read
- pressed_4:
- MOV R0, '4'
- JMP key_read
- pressed_5:
- MOV R0, '5'
- JMP key_read
- pressed_6:
- MOV R0, '6'
- JMP key_read
- pressed_B:
- MOV R0, 'B'
- JMP key_read
- pressed_7:
- MOV R0, '7'
- JMP key_read
- pressed_8:
- MOV R0, '8'
- JMP key_read
- pressed_9:
- MOV R0, '9'
- JMP key_read
- pressed_C:
- MOV R0, 'C'
- JMP key_read
- pressed_asterix:
- MOV R0, '*'
- JMP key_read
- pressed_0:
- MOV R0, '0'
- JMP key_read
- pressed_hash:
- MOV R0, '#'
- JMP key_read
- pressed_D:
- MOV R0, 'D'
- JMP key_read
- pressed_none:
- MOV R0, 'X'
- key_read:
- POP ACC
- RET
- ;--------------------------------------------------
- ; R0 - source adress
- ; R1 - destination address
- ; R2 - size
- ;--------------------------------------------------
- IRAMtoIRAM:
- MOV A, @R0
- MOV @R1, A
- INC R0
- INC R1
- DJNZ R2, IRAMtoIRAM
- RET
- ;--------------------------------------------------
- ; R0 - source adress
- ; DPTR - destination address
- ; R2 - size
- ;--------------------------------------------------
- IRAMtoXRAM:
- MOV A, @R0
- MOVX @DPTR, A
- INC R0
- INC DPTR
- DJNZ R2, IRAMtoXRAM
- RET
- END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement