What should I know when switching from MIPS to x86 assembly?

mmcdole picture mmcdole · Jan 17, 2009 · Viewed 14.5k times · Source

At school we have been programming in MIPS assembly language for some time. I'm interested into delving into x86 assembly and I have heard that is somewhat harder (even my MIPS textbook says this).

What core information should I know as a MIPS programmer before making the dive into the x86 world?

Answer

Serafina Brocious picture Serafina Brocious · Jan 17, 2009

The biggest things to keep in mind are:

  • Few general purpose registers, and the ones you do have are not pure GP -- many instructions require you to use certain registers for a specific purpose.
  • x86 instructions are two-opcode form rather than three-opcode which can make certain operations more complex. That is, instead of add r0, r1, r2 (r0 = r1 + r2), you do add eax, ebx (eax += ebx).
  • Segments in protected mode (all 32-bit code outside of DOS, effectively) make your memory addressing scheme extremely non-obvious, which can bite you in the ass when you're starting out.
  • You're going to be looking up the flags set/cleared by instructions all the time. Learn to love the Intel manuals.
  • Edit, one thing I forgot: The use of subregisters (e.g. ah to access the high 8 bits of the low 16-bits of the eax register) can make tracking manipulations to your registers very difficult. Be careful and comment liberally until you get things down.

Other than that, x86 is pretty straight forward. When you learn to abuse instructions like 'lea' and 'test', you learn to love it. Also, protip: Intel will send you copies of the instruction set manuals for free, don't even have to pay for shipping. Look around their site for the fulfillment email and request the books by SKU.