Show Menu
Cheatography

x86 Assembly, C Linking, Loading etc Cheat Sheet by

A cheat sheet for systems class

x86 Assembly Instru­ctions

ADD <de­st>, <so­urc­e>
Adds <so­urc­e> to <de­st>. <de­st> may be a register or memory. <so­urc­e> may Be a register, memory or immediate value.
CALL <lo­c>
Call a function and return to the next instru­ction when finished. <pr­oc> may be a relative offset from the current location, a register or memory addr.
CMP <de­st>, <so­urc­e>
Compare <so­urc­e> with <de­st>. Similar to SUB instru­ction but does not Modify the <de­st> operand with the result of the subtra­ction.
DEC <de­st>
Subtract 1 from <de­st>. <de­st> may be a register or memory.
DIV <di­vis­or>
Divide the EDX:EAX registers (64‐bit combo) by <di­vis­or>. <di­vis­or> may be a register or memory.
INC <de­st>
Add 1 to <de­st>. <de­st> may be a register or memory.
JE <lo­c>
Jump if Equal (ZF=1) to <lo­c>.
JG <lo­c>
Jump if Greater (ZF=0 and SF=OF) to <lo­c>.
JGE <lo­c>
Jump if Greater or Equal (SF=OF) to <lo­c>.
JLE <lo­c>
Jump is Less or Equal (SF<>OF) to <lo­c>.
JMP <lo­c>
Jump to <lo­c>. Uncond­iti­onal.
JNE <lo­c>
Jump if Not Equal (ZF=0) to <lo­c>.
JNZ <lo­c>
Jump if Not Zero (ZF=0) to <lo­c>.
JZ <lo­c>
Jump if Zero (ZF=1) to <lo­c>.
LEA <de­st>, <so­urc­e>
Load Effective Address. Gets a pointer to the memory expression <so­urc­e> and stores it in <de­st>.
MOV <de­st>, <so­urc­e>
Move data from <so­urc­e> to <de­st>. <so­urc­e> may be an immediate value, register, or a memory address. Dest may be either a memory address or a register. Both <so­urc­e> and <de­st> may not be memory addresses.
MOVZBL <de­st>, <so­urc­e>
Zero extend <so­urc­e> to long and save in <de­st>.
MUL <so­urc­e>
Multiply the EDX:EAX registers (64‐bit combo) by <so­urc­e>. <so­urc­e> may be a register or memory.
POP <de­st>
Take a 32‐bit value from the stack and store it in <de­st>. ESP is increm­ented by 4. <de­st> may be a register, including segment registers, or memory.
PUSH <va­lue>
Adds a 32‐bit value to the top of the stack. Decrements ESP by 4. <va­lue> may be a register, segment register, memory or immediate value.
ROL <de­st>, <co­unt>
Bitwise Rotate Left the value in <de­st> by <co­unt> bits. <de­st> may be a register or memory address. <co­unt> may be immediate or CL register.
ROR <de­st>, <co­unt>
Bitwise Rotate Right the value in <de­st> by <co­unt> bits. <de­st> may be a register or memory address. <co­unt> may be immediate or CL register.
SHL <de­st>, <co­unt>
Bitwise Shift Left the value in <de­st> by <co­unt> bits. Zero bits added to the least signif­icant bits. <de­st> may be reg. or mem. <co­unt> is imm. or CL.
SHR <de­st>, <co­unt>
Bitwise Shift Right the value in <de­st> by <co­unt> bits. Zero bits added to the least signif­icant bits. <de­st> may be reg. or mem. <co­unt> is imm. or CL.
SUB <de­st>, <so­urc­e>
Subtract <so­urc­e> from <de­st>. <so­urc­e> may be immediate, memory or a register. <de­st> may be memory or a register. (source = dest)‐­>ZF=1, (source > dest)‐­>CF=1, (source < dest)‐­>CF=0 and ZF=0
TEST <de­st>, <so­urc­e>
Performs a logical OR operation but does not modify the value in the <de­st> operand. (source = dest)‐­>ZF=1, (source <> dest)‐­>ZF=0.
XCHG <dest, <so­urc­e>
Exchange the contents of <so­urc­e> and <de­st>. Operands may be register or memory. Both operands may not be memory.
XOR <de­st>, <so­urc­e>
Bitwise XOR the value in <so­urc­e> with the value in <de­st>, storing the result in <de­st>. <de­st> may be reg or mem and <so­urc­e> may be reg, mem or imm.
 

What does a Linker do?

– Merges multiple reloca­table (.o) object files into a single executable object file that can loaded and executed by the loader.
– As part of the merging process, resolves external refere­nces. • External reference: reference to a symbol defined in another object file.
– Relocates symbols from their relative locations in the .o files to new absolute positions in the execut­able.
– Updates all references to these symbols to reflect their new positions. • References can be in either code or data
 

Memory Management

Info
       
 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          Extending Ruby with C - Part 2 Cheat Sheet
          C program Cheat Sheet