Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

nasm

std › x86_64 › nasm

NASM-flavored x86-64 assembly: everything std.x86_64.intel provides, plus the NASM spellings it doesn’t have.

from std.x86_64.nasm import *

lea rsi, [rel msg]
mov eax, [rel counter]
add [rel total], rcx

msg:
    db "Hello, World!", 10
counter:
    dd 0
total:
    dq 0

[rip+disp] from std.x86_64.intel takes a displacement you already know; [rel label] takes a label and computes the displacement once the code is laid out. The two can’t share a spelling: a label is a plain int too, so [rip+label] would be exactly as well-typed as [rip+disp].

Not covered: NASM’s $/$$, equ, times, resb, and global/extern (use const, @for, and pub labels instead).

Re-exports std.x86_64.intel.

Macros

reg_field

The low 3 bits of r’s number: the part a ModRM or SIB field, or an opcode, holds.

SyntaxParametersResultDescriptionFrom
reg_field(r)r: Regreturns intstd.x86_64.impl

reg_ext

Bit 3 of r’s number, which goes in the REX prefix: 1 for r8 to r15.

SyntaxParametersResultDescriptionFrom
reg_ext(r)r: Regreturns intstd.x86_64.impl

rex_byte

A REX prefix, 0100WRXB. w selects 64-bit operands; r, x and b are bit 3 of the ModRM.reg, SIB.index and ModRM.rm (or SIB.base, or opcode) register numbers.

SyntaxParametersResultDescriptionFrom
rex_byte(w, r, x, b)w: int, r: int, x: int, b: intreturns Bytestd.x86_64.impl

modrm_byte

A ModRM byte: mod (2 bits), reg (3) and rm (3).

SyntaxParametersResultDescriptionFrom
modrm_byte(mod, reg, rm)mod: int, reg: int, rm: intreturns Bytestd.x86_64.impl

sib_byte

A SIB byte: scale (2 bits, log2 of the index’s multiplier), index (3) and base (3).

SyntaxParametersResultDescriptionFrom
sib_byte(scale, index, base)scale: int, index: int, base: intreturns Bytestd.x86_64.impl

byte_of

Byte index of value, counting from the least significant, byte 0.

SyntaxParametersResultDescriptionFrom
byte_of(value, index)value: int, index: intreturns Bytestd.x86_64.impl

mov

SyntaxParametersResultDescriptionFrom
mov rd, rs, wrd: Reg, rs: Reg, w: intemits Bytes<...>rd = rs.std.x86_64.impl
mov rd, imm, wrd: Reg, imm: int, w: intemits Bytes<...>rd = imm. With w = 1 it takes a full 64-bit imm.std.x86_64.impl
mov dst, rs, wdst: MemOperand, rs: Reg, w: intemits Bytes<...>Stores rs at dst.std.x86_64.impl
mov rd, src, wrd: Reg, src: MemOperand, w: intemits Bytes<...>Loads the value at src into rd.std.x86_64.impl
mov dst, imm, wdst: MemOperand, imm: int, w: intemits Bytes<...>Stores imm at dst: 32 bits, sign-extended to 64 when w is 1.std.x86_64.impl
mov rd, src, wrd: Reg, src: RipLabel, w: intLoads the value at the label src into rd.std.x86_64.impl
mov dst, rs, wdst: RipLabel, rs: Reg, w: intStores rs at the label dst.std.x86_64.impl
mov rd, rsrd: Reg, rs: Regrd = rs.std.x86_64.intel
mov rd, immrd: Reg, imm: intrd = imm.std.x86_64.intel
mov rd, rsrd: Reg32, rs: Reg32rd = rs, in 32 bits.std.x86_64.intel
mov rd, immrd: Reg32, imm: intrd = imm, in 32 bits.std.x86_64.intel
mov rd, srcrd: Reg, src: RipLabelLoads the value at src into rd.
mov rd, srcrd: Reg32, src: RipLabel
mov dst, rsdst: RipLabel, rs: RegStores rs at dst.
mov dst, rsdst: RipLabel, rs: Reg32

