我刚学习ARM程序集,我不确定我的代码是否正确。这段代码应该实现声音延迟。
我已按照以下说明操作,但我不知道代码中是否有任何错误。
.set AD0GDR, 0xE0034004
.set DACR, 0xE006C000
.set BUFLEN,10000
.bss
.balign 2
buf:.skip( 2 * BUFLEN); //'buf' intialized
.data
.balign 2
.skip 2
.text
/**
* void delay_audio();
*/
.text
.balign 4
.global delay_audio
delay_audio:
LDR r2, =0xE0034004
LDR r3, =0xE006C000
LDR r1,=buf //Store size of buf in one register
CMP r0,r1 //Comapre Index ro and buf register
LDRLT r0,[r1 , #0] //if(r0<r1) then r1 is the first element in the array
LDRLT r0,[r1] //add size of buf with r1, so r1 will become the last element
CMP r0,r1 //Compare again
LDRGT r0,=buf //if(r0>r1) then r1 will be initialized to buf
LDRH r0,[r2] //load from ADC to r0( r0 is index)
STRH r0,[r3] //Store the same half word in DAC
STRH r0,[r1],#2 //increment index by 2
bx lr // return
.end