Lecture03-Computer Architecture 1 and Assembly Language
Lecture03-Computer Architecture 1 and Assembly Language
1
CPU and Memory
• Every instruction executed by the CPU requires
memory access
6-2
CPU: Major Components
• ALU (arithmetic logic unit)
- Performs calculations and comparisons
- Uses the accumulator which is a register in which intermediate
arithmetic and logic results are stored.
• CU (control unit)
- Performs fetch/execute cycle
• Accesses program instructions and issues commands to the ALU
• Moves data to and from CPU registers and other hardware
components
- Subcomponents:
• Memory management unit: supervises fetching instructions and
data from memory
• I/O Interface: sometimes combined with memory management unit
as Bus Interface Unit, manages input-output transfers
6-3
Memory (Write)
Data
A demultiplexer of 2n D1 D0
outputs has n select lines, Address
which are used to select
which output line to send A1 A0
the input. A demultiplexer
is also called a data D Q D Q
distributor. >C >C
Y3
Demux D Q D Q
>C >C
Y2
Write D Q D Q
Enable >C >C
Y1
D Q D Q
>C >C
Y0
4
What is a Flip flop?
A flip flop is an electronic circuit with two stable states that
can be used to store binary data. The stored data can be
changed by applying varying inputs. Flip-flops and latches are
fundamental building blocks of digital electronics systems
used in computers, communications, and many other types of
systems. Both are used as data storage elements.
Tristate Buffer Memory (Read)
Data
Q1Q0
Address
A1 A0
D Q D Q
>C >C
Y3
Demux D Q D Q
>C >C
Y2
Output Enable D Q D Q
>C >C
Y1
D Q D Q
>C >C
Y0
6
Tri- state buffer
A tri-state buffer has two inputs: a data input x and a
control input c. The control input acts like a valve. When
the control input is active, the output is the input. That is,
it behaves just like a normal buffer. The "valve" is open.
8
Memory
• Flip flops are grouped into bytes (or larger)
– Each byte has a unique address
– To write
• Present the address and the data
• Tell chip to write
– To read
• Present the address
• Tell the chip to read
• Look at the data
11
Control Unit
• Coordinates the operation of the computer
• Generates control signals
– Connect registers to the bus
– Control the function of the ALU
– Provides timing signals to the system
12
Registers
• Registers are memory cells with names
– Hold data, instructions, or other items
– Various sizes (typically: 8, 16, 32, or 64 bits)
– Program counter (PC) and memory address registers must be
same width as address bus
– Registers which hold data must be same width as memory
words
• The accumulator is a special register
– Source of one of the operands
– Destination of the result
13
Computer!
14
Stored Program Computer
Address (A)
15
Von Neumann Architecture
• Three key concepts:
– Data and instructions are stored in a single read-write
memory
– Contents of memory are addressable by location, without
regard to the type of data contained
– Execution occurs in a sequential fashion, unless explicitly
altered, from one instruction to the next
16
High vs. Low Level Language
18
Machine Code
• These numbers tell the computer what to do
• They tell the CPU to
– Assign values to registers
– Load registers from memory
– Add numbers to registers
– Store registers in memory
– And so on
• Each different CPU has its own mnemonics and its own
assembly language (its own machine language)
19
Assembly
Language
Example
20
Assembly Language
• We can give names (labels) to memory locations
– In this case PRINT is the name of the memory location where the
routine is stored. DONE is the name of the memory location where
the return statement is stored
• There is a direct correspondence between mnemonic
assembly language and machine code.
– An assembler translates from assembly to machine code, a
disassembler translates from machine code to assembly language
21
Multiple Data Instructions
• Perform a single operation( add) on multiple pieces of
data simultaneously
- SIMD: Single Instruction, Multiple Data
- Commonly used in multimedia, vector and array processing
applications
22
Instruction Elements
OPCODE: task
Source Result
OPCODE
OPERAND OPERAND
23
Opcodes means "operation codes". They tell the circuitry
(in this case, the microprocessor) which operation to
perform e.g. addition, subtraction.
Simple
32-bit Instruction Format
25
Recap!
An instruction format defines the different component of an instruction. The main
components of an instruction are opcode (which instruction to be executed) and
operands (data on which instruction to be executed).
Opcode: The operation code (opcode) represents action that the processor must
execute. It tells the processor what basic operations to perform.
Operands: The operand code defines the parameters of the action and depends on
the operation. It specifies the locations of the data or the operand on which the
operation is to be performed. It can be data or a memory address.
Instruction Format
• Instruction set
The instruction set provides commands to the
processor, to tell it what it needs to do.
- Design defines functions performed by the processor
- Differentiates computer architecture by the
• Number of instructions
• Complexity of operations performed by individual instructions
• Data types supported
• Format (layout, fixed vs. variable length)
• Use of registers
• Addressing (size, modes)
27
Instruction Set
• The set of all instructions for the particular CPU is called the
instruction set
– It is determined by the designers
• Instructions consist of one or more fields
– The mnemonic opcodes that indicate the operations to be
performed.
E.g. Increment the X register (INX)
– And (optionally) parameters called operands
E.g. Goto (JMP PRINT)
• Instructions are of different lengths
28
Instruction Format Examples
28