Chapter 4
Chapter 4
o Von Neumann realized data & programs are indistinguishable and can therefore use
same memory.
Registers: smallest unit of storage of microprocessor; allows fast data transfer between other
registers
o Used to temporarily store data values which have been read from memory or some
processed result
Memory Data Register (MDR): holds data value fetched from memory
Accumulator (ACC): holds all values that are processed by arithmetic & logical
operations.
o Arithmetic and Logic Unit (ALU): part of processor that processes instructions which
require some form of arithmetic or logical operation
o Control Unit (CU): part of CPU that fetches instructions from memory, decodes them &
synchronizes operations before sending signals to computer’s memory, ALU and I/O
devices to direct how to respond to instructions sent to processor
o System Clock: timing device connected to processor that is needed to synchronize all
components.
Buses
o set of parallel wires that allow the transfer data between components in a computer
system
o Data bus: bidirectional bus that carries data instructions between processor, memory,
and I/O devices.
o Address bus: unidirectional bus that carries address of main memory location or
input/output device about to be used, from processor to memory address register
(MAR)
o Control bus
Bidirectional
used to transmit control signals from control unit to ensure access/use of data &
address buses by components of system does not lead to conflict
o Clock Speed
number of pulses the clock sends out in a given time interval, which determines
the number of cycles (processes) the CPU executes in a given time interval
If the clock speed is increased, then the execution time for instructions
decreases. Hence, more cycles per unit time, which increases performance.
However, there is a limit on clock speed since the heat generated by higher
clock speeds cannot be removed fast enough, which leads to overheating.
o Bus Width
o Cache Memory
Commonly used instructions are stored in the cache memory area of the CPU.
o Number of Cores
Most CPU chips are multi-core — have more than one core (essentially a
processor)
Ports
o Hardware which provides a physical interface between a device with CPU and a
peripheral device
o Peripheral (I/O) devices cannot be directly connected to the CPU, hence connected
through ports.
o Universal Serial Bus (USB): Can connect both input and output devices to the processor
through a USB port.
Can only connect output devices (e.g. LCD) to the processor through a HDMI
port
Can only connect output devices (e.g. second monitor/display) to the processor
through a VGA port
VGA ports allow only the transmission of video streams but not audio
components
o Fetch stage
PC is incremented
o Decode stage: The opcode and operand parts of instruction are identified
o Execute stage: Instructions executed by the control unit sending control signals
MAR ← [PC]
PC ← [PC] + 1
MDR ← [[MAR]]
CIR ← [MDR]
Decode
Execute
Return to start
Double square brackets: CPU is getting value stored at the address in the
register
Interrupts
o The processor checks the interrupt register for interrupt at the end of the F-E cycle for
the current instruction
o If the interrupt flag is set in the interrupt register, the interrupt source is detected
All contents of registers of the running process are saved on the stack
Once ISR is completed, the processor restores the registers’ contents from the
stack, and the interrupted program continues its execution.
Assembly Language
Machine code: code written in binary that uses the processor’s basic machine operations
Relationship between machine and assembly language: every assembly language instruction
(source code) translates into exactly one machine code instruction (object code)
Symbolic addressing
o Software that changes assembly language into machine code for the processor to
understand
o The assembler replaces all mnemonics and labels with their respective binary values
(that are predefined before by the assembler software)
o Assembler converts mnemonic source code into machine code in one sweep of program
Symbol table created to enter symbolic addresses and labels into specific
addresses
Modes of Addressing
o Indirect Addressing: The address to be used is at given address. Load contents of this
second address to ACC
o Indexed addressing: form the address to be used as
Bit Manipulation
Arithmetic shift: Used to carry out multiplication and division of signed integers represented by
bits in the accumulator by ensuring that the sign-bit (usually the MSB) is the same after the shift.
Cyclic shift: the bit that is removed from one end by the shift is added to the other end.
Bit Masking
Masking: an operation that defines which bits you want to keep and which bits
you want to clear.
Mask the content of the register with a mask pattern which has 0 in the ‘mask
out’ positions and 1 in the ‘retain’ positions.
Set the result with the match pattern by using the AND command with a direct
address.
Mask the content of the register with a mask pattern which has 0 in the ‘mask
out’ positions and 1 in the ‘retain’ positions.
Compare the result with the match pattern by using the CMP command or by
“Checking the pattern”.
The final ‘non-zero’ result confirms the patterns are not the same else vice
versa.