gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

ASM > Writing a value from one address to another

#78442 - Peter - Fri Apr 07, 2006 10:47 am

Hello,

I wonder if it is possible to write a value from one memory address directly to another. At the moment my code looks like:
Code:

ldrh r0, [r1], #2 @ load value from source address
strh r0, [r2], #8 @ store value at destination address

r1 is the address of source values and r2 is the destination address. Is it possible to write code that will perform "write value from address in r1 to address in r2" without loading it temporarily to r0? Would save me a few cycles.

Thanks in advance

#78443 - chishm - Fri Apr 07, 2006 11:05 am

It's not possible using the CPU only. However, you can use DMA to transfer directly from one memory address to another, but the setup overhead makes it useless for small copies (in the range of a few words).
_________________
http://chishm.drunkencoders.com
http://dldi.drunkencoders.com

#80817 - Miked0801 - Tue Apr 25, 2006 7:24 pm

Can you load whole words instead of halfwords for a quick optimization? If so, then ldm, stm becomes your friend.