add

SyntaxParametersResultDescriptionFrom
add rd, rs, wrd: Reg, rs: Reg, w: intemits Bytes<...>rd = rd + rs.std.x86_64.impl
add rd, imm, wrd: Reg, imm: int, w: intemits Bytes<...>rd = rd + imm, with a 32-bit imm sign-extended to 64 bits.std.x86_64.impl
add dst, rs, wdst: MemOperand, rs: Reg, w: intemits Bytes<...>[dst] = [dst] + rs.std.x86_64.impl
add dst, imm, wdst: MemOperand, imm: int, w: intemits Bytes<...>[dst] = [dst] + imm, with a 32-bit imm.std.x86_64.impl
add dst, rs, wdst: RipLabel, rs: Reg, w: int[dst] = [dst] + rs, where dst is a label.std.x86_64.impl
add rd, rsrd: Reg, rs: Regrd = rd + rs.std.x86_64.intel
add rd, immrd: Reg, imm: intrd = rd + imm.std.x86_64.intel
add rd, rsrd: Reg32, rs: Reg32rd = rd + rs, in 32 bits.std.x86_64.intel
add rd, immrd: Reg32, imm: intrd = rd + imm, in 32 bits.std.x86_64.intel
add dst, rsdst: RipLabel, rs: RegAdds rs to the value at dst.
add dst, rsdst: RipLabel, rs: Reg32

or

SyntaxParametersResultDescriptionFrom
or rd, rs, wrd: Reg, rs: Reg, w: intemits Bytes<...>rd = rd | rs.std.x86_64.impl
or rd, imm, wrd: Reg, imm: int, w: intemits Bytes<...>rd = rd | imm, with a 32-bit imm sign-extended to 64 bits.std.x86_64.impl
or dst, rs, wdst: MemOperand, rs: Reg, w: intemits Bytes<...>[dst] = [dst] | rs.std.x86_64.impl
or dst, imm, wdst: MemOperand, imm: int, w: intemits Bytes<...>[dst] = [dst] | imm, with a 32-bit imm.std.x86_64.impl
or dst, rs, wdst: RipLabel, rs: Reg, w: int[dst] = [dst] | rs, where dst is a label.std.x86_64.impl
or rd, rsrd: Reg, rs: Regrd = rd | rs.std.x86_64.intel
or rd, immrd: Reg, imm: intrd = rd | imm.std.x86_64.intel
or rd, rsrd: Reg32, rs: Reg32rd = rd | rs, in 32 bits.std.x86_64.intel
or rd, immrd: Reg32, imm: intrd = rd | imm, in 32 bits.std.x86_64.intel
or dst, rsdst: RipLabel, rs: RegORs rs into the value at dst.
or dst, rsdst: RipLabel, rs: Reg32

and

SyntaxParametersResultDescriptionFrom
and rd, rs, wrd: Reg, rs: Reg, w: intemits Bytes<...>rd = rd & rs.std.x86_64.impl
and rd, imm, wrd: Reg, imm: int, w: intemits Bytes<...>rd = rd & imm, with a 32-bit imm sign-extended to 64 bits.std.x86_64.impl
and dst, rs, wdst: MemOperand, rs: Reg, w: intemits Bytes<...>[dst] = [dst] & rs.std.x86_64.impl
and dst, imm, wdst: MemOperand, imm: int, w: intemits Bytes<...>[dst] = [dst] & imm, with a 32-bit imm.std.x86_64.impl
and dst, rs, wdst: RipLabel, rs: Reg, w: int[dst] = [dst] & rs, where dst is a label.std.x86_64.impl
and rd, rsrd: Reg, rs: Regrd = rd & rs.std.x86_64.intel
and rd, immrd: Reg, imm: intrd = rd & imm.std.x86_64.intel
and rd, rsrd: Reg32, rs: Reg32rd = rd & rs, in 32 bits.std.x86_64.intel
and rd, immrd: Reg32, imm: intrd = rd & imm, in 32 bits.std.x86_64.intel
and dst, rsdst: RipLabel, rs: RegANDs rs into the value at dst.
and dst, rsdst: RipLabel, rs: Reg32

