ARM instruction set pseudo instructions

Does anyone know if there is a list of ARM instruction set pseudo instructions?

Or better yet, an instruction list like PPC's, where there is a list of 'true instructions' with mnemonics and

another list of "simplified mnemonics" (=pseudo instructions) in terms of the "true instructions" (mnemonics).

There are 499 ARM instructions listed in ARMv7-A/R ARM and going through them one by one is quite a job.

The "true" PPC instructions are explained much like ARM instructions in ARMv7-A/R ARM, but in the

"simplified mnemonics" chapter the pseudo instructions are described like:

Simplified Mnemonic    MnemonicInstruction
bctr                         bcctr 20,0Branch unconditionally (bcctr without LR update)
bctrlbcctrl 20,0Branch unconditionally (bcctrl with LR Update)
...
mr rA,rSor rA,rS,rSMove register

How many pseudo instructions (roughly) are there for Cortex-A7?

ARMv7-A/R ARM doesn't seem to make a difference.

The basic LDR/STR instructions (bits 27 - 25 = 0 1 0 or 0 1 1) are pseudo instructions and there is really

two basic "single data load/store" instructions: the immediate form and the register form.

The special LDR/STR instructions (bits 27 - 25 = 0 0 0) (LDRH, STRD, ...) are different instructions:

the instruction bits have different meanings and/or are in different places.

Also some PC-related instructions are "true", because unlike with other registers, using PC also loads

the CPSR, so it's functionally different even if the encoding bits are exactly the same.

Parents
  • I'm not able to give a list, but I might be able to help out on the 16-bit thumb. Even the 16-bit thumb has pseudo instructions and simplified instructions.

    pseudo-instructions for thumb include the ldr=, which Yasuhiko Koumoto mentioned already.

    I think what you're after is simplified instructions, where pseudo-instructions are defined to be more like a "macro". Thus MOV32 is a pseudo-instruction (eg. a macro) which (always) produces two 32-bit instructions: MOVW + MOVT (resulting in 8 bytes of code). This is (almost) similar to the LIL pseudo-instruction on PPC (LI+ADDIS).

    That said, there is a pseudo-instruction, which you'd be interested in: The UND instruction, which generates an UNDEFINED instruction. It takes a single parameter, which is an expression.

         UND    #0...65535                         /* A32 instruction set */

         UND    #0...4095                          /* T2 (32-bit thumb) instruction set */

         UND    #0...255                            /* T1 (16-bit thumb) instruction set */

    The simplified instructions I know of on the 16-bit thumb are NOP, NOT and NEG. As far as I know, NOP is a simplified MOV R8,R8.

    (any MOV Rn,Rn would act as a NOP, but I believe R8 was chosen, because this register is not used very often, and thus if the code runs on newer architectures, the risk of register-clashing / RAW/WAR would be minimized, in case it would mean anything on such architectures).

    NOT is a MVN Rn,Rn instruction.

    NEG is RSB Rn,#0 (the immediate value on 16-bit thumb is restricted to only #0, nothing else)

    On 16-bit thumb, LSRS, LSLS, ASRS, ASLS, RORS and RRXS are not simplified instructions. This is because there's not room for supporting "operand2" on the thumb.

    But on thumb2, LSRS, LSLS, ASRS, ASLS, RORS and RRXS are actually MOVS instructions with the second operand specifying the shift type and count.

    LSL, LSR, ASL, ASR, ROR and RRX similarly usese MOV.

    Also, PUSH and POP on 16-bit thumb are special; since they do not act exactly like STMIA/LDMIA.

    Note: TST is not a simplified ANDS instruction, because it does not modify any register like ANDS would.

    On Cortex-M3 and Cortex-M4, I have a feeling that UXTB, UXTH, SXTB and SXTH are simplified versions of UBFX and SBFX, but I have not checked the disassembly.

Reply
  • I'm not able to give a list, but I might be able to help out on the 16-bit thumb. Even the 16-bit thumb has pseudo instructions and simplified instructions.

    pseudo-instructions for thumb include the ldr=, which Yasuhiko Koumoto mentioned already.

    I think what you're after is simplified instructions, where pseudo-instructions are defined to be more like a "macro". Thus MOV32 is a pseudo-instruction (eg. a macro) which (always) produces two 32-bit instructions: MOVW + MOVT (resulting in 8 bytes of code). This is (almost) similar to the LIL pseudo-instruction on PPC (LI+ADDIS).

    That said, there is a pseudo-instruction, which you'd be interested in: The UND instruction, which generates an UNDEFINED instruction. It takes a single parameter, which is an expression.

         UND    #0...65535                         /* A32 instruction set */

         UND    #0...4095                          /* T2 (32-bit thumb) instruction set */

         UND    #0...255                            /* T1 (16-bit thumb) instruction set */

    The simplified instructions I know of on the 16-bit thumb are NOP, NOT and NEG. As far as I know, NOP is a simplified MOV R8,R8.

    (any MOV Rn,Rn would act as a NOP, but I believe R8 was chosen, because this register is not used very often, and thus if the code runs on newer architectures, the risk of register-clashing / RAW/WAR would be minimized, in case it would mean anything on such architectures).

    NOT is a MVN Rn,Rn instruction.

    NEG is RSB Rn,#0 (the immediate value on 16-bit thumb is restricted to only #0, nothing else)

    On 16-bit thumb, LSRS, LSLS, ASRS, ASLS, RORS and RRXS are not simplified instructions. This is because there's not room for supporting "operand2" on the thumb.

    But on thumb2, LSRS, LSLS, ASRS, ASLS, RORS and RRXS are actually MOVS instructions with the second operand specifying the shift type and count.

    LSL, LSR, ASL, ASR, ROR and RRX similarly usese MOV.

    Also, PUSH and POP on 16-bit thumb are special; since they do not act exactly like STMIA/LDMIA.

    Note: TST is not a simplified ANDS instruction, because it does not modify any register like ANDS would.

    On Cortex-M3 and Cortex-M4, I have a feeling that UXTB, UXTH, SXTB and SXTH are simplified versions of UBFX and SBFX, but I have not checked the disassembly.

Children