INDEXED MEMORY?。蚈DE
.section .data
values:
.int 10,15,20,25,30,35,40,45,50,55,60
base_address(offset_address, index,size)
==> base_address + offset_address + index*size
movl $2, %edi
movl values(,%edi,4),%eax
間接尋址
- 在寄存器標(biāo)號(hào)前加
$取得是地址 - 在寄存器標(biāo)號(hào)加
()取的是該寄存器地址所指向的內(nèi)存的內(nèi)容
在這里插入圖片描述 - example:
.section .data
values:
.int 10,15,20,25,30,35,40,45,50,55,60
.sectio .text
.globl main
main:
nop
movl values, %eax # %eax=10
movl $values, %edi # %edi=&values
movl $100, 4(%edi) # 15換成100
movl $1, %edi # %edi=1
movl values(,%edi,4),%ebx # 100賦給%ebx
movl $1 %eax # %eax = 1
int $0x80
在這里插入圖片描述
-
inc= ++ -
cmpl比較 -
jnejump if not equal
DATA EXCHANGE
XCHG operand1, operand2-
bubble sort:
bubblesort -
%esi作為指針(保存數(shù)組起點(diǎn)) -
jgejump greater then equal 后-前是否>=0 -
dec=-- -
jnz上一條語(yǔ)句的結(jié)果是否為0 -
xchg寄存器和操作數(shù)
ADD
add? sourcr destination把source加到destinationSource operand: register,memory,immediate value
-
Destination operand:register,memory
在這里插入圖片描述 CF: 若進(jìn)位則為1
OF: 前面兩個(gè)高位相同且與第三個(gè)高位不同則為1
SF: 結(jié)果的高位是什么就是什么
ZF: 結(jié)果是0就是1 否則為0
sub? source destination:destination - sourceneg? destination:取反(negative)inc? destination:--dec? destination:++-
mul? source:無符號(hào)數(shù)乘法-
8位的數(shù)與
%al相乘,結(jié)果放入%ax中 imul? sourceimul? source, destination-
imul? multipler, source, destination:destination = multipler*source
-
8位的數(shù)與
multiple rules
在這里插入圖片描述
DIVIDE
- dividend / devisor = quotient * divisor + remainder
div? divisoridiv? divisor- 被除數(shù)是除數(shù)長(zhǎng)度的兩倍

div
SHIFT LEFT(MULTIPLY 2^N)
-
sal? destination: *2 -
sal? %cl,destination: *2^cl -
sal? shifter destination: *2^shifter(立即數(shù)) shl? (as same as sal)
SHIFT RIGHT(DIVIDED BY 2^N)
sar? destination-
sar? %cl,destination: /2^cl -
sar? shifter destination: /2^shifter(立即數(shù)) shr? (same as sar except always filling zero)
ROTATE SHIFT
在這里插入圖片描述
BOOLEAN LOGIC
- NOT
not? destination
- AND
- OR
- XOR
-
and?/or?/xor? source, destination
在這里插入圖片描述
-
- 清零
- xor 三個(gè)時(shí)鐘周期
- mov 四個(gè)時(shí)鐘周期
REVIEW
在這里插入圖片描述
INSTRUCTION POINTER
在這里插入圖片描述
-
jmp無條件跳
在這里插入圖片描述
CMOVE
在這里插入圖片描述
COMPARE
在這里插入圖片描述
LOOP
在這里插入圖片描述
PRINTF
p

在這里插入圖片描述

