This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Inline Assembly: Assembling ARM/Thumb-16 ADDS or ADD with status update
Jeffrey Walton <noloader@gmail.com> writes:
> __asm__ volatile
> (
> // Per the ARM ABI, A and B are in R0 and R1.
>
> "mov r3, #1 ;" // R3 = no_carry = TRUE
>
> // "adds r1, r1, r0 ;" // Nope - assembler error
> ".short 0x1809 ;" // Same as ADDS R1, R1, R0
> "bcc 1f ;"
> "mov r3, #0 ;" // R3 = no_carry = FALSE
>
> "1: ;"
> "str r1, %[xr] ;" // result = R1
> "str r3, %[xc] ;" // no_carry = R3
Hmm, just a comment (and I know nothing about the ARM), but... I find
it's often a good idea to let gcc handle any pre/post register
loading/storing for asm statements -- it can often do a better job
(whereas loads/stores/moves embedded in the asm are pretty much fixed).
Also, it seems like having explicit asm inputs for A and B would be more
clear....
-Miles
--
Ocean, n. A body of water covering seven-tenths of a world designed for Man -
who has no gills.