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

Which instruction format does Cortex-R support,encoding A1 orA2?

I see it support encoding T2 for Thumb-2 instruction set.But which instruction format does Cortex-R support for ARM instruction,encoding A1 orA2?

Parents
  • Yes, the mnemonic you write in assembler (MOV or MOVW) is only one part of the choice of the encoding which the assembler will emit.

    If you write MOV, the assembler is free to choose from all available encodings (provided the registers used, the choice of flag-setting and the length of the constant fit options for the encoding).

    So, if you write MOV r0, #8, the assembler can choose from all available encodings for the instruction except T1 (because T1 always sets the flags).

    If you write MOVS r0, #8, it could choose from T1, T2 or A1. It will choose T1 because it's the shortest. For other values of the constant, it might prefer T2 or A1.

    If you write MOV with a 16-bit constant which cannot be encoded in the 12-bit format, the assembler will use encoding T3 or A2. The only difference between them is that A2 cannot be used when the destination register is PC, and T3 cannot be used when the destination register is PC or SP.

    However, if you write MOVW, it will be restricted to use T3 or A2. So, if you really must have one of those two, write MOVW.

    Hope that makes sense!

    Chris

Reply
  • Yes, the mnemonic you write in assembler (MOV or MOVW) is only one part of the choice of the encoding which the assembler will emit.

    If you write MOV, the assembler is free to choose from all available encodings (provided the registers used, the choice of flag-setting and the length of the constant fit options for the encoding).

    So, if you write MOV r0, #8, the assembler can choose from all available encodings for the instruction except T1 (because T1 always sets the flags).

    If you write MOVS r0, #8, it could choose from T1, T2 or A1. It will choose T1 because it's the shortest. For other values of the constant, it might prefer T2 or A1.

    If you write MOV with a 16-bit constant which cannot be encoded in the 12-bit format, the assembler will use encoding T3 or A2. The only difference between them is that A2 cannot be used when the destination register is PC, and T3 cannot be used when the destination register is PC or SP.

    However, if you write MOVW, it will be restricted to use T3 or A2. So, if you really must have one of those two, write MOVW.

    Hope that makes sense!

    Chris

Children