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 > writeback feature in GAS

#23640 - Darmstadium - Fri Jul 16, 2004 8:06 pm

I can't get the writeback feature to work when assembling with GAS...
I try it like this:
strh r0,[r4]+2!
but I get the error
garbage following instruction -- `strh r0,[r4]+2!'
can someone tell me how to use it?
thanks

#23641 - poslundc - Fri Jul 16, 2004 8:23 pm

If you are writing back the width of the memory you loaded/stored, you can just use the exclamation flag like this:

Code:
     strh     r0, [r4]!
@ r4 += 2 after the write


You can also do post-indexed offsetting to specify a different amount to offset by, eg.

Code:
     strh     r0, [r4], 4
@ r4 += 4 after the write


Dan.

#23644 - Darmstadium - Fri Jul 16, 2004 10:18 pm

hmm when I try
strh r5,[r4]!
the result of my demo isn't right and when I try
strh r5,[r4],2
I get the error
register expected, not '2' -- `strh r5,[r4],2'
are you talking about THUMB? i'm doing ARM

#23645 - poslundc - Fri Jul 16, 2004 10:29 pm

Sorry, that should've been #4, not plain 4. So if you're doing it the post-indexed offset way it would be:

Code:
     strh     r5, [r4], #2


The # sign always precedes literal constants in GAS.

Can't speak for the results of your demo, but ! is the writeback flag.

Dan.

#23647 - Darmstadium - Fri Jul 16, 2004 10:35 pm

ah, i figured out why the ! didn't work for me, and I have the
str r0,[r1],#4
method working.
thanks!