📄 main.asm
字号:
.include "pbir.h" .include "../serial/serial.h" .module main_asmAUTOSTART = 0PAULMON = 1;---------------------------------------------------------;;Bits .area bits (ABS)irprefound: .blkb 1;---------------------------------------------------------;;Data .area data (REL)bits: .blkb 1irbitcnt: .blkb 1irmesg: .blkb 2ircode: .blkb 1irtimersample: .blkb 2stack:;---------------------------------------------------------;;Interrupt vectors .area vectors (REL);reset vector ljmp init;ext int0 vector (base + 3) ljmp pbir_isr .blkb 5;timer0 vector (base + 11) reti .blkb 7;ext int1 vector (base + 19) reti .blkb 7;timer1 vector (base + 27) reti .blkb 7;serial vector (base + 35) reti .blkb 7;timer2 vector (base + 43) 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".endif ; PAULMON;---------------------------------------------------------; . = . + 9init:: 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;hello message mov dptr, #initstr lcall pstr;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_startmain_loop1: mov a, #0xffmain_loop2: cjne a, ircode, main_print jnb ri, main_loop2 ljmp 0;print received codemain_print: xch a, ircode mov b, a anl a, #0b00001111 cjne a, #0x8, main_print_not8 mov dptr, #lookup_lsb8 sjmp main_print_lookupmain_print_not8: cjne a, #0x2, main_print_not2 mov dptr, #lookup_lsb2 sjmp main_print_lookupmain_print_not2: jnz main_print_unk mov dptr, #lookup_lsb0main_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_donemain_print_unk: mov a, b lcall phexmain_print_done: lcall newline sjmp main_loop1;---------------------------------------------------------;; Strings & tablesinitstr: .asciz "\r\nPackard Bell Infrared Remote receiver startup\r\n" .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 .IRF7lookup_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 .IRFDlookup_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 + -