Lecture 01
Lecture 01
Intelligence
● RAM
● Register Vs Immediate
5
Outline
● Relative Addressing
● Example Programs
6
First Generation Computers & Architecture
First generation computers & architecture
● The Electronic Numerical Integrator And Computer (ENIAC) designed & developed by
Prof. John Mauchley and his student J. Presper Eckert
9
First generation computers & architecture
● He came to realize that the program could be represented in digital form in the
computer’s memory, along with the data
● He also saw that the clumsy serial decimal arithmetic used by the ENIAC, with
each digit represented by 10 vacuum tubes (1 on and 9 off) could be replaced
by using parallel binary arithmetic
10
First generation computers & architecture
11
First generation computers & architecture
● Each word held either two 20-bit instructions or a 40-bit signed integer
● The instructions had 8 bits devoted to telling the instruction type and
12 bits for specifying one of the 4096 memory words.
● Together, the arithmetic logic unit and the control unit formed
the ‘‘brain’’ of the computer.
● In modern computers they are combined onto a single chip called the
CPU (Central Processing Unit).
12
Basic Computing Concepts
Basic Computing Concepts
15
Basic Computing Concepts
16
Basic Computing Concepts
Storage
● To say that a computer "read" and "writes" numbers implies that there is
at least one number-holding structure that it reads from and writes to.
● All computers have a place to put numbers - a storage area that can be
read from and written to
17
Basic Computing Concepts
● To say that computer "modifies" numbers implies that the computer contains
a device for performing operations on numbers. This device is ALU.
● It's the part of the computer that performs arithmetic operations (+, -, *, /)
● Numbers are read from storage into the ALU's data input port.
● Once inside the ALU, they are modified by means of an arithmetic calculation
18
Basic Computing Concepts
Bus
● The ALU reads from and writes to the data storage area by means of the
data bus
19
Basic Computing Concepts
Storage Area
Instructio
t
Resul
Data
ns
ALU
20
Basic Computing Concepts
● These three steps are carried out billions (10 9) of times per second on a
modern CPU.
21
The Register File
The Register File
● Most computers have a relatively small number of very fast data storage
locations attached to the ALU
● The first x86 computers only had eight of them to work with
24
The Register File
25
The Register File - Example
● Task: Add contents of two registers and overwrite the contents of third
register with the resulting sum
Code Comments
26
The Register File - Example
27
RAM
RAM
● A small portion of that data set at a time is moved to the registers for
easy access from the ALU
30
RAM
ALU
31
CPU
Computation
● How a computer uses main memory, the registers and the ALU to add two
numbers
● Load the two operands (numbers) from main memory into two source
registers
● Add the contents of the source registers and place the result in the
destination register using the ALU. To do so, the ALU must perform these
steps:
○ Read the contents of registers A and B into the ALUs input ports
○ Add the contents of A & B in the ALU
○ Write the result to the register C via ALU's output port
32
Computation
● The existence of main memory means that the user must manage the
flow of information between main memory and the CPU's registers
● This means that user must issue instructions to more than just the
processor's ALU
● He or she must also issue instruction to the parts of the CPU that handle
memory traffic.
33
A Closer Look At The Code Stream
A Closer Look At The Code Stream
● Instructions are commands that tell the whole computer (Not just ALU)
exactly what actions to perform
36
A Closer Look At The Code Stream
● A load instruction to move the two numbers from memory into the registers
● A store instruction to tell the computer to place the result of the addition back
into memory, overwriting what was previously there.
● Memory-access instructions: These tell the parts of the processor that deal with
main memory to move data from and to main memory (load and store).
37
A Closer Look At The Code Stream
38
DLW-1's Arithmetic Instruction Format
● There are four parts to this instruction format each of which is called a field
● The instruction field specifies the type of operation being performed (+, -, /, *)
● The two source fields tell the computer which registers hold the two number
being operated on
● The destination field tells the computer which register to place the result in.
● Instruction: add A, B, C
39
DLW-1's Memory Instruction Format
● To get the processor to move two operands from main memory into
source registers, a memory-access instruction load is used.
● The load instruction loads the appropriate data from main memory into
the appropriate registers.
40
An Example DLW-1 Program
● Programmer needs to know the exact memory location to load and store
● For small programs this may be feasible. But real computers have billions of
possible locations
44
Immediate Values
45
Immediate Value
3 load #13, B Read the contents of memory cell #13 into register B
● If the starting address of the data segment is known, one can access all other
memory locations in the segment using the formula base address + offset
● Where offset is the distance of bytes of the desired memory location from the
data segment's base address
11 12 13 14 15 16
● Assume base address is: 11
50
DLW-1 Program With Use Of Relative Addressing
● Load and store units on modern processor contain very fast integer
addition hardware.
Code Comments
51
Mechanics of Program Execution
Mechanics of Program Execution
54
Mechanics of Program Execution
55
Mechanics of Program Execution
● The binary values representing both the opcodes and the register codes
are arranged in one number of a 16-bit (2-byte) format to get a
complete machine language instruction.
● This is a binary number which can be stored in RAM and used by the
processor
56
Binary Encoding of Arithmetic Instructions
Binary Encoding of Arithmetic Instructions
8 9 10 11 12 13 14 15
destinatio 0 0 0 0 0 0
n
59
Binary Encoding of Arithmetic Instructions – Example
● add A, B, C
0 1 2 3 4 5 6 7
0 0 0 0 0 0 1
0
8 9 10 11 12 13 14 15
1 0 0 0 0 0 0 0
60
Binary Encoding of Arithmetic Instructions – Example
● add C, D, A
0 1 2 3 4 5 6 7
0 0 0 1 0 1 1
0
8 9 10 11 12 13 14 15
0 0 0 0 0 0 0 0
61
Binary Encoding of Arithmetic Instructions – Example
● sub C, D, A
0 1 2 3 4 5 6 7
0 0 0 1 0 1 1
1
8 9 10 11 12 13 14 15
0 0 0 0 0 0 0 0
62
Binary Encoding of Arithmetic Instructions With
Immediate Value
Binary Encoding of Arithmetic Instructions With Immediate Value
0 1 2 3 4 5 6 7
65
Binary Encoding of Arithmetic Instructions With Immediate Value
● Example: add 5, A, C
0 1 2 3 4 5 6 7
1 0 0 0 0 0 1 0
8 9 10 11 12 13 14 15
0 0 0 0 0 1 0 1
66
Binary Encoding of Arithmetic Instructions With Immediate Value
0 1 2 3 4 5 6 7
1 0 0 0 0 0 1 0
8 9 10 11 12 13 14 15
0 0 0 1 1 0 0 1
67
Binary Encoding of Memory Access Instructions
Binary Encoding of Memory Access Instructions
● As load's source is immediate and not register, bits 4 & 5 takes value 0.
70
Binary Encoding of Memory Access Instructions
0 1 2 3 4 5 6 7
1 0 1 0 0 0 0
0
8 9 10 11 12 13 14 15
0 0 0 0 1 1 0 0
● As load's source is immediate and not register, bits 4 & 5 takes value 0.
71
Binary Encoding of Memory Access Instructions
0 1 2 3 4 5 6 7
8 9 10 11 12 13 14 15
Destinatio 0 0 0 0 0 0
n
● As load's instruction is register-type, bits 6 & 7 takes value 0.
72
Binary Encoding of Memory Access Instructions
0 1 2 3 4 5 6 7
73
The Store Instruction
The Store Instruction
79
Thank You!