Search code examples
assemblyarmmachine-code

What version of ARM does the given machine code correspond to?


I attempted to assemble the following code with two different assemblers (one of which is online and the other is FASMARM):

lsl   r1, r2, #4
lslge r1, r2, #4

The resulting machine code is (in little-endian):

02 12 a0 e1
02 12 a0 a1

This tells me that the condition field is positioned in the second-to-last nibble. This is very different from the representation I see in my book in which it is positioned in the beginning (my book describes the ARMv4 architecture): enter image description here

I would like to ask:

  1. What version does the resulting machine code correspond to?
  2. How can I assemble a snippet of ARM instructions into ARMv4 in Linux or online (just assemble, not execute)?

Solution

  • ARM machine code is represented in little endian, regardless of operation mode or byte order configured.

    The encoded instruction you have are thus e1a01202 and a1a01202 when read as words. This matches the diagram from your picture. The encoding is for ARM mode and applies to any version of the AArch32 architecture that can execute code in ARM (A32) state.