Re: Inline Assembly: Assembling ARM/Thumb-16 ADDS or ADD with status update
Re: Inline Assembly: Assembling ARM/Thumb-16 ADDS or ADD with status update
- Subject: Re: Inline Assembly: Assembling ARM/Thumb-16 ADDS or ADD with status update
- From: Jonas Maebe <email@hidden>
- Date: Tue, 21 Jun 2011 10:19:34 +0200
On 21 Jun 2011, at 08:03, Jeffrey Walton wrote:
Unfortunately, the status flags are not being updated, so I'm getting
incorrect results. To remediate, I moved to a ".code 32" directive for
ADDS:
__asm__ volatile
(
"ldr r4, %[xa] ;" // R4 = a
"ldr r5, %[xb] ;" // R5 = b
".code 32 ;" // same as ".arm"
"adds r6, r4, r5 ;" // R6 = R4 + R5, set status
".code 16 ;" // same as ".thumb"
This cannot work. You cannot just go from ARM to Thumb mode from one
instruction to the next. The mode switch always has to occur via bx/
blx or similar instruction.
Regarding the add/adds: GCC by default uses the "divided" assembler
syntax, which did use the mnemonic "add" rather than "adds" in Thumb
mode. It should still set the flags though (especially if you use
three different registers, since the non-flag setting variant only
supports two).
You may be able to switch to the unified syntax so that it corresponds
to what is used in the current ARM manuals by following the
instructions at http://sourceware.org/binutils/docs/as/ARM_002dInstruction_002dSet.html
, but I don't know whether this is supported by the GCC
versions that Apple ships.
Jonas
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden