Académique Documents
Professionnel Documents
Culture Documents
COE 205
Computer Organization and Assembly Language
Computer Engineering Department King Fahd University of Petroleum and Minerals
Presentation Outline
Basic Computer Organization Intel Microprocessors IA-32 Registers Instruction Execution Cycle IA-32 Memory Management
IA-32 Architecture
Address Bus
Control Bus
Memory
I/O Device #1
I/O Device #2
IA-32 Architecture
Processor
Processor consists of
Datapath
ALU
Registers
Control unit
ALU
Performs arithmetic and logic instructions
Clock
Synchronizes Processor and Bus operations
Clock cycle = Clock period = 1 / Clock rate
Cycle 1 Cycle 2 Cycle 3
Memory
Ordered sequence of bytes
The sequence number is called the memory address
Address Space
Address Space is the set of memory locations (bytes) that can be addressed
IA-32 Architecture
Memory Unit
Address Bus
Data Bus
Data is placed on the data bus
IA-32 Architecture
Write cycle
1. Processor places address on the address bus 2. Processor asserts the memory write control signal
CLK
Address ADDR
RD
Data DATA
IA-32 Architecture
Memory Devices
ROM = Read-Only Memory
Stores information permanently (non-volatile) Used to store the information required to startup the computer Many types: ROM, EPROM, EEPROM, and FLASH FLASH memory can be erased electrically in blocks
Memory Hierarchy
Registers
Fastest storage elements, stores most frequently used data
Cache Memory
Fast SRAM that stores recently used instructions and data Recent processors have 2 levels
Read/write head
Actuator
Recording area
Seek Time: head movement to the desired track (milliseconds) Rotation Latency: disk rotation until desired sector arrives under the head Transfer Time: to transfer one sector
IA-32 Architecture
Calculate
Time of one rotation (in milliseconds)
Average time to access a block of 32 consecutive sectors
Answer
Rotations per second = 7200/60 = 120 RPS Rotation time in milliseconds = 1000/120 = 8.33 ms Average rotational latency = time of half rotation = 4.17 ms Time to transfer 32 sectors = (32/200) * 8.33 = 1.33 ms
I/O Controllers
I/O devices are interfaced via an I/O controller
I/O controller uses the system bus to communicate with processor
IA-32 Architecture
Next ...
Basic Computer Organization Intel Microprocessors IA-32 Registers Instruction Execution Cycle IA-32 Memory Management
IA-32 Architecture
Intel Microprocessors
Intel introduced the 8086 microprocessor in 1979 8086, 8087, 8088, and 80186 processors
16-bit processors with 16-bit registers
16-bit data bus and 20-bit address bus
Physical address space = 220 bytes = 1 MB
Separate 8 KB instruction and 8 KB data caches MMX instructions (later models) for multimedia applications
IA-32 Architecture COE 205 Computer Organization and Assembly Language KFUPM Muhamed Mudawar slide 19
Next ...
Basic Computer Organization Intel Microprocessors IA-32 Registers Instruction Execution Cycle IA-32 Memory Management
IA-32 Architecture
CS
SS
ES
FS
DS
GS
Muhamed Mudawar slide 25
IA-32 Architecture
General-Purpose Registers
Used primarily for arithmetic and data movement
mov eax, 10 move constant 10 into register eax
AH
AL
8 bits + 8 bits
AX
16 bits
ESI, EDI, EBP, ESP have only 16-bit names for lower half
EAX
32 bits
IA-32 Architecture
Stack
IA-32 Architecture COE 205 Computer Organization and Assembly Language KFUPM Muhamed Mudawar slide 28
EFLAGS Register
Status Flags
Status of arithmetic and logical operations
Programs can set and clear individual bits in the EFLAGS register
IA-32 Architecture COE 205 Computer Organization and Assembly Language KFUPM Muhamed Mudawar slide 29
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
Parity Flag
Set when parity is even Least-significant byte in result contains even number of 1s
IA-32 Architecture COE 205 Computer Organization and Assembly Language KFUPM Muhamed Mudawar slide 30
Opcode Register
IA-32 Architecture COE 205 Computer Organization and Assembly Language KFUPM Muhamed Mudawar slide 31
Next ...
Basic Computer Organization Intel Microprocessors IA-32 Registers Instruction Execution Cycle IA-32 Memory Management
IA-32 Architecture
IA-32 Architecture
...
registers
registers
I1 instruction register
Execute
write write
decode
Result Writeback
flags (output)
ALU execute
IA-32 Architecture
Pipelined Execution
Instruction execution can be divided into stages Pipelining makes it possible to start an instruction before completing the execution of previous one
Stages
1 2 3 4 5 6 7 8 9 10 S1 I-1 S2 I-1 I-1 I-1 I-1 I-1 I-2 I-2 I-2 I-2 S3 S4 S5 S6
S2
S3
S4
S5
S6
Cycles
Cycles
3 4 5 6 7
11 12
IA-32 Architecture
I-2
I-2
Pipelined Execution
Stages
1 2 3 4 5 6 7 8 9 10 11 S1 I-1 I-2 I-3 S2 I-1 I-2 I-3 S3 exe S4 S5 S6
Cycles
Superscalar Architecture
A superscalar processor has multiple execution pipelines The Pentium processor has two execution pipelines
Called U and V pipes
Stages
S4 S3 u v S5 S6
Second pipeline eliminates wasted cycles For k stages and n instructions, number of cycles = k + n
IA-32 Architecture
I-1 I-2 I-3 I-4 I-1 I-1 I-3 I-3 I-2 I-2 I-4 I-4 I-1 I-2 I-3 I-4 I-1 I-2 I-3 I-4
Muhamed Mudawar slide 37
Next ...
Basic Computer Organization Intel Microprocessors IA-32 Registers Instruction Execution Cycle IA-32 Memory Management
IA-32 Architecture
Modes of Operation
Real-Address mode (original mode provided by 8086)
Only 1 MB of memory can be addressed, from 0 to FFFFF (hex) Programs can access any part of main memory MS-DOS runs in real-address mode
Data segment
Extra segments (up to 3)
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 COE 205 Computer Organization and Assembly Language KFUPM Muhamed Mudawar slide 41
Your turn . . .
What linear address corresponds to logical address 028F:0030?
EIP Register
Points at next instruction
ESI EDI
32-bit address
EIP
32-bit address
EBP ESP CS DS SS ES
Unused
32-bit offset (EIP, ESP, EBP, ESI ,EDI, EAX, EBX, ECX, EDX)
IA-32 Architecture
Upper 13 bits of segment selector are used to index the descriptor table
GDTR, LDTR
TI = Table Indicator Select the descriptor table 0 = Global Descriptor Table 1 = Local Descriptor Table
IA-32 Architecture COE 205 Computer Organization and Assembly Language KFUPM Muhamed Mudawar slide 46
Segment Limit
20-bit number that specifies the size of the segment The size is specified either in bytes or multiple of 4 KB pages Using 4 KB pages, segment size can range from 4 KB to 4 GB
Access Rights
Whether the segment contains code or data Whether the data can be read-only or read & written Privilege level of the segment to protect its access
IA-32 Architecture COE 205 Computer Organization and Assembly Language KFUPM Muhamed Mudawar slide 48
IA-32 Architecture
Paging
Paging divides the linear address space into
Fixed-sized blocks called pages, Intel IA-32 uses 4 KB pages
Paging contd
Main Memory
The operating system uses page tables to map the pages in the linear virtual address space onto main memory Each running program has its own page table
...
Hard Disk
Pages that cannot fit in main memory are stored on the hard disk
The operating system swaps pages between memory and the hard disk
As a program is running, the processor translates the linear virtual addresses onto real memory (called also physical) addresses
IA-32 Architecture COE 205 Computer Organization and Assembly Language KFUPM Muhamed Mudawar slide 51