Chapter 4 Processor Fundamentals
Chapter 4 Processor Fundamentals
Registers:
The register is among the Von Neumann system's most essential parts. Small, quick storage areas in the
CPU that are used to temporarily store addresses, data, and instructions while they are being executed.
Registers increase processing speed and efficiency by giving the CPU instant access to vital information
and instructions.
Table displays the special registers that are most frequently mentioned in this book. The detailed
explanation of how to use many of these registers is provided.
When an instruction calls for arithmetic or logic operations, a status register is utilized. A flag is a name
for each bit. The four flags listed below are present in most systems.
• When an addition operation results in a CARRY, the carry flag (C) is set to 1.
• When a calculation yields a NEGATIVE value, the negative flag (N) is set to 1.
• When an arithmetic operation produces an OVERFLOW, the overflow flag (V) is set to 1.
• When an arithmetic operation yields ZERO, the zero flag (Z) is set to 1.
Think about the following math operation:
The answer shouldn't be negative because we are adding two positive values. Two mistakes are indicated
by the flags: an overflow occurred and a negative result was obtained.
Now consider this operation:
The answer should be negative because we are adding two negative values. The flags show that there
have been two errors: a carry that was generated and a ninth bit overflow.
System buses:
System buses are essential lines of communication that link the CPU, memory, and input/output (I/O)
devices in a computer system, facilitating data transfer and coordination. System buses come in three
primary varieties:
Address bus:
Carries the addresses of memory locations that should be used for writing or reading data.
The address bus is unidirectional, meaning that bits can only move in one direction between the CPU and
memory. The width of the address bus determines the maximum addressable memory.
For example, a 32-bit address bus can address up to 4 GB of memory.
Data bus:
The data bus is bidirectional. Between the CPU, memory, and I/O devices, transfers actual data.
The amount of data that may be transmitted simultaneously depends on the width of the data bus (e.g.,
8-bit, 16-bit, 32-bit, 64-bit). Faster data transfer speeds are possible with a bigger data bus.
A word is a group of bits which can be regarded as a single unit, for example, 16-bit, 32-bit or 64-bit word
lengths are the most common.
Control bus:
In addition, the control bus is bidirectional. From the CU, it transmits signals to every other part of the
computer. Since it solely transmits control signals, it is typically 8 bits wide.
Here, it is important to discuss the function of the system clock. The clock establishes the clock cycle that
keeps all computer functions in sync. As was already mentioned, timing signals are transmitted by the
control bus to guarantee complete synchronization. The computer's processing speed increases in tandem
with an increase in clock speed.
• A computer system's speed and performance are increased by widening its bus (data and address
buses).
• A computer's speed typically rises with rising clock speed.
• Bus width, clock speed, and the utilization of multi-core CPUs can all be adjusted to modify a
computer's performance.
• A processor's performance can also be increased by using cache memory.
Computer ports:
On a computer, computer ports are interfaces or connection
points where external devices or peripherals can be plugged
in. They make it possible for the computer and the linked
devices to communicate and exchange data. The following
are a few typical kinds of computer ports:
USB ports:
Asynchronous serial data transmission using the Universal Serial Bus (USB) is possible. It has swiftly
evolved into the accepted procedure for data transfer between a computer and several devices.
The USB cable is made up of four wires: two for data transmission, two for power and ground, and two
for shielding. When a USB port on a computer is used to connect a device
• The device is immediately recognized by the computer
• the proper device driver is loaded so that the device and computer can communicate with each
other efficiently.
• The computer will search for the appropriate device driver if a new device is discovered. The user
is requested to download the necessary software if this is not available.
Advantages and Disadvantages of USB Ports:
Advantages of USB Ports Disadvantages of USB Ports
Incorrect connections cannot be formed since the Currently, transmission rates can only
connectors can only fit one way. reach 500 megabits per second or less.
As a result of this becoming the industry standard, users In the near future, there may be no
have access to a great deal of support. support for the older USB standard.
Device drivers are automatically loaded into plugged-in Currently, the longest cable length is
devices and automatically detected by the computer. around five meters.
There are multiple supported data transmission rates.
Older USB standards and later USB standards are
backwards compatible.
High-definition multimedia interface (HDMI):
HDMI ports provide the output of audio and video data from a computer to a device that supports HDMI.
Both enhanced and ordinary high definition transmissions are supported by them. With the introduction
of HDMI, the outdated Video Graphics Array (VGA) analog technology was digitally replaced.
Due to the following capabilities of contemporary HD (high definition) televisions, VGA is becoming
obsolete technology:
• Their widescreen format (16:9 aspect ratio)
• makes advantage of more pixels, with screens typically having 1920 × 1080.
• The refresh rate of the screens is quicker (e.g., 120 Hz or 120 frames per second).
• There is a very wide variety of colors.
Since HDMI employs high-bandwidth digital copy protection, it can also afford some degree of anti-piracy
protection (HDCP). One kind of authentication protocol is used by HDCP.
Video Graphics Array (VGA):
The end of the 1980s saw the introduction of VGA. 640 x 480 pixels can be seen on a television or monitor
screen thanks to VGA capability. Additionally, it can manage a refresh rate of up to 60Hz, or 60 frames per
second, as long as 16 distinct colors are being used. It can accommodate up to 256 colors if the pixel
density is lowered to 200 × 320.
summarizes the benefits and drawbacks of VGA and HDMI.
Advantages of HDMI Disadvantages of HDMI
The current benchmark for contemporary monitors and Not a really strong bond (It's simple to lose connection
televisions by just moving the device)
Permits an extremely high rate of data transfer Restricted wire length to maintain a strong signal
Improved security Currently, there are five standards for connections and
Helps contemporary digital systems cables.
How the fetch-execute cycle is carried out in the Von Neumann computer model
Register Transfer Notation (RTN) can be used to explain what's happening when registers are involved.
At its most basic:
In the third line, double braces are used to indicate that data stored at the address indicated in MAR is
being copied to MDR rather than the contents of MAR.
RTN can be concrete (specific to a certain machine – example shown below) or abstract (generic notation
– as demonstrated on page 117). As an illustration, on a RISC computer:
Interrupts:
A signal transmitted to the CPU by a device or piece of software is called an interrupt.
The CPU will then be forced to momentarily halt its current task in order to handle the interrupt. Among
the things that can cause interruptions are:
• a timing signal
• processes related to input/output (such as a disk drive that is prepared to receive additional data)
• hardware malfunctions (like a paper jam in a printer)
• user interaction (the user pressed a key to end the current process, like \ALT>)
• software errors that cannot be disregarded (like a program not being able to be executed because
a.exe file could not be found OR an attempt to divide by zero, for example).
The processor either continues what it was doing after receiving the interrupt signal or pauses to provide
support for the device or program that caused the interrupt. Both the sort of interrupt and its priority
level must be determined by the computer.
When a computer's CPU receives an interrupt signal, it will perform an interrupt service routine (ISR),
which is a unique function or sequence of instructions. Before giving control back to the main program, it
completes the precise activities needed to handle the interrupt, including reading data from an input
device or processing an error.
Assembly language
Assembly language and machine code:
Machine code is the only programming language that a CPU is capable of using.
There are specific machine code instructions for each type of computer or chip. A computer program is a
set of machine code instructions that are kept in main memory and are executed automatically by the
CPU during the fetch-execute cycle. Every machine code instruction completes a single, straightforward
operation, such as putting a value in a memory address at a specific position. In order to make machine
code instructions easier for human programmers to understand, machine code is binary and occasionally
presented on a screen as hexadecimal.
Assembly language was the first programming language to be created; it is similar to machine code and
employs mnemonics rather than binary.
Machine code instructions and assembly language instructions have the same structure.
Every instruction has an opcode that indicates the task that the CPU is to perform. An operand designates
the data that the opcode will utilize, and it is present in the majority of instructions.
Stages of assembly:
A program written in assembly language (source code) must first be converted into machine code in order
to be run. An assembler is a type of program that does the translation. Every instruction in assembly
language is converted into a machine code instruction by an assembler. A program written in assembly
language is also examined by an assembler to make sure that only opcodes from the relevant machine
code instruction set are utilized.
Types:
There are two types of assembler
➢ single pass assemblers
➢ two pass assemblers.
A single pass assembler puts the machine code instructions straight into the computer memory to be
executed.
A two pass assembler produces an object program in machine code that can be stored, loaded then
executed at a later stage.
This requires the use of another program called a loader. Two pass assemblers need to scan the source
program twice, so they can replace labels in the assembly program with memory addresses in the machine
code program.
Pass 1:
• Line by line, read the assembly language program.
• Anything not necessary, including comments, should be ignored.
• Assign the line of code an address in memory.
• Verify if the instruction set includes the opcode.
• If you know the address, add any additional labels to the symbol table.
• Put the labeled instruction's address in the symbol table.
Pass 2:
• Line by line, read the assembly language program.
• Create object code from the symbol table produced in Pass 1 that includes the operand and
opcode.
• Save the program or run it.
Since certain labels might be referred to before their address is known, a second pass is necessary. For
instance, the JPN instruction's forward reference is Found.
In the event that the program is loaded at memory address 100 and every memory location has 16 bits,
the symbol table for this little program segment might resemble this:
Compare instructions:
Addressing modes:
Depending on the needs of the program, programs written in machine code and assembly language
employ multiple addressing mechanisms.
Absolute addressing: The operand makes use of the contents of the memory location. For example, if the
value 20 was present in the memory location associated with address 200, the assembly language
instruction LDD 200 would put 20 in the accumulator.
Direct addressing: The operand makes use of the contents of the memory location. For example, if the
value 20 was present in the memory location associated with address 200, the assembly language
instruction LDD 200 would put 20 in the accumulator. Direct and absolute addressing are interchangeable.
Indirect addressing: In the operand, the contents of the memory address are utilized. The assembly
language instruction LDI 200 would store 5 in the accumulator, for example, if the memory location with
address 200 held the value 20 and the memory location with address 20 contained the value 5.
Indexed addressing: The operand's address of the memory location is multiplied by the contents of the
index register (IR) to find the contents of the memory location. For instance, the assembly language
instruction LDX 200 would put value 17 in the accumulator if IR contained the value 4 and memory location
with address 204 contained the value 17.
Immediate addressing: Only the operand's value is utilized. For instance, the accumulator would hold 200
when the assembly language instruction LDM #200 was executed.
Relative addressing: The operand's current memory address is the memory address that is used. JMR #5,
for instance, would hand off control to instruction 5 positions subsequent to the present instruction.
Symbolic addressing: used exclusively in programming in assembly language. A value is substituted for a
label. For instance, the assembly language instruction LDD Mysore would store 20 in the accumulator if
the value 20 was present in the memory location with address labeled Mysore.
Programs written in assembly language can be modified more easily with labels since, in the case of
absolute addresses, each reference to that address must be changed, say, if an additional instruction is
introduced.
In the event that the program loads at memory address 100 upon translation and that each memory
location has 16 bits, the following would be the symbol table for this brief program section:
A trace table can be used to track the contents of ACC, CIR, and the variables utilized when this section
of code is performed.
A loop would normally be used in a high-level language to add a list of numbers together and store the
result.
The index register (IX) would be needed for the same task written in assembly language. The program
written in assembly language might resemble this:
In the event that the program loads at memory address 100 upon translation and that each memory
location has 16 bits, the following would be the symbol table for this brief program section:
When this section of code is executed the contents of ACC, CIR, IX and the variables used can be traced
using a trace table:
Bit Manipulation
Binary shifts:
A shift is the process of rearranging the bits that are kept in a register in a specific number of locations.
There are various possible uses for each bit in the register. For example, every bit in the IR designates a
distinct interrupt.
There are numerous varieties of shifts.
Logical shift: Zeros are used to replace bits that are moved out of the register. For instance, shifting an 8-
bit register with the binary value 10101111 three places to the left would logically result in 01111000.
Arithmetic shift: The number's sign is maintained. For instance, 11110101 would be the result of shifting
an 8-bit register holding the binary value 10101111 three places arithmetically to the right. You can divide
or multiply by powers of two using arithmetic shifts.
Cyclic shift: Not a single bit is lost in a shift. Bits are introduced at one end of the register and relocated
out of the other. An 8-bit register with the binary value 10101111, for instance, would become 01111101
if it were shifted left cyclically three places.
Left shift: bits are shifted to the left; gives the direction of shift for logical, arithmetic and cyclic shifts.
Right shift: bits are moved to the right; this indicates the shift's direction for shifts that are arithmetical,
logical, and cyclical.
shows the logical shifts that you are expected to use in assembly language programming.