The stored program concept
The stored program concept
● by a processor that performs arithmetic and logical operations The stored program concept
● This can be exploited in hacks that work by placing instructions in the position of data in order to
make the computer execute malicious code
● The universal Turing machine is seen as an early example of the stored program concept
● Computers that use the stored program concept can be based on one of two different
architectures: ○ Harvard architecture ○ von Neumann architecture
Processor Fundamentals
Central Processing Unit Architecture
Von Neumann model
o Von Neumann realized data & programs are indistinguishable and can therefore use
same memory.
o Von Neumann architecture uses a single processor.
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
Memory Address Register (MAR): Holds address of memory cell of program which is
to be accessed
Accumulator (ACC): holds all values that are processed by arithmetic & logical
operations.
Status Register: holds results of comparisons to decide later for action, intermediate
o Arithmetic and Logic Unit (ALU): part of processor that processes instructions which
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
o Immediate Access Store (IAS): memory unit that can be directly accessed by the
processor
all components.
Buses
o set of parallel wires that allow the transfer data between components in a computer
system
Data bus: bidirectional bus that carries data instructions between processor,
Address bus: unidirectional bus that carries address of main memory location or
(MAR)
o Control bus
Bidirectional
used to transmit control signals from control unit to ensure access/use of data &
o Clock Speed
number of pulses the clock sends out in a given time interval, which determines the
If the clock speed is increased, then execution time for instructions decreases.
However, there is a limit on clock speed since the heat generated by higher clock
o Bus Width
Increasing bus width increases number of bits transferred at one time, hence
o Cache Memory
Commonly used instructions are stored in the cache memory area of the CPU.
stored and the need for the CPU to wait for instructions to be loaded reduces, hence
CPU executes more cycles per unit time, thus improving performance
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 CPU, hence connected
through ports
o Universal Serial Bus (USB): Can connect both input and output devices to processor
Can only connect output devices (e.g. LCD display) to the processor through a HDMI
port
HDMI cables transmit high-bandwidth and high-resolution video & audio streams
Can only connect output devices (e.g. second monitor/display) to the processor
VGA ports allows 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 interrupt register for interrupt at the end of the F-E cycle for
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 registers’ contents from the stack,
Assembly Language
Assembly language: low-level programming language with instructions made up of
Machine code: code written in binary that uses the processor’s basic machine
operations
instruction (source code) translates into exactly one machine code instruction (object
code)
Symbolic addressing
Assembler
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
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
B denotes a binary number, e.g. B01001010 & denotes a hexadecimal number, e.g.
&4A
Modes of Addressing
locations away, relative to address of current instruction held in PC; allows for
relocatable code
o Conditional jump: has a condition that will be checked (like using an IF statements)
as specified
Bit Manipulation
Binary numbers can be multiplied or divided by shifting
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
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.
Matching: an operation that allows the accumulator to compare the value it contains
to the given value in order to change the state of the status register.
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’
Compare the result with the match pattern by using the CMP command or by
The final ‘non-zero’ result confirms the patterns are not the same else vice versa.