Consider a program where an audio snippet is endlessly looped in a 1 second buffer:
Code: Select all
mem buffer 32767 ; 1 second delay when run w 32768 hz clock
equ feedback reg0
ldax adcl
rdax feedback
wra buffer, 0
rda buffer#, 1
wrax feedback, 1
wrax dacl, 0
I wish to store the memory address of one specific sample for the purpose of a timing function I'm working on. By sample I mean an amplitude value that has been read by the adc and stored in the buffer, where it endlessly skips from one address to the next until it loops back around to the start of the buffer via the feedback register.
Code: Select all
equ ref reg1
equ limit reg2
skp RUN, start
clr
or 32768*256
wrax limit, 0
start:
clr
or 256 ; 1 sample
rdax ref, 1 ; add reference register
wrax ref, 1 ; store new reference
rdax limit, -1 ; - limit
skp NEG, refReset ; if GEZ (ref >= limit) :
clr
wrax ref, 0 ; reset ref register
refReset:
In the code above I'm uncertain of a few things. Am I correct in setting the "limit" register to 32768*256 (instead of 767 or 769)? And will my counter implementation be accurate enough to follow the exact same sample through the buffer indefinitely? Other observations/glaring mistakes?
Thanks!