sub

SyntaxParametersResultDescriptionFrom
sub rd, rs, wrd: Reg, rs: Reg, w: intemits Bytes<...>rd = rd - rs.std.x86_64.impl
sub rd, imm, wrd: Reg, imm: int, w: intemits Bytes<...>rd = rd - imm, with a 32-bit imm sign-extended to 64 bits.std.x86_64.impl
sub dst, rs, wdst: MemOperand, rs: Reg, w: intemits Bytes<...>[dst] = [dst] - rs.std.x86_64.impl
sub dst, imm, wdst: MemOperand, imm: int, w: intemits Bytes<...>[dst] = [dst] - imm, with a 32-bit imm.std.x86_64.impl
sub dst, rs, wdst: RipLabel, rs: Reg, w: int[dst] = [dst] - rs, where dst is a label.std.x86_64.impl
sub rd, rsrd: Reg, rs: Regrd = rd - rs.std.x86_64.intel
sub rd, immrd: Reg, imm: intrd = rd - imm.std.x86_64.intel
sub rd, rsrd: Reg32, rs: Reg32rd = rd - rs, in 32 bits.std.x86_64.intel
sub rd, immrd: Reg32, imm: intrd = rd - imm, in 32 bits.std.x86_64.intel
sub dst, rsdst: RipLabel, rs: RegSubtracts rs from the value at dst.
sub dst, rsdst: RipLabel, rs: Reg32

xor

SyntaxParametersResultDescriptionFrom
xor rd, rs, wrd: Reg, rs: Reg, w: intemits Bytes<...>rd = rd ^ rs.std.x86_64.impl
xor rd, imm, wrd: Reg, imm: int, w: intemits Bytes<...>rd = rd ^ imm, with a 32-bit imm sign-extended to 64 bits.std.x86_64.impl
xor dst, rs, wdst: MemOperand, rs: Reg, w: intemits Bytes<...>[dst] = [dst] ^ rs.std.x86_64.impl
xor dst, imm, wdst: MemOperand, imm: int, w: intemits Bytes<...>[dst] = [dst] ^ imm, with a 32-bit imm.std.x86_64.impl
xor dst, rs, wdst: RipLabel, rs: Reg, w: int[dst] = [dst] ^ rs, where dst is a label.std.x86_64.impl
xor rd, rsrd: Reg, rs: Regrd = rd ^ rs.std.x86_64.intel
xor rd, immrd: Reg, imm: intrd = rd ^ imm.std.x86_64.intel
xor rd, rsrd: Reg32, rs: Reg32rd = rd ^ rs, in 32 bits.std.x86_64.intel
xor rd, immrd: Reg32, imm: intrd = rd ^ imm, in 32 bits.std.x86_64.intel
xor dst, rsdst: RipLabel, rs: RegXORs rs into the value at dst.
xor dst, rsdst: RipLabel, rs: Reg32

cmp

SyntaxParametersResultDescriptionFrom
cmp rd, rs, wrd: Reg, rs: Reg, w: intemits Bytes<...>Sets the flags from rd - rs, without storing it.std.x86_64.impl
cmp rd, imm, wrd: Reg, imm: int, w: intemits Bytes<...>Sets the flags from rd - imm, without storing it.std.x86_64.impl
cmp dst, rs, wdst: MemOperand, rs: Reg, w: intemits Bytes<...>Sets the flags from [dst] - rs, without storing it.std.x86_64.impl
cmp dst, imm, wdst: MemOperand, imm: int, w: intemits Bytes<...>Sets the flags from [dst] - imm, without storing it.std.x86_64.impl
cmp dst, rs, wdst: RipLabel, rs: Reg, w: intSets the flags from [dst] - rs, where dst is a label, without storing it.std.x86_64.impl
cmp rd, rsrd: Reg, rs: RegSets the flags from rd - rs, without storing it.std.x86_64.intel
cmp rd, immrd: Reg, imm: intSets the flags from rd - imm, without storing it.std.x86_64.intel
cmp rd, rsrd: Reg32, rs: Reg32Sets the flags from rd - rs, in 32 bits, without storing it.std.x86_64.intel
cmp rd, immrd: Reg32, imm: intSets the flags from rd - imm, in 32 bits, without storing it.std.x86_64.intel
cmp dst, rsdst: RipLabel, rs: RegCompares the value at dst with rs, setting flags like sub without storing.
cmp dst, rsdst: RipLabel, rs: Reg32

