#11178 - Snoobab - Sun Sep 28, 2003 8:54 am
Hi,
I want to write my GBA lib's DMA functions in ASM (in an external *.s
file). But seeing as I've not done much RISC ASM coding before it is quite difficult. How would I go about doing this? And will the hand-written ASM DMA functions perform better than plain old inline DMA functions?
Thanks a lot,
- Ed.
#11182 - poslundc - Sun Sep 28, 2003 3:07 pm
A good start would be running gcc -S on your C file to see what assembly code the compiler would generate, then seeing what you can optimize out of that.
I remember seeing a website at one point explaining how to improve DMA setup time through assembler... IIRC it involved taking advantage of the fact that the DMA registers are next to each other in memory, so you can possibly do it with fewer memory transfer instructions. Someone else may be able to provide you with the actual link to the website in question.
Good luck,
Dan.
#11187 - Snoobab - Sun Sep 28, 2003 4:41 pm
I'll give it a try, thanks.
- Ed.
#11276 - torne - Wed Oct 01, 2003 12:25 am
I don't know the site you are talking about, but here's how you do it:
Code: |
ldr r0, =REG_DMAxSAD (source address register for whichever dma you want)
ldr r1, =source_address
ldr r2, =dest_address
ldr r3, =( top 2 bytes are the flags, bottom 2 bytes are the count)
stmia r0!, {r1-r3} |
My version is tweaked a bit more than that still as I use macros that synthesise numbers using shifts and adds where faster, instead of using ldr; the macros are around on the ASM forum somewhere.
#11325 - Snoobab - Thu Oct 02, 2003 6:31 pm
Nice, thanks torne.