Each operation in gas has a character suffix, indicating the size of the operand.
C statement |
Gas suffix |
Size (bytes) |
Char |
B |
1 |
Short |
W |
2 |
(Unsigned) int/long/char * |
L |
4 |
Float |
S |
4 |
Double |
L |
8 |
Long double |
T |
10/12 |
Note: Gal uses the suffix "L" to indicate both 4-byte integers and 8-byte double-precision floating point numbers. This does not produce ambiguity because floating point numbers use completely different commands and registers. Operand format:
Format |
Operation Value |
Name |
Example (gas = C) |
$ IMM |
IMM |
Immediate addressing |
$1 = 1 |
EA |
R [EA] |
Register addressing |
% Eax = eax |
IMM |
M [Imm] |
Absolute addressing |
0x104 = * 0x104 |
(Ea) |
M [R [EA] |
Indirect addressing |
(% Eax) = * eax |
Imm (EA) |
M [Imm + R [EA] |
(Base address + offset) Addressing |
4 (% eax) = * (4 + eax) |
(Ea, EB) |
M [R [EA] + R [Eb] |
Address Change |
(% Eax, % EBX) = * (eax + EBX) |
Imm (EA, EB) |
M [Imm + R [EA] + R [Eb] |
Addressing |
9 (% eax, % EBX) = * (9 + eax + EBX) |
(, EA, S) |
M [R [EA] * s] |
Scaling address change addressing |
(, % Eax, 4) = * (eax * 4) |
Imm (, EA, S) |
M [Imm + R [EA] * s] |
Scaling address change addressing |
0xfc (, % eax, 4) = * (0xfc + eax * 4) |
(Ea, EB, S) |
M (R [EA] + R [Eb] * s) |
Scaling address change addressing |
(% Eax, % EBX, 4) = * (eax + EBX * 4) |
Imm (EA, EB, S) |
M (IMM + R [EA] + R [Eb] * s) |
Scaling address change addressing |
8 (% eax, % EBX, 4) = * (8 + eax + EBX * 4) |
Note: M [XX] indicates the value of XX address in memory, and R [XX] indicates the value of register XX. This representation shows the form of a large array for both registers and memory. Data transmission command:
Command |
Effect |
Description |
Movl S, d |
D <-- S |
Double-character Transfer |
Movw S, d |
D <-- S |
Text Transfer |
Movb S, d |
D <-- S |
Byte Transfer |
Movsbl S, d |
D <-- symbol extension s |
Symbol bit filling (byte-> double-character) |
Movzbl S, d |
D <-- zero-scaling s |
Zero-padding (byte-> double-character) |
Pushl s |
R [% esp] <-- R [% esp]-4; M [R [% esp] <-- S |
Stack pressure |
Popl d |
D <-- M [R [% esp]; R [% esp] <-- R [% esp] + 4; |
Outbound Stack |
Note: It is assumed that the stack is extended to the lower address. Arithmetic and logical operation address:
Command |
Effect |
Description |
Leal S, d |
D = & S |
Movl local version, s address into D, D can only be a register |
Incl d |
D ++ |
Add 1 |
Decl d |
D -- |
Minus 1 |
Negl d |
D =-d |
Take negative |
Notl d |
D = ~ D |
Invert |
Addl S, d |
D = d + S |
Add |
Subl S, d |
D = D-S |
Subtraction |
Imull S, d |
D = D * s |
Multiplication |
Xorl S, d |
D = d ^ s |
Exclusive or |
Orl S, d |
D = d | S |
Or |
Andl S, d |
D = D & S |
And |
Sall K, d |
D = d <K |
Move left |
Shll K, d |
D = d <K |
Shift left (same as Sall) |
Sarl k, d |
D = D> K |
Shift right |
Shrl K, d |
D = D> K |
Right Shift of Logic |
Special arithmetic operations:
Command |
Effect |
Description |
Imull s |
R [% edX]: R [% eax] = S * R [% eax] |
Unsigned 64-bit Multiplication |
Mull S |
R [% edX]: R [% eax] = S * R [% eax] |
Signed 64-bit Multiplication |
Cltd s |
R [% edX]: R [% eax] = symbol bit extension R [% eax] |
Convert to 4 bytes |
Idivl s |
R [% edX] = R [% edX]: R [% eax] % s; R [% eax] = R [% edX]: R [% eax]/s; |
Signed division, saving the remainder and operator |
Divl s |
R [% edX] = R [% edX]: R [% eax] % s; R [% eax] = R [% edX]: R [% eax]/s; |
Unsigned division, stores the remainder and operator |
Note: 64-bit data is usually stored, 32-bit high data is stored in edX, and 32-bit low data is stored in eax. Condition code: The condition code register describes the attributes of recent arithmetic or logical operations. Cf: Carry flag. The highest digit generates carry, which can be used to check for unsigned overflow. Of: overflow flag, binary complement overflow-positive overflow or negative overflow. ZF: Indicates zero. The result is 0. SF: Symbol flag. The operation result is negative. Comparison command:
Command |
Based on |
Description |
Cmpb S2, S1 |
S1-S2 |
Compare byte, difference |
Testb S2, S1 |
S1 & S2 |
Test byte and relationship |
Cmpw S2, S1 |
S1-S2 |
Comparison word and Difference |
Testw S2, S1 |
S1 & S2 |
Test words and relationships |
CMPL S2, S1 |
S1-S2 |
Double-character comparison, difference |
Testl S2, S1 |
S1 & S2 |
Test dual-word and relationship |
Access condition code command:
Command |
Synonymous name |
Effect |
Set conditions |
Sete d |
Setz |
D = ZF |
Equal/zero |
Setne d |
Setnz |
D = ~ ZF |
Unequal/non-zero |
Sets d |
|
D = SF |
Negative |
Setns d |
|
D = ~ SF |
Non-negative |
Setg d |
Setnle |
D = ~ (SF ^ of) & ZF |
Greater than (signed>) |
Setge d |
Setnl |
D = ~ (SF ^) |
Less than or equal to (signed> =) |
SETl d |
Setnge |
D = SF ^ |
Less than (signed <) |
Setle d |
Setng |
D = (SF ^ of) | ZF |
Less than or equal to (signed <=) |
Seta d |
Setnbe |
D = ~ Cf &~ ZF |
Exceeds (unsigned>) |
Setae d |
Setnb |
D = ~ Cf |
Greater than or equal to (unsigned> =) |
SETB d |
Setnae |
D = cf |
Lower than (unsigned <) |
Setbe d |
Setna |
D = CF | ZF |
Less than or equal to (unsigned <=) |
Jump command:
Command |
Synonymous name |
Jump Condition |
Description |
JMP label |
|
1 |
Jump directly |
JMP * operand |
|
1 |
Indirect jump |
Je label |
JZ |
ZF |
Equal to/zero |
JNE label |
Jnz |
~ ZF |
Unequal/non-zero |
JS label |
|
SF |
Negative |
Jnz label |
|
~ SF |
Non-negative |
JG label |
Jnle |
~ (SF ^ )&~ ZF |
Greater than (signed>) |
Jge label |
JNL |
~ (SF ^) |
Greater than or equal to (signed> =) |
Jl label |
Jnge |
SF ^ |
Less than (signed <) |
Jle label |
Jng |
(SF ^ of) | ZF |
Less than or equal to (signed <=) |
Ja label |
Jnbe |
~ Cf &~ ZF |
Exceeds (unsigned>) |
Jae label |
JNB |
~ Cf |
Greater than or equal to (unsigned> =) |
JB label |
Jnae |
Cf |
Lower than (unsigned <) |
Jbe label |
JNA |
Cf | ZF |
Less than or equal to (unsigned <=) |
Transfer control command: (function call ):
Command |
Description |
Call label |
Process call, return address into Stack, jump to the start of the call process, return address is the address of the command after the call |
Call * operand |
Leave |
Prepare the stack for the returned result and the stack for the ret. This mainly refers to the use of the stack in the function and % EBP. |
|