; Chapter 15 6812 assembly language programs ; Jonathan W. Valvano, 2/26/07 ; This software accompanies the book, ; Embedded Microcomputer Systems: Real Time Interfacing, Second Edition ; published by Thomson Engineering, 2006 ; ; y=(x[0]+x[3])>>1; ldab x:3 ; 8-bit x[3] clra ; promote into RegD tfr D,X ; save in RegX ldab x ; 8-bit x[0] leax D,X ; 16-bit x[0]+x[3] asra rolb ; 16-bit shift stab y ; demote to 8 bit ;Program 15.4 Compiler-generated assembly listings for the filter implementation. ; 9S12C32 assembly org RAM XN ds 2 ; x(n) current XN1 ds 2 ; x(n-1) previous XN2 ds 2 ; x(n-2) 2 samples ago YN1 ds 2 ; y(n-1) previous YN2 ds 2 ; y(n-2) 2 samples ago YN ds 2 ; y(n) current acc ds 4 ; temporary 32-bit org ROM COEF dc.w 113,0,113,0,-98 TC5Handler movb #$20,TFLG1 ; ack ldd TC5 addd #16667 ; 240Hz std TC5 movw YN1,YN2 ; shift MACQ movw YN,YN1 movw XN1,XN2 movw XN,XN1 jsr ADC_In std XN ; new data ldx #XN ; data ldy #COEF ; coef ldd #0 std acc ; clear temporary std acc+2 ldaa #5 ; number of terms loop emacs acc ;acc=acc+{X}*{Y} leax 2,x leay 2,y dbne A,loop ldy acc ldd acc+2 ;Y:D=113*(x[0]+x[2])-98*y[2] ldx #128 edivs sty YN rti ; Program 15.7. Real time data acquisition with a 60 Hz notch digital filter, Equation 58.