X86組合語言/基本指令集
外觀
< X86組合語言
首頁 > 電腦科學與技術書架 > X86組合語言 > 基本指令集
資料搬移指令(Data transfer instructions)
[編輯]- MOV:在通用暫存器之間移動資料;在主記憶體和通用或區段暫存器之間移動資料;將立即數值移動到通用暫存器。(Move data between general-purpose registers; move data between memory and general purpose or segment registers; move immediates to general-purpose registers.)
- CMOVE/CMOVZ:Conditional move if equal/Conditional move if zero.
- CMOVNE/CMOVNZ:Conditional move if not equal/Conditional move if not zero.
- CMOVA/CMOVNBE:Conditional move if above/Conditional move if not below or equal.
- CMOVAE/CMOVNB:Conditional move if above or equal/Conditional move if not below.
- CMOVB/CMOVNAE:Conditional move if below/Conditional move if not above or equal.
- CMOVBE/CMOVNA:Conditional move if below or equal/Conditional move if not above.
- CMOVG/CMOVNLE:Conditional move if greater/Conditional move if not less or equal.
- CMOVGE/CMOVNL:Conditional move if greater or equal/Conditional move if not less.
- CMOVL/CMOVNGE:Conditional move if less/Conditional move if not greater or equal.
- CMOVLE/CMOVNG:Conditional move if less or equal/Conditional move if not greater.
- CMOVC:Conditional move if carry.
- CMOVNC:Conditional move if not carry.
- CMOVO:Conditional move if overflow.
- CMOVNO:Conditional move if not overflow.
- CMOVS:Conditional move if sign (negative).
- CMOVNS:Conditional move if not sign (non-negative).
- CMOVP/CMOVPE:Conditional move if parity/Conditional move if parity even.
- CMOVNP/CMOVPO:Conditional move if not parity/Conditional move if parity odd.
- XCHG:交換。(Exchange.)
- BSWAP:Byte swap.
- XADD:Exchange and add.
- CMPXCHG:Compare and exchange.
- CMPXCHG8B:Compare and exchange 8 bytes.
- PUSH:Push onto stack.
- POP:Pop off of stack.
- PUSHA/PUSHAD:Push general-purpose registers onto stack.
- POPA/POPAD:Pop general-purpose registers from stack.
- CWD/CDQ:Convert word to doubleword/Convert doubleword to quadword.
- CBW/CWDE:Convert byte to word/Convert word to doubleword in EAX register.
- MOVSX:Move and sign extend.
- MOVZX:Move and zero extend.
二進位算術指令(Binary Arithmetic Instructions)
[編輯]- ADCX:Unsigned integer add with carry.
- ADOX:Unsigned integer add with overflow.
- ADD:Integer add.
- ADC:含進位的加法。(Add with carry.)
- SUB:減法。(Subtract.)
- SBB:含借位的減法。Subtract with borrow.
- IMUL:有號數乘法。(Signed multiply.)
- MUL:無號數乘法。(Unsigned multiply.)
- IDIV:有號數除法。(Signed divide.)
- DIV:無號數除法。(Unsigned divide.)
- INC:加一。(Increment.)
- DEC:減一。(Decrement.)
- NEG:Negate.
- CMP:比較。(Compare.)
十進位算術指令(Decimal Arithmetic Instructions)
[編輯]- DAA:Decimal adjust after addition.
- DAS:Decimal adjust after subtraction.
- AAA:ASCII adjust after addition.
- AAS:ASCII adjust after subtraction.
- AAM:ASCII adjust after multiplication.
- AAD:ASCII adjust before division.
邏輯指令(Decimal Arithmetic Instructions)
[編輯]- AND:Perform bitwise logical AND.
- OR:Perform bitwise logical OR.
- XOR:Perform bitwise logical exclusive OR.
- NOT:Perform bitwise logical NOT
移位及輪轉指令(Shift and Rotate Instruction)
[編輯]- SAR:Shift arithmetic right.
- SHR:Shift logical right.
- SAL/SHL:Shift arithmetic left/Shift logical left.
- SHRD:Shift right double.
- SHLD:Shift left double.
- ROR:Rotate right.
- ROL:Rotate left.
- RCR:Rotate through carry right.
- RCL:Rotate through carry left
位元及位元組指令(Bit and Byte Instructions)
[編輯]- BT:Bit test.
- BTS:Bit test and set.
- BTR:Bit test and reset.
- BTC:Bit test and complement.
- BSF:Bit scan forward.
- BSR:Bit scan reverse.
- SETE/SETZ:Set byte if equal/Set byte if zero.
- SETNE/SETNZ:Set byte if not equal/Set byte if not zero.
- SETA/SETNBE:Set byte if above/Set byte if not below or equal.
- SETAE/SETNB/SETNC:Set byte if above or equal/Set byte if not below/Set byte if not carry.
- SETB/SETNAE/SETC:Set byte if below/Set byte if not above or equal/Set byte if carry.
- SETBE/SETNA:Set byte if below or equal/Set byte if not above.
- SETG/SETNLE:Set byte if greater/Set byte if not less or equal.
- SETGE/SETNL:Set byte if greater or equal/Set byte if not less.
- SETL/SETNGE:Set byte if less/Set byte if not greater or equal.
- SETLE/SETNG:Set byte if less or equal/Set byte if not greater.
- SETS:Set byte if sign (negative).
- SETNS:Set byte if not sign (non-negative).
- SETO:Set byte if overflow.
- SETNO:Set byte if not overflow.
- SETPE/SETP:Set byte if parity even/Set byte if parity.
- SETPO/SETNP:Set byte if parity odd/Set byte if not parity.
- TEST:Logical compare.
- CRC32:Provides hardware acceleration to calculate cyclic redundancy checks for fast and efficient implementation of data integrity protocols.
- POPCNT:This instruction calculates of number of bits set to 1 in the second operand (source) and returns the count in the first operand (a destination register)
控制轉移指令(Control Transfer Instruction)
[編輯]- JMP:無條件跳躍(Jump.)
- JE/JZ:Jump if equal/Jump if zero.
- JNE/JNZ:Jump if not equal/Jump if not zero.
- JA/JNBE:Jump if above/Jump if not below or equal.
- JAE/JNB:Jump if above or equal/Jump if not below.
- JB/JNAE:Jump if below/Jump if not above or equal.
- JBE/JNA:Jump if below or equal/Jump if not above.
- JG/JNLE:Jump if greater/Jump if not less or equal.
- JGE/JNL:Jump if greater or equal/Jump if not less.
- JL/JNGE:Jump if less/Jump if not greater or equal.
- JLE/JNG:Jump if less or equal/Jump if not greater.
- JC:Jump if carry.
- JNC:Jump if not carry.
- JO:Jump if overflow.
- JNO:Jump if not overflow.
- JS:Jump if sign (negative).
- JN:Jump if not sign (non-negative).
- JPO/JNP:Jump if parity odd/Jump if not parity.
- JPE/JP:Jump if parity even/Jump if parity.
- JCXZ/JECXZ:Jump register CX zero/Jump register ECX zero.
- LOOP:Loop with ECX counter.
- LOOPZ/LOOPE:Loop with ECX and zero/Loop with ECX and equal.
- LOOPNZ/LOOPNE:Loop with ECX and not zero/Loop with ECX and not equal.
- CALL:呼叫副程式或函數。(Call procedure.)
- RET:從副程式或函數返回。(Return.)
- IRET:從插斷返回。(Return from interrupt.)
- INT:軟體插斷。(Software interrupt.)
- INTO:Interrupt on overflow.
- BOUND:Detect value out of range.
- ENTER:High-level procedure entry.
- LEAVE:High-level procedure exit
字串指令(String Instruction)
[編輯]- MOVS/MOVSB:Move string/Move byte string.
- MOVS/MOVSW:Move string/Move word string.
- MOVS/MOVSD:Move string/Move doubleword string.
- CMPS/CMPSB:Compare string/Compare byte string.
- CMPS/CMPSW:Compare string/Compare word string.
- CMPS/CMPSD:Compare string/Compare doubleword string.
- SCAS/SCASB:Scan string/Scan byte string.
- SCAS/SCASW:Scan string/Scan word string.
- SCAS/SCASD:Scan string/Scan doubleword string.
- LODS/LODSB:Load string/Load byte string.
- LODS/LODSW:Load string/Load word string.
- LODS/LODSD:Load string/Load doubleword string.
- STOS/STOSB:Store string/Store byte string.
- STOS/STOSW:Store string/Store word string.
- STOS/STOSD:Store string/Store doubleword string.
- REP:Repeat while ECX not zero.
- REPE/REPZ:Repeat while equal/Repeat while zero.
- REPNE/REPNZ:Repeat while not equal/Repeat while not zero.
輸入及輸出指令(I/O Instruction)
[編輯]- IN:Read from a port.
- OUT:Write to a port.
- INS/INSB:Input string from port/Input byte string from port.
- INS/INSW:Input string from port/Input word string from port.
- INS/INSD:Input string from port/Input doubleword string from port.
- OUTS/OUTSB:Output string to port/Output byte string to port.
- OUTS/OUTSW:Output string to port/Output word string to port
進入及離開指令(Enter and Leave Instruction)
[編輯]- ENTER:High-level procedure entry.
- LEAVE:High-level procedure exit
旗標控制(EFLAG)指令(Flag Control (EFLAG) Instructions)
[編輯]- STC:設置進位旗標。(Set carry flag.)
- CLC:清除進位旗標。(Clear the carry flag.)
- CMC:Complement the carry flag.
- CLD:Clear the direction flag.
- STD:Set direction flag.
- LAHF:Load flags into AH register.
- SAHF:Store AH register into flags.
- PUSHF/PUSHFD:Push EFLAGS onto stack.
- POPF/POPFD:Pop EFLAGS from stack.
- STI:設置插斷旗標。(Set interrupt flag.)
- CLI:清除插斷旗標。(Clear the interrupt flag)
區段暫存器指令(Segment Register Instruction)
[編輯]- LDS:Load far pointer using DS.
- LES:Load far pointer using ES.
- LFS:Load far pointer using FS.
- LGS:Load far pointer using GS.
- LSS:Load far pointer using SS
雜項指令(Miscellaneous Instruction)
[編輯]- LEA:Load effective address.
- NOP:無運算。(No operation.)
- UD:Undefined instruction.
- XLAT/XLATB:Table lookup translation.
- CPUID:Processor identification.
- MOVBE: Move data after swapping data bytes.
- PREFETCHW: Prefetch data into cache in anticipation of write.
- PREFETCHWT: Prefetch hint T1 with intent to write.
- CLFLUSH:Flushes and invalidates a memory operand and its associated cache line from all levels of the processor’s cache hierarchy.
- CLFLUSHOPT:Flushes and invalidates a memory operand and its associated cache line from all levels of the processor’s cache hierarchy with optimized memory system throughput
使用者模式擴展狀態的儲存及還原指令(User Mode Extended Sate Save/Restore Instruction)
[編輯]- XSAVE:Save processor extended states to memory.
- XSAVEC:Save processor extended states with compaction to memory.
- XSAVEOPT:Save processor extended states to memory, optimized.
- XRSTOR:Restore processor extended states from memory.
- XGETBV:Reads the state of an extended control register
亂數產生指令(Random Number Generator Instructions)
[編輯]- RDRAND:Retrieves a random number generated from hardware.
- RDSEED:Retrieves a random number generated from hardwar
(BMI1, BMI2)
[編輯]- ANDN:Bitwise AND of first source with inverted 2nd source operands.
- BEXTR:Contiguous bitwise extract.
- BLSI:Extract lowest set bit.
- BLSMSK:Set all lower bits below first set bit to 1.
- BLSR:Reset lowest set bit.
- BZHI:Zero high bits starting from specified bit position.
- LZCNT:Count the number leading zero bits.
- MULX:Unsigned multiply without affecting arithmetic flags.
- PDEP:Parallel deposit of bits using a mask.
- PEXT:Parallel extraction of bits using a mask.
- RORX:Rotate right without affecting arithmetic flags.
- SARX:Shift arithmetic right.
- SHLX:Shift logic left.
- SHRX:Shift logic right.
- TZCNT:Count the number trailing zero bits
(Detection of VEX-encoded GPR Instructions, LZCNT and TZCNT, PREFETCH)
[編輯]以下內容待整理
[編輯]資料搬移指令 (Data transfer instructions)
[編輯]整數運算指令
[編輯]加法
[編輯]減法
[編輯]乘法
[編輯]除法
[編輯]邏輯運算指令
[編輯]位元位移指令
[編輯]程式流程控制
[編輯]跳越指令
[編輯]無條件跳越
[編輯]無號數運算(比較)後使用的條件跳越指令
[編輯]指令 | 意義 | 條件 | |
je | 若等於則跳越 | x = y | ZF=1 |
jne | 若不等於則跳越 | x≠y | ZF=0 |
ja jnbe |
若高於則跳越 若不低於則跳越 |
x > y | CF=0且ZF=0 |
jae jnb |
若高於或等於則跳越 若不低於或等於則跳越 |
x≧y | CF=0 |
jb jnae |
若低於則跳越 若不高於或等於則跳越 |
x < y | CF=1 |
jbe jna |
若低於或等於則跳越 若不高於則跳越 |
x≦y | CF=1或ZF=1 |
有號數運算(比較)後使用的條件跳越指令
[編輯]指令 | 意義 | 條件 | |
je | 若等於則跳越 | x = y | ZF=1 |
jne | 若不等於則跳越 | x≠y | ZF=0 |
jg jnle |
若大於則跳越 若不低於或等於則跳越 |
x > y | ZF=0且SF=OF |
jge jnl |
若高於於或等於則跳越 若不低於則跳越 |
x≧y | SF=OF |
jl jngl |
若低於則跳越 若不大於或等於則跳越 |
x < y | SF≠OF |
jle jng |
若低於或等於則跳越 若不大於則跳越 |
x≦y | ZF=1或SF≠OF |
依旗號狀態判斷的條件跳越指令
[編輯]指令 | 意義 | 條件 |
jc | 若進位則跳越 | CF=1 |
jnc | 若無進位則跳越 | CF=0 |
js | 若為負數則跳越 | SF=1 |
jns | 若為正數則跳越 | SF=0 |
jz | 若等於0則跳越 | ZF=1 |
jnz | 若不等於0則跳越 | ZF=0 |
jp | 若同位則跳越 | PF=1 |
jnp | 若沒有同位則跳越 | PF=0 |
jpe | 若偶同位則跳越 | PF=1 |
jpo | 若奇同位則跳越 | PF=0 |
jo | 若溢位則跳越 | OF=1 |
jno | 若沒有溢位則跳越 | OF=0 |
迴圈控制指令
[編輯]中斷指令(Interrupt Instruction)
[編輯]旗標控制相關指令
[編輯]中斷標誌位
[編輯]進位標誌位
[編輯]- 以下暫存
mov:這是組語裡面最常見的指令,將數值記入暫存器或是將A暫存器的內涵值移入B暫存器等等. 範例語法: mov 目的,來源 <==將來源值移入目的暫存器 mov DX,[zzz] <==將zzz變數內涵移入DX暫存器 mov EAX,14h <==移14h值移入EAX
int:呼叫中斷來處理之前暫存器內涵值所對應的工作.例如Linux是int 0x80. add:加 sub:減 mul:乘 div:除