基础汇编指令
寄存器
本文中使用的寄存器通常为 ra, rb, rc, rd。
mov 指令
mov dst, src
一些例子:
# Moves the content of register rb into ra
mov ra, rb
# Moves the immediate 35h into ra
mov ra, 35h
# Moves the data at memory location ra into register rd
mov rd, [ra]
# Moves the data at memory location 12h into register rd
mov rd, [12h]
# Moves the content of register rc to the memory location rb.
mov [rb], rc
# Moves the immediate 07h to the memory location rb.
mov [rb], 07h
ALU 指令
instruction dst, src
将 dst 作为第一个操作数,src 作为第二个操作数,将运算结果存在 dst 中。
CMP 指令
cmp rn, rm
cmp rn, i
dst = src: Zero flag set, Carry flag cleardst > src: Zero flag clear, Carry flag cleardst < src: Zero flag clear, Carry flag set
JUMP 指令
jxxx src
- jz/je: jump if zero/equal (Zero set)
- jne/njz: jump if not zero/equal (Zero clear)
- ja: jump if above (Zero clear, carry clear)
- jb: jump if below (Zero clear, carry set)