test

SyntaxParametersResultDescriptionFrom
test rd, rs, wrd: Reg, rs: Reg, w: intemits Bytes<...>Sets the flags from rd & rs, without storing it.std.x86_64.impl
test rd, imm, wrd: Reg, imm: int, w: intemits Bytes<...>Sets the flags from rd & imm, without storing it.std.x86_64.impl
test dst, rs, wdst: MemOperand, rs: Reg, w: intemits Bytes<...>Sets the flags from [dst] & rs, without storing it.std.x86_64.impl
test dst, imm, wdst: MemOperand, imm: int, w: intemits Bytes<...>Sets the flags from [dst] & imm, without storing it.std.x86_64.impl
test dst, rs, wdst: RipLabel, rs: Reg, w: intSets the flags from [dst] & rs, where dst is a label, without storing it.std.x86_64.impl
test rd, rsrd: Reg, rs: RegSets the flags from rd & rs, without storing it.std.x86_64.intel
test rd, immrd: Reg, imm: intSets the flags from rd & imm, without storing it.std.x86_64.intel
test rd, rsrd: Reg32, rs: Reg32Sets the flags from rd & rs, in 32 bits, without storing it.std.x86_64.intel
test rd, immrd: Reg32, imm: intSets the flags from rd & imm, in 32 bits, without storing it.std.x86_64.intel
test dst, rsdst: RipLabel, rs: RegANDs the value at dst with rs, setting flags without storing.
test dst, rsdst: RipLabel, rs: Reg32

Mem

The memory at [base + disp]. A displacement from -128 to 127 takes one byte; any other takes four.

SyntaxParametersResultDescriptionFrom
Mem(base, disp)base: Reg, disp: intreturns MemOperandstd.x86_64.impl

MemIndexed

The memory at [base + index * scale + disp]. scale is 1, 2, 4 or 8, and index can be any register but rsp.

from std.x86_64.impl import *

mov rax, MemIndexed(rbx, r12, 4, 0), 1
4a 8b 04 a3
from std.x86_64.impl import *

mov rax, MemIndexed(rbx, rsp, 4, 0), 1
rsp cannot be a SIB index register
SyntaxParametersResultDescriptionFrom
MemIndexed(base, index, scale, disp)base: Reg, index: Reg, scale: int, disp: intreturns MemOperandstd.x86_64.impl

MemRipRelative

The memory at [rip + disp]: disp bytes past the end of the instruction. To address a label, use a RipLabel instead.

SyntaxParametersResultDescriptionFrom
MemRipRelative(disp)disp: intreturns MemOperandstd.x86_64.impl

jmp

Jumps to the label target.

SyntaxParametersResultDescriptionFrom
jmp targettarget: intemits Rel32Instrstd.x86_64.impl

call

Pushes the address of the next instruction and jumps to the label target.

SyntaxParametersResultDescriptionFrom
call targettarget: intemits Rel32Instrstd.x86_64.impl

je

Jumps to the label target if equal (ZF = 1).

SyntaxParametersResultDescriptionFrom
je targettarget: intemits Rel32Instr2std.x86_64.impl

jne

Jumps to the label target if not equal (ZF = 0).

SyntaxParametersResultDescriptionFrom
jne targettarget: intemits Rel32Instr2std.x86_64.impl

jb

Jumps to the label target if below, unsigned (CF = 1).

SyntaxParametersResultDescriptionFrom
jb targettarget: intemits Rel32Instr2std.x86_64.impl

jae

Jumps to the label target if above or equal, unsigned (CF = 0).

SyntaxParametersResultDescriptionFrom
jae targettarget: intemits Rel32Instr2std.x86_64.impl

ja

Jumps to the label target if above, unsigned.

SyntaxParametersResultDescriptionFrom
ja targettarget: intemits Rel32Instr2std.x86_64.impl

jbe

Jumps to the label target if below or equal, unsigned.

SyntaxParametersResultDescriptionFrom
jbe targettarget: intemits Rel32Instr2std.x86_64.impl

jl

Jumps to the label target if less, signed.

SyntaxParametersResultDescriptionFrom
jl targettarget: intemits Rel32Instr2std.x86_64.impl

jge

Jumps to the label target if greater or equal, signed.

SyntaxParametersResultDescriptionFrom
jge targettarget: intemits Rel32Instr2std.x86_64.impl

jle

Jumps to the label target if less or equal, signed.

SyntaxParametersResultDescriptionFrom
jle targettarget: intemits Rel32Instr2std.x86_64.impl

jg

Jumps to the label target if greater, signed.

SyntaxParametersResultDescriptionFrom
jg targettarget: intemits Rel32Instr2std.x86_64.impl

js

Jumps to the label target if the result was negative (SF = 1).

SyntaxParametersResultDescriptionFrom
js targettarget: intemits Rel32Instr2std.x86_64.impl

jns

Jumps to the label target if the result wasn’t negative (SF = 0).

SyntaxParametersResultDescriptionFrom
jns targettarget: intemits Rel32Instr2std.x86_64.impl

jo

Jumps to the label target on signed overflow (OF = 1).

SyntaxParametersResultDescriptionFrom
jo targettarget: intemits Rel32Instr2std.x86_64.impl

jno

Jumps to the label target without signed overflow (OF = 0).

SyntaxParametersResultDescriptionFrom
jno targettarget: intemits Rel32Instr2std.x86_64.impl

jp

Jumps to the label target if the parity flag is set (PF = 1).

SyntaxParametersResultDescriptionFrom
jp targettarget: intemits Rel32Instr2std.x86_64.impl

jnp

Jumps to the label target if the parity flag is clear (PF = 0).

SyntaxParametersResultDescriptionFrom
jnp targettarget: intemits Rel32Instr2std.x86_64.impl

jz

je, under another name.

SyntaxParametersResultDescriptionFrom
jz targettarget: intemits Rel32Instr2std.x86_64.impl

jnz

jne, under another name.

SyntaxParametersResultDescriptionFrom
jnz targettarget: intemits Rel32Instr2std.x86_64.impl

jc

jb, under another name.

SyntaxParametersResultDescriptionFrom
jc targettarget: intemits Rel32Instr2std.x86_64.impl

jnae

jb, under another name.

SyntaxParametersResultDescriptionFrom
jnae targettarget: intemits Rel32Instr2std.x86_64.impl

jnc

jae, under another name.

SyntaxParametersResultDescriptionFrom
jnc targettarget: intemits Rel32Instr2std.x86_64.impl

jnb

jae, under another name.

SyntaxParametersResultDescriptionFrom
jnb targettarget: intemits Rel32Instr2std.x86_64.impl

jnbe

ja, under another name.

SyntaxParametersResultDescriptionFrom
jnbe targettarget: intemits Rel32Instr2std.x86_64.impl

jna

jbe, under another name.

SyntaxParametersResultDescriptionFrom
jna targettarget: intemits Rel32Instr2std.x86_64.impl

jnge

jl, under another name.

SyntaxParametersResultDescriptionFrom
jnge targettarget: intemits Rel32Instr2std.x86_64.impl

jnl

