Professional Documents
Culture Documents
1. CPU
2. Memory
3. Input / Output devices
4. Computer Software
Chapter 4 1
1. CPU
1.1. History of CPUs
1950s:
Ferranti Mark 1, 1951: from University of Manchester
single 80-bit accumulator , the 40-bit "multiplicand/quotient
register"
UNIVAC I (UNIVersal Automatic Computer I) designed
principally by J. Presper Eckert and John Mauchly, the
inventors of the ENIAC
1,905 operations per second running on a 2.25 MHz clock.
IBM 704 in 1957:
1
3/3/2021
1. CPU
1.1. History of CPUs
1960s:
IBM System/360 (S/360): 34,500 instructions per
second, with memory from 8 to 64 KB
PDP-11: developed by Digital Equipment Corporation
32 bit processor, allow 4 MB of physical memory
Motorola 68000:
Initial speed grades were 4, 6, and 8 MHz.
68k instruction set
1. CPU
1.1. History of CPUs
1970s:
Intel 4004 (1971):
a single instruction cycle was 10.8 microseconds
Clock rate is 1 MHz
2
3/3/2021
Chapter 4 5
1. CPU
1.2. Intel x86 Processors
Dominate laptop/desktop/server market
Evolutionary design
Backwards compatible up until 8086, introduced in 1978
Added more features as time goes on
3
3/3/2021
Chapter 4 7
Chapter 4 8
4
3/3/2021
Desktop Model
4 cores
Integrated graphics
3.3-3.8 GHz
65W
Server Model
8 cores
Integrated I/O
2-2.6 GHz
45W
Chapter 4 9
1. CPU
1.3. x86 Processors
8086 processor
40 pin dual in-line package
16-bit wide data bus
16-bit registers
20-bit external address bus
provides a 1 MB physical
address space
The maximum linear address
space is limited to 64 KB
Max CPU clock: 5- 10 MHz
Chapter 4 10
5
3/3/2021
Chapter 0 11
1. CPU
1.3. x86 Processors - 8086
Instructions:
One-address or two addresses operations
Support Assembly and high-level programming language (C,
Pascal)
Main registers: are called data register or general register
16 bit data
Can be accessed by 8-bit registers
AH AL AX (primary accumulator)
BH BL BX (base, accumulator)
CH CL CX (counter, accumulator)
DH DL DX (accumulator, other functions
Chapter 4 12
6
3/3/2021
1. CPU
1.3. 8086 Processors - 8086
Index registers: for addressing
SI Source Index
DI Destination Index
BP Base Pointer
SP Stack Pointer
Program counter:
IP Instruction Pointer
Segment registers:
CS Code Segment
DS Data Segment
ES Extra Segment
SS Stack Segment
Chapter 4 13
1. CPU
1.3. 8086 Processors
Segment registers:
a way to allow programs to address more than 64 KB
the registers CS, DS, SS, and ES point to the currently used program code
segment (CS), the current data segment (DS), the current stack segment
(SS), and one extra segment determined by the programmer (ES).
CS Code Segment
DS Data Segment
ES Extra Segment
SS Stack Segment
0110 1000 1000 0111 0000 Segment, 16 bits, shifted 4 bits left
+ 0011 0100 1010 1001 Offset, 16 bits
Chapter 4 14
7
3/3/2021
1. CPU
1.3. 8086 Processors - 8086
Examples for x86
memory segmentation
Chapter 4 15
1. CPU
1.3. x86 Processors
x86-32: 80386, 80486
Register extend to 32-bit
EAX. EBX ECX, EDX
ESI, EDI, EBP, ESP, EIP, EFLAGS
Two new segment registers (FS and GS) were added
FS, GS is extra data for segment registers
x86-64: AMD64, Core i5, Core i7,
An R-prefix identifies the 64-bit registers (RAX, RBX,
RCX, RDX, RSI, RDI, RBP, RSP, RFLAGS, RIP)
Add eight additional 64-bit general registers (R8-R15)
Chapter 4 16
8
3/3/2021
source
%esi %si index
destination
%edi %di index
stack
%esp %sp
pointer
base
%ebp %bp
pointer
9
3/3/2021
2. Memory
Chapter 4 19
2. Memory
Chapter 4 20
10
3/3/2021
2. Memory
Chapter 4 21
Memory locations are called words. Words are 8 bits (one byte) in size, or
a multiple of 8. Common word sizes are 16, 32 and 64 bits.
0 1 0 0 1 0 0 0 1
1
1 1 0 1 0 0 1 1
2
0 1 0 0 0 0 0 0
3
4 1 0 1 0 0 1 1 1
5 1 1 1 0 1 0 1 0
1 1 0 0 1 0 1 0
11
3/3/2021
2. Memory
1. 1 byte = 8 bits
FE ED FA CE
00 0x5 00 FE ED FA CE
00 0x4 00
CE 0x3 FE
FA 0x2 ED
ED 0x1 FA
FE 0x0 CE
Low Memory Addresses
Chapter 4 24
12
3/3/2021
2. Memory
Chapter 4 25
Quiz
1) Pick the correct choice for the 8086 CPU.
A 16 bit word size, 8 bit data path
B 8 bit word size, 8 bit data path
C 16 bit word size, 16 bit data path
D 4 bit word size, 8 bit data path
E 8 bit word size, 16 bit data path
2) Pick the correct choice for the 80386SX CPU.
A 16 bit word size, 16 bit data path
B 32 bit word size, 16 bit data path
C 8 bit word size, 32 bit data path
D 32 bit word size, 8 bit data path
E 32 bit word size, 32 bit data path
3) Pick the correct choice for the 80486DX CPU.
A 32 bit word size, 16 bit data path
B 64 bit word size, 32 bit data path
C 32 bit word size, 32 bit data path
D 32 bit word size, 16 bit data path
E 32 bit word size, 64 bit data path
Chapter 4 26
13
3/3/2021
Quiz
4) What is the first CPU to include an internal math
coprocessor?
A 386DX
B 486SX
C 486DX
D Pentium
5) What are the two main components of the CPU?
A The Control Unit and ALU
B The Registers and Output/Input management
C The ALU and FPU
6) What are the two main desktop CPU manufacturers?
A Intel and AMD
B Via and Power PC Address Content
C Marek and Sun UltraSparc 0x4000 2F
7) What are the 32-bit data when we read a double-word at 0x4001 65
the address 0x4000 with Big Endian mode?
0x4002 7E
A 0xAC7E652F
B 0x2F657EAC 0x4003 AC
C 0xCAE756F2 Chapter 4 27
Exercises
1. Suppose that you discover that RAM addresses 000C0000 to 000C7FFF are
reserved for a PC’s video adapter. How many bytes of memory is this?
2. Suppose that you have an Intel 8086. Find the five-hex-digit address that
corresponds to each of these segment:offset pairs:
(a) 2B8C:8D21 (b) 059A:7A04 (c) 1234:5678
3. In an 8086 program, suppose that the data segment register DS contains the
segment number 23D1 and that an instruction fetches a word at offset 7B86
in the data segment. What is the five-hex-digit address of the word that is
fetched?
4. In an 8086 program, suppose that the code segment register CS contains the
segment number 014C and that the instruction pointer IP contains 15FE.
What is the five-hex-digit address of the next instruction to be fetched?
5. What are advantages and disadvantage of secondary memory?
Chapter 4 28
14
3/3/2021
Chapter 4 29
2 Output Devices
Monitor (VDU)
Printer
Chapter 4 30
15
3/3/2021
Chapter 4 31
Chapter 4 32
16
3/3/2021
Chapter 4 33
examples
1. Serial port (Com)
2. Parallel Port
3. USB port
4. Ethernet Port
Chapter 4 34
17
3/3/2021
Chapter 4 35
4. Computer Software
Assembly/Machine Code View
CPU Memory
Addresses
Registers
Data Code
PC Data
Condition Instructions Stack
Codes
Programmer-Visible State
PC: Program counter Memory
Address of next instruction Byte addressable array
Called “RIP” (x86-64)
Code and user data
Register file
Stack to support procedures
Heavily used program data
Condition codes
Store status information about most
recent arithmetic or logical operation
Used for conditional branching
Chapter 4 36
18
3/3/2021
4. Computer Software
Turning C into Object Code
Code in files p1.c p2.c
Compile with command: gcc –Og p1.c p2.c -o p
Use basic optimizations (-Og) [New to recent versions of GCC]
Put resulting binary in file p
4. Computer Software
Compiling Into Assembly
C Code (sum.c) Generated x86-64 Assembly
long plus(long x, long y); sumstore:
pushq %rbx
void sumstore(long x, long y, movq %rdx, %rbx
long *dest) call plus
{ movq %rax, (%rbx)
long t = plus(x, y); popq %rbx
*dest = t; ret
}
Obtain (on shark machine) with command
gcc –Og –S sum.c
Produces file sum.s
Warning: Will get very different results on non-Shark machines (Andrew Linux,
Mac OS-X, …) due to different versions of gcc and different compiler settings.
Chapter 4 38
19
3/3/2021
Chapter 4 39
Chapter 4 40
20
3/3/2021
Chapter 4 41
Chapter 4 42
21
3/3/2021
Chapter 4 43
Chapter 4 44
22
3/3/2021
Chapter 4 45
Different
options can be
set for release
vs debug
builds
Chapter 4 46
23
3/3/2021
Chapter 4 47
Chapter 4 48
24
3/3/2021
Building project
Chapter 4 49
Building project 2
Information about whether the build
succeeded will be here. If it fails, a
separate error tab will open up
Chapter 4 50
25
3/3/2021
Chapter 4 51
Stop debugging
Restart debugging
Chapter 4 52
26
3/3/2021
Showing assembly
Chapter 4 53
Watching registers
Chapter 4 54
27
3/3/2021
Showing registers
Chapter 4 55
Chapter 4 56
28
3/3/2021
Click “Reevaluate
Automatically” so that it
Chapter 4
will change the display as 57
esp changes
29