📄 xsdispa.asm
字号:
LDI 28,IR1
LDI 4,IR0
LDI 6,RC
CALL iir
PUSH R0 ;to sub from the R2 exponent 14
PUSHF R0
POPF R0
ASH -32,R0
ADDI 14,R2
ASH 32,R0
POP R0
LDI 6,BK
FIX R0
STI R0,*AR2++(1)% ;to transmit audiosignal to AIC
;LDI R5,R2 to processing the signal to transimit to yuandong
LDI yudcoshaddr,AR0 ;do receive filtering
LDI dyudrec,AR1
;LDI 32,IR1
;LDI 4,IR0
;LDI 7,RC
CALL iir
PUSH R0 ;to sub from the R2 exponent 14
PUSHF R0
POPF R0
ASH -32,R0
SUBI 14,R2
ASH 32,R0
POP R0
FIX R0
STI R0,*AR2++(1)% ;to transmit yuandong signal to AIC
LDI 0,R0 ;to transmit the anlgpretec signal to AIC
STI R0,*AR2++(1)% ;the three processed signal will be transmit in receive INT
BR main2
anlgprosh:
LDI 0,R0
STI R0,*AR2++(1)%
STI R0,*AR2++(1)%
;processing the data from dispB
PUSH R2 ;to sub from the R2 exponent 14
PUSHF R2
POPF R2
ASH -32,R2
ADDI 14,R2
ASH 32,R2
POP R2
FIX R2
STI R2,*AR2++(1)%
BR main2
;**************************************************************
; the following will the INT processing program and subroutine
;**************************************************************
;****************************************************
;the following is the serial port INT service
;****************************************************
RCV0: PUSH BK
PUSH R6
PUSHF R6
LDI 3,BK ;this is the serial port receive INT
ADDI 1,R7 ;and this INT has the higher priority
LDI @datarec,R5 ;here we don't care the register protect
FLOAT R5
STF R5,*AR5++%
;to transmit a data to AIC
LDI *AR3++(1),R5
STI R5,@datatra
LDI 1,R6
CMPI @todisp1,R6
POPF R6
POP R6
POP BK
RETI
;**********************************************
;iir filter subroutine N biquad
;**********************************************
iir: MPYF3 *AR0,*AR1,R0
;A2(0)*d(0,n-2)->R0
MPYF3 *AR0++(1),*AR1--(1),R1
;B2(0)*d(0,n-2)->R1
MPYF3 *++AR0(1),*AR1,R0; A1(0)*d(0,n-1)->R0
|| ADDF3 R0,R2,R2;first sum term of d(0,n)
MPYF3 *++AR0(1),*AR1--(1),R0;B1(0)*d(0,n-1)->R0
|| ADDF3 R0,R2,R2 ;second sum term of d(0,n)
MPYF3 *++AR0(1),R2,R2;B1(0)*d(0,n)->R2
|| STF R2,*AR1--(1)%
;store d(0,n);point to d(0,n-2)
RPTB LOOP
MPYF3 *++AR0(1),*++AR1(IR0),R0; A2(i)*d(i,n-2)->R0
|| ADDF3 R0,R2,R2;first sum term of y(i-1,n)
MPYF3 *++AR0(1),*AR1--(1),R1;B2(i)*d(i,n-2)->R1
|| ADDF3 R1,R2,R2 ;second sum term of y(i-1,n)
MPYF3 *++AR0(1),*AR1,R0; A1(i)*d(i,n-1)->R0
|| ADDF3 R0,R2,R2;first sum term of d(i,n)
MPYF3 *++AR0(1),*AR1--(1),R0;B1(i)*d(i,n-1)->R0
|| ADDF3 R0,R2,R2 ;second sum term of d(i,n)
STF R2,*AR1--(1)
;store d(i,n);poit to d(i,n-2)
LOOP: MPYF3 *++AR0(1),R2,R2
;final summation
ADDF R0,R2 ;first sum term of y(n-1,n)
ADDF3 R1,R2,R0 ;second sum term of y(n-i,n)
NOP *AR1--(IR1) ;return to the first biquad
NOP *AR1--(1) ;point to d(0,n-1)
;return sequence
RETS ;return
;*************************************************
;this is a single biquad iir filter subroutine
;*************************************************
iir1:
MPYF3 *AR0,*AR1,R0
;a2*d(n-2)->R0
MPYF3 *++AR0(1),*AR1--(1)%,R1
;b2*d(n-2)->R1
MPYF3 *++AR0(1),*AR1,R0 ;a1*d(n-1)->R0
|| ADDF3 R0,R2,R2 ;a2*d(n-2)+x(n)->R2
MPYF3 *++AR0(1),*AR1--(1)%,R0;b1*d(n-1)->R0
|| ADDF3 R0,R2,R2 ;a1*d(n-1)+a2*d(n-2)+x(n)->R2
MPYF3 *++AR0(1),R2,R2 ;b0*d(n)->R2
|| STF R2,*AR1++(1)%
;store d(n) and point to d(n-1)
ADDF R0,R2 ;b1*d(n-1)+b0*d(n)->R2
ADDF3 R1,R2,R0 ;b2*d(n-2)+b1*d(n-1)+b0*d(n)->R0
RETS ;return
;***************************************************
;the following is fir
;***************************************************
fir: MPYF3 *AR0++(1),*AR1++(1)%,R0
;h(N-1)*x(n-(N-1))->R0
LDF 0.0,R2 ;initialize R2
;FILTER (1<=i<N)
RPTS RC ;setup the repeat cycles
MPYF3 *AR0++(1),*AR1++(1)%,R0
|| ADDF3 R0,R2,R2 ;mutiply and add operation
ADDF R0,R2,R0 ;add last product
;return sequence
RETS
;***************************************************
;the following is to get the inverse of a float
;***************************************************
.global invf
invf: LDF R0,R3 ;v is saved for latter
ABSF R0 ;the algorithem uses the v=|v|
PUSHF R0
POP R1
ASH -24,R1 ;the 8 lsbs of R1 contain the exponent
;of v
NEGI R1
SUBI 1,R1
ASH 24,R1
PUSH R1
POPF R1 ;now R1=x[0]=1.0*2**(-e-1)
MPYF R1,R0,R2 ;R2=v*x[0]
SUBRF 2.0,R2 ;R2=2.0-v*x[0]
MPYF R2,R1 ;R1=x[1]=x[0]*(2.0-v*x[0])
MPYF R1,R0,R2 ;R2=v*x[1]
SUBRF 2.0,R2 ;R2=2.0-v*x[1]
MPYF R2,R1 ;R1=x[2]=x[1]*(2.0-v*x[1])
MPYF R1,R0,R2 ;R2=v*x[2]
SUBRF 2.0,R2 ;R2=2.0-v*x[2]
MPYF R2,R1 ;R1=x[3]=x[2]*(2.0-v*x[2])
MPYF R1,R0,R2 ;R2=v*x[3]
SUBRF 2.0,R2 ;R2=2.0-v*x[3]
MPYF R2,R1 ;R1=x[4]=x[3]*(2.0-v*x[3])
RND R1 ;this minimize the error in LSBS
MPYF R1,R0,R2 ;R2=v*x[4]=1.0..01..=>1
SUBF 1.0,R2 ;R2=1.0-v*x[4]=0.0..01..=>0
MPYF R1,R2 ;R2=x[4]*(1.0-v*x[4])
ADDF R2,R1 ;R2=x[5]=(x[4]*(1.0-(v*x[4])))*x[4]
RND R1,R0 ;ROUND since this is followed by a MPYF
NEGF R0,R2
LDF R3,R3 ;This sets the condition flags
LDFN R2,R0 ;if v<0 then R0=-R0
RETS
;***************************************************
;the following is the INT0 to receive data from uc
;***************************************************
ISR0:
;this is the INT1 to set the statebuffer through
;485 which has the lower priority
PUSH ST ;it request that both XF0 and INT0 are connected to the input
PUSH IE
PUSH AR7
LDI 020H,IE ;unmask only the serial receive INT
;XOR 01H,IE ;disable INT0
OR 02000H,ST ;enable all the interrupts
LDI half_bit_time,AR7
STI AR7,@0808028H
LDI 03C1H,AR7 ;start rx_timer
STI AR7,@0808020H
LDI 0AH,AR7 ;
STI AR7,@rx_counter
POP AR7
POP IE
POP ST
RETI
;time0 interrupt service routine for byte reception
TIME0:
PUSH ST
PUSH IE
PUSH AR7
LDI 020H,IE
OR 02000H,ST ;unmask only the serial receive INT
LDI @rx_counter,AR7
CMPI 0AH,AR7 ;are we at start bit?
BNE stop ;nope,check for stop bit
CMPI 080H,IOF ;check rx_bit (IOF1)
BLT OK ;if less than 80h(IOF1=0)?
OR 01H,IE ;bad start bit ,reenable INT0
BR CLEANUP2 ;go back to main
OK: SUBI 1,AR7 ;decrejent rx_counter
STI AR7,@rx_counter
LDI whole_bit_time,AR7
STI AR7,@0808028H
LDI 031H,AR7 ;start rx_timer
STI AR7,@0808028H
POP AR7
POP IE
POP ST
RETI
stop: PUSH AR6
LDI @rx_byte,AR6
DBNZ AR7,next
CMPI 080H,IOF
BLT CLEANUP2
LSH -24,AR6
STI AR6,@rx_byte
TRAPU TRAP0 ;receives is a soft interrupt
OR 01H ,IE ;reenable INT0
BR CLEANUP
next: CMPI 080H,IOF
OR 01H,ST
BGE ONE
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -