x86_64 assembly

general information

  • registers

    see [[Registers]]
    
  • some jump instructions

    Instruction Mnemonic C Example Flags
    j (jmp) Jump break; (Unconditional)
    je (jz) Jump if equal (zero) if (x == y) ZF
    jne (jnz) Jump if not equal (nonzero) if (x != y) !ZF
    jg (jnle) Jump if greater if (x > y), signed !ZF && !(SF ^ OF)
    jge (jnl) Jump if greater or equal if (x >= y), signed !(SF ^ OF)
    jl (jnge) Jump if less if (x < y), signed SF ^ OF
    jle (jng) Jump if less or equal if (x <= y), signed (SF ^ OF) or JF
    ja (jnbe) Jump if above if (x > y), unsigned !CF && !ZF
    jae (jnb) Jump if above or equal if (x >= y), unsigned !CF
    jb (jnae) Jump if below if (x < y), unsigned CF
    jbe (jna) Jump if below or equal if (x <= y), unsigned CF or ZF
    js Jump if sign bit if (x < 0), signed SF
    jns Jump if not sign bit if (x >= 0), signed !SF
    jc Jump if carry bit N/A CF
    jnc Jump if not carry bit N/A !CF
    jo Jump if overflow bit N/A OF
    jno Jump if not overflow bit N/A !OF
    Pasted image 20250203092952.png
  • Figure 2 shows the stack layout, both before and after a function call. If the function has more than 6 arguments, then arguments 0 . . . 5 get passed in reg- isters rdi, rsi, rdx, rcx, r8, and r9, and arguments 6 . . . n − 1 get passed on the stack. If the function has at most 6 arguments, all arguments get passed in registers. Just before the caller executes the call in- struction, the stack layout is as shown in Figure 2(a), with register rsp (the stack pointer) pointing to the lowest argument on the stack
    #assembly #programming