📄 install.a51
字号:
;********************************************************************
InitSerial: mov T3CM, #010h ; turn on baud doubler
mov SCON2,#050h ; serport 2 mode 1, enable receive
orl T3CM, #002H ; timer 3, 8-bit auto-reload
; mov th3, #0FAh ; 36.864 MHz, 38400 baud, divisor=4
mov th3, #0FEh ; 115200 baud
orl T3CM, #020H ; Timer 3 = Oscillator / 4
orl T3CM, #040H ; Enable timer 3 to run
orl SCON2,#002H ; Serial 2 transmit indicator set
JMP MONSTART
IDENT_STRING: DB 'MONITOR-400 USING TIMER 3 FOR BAUDRATES',0
$ENDIF
$IF (SERIAL = 0 OR SERIAL = 1)
;********************************************************************
;* Interface via standard on-chip UART *
;********************************************************************
SENDBYTE PROC NEAR
;ORL P1,#1
CLR TI ; Only A & PSW can be destroyed!
MOV SBUF,A
;ORL P1,#1
RET
ENDP
SENDCHECK PROC NEAR
JNB TI,$ ; Only A & PSW can be destroyed!
RET
ENDP
RECEIVEBYTE PROC NEAR
;ORL P1,#2
JNB RI,$ ; Only A & PSW can be destroyed!
MOV A,SBUF
CLR RI
;ORL P1,#2
RET
ENDP
SERINT_ENABLE PROC NEAR
CLR TI ; No Transmitter Interrupt yet
SETB ES ; Enable Serial Interrupt
RET
ENDP
SERINT_DISABLE PROC NEAR
CLR ES ; Disable Serial Interrupt
SETB TI ; Set Transmitter Interrupt Flag
RET
ENDP
$ENDIF
$IF (SERIAL = 2)
;********************************************************************
;* Interface via super-duper standard on-chip UART *
;********************************************************************
SENDBYTE PROC NEAR
anl scon2, #0FDh ; Clear the transmit indicator flag
mov sbuf2,A
ret
ENDP
SENDCHECK PROC NEAR
push acc
sc_top: mov a, scon2
jnb acc.1, sc_top
pop acc
ret
ENDP
RECEIVEBYTE PROC NEAR
rb_top: mov a, scon2
jnb acc.0, rb_top ; Only A & PSW can be destroyed!
mov a, sbuf2
anl scon2, #0FEh ; clear the lowest (RI) bit
ret
ENDP
SERINT_ENABLE PROC NEAR
anl scon2, #0FDh ; No Transmitter Interrupt yet
setb es2 ; Enable Serial Interrupt
ret
ENDP
SERINT_DISABLE PROC NEAR
clr es2 ; Disable Serial Interrupt
orl scon2, #02h ; Set Transmitter Interrupt Flag
ret
ENDP
$ENDIF
;-----------------------------------------------------------------------------
BEFORE_GO: ; this code is executed before a
RET ; a go or proc step is executed
AFTER_GO: ; this code is executed after a go
RET ; command (when a breakpoint was set)
WR_CODE: MOVX @DPTR,A ; insert different code here, but
RET ; do not change any other register
; without saving it
WR_XDATA: MOVX @DPTR,A ; insert different code here, but
RET ; do not change any other register
; without saving it
STK_BASE: ; RETURN STACK BASE (DEVICE DEPENDANT)
MOV A,MCON
ANL A,#0C0H
CJNE A,#000H,N_STK_BASE0
MOV R1,#BYTE0 STK_BASE0 ; IDM1=0, IDM0=0
MOV R2,#BYTE1 STK_BASE0
MOV R3,#BYTE2 STK_BASE0
RET
N_STK_BASE0: CJNE A,#040H,N_STK_BASE1
MOV R1,#BYTE0 STK_BASE1 ; IDM1=0, IDM0=1
MOV R2,#BYTE1 STK_BASE1
MOV R3,#BYTE2 STK_BASE1
RET
N_STK_BASE1: CJNE A,#040H,N_STK_BASE2
MOV R1,#BYTE0 STK_BASE2 ; IDM1=1, IDM0=0
MOV R2,#BYTE1 STK_BASE2
MOV R3,#BYTE2 STK_BASE2
RET
N_STK_BASE2: MOV R1,#BYTE0 STK_BASE3 ; IDM1=1, IDM0=1
MOV R2,#BYTE1 STK_BASE3
MOV R3,#BYTE2 STK_BASE3
RET
;-----------------------------------------------------------------------------
;
; Copy four bytes from dptr0 to dptr1. Meant to be used to copy code snippets around.
;
; Destroys: A, dptr0, dptr1, dps
;
Init_Copy4:
movx a, @dptr ; get byte of interrupt vector
inc dptr
inc dps
movx @dptr, a ; put byte of interrupt vector
inc dptr
inc dps
; do it 3 more times
movx a, @dptr ; get byte of interrupt vector
inc dptr
inc dps
movx @dptr, a ; put byte of interrupt vector
inc dptr
inc dps
; do it 2 more times
movx a, @dptr ; get byte of interrupt vector
inc dptr
inc dps
movx @dptr, a ; put byte of interrupt vector
inc dptr
inc dps
; do it 1 more time
movx a, @dptr ; get byte of interrupt vector
inc dptr
inc dps
movx @dptr, a ; put byte of interrupt vector
inc dptr
mov dps, #0
ret
install_default_interrupts:
mov dptr, #int_adr_off
mov a, #01h
movx @dptr, a
inc dptr
mov a, #HIGH(MONITOR_HACK_LJMP)
movx @dptr, a
inc dptr
mov a, #LOW(MONITOR_HACK_LJMP)
movx @dptr, a
mov a, #032h ; code for 'reti'
mov dpl, #03h
movx @dptr, a
mov dpl, #0Bh
movx @dptr, a
mov dpl, #13h
movx @dptr, a
mov dpl, #1Bh
movx @dptr, a
mov dpl, #2Bh
movx @dptr, a
mov dpl, #33h
movx @dptr, a
mov dpl, #3Bh
movx @dptr, a
mov dpl, #43h
movx @dptr, a
mov dpl, #4Bh
movx @dptr, a
mov dpl, #53h
movx @dptr, a
mov dpl, #5Bh
movx @dptr, a
mov dpl, #63h
movx @dptr, a
mov dpl, #6Bh
movx @dptr, a
mov dpl, #73h
movx @dptr, a
mov dpl, #7Bh
movx @dptr, a
mov dpl, #83h
movx @dptr, a
mov dpl, #8Bh
movx @dptr, a
mov dpl, #93h
movx @dptr, a
mov dpl, #9Bh
movx @dptr, a
mov dpl, #0A3h
movx @dptr, a
mov dpl, #0ABh
movx @dptr, a
mov dpl, #0B3h
movx @dptr, a
mov dpl, #0BBh
movx @dptr, a
mov dpl, #0C3h
movx @dptr, a
mov dpl, #0CBh
movx @dptr, a
mov dpl, #0D3h
movx @dptr, a
mov dpl, #0DBh
movx @dptr, a
mov dpl, #0E3h
movx @dptr, a
mov dpl, #0F3h
movx @dptr, a
mov dpl, #0FBh
movx @dptr, a
ret
;
; input: A - byte to output to debug port
;
output_ASCII:
push psw
push acc
push r0_b0
push r2_b0
mov R2,#9 ; Loop for 9 bits
clr C
;WOS_DISABLE_INTERRUPTS
clr ea
SendLoop0:
mov INFOTX_PIN_ONEWIRE,C ; 2 0.000/8.68 Begin a data bit
rrc A ; 1 0.217
mov R0,#24 ; 2 0.325
djnz R0,$ ; 3*24 0.543
djnz R2,SendLoop0 ; 3 8.35
setb INFOTX_PIN_ONEWIRE ; 2 8.68/0.000 Begin stop bit
;WOS_ENABLE_INTERRUPTS
setb ea
mov R0,#30 ; 2 0.217 Make long inter-byte time.....
djnz R0,$ ; 3*30 10.20
pop r2_b0
pop r0_b0
pop acc
pop psw
ret
PUBLIC MONDATA
?FD?MON_DATA SEGMENT HDATA AT MON_RAM_START
RSEG ?FD?MON_DATA
MONDATA: DS 32 ; Monitor data area; DO NOT CHANGE SIZE
MONDATA_CODE EQU MON_RAM_START
PUBLIC MONDATA_CODE
END
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -