#77950 - HyperHacker - Tue Apr 04, 2006 5:11 am
This little piece of code here, on the DS's ARM9 in ARM:
Code: |
ldr r3, =0xEEEEEEEE
strb r3, [r1, #1]! |
always seems to store 0 at r1. Doesn't appear to make any difference what I do to r3. Making it a str instead of strb does it fine, but that's not what I need to do. r1 is word-aligned.
#77954 - poslundc - Tue Apr 04, 2006 5:38 am
The address format you're using is doing pre-indexing. This means it's adding 1 to r1 before it stores out the value, so you're going to write out to 1 byte further ahead in memory than what you're intending.
You want to use a post-indexing format:
You should be able to achieve the same effect with the writeback flag:
... but I've run into trouble with it not always behaving as I expect it to depending on the opcode I'm using, so I almost always explicitly specify the amount to post-index in the writeback.
Dan.
#77955 - DekuTree64 - Tue Apr 04, 2006 5:40 am
You do know that putting the #1 inside the brackets means pre-indexing, right? So the byte will be stored at r1 + 1, and then the ! says to write that address back to r1. Or is it just not storing anything at all?
EDIT: Curse you, Dan.
_________________
___________
The best optimization is to do nothing at all.
Therefore a fully optimized program doesn't exist.
-Deku
#77958 - HyperHacker - Tue Apr 04, 2006 6:08 am
I used pre-indexing because if I just did strb r3, [r1]! it seemed to not increment at all. (Doesn't the ! mean to add the index amount? So if you don't specify one, then it's adding zero.) I tried subtracting one from r1 before doing the store to compromise, but it's not helping. It just always seems to store zero.
...Shoot. You can't do 8-bit writes to DS VRAM, can you? >_<
#77966 - gladius - Tue Apr 04, 2006 7:50 am
Vram needs 16 bit writes.
strb r0,[r1]! does not increment r1, it is the semantic equivalent of strb r0,[r1,#0]! which does nothing.
#78050 - HyperHacker - Tue Apr 04, 2006 9:56 pm
Bah, I knew it was some stupid mistake like that. (Can you do 32 bit writes? Just curious.)
#78073 - poslundc - Wed Apr 05, 2006 12:05 am
HyperHacker wrote: |
Bah, I knew it was some stupid mistake like that. (Can you do 32 bit writes? Just curious.) |
Yes, although memory is still only being accessed 16 bits at a time.
Dan.