BetterOS.org : An attempt to make computer machines run better


home | better linux | games | software | tutorials | reference | web log |

Reference Material: index | syscalls | calling conventions | amd64 instructions | x11 | reusable code |

Reference Material

INTRODUCTION:
This is meant to be a useful list of AMD64 (x86_64) instructions, along with descriptions, tips, and registers/operands used. This is not an exhaustive list, just a useful reference.


INSTRUCTIONS:
InstructionOperandsInformation
OpcodeMnemonicName123DescriptionTips
movMovedestinationsource Copies data from source to destination. Cannot copy from memory to memory, only register to memory, memory to register, or register to register.
leaLoad Effective Addressdestinationsource Stores an address from source in destination.Can also be used to perform simple math.
addAdddestinationsource Adds operands and stores result in destination.This sets relavent flags.
subSubtractdestinationsource Subtracts source from destination and stores result in destination.This sets relavent flags.
syscallSystem Call Executes a system call.System V Calling Convention states that rax should contain the syscall number.
callCalladdr Calls routine at addr. This also pushes the return address onto the stack.
retReturn Returns execution to the caller (return address).System V Calling Convention states that rax should contain returned 64-bit data, or xmm0 should contain returned 128-bit data.
cmpCompareab Compares a to b and sets relavent flags.
jmpJumpaddr Jumps to addr.No return address is pushed to the stack.
jeJump if Equaladdr Jumps to addr if the zero flag is set.Zero flag will be set if previous comparison was equal.
jzJump if Zeroaddr Jumps to addr if the zero flag is set.Zero flag will be set if previous comparison was equal.
jneJump if Not Equaladdr Jumps to addr if the zero flag is clear.Zero flag will be clear if previous comparison was not equal.
jnzJump if Not Zeroaddr Jumps to addr if the zero flag is clear.Zero flag will be clear if previous comparison was not equal.
jaJump if Aboveaddr Jumps to addr if the zero flag is clear and carry flag is clear.Used for comparisons of unsigned intagers.
jnbeJump if Not Below or Equaladdr Jumps to addr if the zero flag is clear and carry flag is clear.Used for comparisons of unsigned intagers.
jbJump if Belowaddr Jumps to addr if the carry flag is set.Used for comparisons of unsigned intagers.
jnaeJump if Not Above or Equaladdr Jumps to addr if the carry flag is set.Used for comparisons of unsigned intagers.
jnbJump if Not Belowaddr Jumps to addr if the carry flag is clear.Used for comparisons of unsigned intagers.
jaeJump if Above or Equaladdr Jumps to addr if the carry flag is clear.Used for comparisons of unsigned intagers.
jnaJump if Not Aboveaddr Jumps to addr if the carry flag is set or zero flag is set.Used for comparisons of unsigned intagers.
jbeJump if Below or Equaladdr Jumps to addr if the carry flag is set or zero flag is set.Used for comparisons of unsigned intagers.
jgJump if Greateraddr Jumps to addr if the zero flag is clear and sign flag is equal to overflow flag.Used for comparisons of signed intagers.
jnleJump if Not Lesser to Equaladdr Jumps to addr if the zero flag is clear and sign flag is equal to overflow flag.Used for comparisons of signed intagers.
jlJump if Lesseraddr Jumps to addr if the sign flag is not equal to overflow flag.Used for comparisons of signed intagers.
jngeJump if Not Greater to Equaladdr Jumps to addr if the sign flag is not equal to overflow flag.Used for comparisons of signed intagers.
popcntPopulation Countdestinationsource Counts the number of bits set in source and stores result in destinationOnly available in processors with at least SSE4.2 or SSE4.a support.
mulMultiply Unsignedmultiplier Multiplies rax (or eax or ax depending on size of multiplier) by the multiplier. Result is stored in rdx:rax.cannot multiply by an immediate.
imulMultiply Signedmultiplier Multiplies rax (or eax or ax depending on size of multiplier) by the multiplier. Result is stored in rdx:rax.cannot multiply by an immediate.
divDivide Unsigneddivisor Divides rdx:rax (or edx:eax or dx:ax depending on size of divisor) by the divisor. Result is stored in rax.cannot divide by an immediate.
idivDivide Signeddivisor Divides rdx:rax (or edx:eax or dx:ax depending on size of divisor) by the divisor. Result is stored in rax.cannot divide by an immediate.
shlShift Leftdestinationcount Performs a binary left shift on destination by the count.count must either be an immediate or the cl register.
shrShift Rightdestinationcount Performs a binary right shift on destination by the count.count must either be an immediate or the cl register.