; Band-pass Filter program, ready to run ; ; The following 68000 assembly language program which reads the ; input array and generate 3 output arrays: ; First, with high pass function applied. ; Second, with low pass applied, and the. ; Third, with both function applied to do the band pass. ; The elements of the array are positive word-size numbers. ; These numbers are actually the digitized values of a sample ; of an analog waveform. ; The arrays, original and filtred, have 3 extra elements ; at the top, namely length of the array, low-pass cut-off ; value and high-pass cut-off vales. ; Run this program and generate a printout with memory contents ; to verify the contents of filtered arrays. ORG $0900 ;start program at this address LOW LEA ARRAYIN,A0 ;set pointer to input array LEA ARRAYLO,A1 ;set pointer to LO pass output BSR LOPASS ;call subroutine LO pass filter HIGH LEA ARRAYIN,A0 ;set pointer to input array LEA ARRAYHI,A1 ;set pointer to HI pass output BSR HIPASS ;call subroutine HI pass filter BAND LEA ARRAYLO,A0 ;set pointer to LO pass filtered array LEA ARRAYBA,A1 ;set pointer to band pass output BSR HIPASS ;call subroutine HI pass filter BRA STOP ;stop the program ;<===== LOPASS =====> ;create the LO pass filter subroutine ;Input from (A0) and output to (A1) LOPASS MOVE.W (A0)+,D0 ;first element is # of elements in array MOVE.W D0,(A1)+ ;COPY IT TO LO ARRAY MOVE.W (A0)+,D1 ;second element is LO pass threshold value MOVE.W D1,(A1)+ ;COPY IT TO LO ARRAY MOVE.W (A0)+,D2 ;third element is HI pass threshold value MOVE.W D2,(A1)+ ;COPY IT TO LO ARRAY CHECKLO CMP.W (A0)+,D1 ;compare data value with LO threshold BCC OKLO ;brach if LO >= current value MOVE.W D1,(A1)+ ;current value > LO, change it to LO value BRA NEXTLO ;get next data value OKLO MOVE.W -2(A0),(A1)+ ;leave output value unchanged NEXTLO SUBQ.W #1,D0 ;decrement # of elements to process BNE CHECKLO ;not done yet, check current data value RTS ;<===== HIPASS =====> ;create the HI pass filter subroutine ;Input from (A0) and output to (A1) HIPASS MOVE.W (A0)+,D0 ;first element is # of elements in array MOVE.W D0,(A1)+ ;COPY IT TO HI ARRAY MOVE.W (A0)+,D1 ;second element is LO pass threshold value MOVE.W D1,(A1)+ ;COPY IT TO HI ARRAY MOVE.W (A0)+,D2 ;third element is HI pass threshold value MOVE.W D2,(A1)+ ;COPY IT TO HI ARRAY CHECKHI CMP.W (A0)+,D2 ;compare data value with HI threshold BLS OKHI ;brach if HI <= current value MOVE.W D2,(A1)+ ;current value < HI, change output to HI value BRA NEXTHI ;get next data value OKHI MOVE.W -2(A0),(A1)+ ;leave output value unchanged NEXTHI SUBQ.W #1,D0 ;decrement # of elements to process BNE CHECKHI ;not done yet, check current data value RTS ;<===== DEFINING INPUT ARRAY =====> ORG $0C00 ;at this address, create an array sample ARRAYIN DC.W $0020 ;assign the array depth DC.W $0200 ;assign the low pass cut-off DC.W $0100 ;assign the hi pass cut-off DC.W $122,$88,$105,$110,$120,$8C,$101,$DF DC.W $1C0,$55,$175,$210,$215,$199,$200,$75 DC.W $123,$90,$25,$101,$12C,$18C,$205,$222 DC.W $250,$214,$175,$160,$152,$102,$89,$74 DC.L $CCCCCCCC ;a marker at the end of input array ORG $0D00 ;at this address ARRAYLO DS.W 35 ;allocate space for LOW pass output DC.L $DDDDDDDD ;a marker at the end of LOW pass ORG $0E00 ;at this address ARRAYHI DS.W 35 ;allocate space for HIGH pass output DC.L $EEEEEEEE ;a marker at the end of HIGH pass ORG $0F00 ;at this address ARRAYBA DS.W 35 ;allocate space for band pass output DC.L $FFFFFFFF ;a marker at the end of band pass STOP MOVE.B #228,D7 TRAP #9