jge, under another name.

SyntaxParametersResultDescriptionFrom
jnl targettarget: intemits Rel32Instr2std.x86_64.impl

jng

jle, under another name.

SyntaxParametersResultDescriptionFrom
jng targettarget: intemits Rel32Instr2std.x86_64.impl

jnle

jg, under another name.

SyntaxParametersResultDescriptionFrom
jnle targettarget: intemits Rel32Instr2std.x86_64.impl

jpe

jp, under another name.

SyntaxParametersResultDescriptionFrom
jpe targettarget: intemits Rel32Instr2std.x86_64.impl

jpo

jnp, under another name.

SyntaxParametersResultDescriptionFrom
jpo targettarget: intemits Rel32Instr2std.x86_64.impl

ret

Returns: pops an address and jumps to it.

SyntaxParametersResultDescriptionFrom
retemits Bytestd.x86_64.impl

shl

SyntaxParametersResultDescriptionFrom
shl rd, imm, wrd: Reg, imm: int, w: intemits Bytes<...>rd = rd << imm.std.x86_64.impl
shl rd, immrd: Reg, imm: intrd = rd << imm.std.x86_64.intel
shl rd, immrd: Reg32, imm: intrd = rd << imm, in 32 bits.std.x86_64.intel

shl_cl

SyntaxParametersResultDescriptionFrom
shl_cl(rd, w)rd: Reg, w: intemits Bytes<...>rd = rd << cl.std.x86_64.impl
shl rd, clrd: Regrd = rd << cl.std.x86_64.intel
shl rd, clrd: Reg32rd = rd << cl, in 32 bits.std.x86_64.intel

shr

rd = rd >> imm, shifting in zeros.

SyntaxParametersResultDescriptionFrom
shr rd, imm, wrd: Reg, imm: int, w: intemits Bytes<...>std.x86_64.impl

shr_cl

SyntaxParametersResultDescriptionFrom
shr_cl(rd, w)rd: Reg, w: intemits Bytes<...>rd = rd >> cl, shifting in zeros.std.x86_64.impl
shr rd, clrd: Regrd = rd >> cl, shifting in zeros.std.x86_64.intel
shr rd, clrd: Reg32rd = rd >> cl, shifting in zeros, in 32 bits.std.x86_64.intel

sar

SyntaxParametersResultDescriptionFrom
sar rd, imm, wrd: Reg, imm: int, w: intemits Bytes<...>rd = rd >> imm, shifting in copies of the sign bit.std.x86_64.impl
sar rd, immrd: Reg, imm: intrd = rd >> imm, shifting in copies of the sign bit.std.x86_64.intel
sar rd, immrd: Reg32, imm: intrd = rd >> imm, shifting in copies of the sign bit, in 32 bits.std.x86_64.intel

sar_cl

SyntaxParametersResultDescriptionFrom
sar_cl(rd, w)rd: Reg, w: intemits Bytes<...>rd = rd >> cl, shifting in copies of the sign bit.std.x86_64.impl
sar rd, clrd: Regrd = rd >> cl, shifting in copies of the sign bit.std.x86_64.intel
sar rd, clrd: Reg32rd = rd >> cl, shifting in copies of the sign bit, in 32 bits.std.x86_64.intel

lea

SyntaxParametersResultDescriptionFrom
lea rd, src, wrd: Reg, src: MemOperand, w: intemits Bytes<...>Loads the address src stands for into rd, without reading memory.std.x86_64.impl
lea rd, src, wrd: Reg, src: RipLabel, w: intLoads the address of the label src into rd.std.x86_64.impl
lea rd, srcrd: Reg, src: RipLabelLoads the address of src into rd.
lea rd, srcrd: Reg32, src: RipLabel

rip_label_instr

An instruction with opcode opcode whose memory operand is the label addr, and whose other operand is r. The dialects’ [rel label] forms are built on it.

SyntaxParametersResultDescriptionFrom
rip_label_instr opcode, addr, r, wopcode: int, addr: RipLabel, r: Reg, w: intstd.x86_64.impl

