Professional Documents
Culture Documents
Zero-Filled
• Example
static int a;
int b;
.local a
.comm a,4,4
.comm b,4,4
Memory Arguments
.section . data
firstint:
.int 40
.section .text
.globl main
.type main, @function
main: Literal: $
pushl %ebp Register: %
movl %esp, %ebp
subl $24, %esp Memory: (no prefix)
andl $-16, %esp
Address: $label
movl $20, %eax
addl firstint, %eax
leave
ret
http://csserver.evansville.edu/~richardson/courses/CS220/resources/supplements/gas/instruction_set.html
Revisit Flags
• Status Flags
Flag Bit Name
CF 0 Carry flag
PF 2 Parity flag
AF 4 Adjust flag
ZF 6 Zero flag
SF 7 Sign flag
OF 11 Overflow flag
• Control Flag Flag manipulation:
DF=0 increase EIP(default), DF=1 decrease EIP stc
• System Flags clc
std
IF bit 9 Interrupt enable flag
cld
……
sti
cli
Revisit Flags
• Meanings of the OF, CF, SF, and ZF Flags
• The following table describes the meanings of the four
flags used in conditional branching:
• OF (Overflow)
– 1 -- result is outside signed-number range0 -- otherwise
• CF (Carry)
– Carry out of (borrow into) high-order bit.
– 1 -- result is outside unsigned-number range0 -- otherwise
• SF (Sign)
– High-order bit of result.
– 1 -- negative signed number.0 -- positive signed number.
• ZF (Zero)
– 1 -- result = 00 -- otherwise
Label & Jump
• Jmp location
Address offset:
Short jump (< 128 bytes)
Far jump (cross segment)
Near jump (all other)
Conditional Branches
• J?? location
Example:
JZ newlocation
• no far jumps – can’t cross segments
Conditional Branches
• Conditional Jumps
• The following table lists the most common jump instructions and the tests they perform:
• The following conditional branches are similar to the above but involve comparisons which treat the operands as unsigned
integers: