This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

ARM Vs GCC assembler

Note: This was originally posted on 25th January 2013 at http://forums.arm.com

Hi,

I have a question regarding the ARM and GCC assemblers i.e. ARMASM and GAS.

MOV.W R4,#0x87C0 is translated to F248_74C0 by ARMASM.

However, GAS throws up the error "invalid constant (87c0) after fixup" for the same instruction. Why does GAS give an error for this?

I realise the operand is 16-bit but I'm using the '.syntax unified'. I thought GAS supports .W and .N suffixes. Even without the .W suffix, GAS gives the same error whereas ARMASM quietly expands the 16-bit instruction to 32-bit.

I'm using 'GCC version 4.7.2 (Sourcety CodeBench Lite 2012.09-63).

Any insight as to why GAS is giving an error is appreciated. The workaround is to use two instructions. The following 2 instructions compile OK.

MOVW  R4  ,#0xC0
MOVT R4  ,#0x87

Thanks and regards,
Ger
Parents
  • Note: This was originally posted on 4th February 2013 at http://forums.arm.com

    mov.w is the T2 encoding for the mov instruction. It's different from the movw instruction (which uses the T3 encoding, or A2 in ARM mode) in that it only has a 12-bit immediate instead of a 16-bit one. This format doesn't support the immediate you're specifying, hence the error. It'd probably work with a supported immediate.

    The ARM architecture reference manual says that just specifying mov should permit all encodings, while movw forces T3/A2. It doesn't seem to specify that the .w suffix is supposed to force the T2/A1 encodings, which is what GAS seems to be doing, or if it allows T3/A2 like ARMASM.
Reply
  • Note: This was originally posted on 4th February 2013 at http://forums.arm.com

    mov.w is the T2 encoding for the mov instruction. It's different from the movw instruction (which uses the T3 encoding, or A2 in ARM mode) in that it only has a 12-bit immediate instead of a 16-bit one. This format doesn't support the immediate you're specifying, hence the error. It'd probably work with a supported immediate.

    The ARM architecture reference manual says that just specifying mov should permit all encodings, while movw forces T3/A2. It doesn't seem to specify that the .w suffix is supposed to force the T2/A1 encodings, which is what GAS seems to be doing, or if it allows T3/A2 like ARMASM.
Children
No data