introduction-to-64-bit-assembly

The faker's guide to reading (x86) assembly language

introduction-to-64-bit-assembly

NASM - The Netwide Assembler

x86-64 下函数调用及栈帧原理

汇编语言基本概念简介

note

mov dst, src

xchg dst, src ; 交换数据 dst <-> src

push src
pop dst

pushf         ; flag register 数值压栈
popf

add dst, src  ; dst = dst + src  可能影响到 C(carray flag 进位标志)
adc dst, src  ; dst = dst + src + C ; (Add withCarry)带进位加法指令 主要用于多字节运算, 比如 u128 类型的数相加
inc dst       ; dst += 1 不影响 C

sub dst, src  ; dst = dst - src
sbb dst, src  ; dst = dst - src -C ; (SubtractionwithBorrow)进位减法指令
dec dst       ; dst -= 1, decrement <oprand> by 1

neg dst       ; dst = -dst   ; (Negate) 求补指令
cmp dst, src  ; dst - src    ; (Compare)比较指令 用以影响标识位


and dst, src  ; dst = dst&src ; 按 bit 与
test dst, src ; dst&src       ; 不保存结果, 只用来影响标识位
or dst, src
xor dst, src
not dst

je  <label>     ; if <op1> == <op2>
jne <label>     ; if <op1> != <op2>

jl  <label>     ; signed, if <op1> < <op2>
jle <label>     ; signed, if <op1> <= <op2>
jg  <label>     ; signed, if <op1> > <op2>
jge  <label>    ; signed, if <op1> >= <op2>

jb  <label>     ; unsigned, if <op1> < <op2>
jbe <label>     ; unsigned, if <op1> <= <op2>
ja  <label>     ; unsigned, if <op1> > <op2>
jae <label>     ; unsigned, if <op1> >= <op2>

check this example

Unsigned Multiplicationn

  mul <src>

image

Instruction Explanation
mul <src>

mul <op8>
mul <op16>
mul <op32>
mul <op64>
Multiply A register (al, ax, eax, or rax) times the <src> operand.
  Byte: ax = al * <src>
  Word: dx:ax = ax * <src>
  Double: edx:eax = eax * <src>
  Quad: rdx:rax = rax * <src>
Note, <src> operand cannot be an immediate
Examples: mul word [wVar]
mul al
mul dword [dVar]
mul qword [qVar]

Signed Multiplication

  imul <source>
  imul <dest>, <src/imm>
  imul <dest>, <src>, <imm>

image

Integer Division

image

  div <src> ; unsigned division
  idiv <src> ; signed division

image

Logical Operations

image
image

Shift Operations

image
image
image
image
image

Rotate Operations

image

mycode

posted on 2019-08-17 21:55  明天有风吹  阅读(274)  评论(0)    收藏  举报

导航

+V atob('d2h5X251bGw=')

请备注:from博客园