📄 main.asm
字号:
.include "pbir.h"
.include "../lib/serial.h"
.module main_asm
AUTOSTART = 0
PAULMON = 0
;---------------------------------------------------------;
;Bits
.area bits (ABS)
irprefound:
.blkb 1
;---------------------------------------------------------;
;Data
.area data (REL)
bits:
.blkb 1
irbitcnt:
.blkb 1
irmesg:
.blkb 2
ircode:
.blkb 1
irtimersample:
.blkb 2
stack:
;---------------------------------------------------------;
;Interrupt vectors
.area vectors (REL)
;reset vector
ljmp init
;ext int0 vector (base + 3)
ljmp pbir_isr
.blkb 5
;timer0 vector (base + 0x0b)
reti
.blkb 7
;ext int1 vector (base + 0x13)
reti
.blkb 7
;timer1 vector (base + 0x1b)
reti
.blkb 7
;serial vector (base + 0x23)
reti
.blkb 7
;timer2 vector (base + 0x2b) 8052 ONLY
reti
;---------------------------------------------------------;
; Code
.area code (REL)
; Paulmon header
.if PAULMON
.db 0xA5, 0xE5, 0xE0, 0xA5 ;signature bytes
.if AUTOSTART
.db 253, 0, 0, 0 ;id
.else
.db 254, 'T, 0, 0 ;id (254=user installed command)
.endif
.db 0, 0, 0, 0 ;reserved
.db 0, 0, 0, 0 ;reserved
.db 0, 0, 0, 0 ;reserved
.db 0, 0, 0, 0 ;reserved
.db 0, 0, 0, 0 ;user defined
.db 255, 255, 255, 255 ;length and checksum (255=unused)
.asciz "Packard Bell Remote RX"
. = . + 9
.endif ; PAULMON
;---------------------------------------------------------;
init::
clr a
mov ie, a ;all interrupts off
mov ip, a
mov psw, a
mov tmod, a
mov tcon, a
mov sp, #stack
lcall serial_init
.if PAULMON
;hello message
mov dptr, #initstr
lcall pstr
.endif
;timer 0
orl tmod, #0x01 ;16 bit counter
setb tr0
lcall pbir_init
;interrupt 0
setb p3.2 ;enable int0 edge triggered
setb it0
setb ex0
lcall pbir_start
setb ea
main_loop:
mov a, #0xff
cjne a, ircode, main_print
jnb ri, main_loop
lcall cin
lcall cout
sjmp main_loop
;print received code
main_print:
xch a, ircode
mov b, a
anl a, #0b00001111
cjne a, #0x8, main_print_not8
mov dptr, #lookup_lsb8
sjmp main_print_lookup
main_print_not8:
cjne a, #0x2, main_print_not2
mov dptr, #lookup_lsb2
sjmp main_print_lookup
main_print_not2:
jnz main_print_unk
mov dptr, #lookup_lsb0
main_print_lookup:
mov a, b
anl a, #0xf0
xrl a, #0xf0 ;table is reversed (from hcll version)
swap a
rl a
mov b, a
movc a, @a+dptr
mov r6, a
mov a, b
inc a
movc a, @a+dptr
mov r7, a
mov dph, r6
mov dpl, r7
lcall pstr
sjmp main_print_done
main_print_unk:
mov a, b
lcall phex
main_print_done:
lcall newline
sjmp main_loop
;---------------------------------------------------------;
; Strings & tables
.if PAULMON
initstr:
.asciz "\r\nPackard Bell Infrared Remote receiver startup\r\n"
.endif
.IR0F: .asciz "DISPLAY"
.IR17: .asciz "IR3"
.IR1D: .asciz "AUX3"
.IR1F: .asciz "AUX1"
.IR2F: .asciz "RIGHT"
.IR37: .asciz "VOLDOWN"
.IR3D: .asciz "IR2"
.IR3F: .asciz "IR8"
.IR47: .asciz "LMOUSE"
.IR4F: .asciz "CHNUP"
.IR57: .asciz "IR9"
.IR5D: .asciz "AUX2"
.IR5F: .asciz "CD"
.IR6F: .asciz "UP"
.IR77: .asciz "MUTE"
.IR7D: .asciz "IR5"
.IR7F: .asciz "IR0"
.IR8F: .asciz "ENTER"
.IR97: .asciz "IR6"
.IR9D: .asciz "SRS"
.IR9F: .asciz "PHONE"
.IRAF: .asciz "DOWN"
.IRB7: .asciz "VOLUP"
.IRBD: .asciz "IR1"
.IRBF: .asciz "IR7"
.IRC7: .asciz "RMOUSE"
.IRCF: .asciz "CHNDOWN"
.IRD7: .asciz "HASH"
.IRDD: .asciz "MESSAGE"
.IRDF: .asciz "HELP"
.IREF: .asciz "LEFT"
.IRF7: .asciz "MENU"
.IRFD: .asciz "IR4"
.IRFF: .asciz "STAR"
.IRERROR:.asciz "ERROR"
;
; string lookup table
;
lookup_lsb8:
.word .IRERROR
.word .IR17
.word .IRERROR
.word .IR37
.word .IR47
.word .IR57
.word .IRERROR
.word .IR77
.word .IRERROR
.word .IR97
.word .IRERROR
.word .IRB7
.word .IRC7
.word .IRD7
.word .IRERROR
.word .IRF7
lookup_lsb2:
.word .IRERROR
.word .IR1D
.word .IRERROR
.word .IR3D
.word .IRERROR
.word .IR5D
.word .IRERROR
.word .IR7D
.word .IRERROR
.word .IR9D
.word .IRERROR
.word .IRBD
.word .IRERROR
.word .IRDD
.word .IRERROR
.word .IRFD
lookup_lsb0:
.word .IR0F
.word .IR1F
.word .IR2F
.word .IR3F
.word .IR4F
.word .IR5F
.word .IR6F
.word .IR7F
.word .IR8F
.word .IR9F
.word .IRAF
.word .IRBF
.word .IRCF
.word .IRDF
.word .IREF
.word .IRFF
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -