.copy "v:\ece320\54x\dsplib\core.asm" ;WAH AUDIO EFFECT CODE ;ECE320 DSP LAB (SPRING 2001) ;PIYA POONGBUNKOR AND VICERUT NONZEE .sect ".data" BRChold .word 23 ; set word for BRC vlue begin .word 0 ; set word for counter start value finish .word 11000 ; set word for counter end value delay .word 512 ; set word for delay length NUMBYTES .set 1 ; set NUMBYTES = 1 .sect ".data" data_buf .space NUMBYTES*16 ; allocate NUMBYTES words for ; serial data buffer data_ptr .word data_buf ; data_ptr initialized to store address ; of first word in serial data buffer .sect ".text" main ; initialize here stm #delay,AR2 ; initialize delay length in AR2 stm #begin,AR4 ; initialize counter start in AR4 stm #finish,AR5 ; initialize counter end in AR5 loop ; Wait for a new block of 64 samples to come in WAITDATA ; BlockLen = the number of samples that come from WAITDATA (64) stm #BlockLen-1, BRC rptb copy-1 mvmd BRC,*(BRChold) lfocounter addm #1,*AR4 ; add 1 into counter address mvmm AR0,AR1 ; move AR0 to AR1 for safe keeping ld *AR4,B ; load counter value into B stl B,AR0 ; store counter value into AR0 nop ; allow cycles for store to take place nop nop cmpr 0,AR5 ; compare counter to desired ending value mvmm AR1,AR0 ; move AR1 back to AR0 bc check,TC ; branch if counter reachs desired value b jump ; else branch to jump check stm #begin,AR4 ; reset counter to LFO counter to 0 mvmm AR0,AR1 ; move AR0 to AR1 for safe keeping stm #0x20,AR0 ; store 32 to AR0 (lower boundary) nop ; allow cycles for store to take place nop nop cmpr 1,AR2 ; compare if less than 32 mvmm AR1,AR0 ; move AR1 back to AR0 bc lfoup,TC ; if less than branch to lfoup stm #0x200,AR0 ; store 512 to AR0 (upper boundary) nop ; allow cycles for store to take place nop nop cmpr 2,AR2 ; compare if greater than 512 mvmm AR1,AR0 ; move AR1 back to AR0 bc lfodwn,TC ; if greater than branch to lfodwn lfodwn ; decrements delay length ldm AR2,B ; load delay lendth into B sub #0x30,B ; subtract B by 48 stl B,AR2 ; store low part of B into AR2 b jump ; branch to jump (output) lfoup ; increments delay length ldm AR2,B ; load delay lendth into B add #0x30,B ; add 48 to B stl B,AR2 ; store low part of B into AR2 b jump ; branch to jump jump ld *AR6+,16,B ; load input to accum B mvmm AR6,AR1 ; move value of AR6 to AR1 mar *+AR6(4) ; input on all other channels WRITPROG 1 ; write to extended memory add #1,A ; add 1 to A (delay counter) mvmm AR0,AR1 ; move AR1 back to AR0 stl A,AR0 ; store low part of A into AR0 nop nop nop cmpr 00,AR2 ; compare if AR0 = AR2 mvmm AR1,AR0 ; move AR1 back to AR0 bc output,NTC ; branc to output if not equal ld #0x0,A ; if equal then reset delay counter to 0 output ; output samples mvmm AR3,AR1 ; move value of AR3 to AR1 to read delayed values READPROG 1 ; read from extended memory add *AR3,16,B ; input + delayed input sth B,*AR7 ; output final mar *+AR7(6) ; output on all other channels copy: _serial_stuff ; this block must only run once ; per WAITDATA call pshm AR3 ; we save AR3 so you don't have to mvdm data_ptr, AR3 ; set AR3 to point to last byte stored ; in the serial data buffer pshm AR0 ; we save AR0 so you don't have to stm #data_buf+NUMBYTES, AR0 ; #data_buf+NUMBYTES is the address of ; the last word in the ; serial data buffer nop cmpr eq, AR3 ; if last byte stored is at the last nop ; address in the serial data buffer, nop ; wrap to beginning of serial data xc 2, TC ; buffer stm #data_buf, AR3 READSER 1 ; copy one byte from ser_rxbuf to ; serial data buffer ; (ser_rxbuf initialized in core file ; and filled automatically when ; data arrives on serial port) mvmd AR3, data_ptr ; save address of last byte stored ; in serial data buffer popm AR0 ; we restore AR0 so you don't have to popm AR3 ; we restore AR3 so you don't have to mvdm data_ptr,AR5 ; move data for flanging sweeping time into AR5 b loop