Differences Between ARM Assembly and x86 Assembly

Nathan Campos picture Nathan Campos · Nov 13, 2009 · Viewed 30.9k times · Source

I'm now going to learn ARM Assembly, to develop for my Windows Mobile 5 iPAQ, but I have some questions:

  • What Are The Main Differences Between ARM Assembly and x86 Assembly?
    • Is Any Differences In The Interrupts(New Types)?
      • Which Are They And What Is The Meaning Of They?
    • Best Assembler To Compile And Where To Get It?
  • Where I Can Find Some Good Resources?

Answer

Michael Burr picture Michael Burr · Nov 14, 2009

Main differences:

  • ARM is a RISC style architecture - instructions have a regular size (32-bit for standard ARM and 16-bits for Thumb mode, though Thumb has some instructions that chew up 2 instruction 'slots')

  • up through at least ARM v5 architecture (I'm not sure what v6 does), the interrupt model on ARM is vastly different than on Intel - instead of pushing registers onto the stack, the ARM swaps to a different set of registers which 'shadow' the normal set. The mode of the processor determines which register file is visible (and not all registers are necessarily shadowed). it's a pretty complex arrangement. Newer ARM Architectures (v7 anyway) have an interrupt model that's closer to Intel's where registers are pushed on to the stack when an interrupt occurs.

Arm instruction have some interesting features that aren't in Intel's:

  • instructions have conditional flags built in - so each instruction can execute as a NOP if the specified condition flags don't match the current status register flag state (this can be used to avoid all those jumps around one or two instructions that you often see in Intel assembly).
  • the ARM has shifting logic that can be embedded as part of the instruction. So when using a register as a source operand, you can shift it as an intrinsic part of the instruction. This helps with indexing arrays, sometimes with arithmetic.

On the other side, the ARM can't do much with memory directly except load from and store to it. Intel assembly can perform more operations directly on memory.

Note that the ARM architecture version doesn't correspond directly to the actual ARM processor versions - for example, if I remember right the ARM7 is a architecture v5 processor. Personally, I find this far more confusing than it should be.

The ARM Architecture references are freely downloadable from http://www.arm.com. I also suggest getting copies of Hitex's guides to various ARM microcontrollers for a good starting point.

There have been several Stackoverflow questions regarding pointers to getting started with ARM. Reviewing them will give you a lot of good places to start: