Professional Documents
Culture Documents
2024
Chapter - 1
1.1. Introduction to Microprocessor and Computer
A Computer is a programmable machine. It has two principal characteristics. Those are: -
It responds to a specific set of instructions in a well-defined manner.
It can execute a prerecorded list of instructions (a program).
Modern computers are electronic and digital. The actual machinery wires, transistors, and
circuits is called hardware; the instructions and data are called software.
All general-purpose computers require the following hardware components:
Memory: Enables a computer to store temporary data and programs.
Mass storage device: Allows a computer to permanently retain large amounts of data.
Common mass storage devices include disk drives and tape drives.
Input device: Usually a keyboard and mouse are the input device through which data and
instructions enter a computer.
Output device: A display screen, printer, or another device that lets you see what the
computer has accomplished.
Central processing unit (CPU): The heart of the computer, this is the component that
actually executes instructions. In addition to these components, many others make it possible
for the basic components to work together efficiently. For example, every computer requires
a bus that transmits data from one part of the computer to another.
Most people associate a personal computer (PC) with the phrase computer. A PC is a small and
relatively inexpensive computer designed for an individual use. PCs are based on the
microprocessor technology that enables manufacturers to put an entire CPU on one chip.
Personal computers at home can be used for a number of different applications including games,
word processing, accounting and other tasks.
Computers are generally classified by size and power as follows, though there is considerable
overlap. The differences between computer classifications generally get smaller as technology
advances, creating smaller and more powerful and cost-friendly components.
Personal computer: A small, single-user computer based on a microprocessor. In addition to
the microprocessor, a personal computer has a keyboard for entering data, a monitor for
displaying information, and a storage device for saving data.
1
BULE HORA UNIVERSITY DEPARTEMENTS OF SOFTWARE ENGINEERING
2024
Working station: A powerful, single-user computer. A workstation is like a personal
computer, but it has a more powerful microprocessor and a higher-quality monitor.
Minicomputer: A multi-user computer capable of supporting from 10 to hundreds of users
simultaneously.
Mainframe: A powerful multi-user computer capable of supporting many hundreds or
thousands of users simultaneously.
Supercomputer: An extremely fast computer that can perform hundreds of millions of
instructions per second.
Microcomputer: The term microcomputer is generally synonymous with personal computer,
or a computer that depends on a microprocessor. Microcomputers are designed to be used by
individuals, whether in the form of PCs, workstations or notebook computers. A
microcomputer contains a CPU on a microchip (the microprocessor), a memory system
(typically ROM and RAM), a bus system and I/O ports, typically housed in a motherboard.
Microprocessor (CPU): A silicon chip that contains a CPU. In the world of personal computers,
the terms microprocessor and CPU are used interchangeably. A microprocessor (sometimes
abbreviated μP) is a digital electronic component with miniaturized transistors on a single
semiconductor integrated circuit (IC). One or more microprocessors typically serve as a central
processing unit (CPU) in a computer system or handheld device. Microprocessors made possible
the advent of the microcomputer. At the heart of all personal computers and most working
stations sits a microprocessor. Microprocessors also control the logic of almost all digital devices,
from clock radios to fuel-injection systems for automobiles.
Three basic characteristics differentiated microprocessors:
Instruction set: The set of instructions that the microprocessor can execute. It is Also called
a command set, the basic set of commands, or instructions, that a microprocessor understands.
One of the principal characteristics that separates RISC from CISC microprocessors is the
size of the instruction set. RISC microprocessors have relatively small instruction sets
whereas CISC processors have relatively large instruction sets.
Bandwidth: The number of bits processed in a single instruction.
(1) Bandwidth is defined as a range within a band of frequencies or wavelengths.
(2) Bandwidth is also defined as the amount of data that can be transmitted in a fixed
amount of time. For digital devices, the bandwidth is usually expressed in bits per
2
BULE HORA UNIVERSITY DEPARTEMENTS OF SOFTWARE ENGINEERING
2024
second(bps) or bytes per second. For analog devices, the bandwidth is expressed in cycles
per second, or Hertz (Hz).
Clock speed: Given in megahertz (MHz), the clock speed determines how many instructions
per second the processor can execute. In this cases, the higher the value, the more powerful
the CPU. For example, a 32-bit microprocessor that runs at 50MHz is more powerful than a
16-bit microprocessor that runs at 25MHz. In addition to bandwidth and clock speed,
microprocessors are classified as being either RISC (reduced instruction set computer) or
CISC (complex instruction set computer).
CPU
Memory
CPU
Memory
I/O Ports
I/O Ports
3
BULE HORA UNIVERSITY DEPARTEMENTS OF SOFTWARE ENGINEERING
2024
Architecture Vocabulary:
Register: a storage location directly on the CPU, used for temporary storage of small
amounts of data during processing.
Memory: an array of randomly accessible memory bytes each identified by a unique address.
Flat memory models, segmented memory models, and hybrid models exist which are
distinguished by the way locations are referenced and potentially divided into sections.
Instruction set: the set of instructions that are interpreted directly in the hardware by the
CPU. These instructions are encoded as bit strings in memory and are fetched and executed
one by one by the processor. They perform primitive operations such as "add 2 to register i1",
"store contents of o6 into memory location 0xFF32A228", etc. Instructions consist of an
operation code (opcode) e.g., load, store, add, etc., and one or more operand addresses.
1.2.1. Memory Hierarchy
All computers need storage to store and work on data during processing. Ideally, this storage
would be quick to access and large in size. But fast memory is expensive and small; slow
memory is cheaper and large. To provide the illusion of both fast and large, the memory system
of modern computers is organized in a hierarchical way. At the very top of the hierarchy there
are the CPU registers. Main memory is below that, one or two levels of fast cache memory may
be inserted in between those two levels. Via virtual memory, the hard disk can expand the
capacity of main memory. A typical memory hierarchy might have five levels:
Registers: The average of modern processor has 16 to 128 on-board registers; each register
can hold a word of memory (typically 32 bits although 64-bit machines are becoming more
common). The total register space is thus just a couple hundred bytes total. Time to access
registers is perhaps a few nanoseconds. Registers are the most expensive. So, we cannot
expand the available space by adding registers to a chip; they are fixed as part of its design.
L1 cache: A level-1 cache is on the same chip as the processor and usually cannot be
expanded. Typical L1 caches are 32-64 KB. Time to access the L1 cache is usually tens of
nanoseconds. L1 caches are pricey, but not as expensive as registers.
L2 cache: A level-2 cache is usually a separate chip from the processor and a typical size is
1-2 MB. The L2 cache size is usually expandable, although expensive. Access time is usually
in the range of 10s of nanoseconds.
4
BULE HORA UNIVERSITY DEPARTEMENTS OF SOFTWARE ENGINEERING
2024
Main memory: refers to physical memory that is internal to the computer. The word main is
used to distinguish it from external mass storage devices such as disk drives. Other terms
used to main memory include RAM and primary storage. The computer can manipulate
only data that is in main memory. Therefore, every program you execute and
every file you access must be copied from a storage device into main memory.
Hard disk: When using our hard disk as back-up, we can further extend memory into the
range of many gigabytes. Disks are cheap, just a fraction of a penny per megabyte, but slow,
access times are measured in 10s or 100s of milliseconds.
Processor Architectures: A processor’s architecture refers to the way in which its memory and
control is organized. Most early computers were designed as accumulator machines.
The processor has a single register called accumulator where arithmetic, logic and comparison
operations occur. All other values and variables are stored in memory and transferred to the
accumulator register when needed.
load, MEM(y) ;load value of y into accumulator
add, MEM(z) ;add value of z into accumulator y + z
store, MEM(x) ;store value of accumulator in x (thus x = y + z)
5
BULE HORA UNIVERSITY DEPARTEMENTS OF SOFTWARE ENGINEERING
2024
Immediate Addressing Mode: - The operand is an immediate value is stored explicitly in
the instruction. it is actual data to be used as the operand is included in the instruction itself.
Index Addressing Mode: - The address of the operand is obtained by adding to the contents
of the general register (called index register) a constant value. The number of the index
register and the constant value are included in the instruction code. Index Mode is used to
access an array whose elements are in successive memory locations. The content of the
instruction code, represents the starting address of the array and the value of the index
register, and the index value of the current element.
Indirect Addressing Mode: - The effective address of the operand is the contents of a
register or main memory location, location whose address appears in the instruction. Here
two references are required. The 1st reference to get effective address and the 2nd reference
to access the data.
Based on the availability of Effective address, Indirect mode is of two kind:
Register Indirect: In this mode effective address is in the register, and corresponding
register name will be maintained in the address field of an instruction.
Here one register reference, one memory reference is required to access the data.
Memory Indirect: In this mode effective address is in the memory, and corresponding
memory address will be maintained in the address field of an instruction.
Here two memory reference is required to access the data.
Direct addressing / Absolute Addressing Mode: The address of the operand is embedded
in the instruction code. It is the address of the operand is specified in the instruction. The
processor will retrieve the data directly from the address specified in the instruction.
Here only one memory reference operation is required to access the data.
Register Addressing Mode: - The number of the CPU register is embedded in the
instruction. The register contains the value of the operand. The number of bits used to specify
the register depends on the total number of registers from the processor set.
It indicates the operand data is stored in the register itself, so the instruction contains the
address of the register. The data would be retrieved from the register and the data is in the
register that is specified by the instruction.
Here one register reference is required to access the data.
6
BULE HORA UNIVERSITY DEPARTEMENTS OF SOFTWARE ENGINEERING
2024
Displacement Addressing Mode: - Similar to index mode, except instead of an index
register a base register will be used. Base register contains a pointer to a memory location.
An integer (constant) is also referred to as a displacement. The address of the operand is
obtained by adding the contents of the base register plus the constant. The difference between
index mode and displacement mode is in the number of bits used to represent the constant.
When the constant is represented a number of bits to access the memory, then we have index
mode. Index mode is more appropriate for array accessing; displacement mode is more
appropriate for structure (records) accessing.
Auto-increment /Auto-decrement Addressing Mode: - A special case of indirect register
mode. The register whose number is included in the instruction code, contains the address of
the operand. Auto-increment Mode is after operand addressing, the contents of the register
are incremented. Decrement Mode is before operand addressing, the contents of the register
are decrement.
7
BULE HORA UNIVERSITY DEPARTEMENTS OF SOFTWARE ENGINEERING
2024
Example: - mov bx, 2
This instruction loads the value 2 into bx where it is stored as a binary number. A number such
as 2 is called an integer constant.
8
BULE HORA UNIVERSITY DEPARTEMENTS OF SOFTWARE ENGINEERING
2024
9
BULE HORA UNIVERSITY DEPARTEMENTS OF SOFTWARE ENGINEERING
2024
It obtains new segment and offset address to accomplish the jump:
Bytes 2 and 3 of this 5-byte instruction contain the new offset address
Bytes 4 and 5 contain the new segment address
In protected mode, the segment address accesses a descriptor with the base address of
the far jump segment
Offset address, either 16 or 32 bits, contains the offset address within the new code
segment
Conditional Jump and Conditional Sets
The conditional jump instructions test the following flag bits: sign (S), zero (Z), carry (C),
parity (P), and overflow (O).
If the condition under test is true, a branch to the label associated with the jump
instruction occurs
Otherwise, the next sequential step in the program executes
Loop
It is a combination of a decrement CX and JNZ conditional jump
Conditional Loops
LOOPE (loop while equal) jumps if CX <> 0 while an equal condition exists
LOOPNE (loop while not equal) jumps if CX <> 0 while a not-equal condition exists
10