03 IA32Architecture
03 IA32Architecture
03 IA32Architecture
Computer Organization
&
Assembly Language Programming
Dr Adnan Gutub
aagutub ‘at’ uqu.edu.sa
[Adapted from slides of Dr. Kip Irvine: Assembly Language for Intel-Based Computers]
Most Slides contents have been arranged by Dr Muhamed Mudawar & Dr Aiman El-Maleh from Computer Engineering Dept. at KFUPM
Outline
Intel Microprocessors
IA-32 Registers
Instruction Execution Cycle
IA-32 Memory Management
Status Flags
Status of arithmetic and logical operations
Control and System flags
Control the CPU operation
Programs can set and clear individual bits in the EFLAGS register
IA-32 Architecture Computer Organization and Assembly Language
slide 18/45
Status Flags
Carry Flag
Set when unsigned arithmetic result is out of range
Overflow Flag
Set when signed arithmetic result is out of range
Sign Flag
Copy of sign bit, set when result is negative
Zero Flag
Set when result is zero
Auxiliary Carry Flag
Set when there is a carry from bit 3 to bit 4
Parity Flag
Set when parity is even
Least-significant byte in result contains even number of 1s
IA-32 Architecture Computer Organization and Assembly Language
slide 19/45
Floating-Point, MMX, XMM Registers
Floating-point unit performs high speed FP operations
Eight 80-bit floating-point data registers
ST(0), ST(1), . . . , ST(7)
Arranged as a stack
Used for floating-point arithmetic
Instruction
Obtain instruction from program storage
Fetch
Instruction
Determine required actions and instruction size
Decode
Infinite Cycle
Operand
Locate and obtain operand data
Fetch
Writeback
Deposit results in storage for later use
Result
decode
Result Writeback
write
write
flags ALU
execute
(output)
5 I-1
6 dc de I-1
7 I-2 loc xe
k c c ut
8 I-2
yc ion
9 I-2 les
10 I-2 Pipelined
11 I-2 Execution
12 I-2
Cycles
4 I-3 I-2 I-1
As more instructions enter the
5 I-3 I-1
pipeline, wasted cycles occur 6 I-2 I-1
7 I-2 I-1
For k stages, where one 8 I-3 I-2
stage requires 2 cycles, n 9 I-3 I-2
instructions require k + 2n – 1 10 I-3
11 I-3
cycles
IA-32 Architecture Computer Organization and Assembly Language
slide 27/45
Superscalar Architecture
A superscalar processor has multiple execution pipelines
The Pentium processor has two execution pipelines
Called U and V pipes
Each segment is 64 KB
Logical address
Segment = 16 bits
Offset = 16 bits
Solution:
A1F00 (add 0 to segment in hex)
+ 04C0 (offset in hex)
A23C0 (20-bit linear address in hex)
IA-32 Architecture Computer Organization and Assembly Language
slide 34/45
Segment Overlap
There is a lot of overlapping
between segments in the main
memory.
A new segment starts every
10h locations (i.e. every 16
locations).
Starting address of a segment
always has a 0h LSD.
Due to segments overlapping
logical addresses are not
unique .
Upper 13 bits of
segment selector GDTR, LDTR
are used to index
the descriptor table
TI = Table Indicator
Select the descriptor table
0 = Global Descriptor Table
1 = Local Descriptor Table
space of Program 1
space of Program 2
page tables to ... ...
map the pages
in the linear Page 2 Page 2
virtual address Page 1 Page 1
space onto Page 0 Page 0
main memory
Hard Disk
The operating
Each running Pages that cannot system swaps
program has fit in main memory pages between
its own page are stored on the memory and the
table hard disk hard disk