push

Pushes the 64-bit rd onto the stack.

SyntaxParametersResultDescriptionFrom
push rdrd: Regemits Bytes<...>std.x86_64.impl

pop

Pops 64 bits off the stack into rd.

SyntaxParametersResultDescriptionFrom
pop rdrd: Regemits Bytes<...>std.x86_64.impl

syscall

Calls the operating system. On Linux, rax holds the call number and rdi, rsi, rdx, … its arguments.

SyntaxParametersResultDescriptionFrom
syscallemits Bytes<2>std.x86_64.impl

assert_valid_reg

Fails to compile unless r is a register number, 0 to 15. The instructions here use it to check their operands.

SyntaxParametersResultDescriptionFrom
assert_valid_reg rr: Regstd.x86_64.intel

mov_load_base

SyntaxParametersResultDescriptionFrom
mov rd, [base]rd: Reg, base: RegLoads the value at [base] into rd.std.x86_64.intel
mov rd, [base]rd: Reg32, base: RegLoads the 32-bit value at [base] into rd.std.x86_64.intel

mov_load_base_disp

SyntaxParametersResultDescriptionFrom
mov rd, [base+disp]rd: Reg, base: Reg, disp: intLoads the value at [base + disp] into rd.std.x86_64.intel
mov rd, [base+disp]rd: Reg32, base: Reg, disp: intLoads the 32-bit value at [base + disp] into rd.std.x86_64.intel

mov_load_indexed

SyntaxParametersResultDescriptionFrom
mov rd, [base+index*scale+disp]rd: Reg, base: Reg, index: Reg, scale: int, disp: intLoads the value at [base + index * scale + disp] into rd.std.x86_64.intel
mov rd, [base+index*scale+disp]rd: Reg32, base: Reg, index: Reg, scale: int, disp: intLoads the 32-bit value at [base + index * scale + disp] into rd.std.x86_64.intel

mov_load_rip

SyntaxParametersResultDescriptionFrom
mov rd, [rip+disp]rd: Reg, disp: intLoads the value at [rip + disp], disp bytes past the end of the instruction, into rd.std.x86_64.intel
mov rd, [rip+disp]rd: Reg32, disp: intLoads the 32-bit value at [rip + disp], disp bytes past the end of the instruction, into rd.std.x86_64.intel

mov_store_base

SyntaxParametersResultDescriptionFrom
mov [base], rsbase: Reg, rs: RegStores rs at [base].std.x86_64.intel
mov [base], rsbase: Reg, rs: Reg32Stores the 32-bit rs at [base].std.x86_64.intel

mov_store_base_disp

SyntaxParametersResultDescriptionFrom
mov [base+disp], rsbase: Reg, disp: int, rs: RegStores rs at [base + disp].std.x86_64.intel
mov [base+disp], rsbase: Reg, disp: int, rs: Reg32Stores the 32-bit rs at [base + disp].std.x86_64.intel

mov_store_indexed

SyntaxParametersResultDescriptionFrom
mov [base+index*scale+disp], rsbase: Reg, index: Reg, scale: int, disp: int, rs: RegStores rs at [base + index * scale + disp].std.x86_64.intel
mov [base+index*scale+disp], rsbase: Reg, index: Reg, scale: int, disp: int, rs: Reg32Stores the 32-bit rs at [base + index * scale + disp].std.x86_64.intel

mov_store_rip

SyntaxParametersResultDescriptionFrom
mov [rip+disp], rsdisp: int, rs: RegStores rs at [rip + disp], disp bytes past the end of the instruction.std.x86_64.intel
mov [rip+disp], rsdisp: int, rs: Reg32Stores the 32-bit rs at [rip + disp], disp bytes past the end of the instruction.std.x86_64.intel

lea_base

SyntaxParametersResultDescriptionFrom
lea rd, [base]rd: Reg, base: RegLoads the address [base] into rd, without reading memory.std.x86_64.intel
lea rd, [base]rd: Reg32, base: RegLoads the address [base] into the 32-bit rd, without reading memory.std.x86_64.intel

lea_base_disp

SyntaxParametersResultDescriptionFrom
lea rd, [base+disp]rd: Reg, base: Reg, disp: intLoads the address [base + disp] into rd, without reading memory.std.x86_64.intel
lea rd, [base+disp]rd: Reg32, base: Reg, disp: intLoads the address [base + disp] into the 32-bit rd, without reading memory.std.x86_64.intel

lea_indexed

SyntaxParametersResultDescriptionFrom
lea rd, [base+index*scale+disp]rd: Reg, base: Reg, index: Reg, scale: int, disp: intLoads the address [base + index * scale + disp] into rd, without reading memory.std.x86_64.intel
lea rd, [base+index*scale+disp]rd: Reg32, base: Reg, index: Reg, scale: int, disp: intLoads the address [base + index * scale + disp] into the 32-bit rd, without reading memory.std.x86_64.intel

lea_rip

SyntaxParametersResultDescriptionFrom
lea rd, [rip+disp]rd: Reg, disp: intLoads the address [rip + disp], disp bytes past the end of the instruction, into rd.std.x86_64.intel
lea rd, [rip+disp]rd: Reg32, disp: intLoads the address [rip + disp], disp bytes past the end of the instruction, into the 32-bit rd.std.x86_64.intel

shr_imm

SyntaxParametersResultDescriptionFrom
shr rd, immrd: Reg, imm: intrd = rd >> imm, shifting in zeros.std.x86_64.intel
shr rd, immrd: Reg32, imm: intrd = rd >> imm, shifting in zeros, in 32 bits.std.x86_64.intel

rel

[rel label]: the memory at label, addressed relative to the next instruction, so the code works wherever it’s loaded.

from std.x86_64.nasm import *

lea rsi, [rel msg]    # msg is 6 bytes past the end of this instruction
mov eax, [rel msg]    # and right after this one

msg:
    db "Hi", 10
48 8d 35 06 00 00 00
8b 05 00 00 00 00
48 69 0a
SyntaxParametersResultDescription
[rel target]target: intreturns RipLabel

data_int

value as width little-endian bytes, truncated the way NASM does.

SyntaxParametersResultDescription
data_int(value, width)value: int, width: intreturns Bytes<...>

data_string

A string literal’s UTF-8 bytes, with no terminator.

SyntaxParametersResultDescription
data_string(source)<S>, source: Sreturns Bytes<...>

db

SyntaxParametersResultDescription
db aa: intBytes. Each operand is an integer, stored in one byte, or a string literal, stored as its UTF-8 bytes with no terminator (add , 0 yourself). Up to four operands; db "Hello", 10 is the common case.
db a<S>, a: S
db a, b<S>, a: S, b: int
db a, b, c<S>, a: S, b: int, c: int
db a, ba: int, b: int
db a, b, ca: int, b: int, c: int
db a, b, c, da: int, b: int, c: int, d: int

dw

SyntaxParametersResultDescription
dw aa: int16-bit little-endian words, one or two per line.
dw a, ba: int, b: int

dd

SyntaxParametersResultDescription
dd aa: int32-bit little-endian doublewords, one or two per line.
dd a, ba: int, b: int

dq

SyntaxParametersResultDescription
dq aa: int64-bit little-endian quadwords, one or two per line.
dq a, ba: int, b: int

Re-exported

From std.x86_64.impl: Reg, r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13, r14, r15, rax, rcx, rdx, rbx, rsp, rbp, rsi, rdi, Reg32, eax, ecx, edx, ebx, esp, ebp, esi, edi, r8d, r9d, r10d, r11d, r12d, r13d, r14d, r15d, Byte, Bytes, MemBase, MemSib, MemRip, MemOperand, Rel32Instr, Rel32Instr2, RipLabel, RipRelInstr, RipRelInstrRex.