Assembly 2016 F 02
Assembly 2016 F 02
Efficiency
2
Outline
General Concepts
Input-Output System
3
Outline
General Concepts
Input-Output System
4
Basic Computer Design
Clock synchronizes CPU operations
Control unit (CU) coordinates sequence of execution steps
ALU performs arithmetic and bitwise processing
data bus
registers
I/O I/O
Central Processor Unit Memory Storage
Device Device
(CPU) Unit
#1 #2
ALU CU clock
control bus
address bus
5
5
Clock
Synchronizes all CPU and bus operations
one cycle
6
Instruction Execution Cycle
Fetch instruction
Decode
Fetch operands
Memory registers (internal)
Execute
Store output
7
Reading from Memory
Multiple cycles are required when reading from memory, because it
responds much more slowly than the CPU
to respond
Data
DATA
Read Line (RD) goes to 1, indicating that the data is on the data bus
8
Cache Memory
High-speed expensive static RAM both inside and outside
the CPU
9
Multitasking
OS can run multiple programs at the same time
10
Execution: OS Role
When you executes a program, the OS does many things for you
Locates the binary executable file on disk
Calls the "loader" to move the file from disk to memory and resolve all
addresses if needed
Locates and links any runtime DLLs
11
Review Questions
1. The central processor unit (CPU) contains registers and what other basic
elements?
2. The central processor unit is connected to the rest of the computer system
using what three buses?
3. Why does memory access take more machine cycles than register access?
4. What are the three basic steps in the instruction execution cycle?
5. Define multitasking?
12
Outline
General Concepts
Input-Output System
13
Intel CPU History
Intel 8086 (1978)/8088 (1979)
1 MB addressable RAM
16-bit registers
14
History of the Intel IA-32 Family
Pentium – P5 (1993)
superscalar (Multiple ALU)
15
64-bit Processors
Intel64 Mode
64-bit linear address space
16
Technologies
Pipelined
simultaneous staggered execution of instructions
SuperScalar
multiple redundant functional units (e.g. ALUs)
HyperThreading
Two tasks execute on a single processor at the same time
Duplicate architectural state components (registers)
17
CISC and RISC
CISC – complex instruction set computing (Intel)
large instruction set
18
Basic Program Execution Registers
Registers are high-speed storage locations directly inside the CPU
designed to be accessed at much higher speed than conventional memory
Types of registers
General purpose registers
32-bit General-Purpose Registers
Segment registers
EAX EBP
EFLAGS CS ES
SS FS
EIP
DS GS
19
General Purpose Registers
These registers are primarily used for arithmetic and data movement.
AX 16 bits
EAX 32 bits
20
Index & Base Registers
Remaining general purpose registers have only a 16-bit
name for their lower half:
Source Index
Destination Index
Stack Pointer
21
Intended Register Use
General-Purpose
Segment
22
Specialized Registers
EFLAGS
23
Status Flags
Carry: unsigned arithmetic out of range
24
Example: Zero Flag
; initially, assume ZF = 0
; ZF is set (ZF = 1)
inc CX ; result is 1
; ZF is cleared (ZF = 0)
25
Summary: Registers
26
Review Questions
1. What are the x86 processor’s three basic modes of operation?
3. Besides the stack pointer (ESP), what other register points to variables on
the stack?
4. Which flag is set when the result of an unsigned arithmetic operation is too
large to fit into the destination?
27
Outline
General Concepts
Input-Output System
28
x86 Memory Management
Protected mode
native mode Windows, Linux
processor prevents programs from referencing memory outside their assigned segments.
Real-address mode
native mode MS-DOS
direct access to system memory and hardware devices: can cause the OS to crash.
• Virtual-8086 mode
• Special case of Protected (each program has its own 8086 computer)
• In short, virtual 8086 mode is whereby the CPU (in protected mode) is running a "Emulated"
(real mode) machine, e.g. cmd command.
29
Addressable Memory
Protected mode
Memory segment up to 4 GB
32-bit address
20-bit address
30
Real-Address Mode
32
Calculating Linear Addresses
Given a segment address:
1. Multiply it by 16 (add a hexadecimal zero), and
33
Program Segments
34
Protected Mode
4 GB addressable RAM (00000000h to FFFFFFFFh)
Memory models
Flat Segment Model
Paging
not used
(4GB)
physical RAM
00000000 00040 ----
00000000
36
Multi-Segment Model
Each program has a local descriptor table (LDT) to hold descriptor
for each segment used by the program
26000
base limit access
00026000 0010
00008000 000A
00003000 0002 8000
3000
37
Paging
Supported directly by the CPU
Divides each segment into 4096-byte (4 Kb) blocks called
pages
Sum of all programs can be larger than physical memory
Part of running program is in memory, part is on disk
Virtual memory manager (VMM) – OS utility that manages
the loading and unloading of pages
Page fault – issued by CPU when a page must be loaded from
disk
38
Review Questions
1. What is the range of addressable memory in protected mode and real-
address mode?
4. In protected mode, which register references the descriptor for the stack
segment?
39
Outline
General Concepts
Input-Output System
40
Levels of Input-Output
Level 3: High-level language function
examples: C++, Java
41
Displaying a String of Characters
• When a HLL program displays a string of characters, the
following steps take place:
OS Function Level 2
Hardware Level 0
42
Programming levels
• Assembly language programs can perform input-output at each
of the following levels:
43
Review Questions
1. Of the four levels of input/output in a computer system, which is the most
universal and portable?
3. Why are device drivers necessary, given that the BIOS already has code that
communicates with the computer’s hardware?
44
Summary
General Concepts
CPU Design, Instruction execution cycle
Input-Output System
Levels of input / output system
45