You are on page 1of 10

BULE HORA UNIVERSITY DEPARTEMENTS OF SOFTWARE ENGINEERING

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).

1.2. Microprocessor and its Architecture


Micro processer Micro controller
It is a single chip It is a CPU
Consists Memory, I/O ports Memory, I/O Ports to be connected externally

CPU
Memory
CPU
Memory
I/O Ports
I/O Ports

Microprocessor Micro controller


 high processing power low processing power
 high power consumption low power consumption
 typically 32/64 bit typically 8/16 bit

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)

1.3. Addressing Modes


The addressing modes refers to the way in which the operand of an instruction is specified. It
specified a rule for interpreting or modifying the address field of the instruction before the
operand is actually executed. It is a job of a microprocessor is to execute a set of instructions
stored in memory to perform a specified task.
The way of specifying data to be operated by an instruction is known as addressing modes. This
specified that the given data is an immediate data or an address. It also specified whether the
given operand is register or register pair. Operations require, the operator or opcode which
determines what will be done and the operands which define the data to be used in the operation.
For example, if we wanted to add the numbers 1 and 2 and get a result, mathematically we would
likely write this as 1 + 2. In this case, our operator is (+), or the addition, and our operands are
the numbers 1 and 2.
Following are the main addressing modes that are used on various platforms and architectures.

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.

1.4. Data Movement Instruction


Data Movement Instructions move data from the source operand to the destination operand. Data
movement instructions can be grouped into loads, stores, moves, and immediate loads.
 Load instructions move data from memory to registers.
 Store instructions move data from registers to memory.
 Move instructions move data from one register to another.
 Immediate load instructions move constants, including addresses, to registers. Immediate
data to a register and Immediate data to a memory
MOV (Move) transfers a byte, word, or doubleword from the source operand to the destination
operand. The MOV instruction is useful for transferring data along any of these paths. There are
also variants of MOV that operate on segment registers.
The mov instruction allows you to copy the contents of one register into another register.
The Mov instruction takes two operands, representing the destination where data is to be placed
and the source of that data.
General Form of Mov Instruction: mov destination, source
Where destination must be either a register or memory location and source may be a constant,
another register or a memory location.

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.

1.5. Arithmetic and Logic Instruction


In assembly language you can only carry out a single arithmetic operation at a time. This means
that if you wish to evaluate an expression such as z = x + y + w – v. You will have to use 3
assembly language instructions, one for each arithmetic operation. These instructions combine
assignment with the arithmetic operation.
The add instruction adds the source operand to the destination operand, leaving the result in the
destination operand.
The inc instruction takes one operand and adds 1 to it. It is provided because of the frequency of
adding 1 to an operand in programming.
The dec instruction like inc takes one operand and subtracts 1 from it. This is also a frequent
operation in programming.
The sub instruction subtracts the source operand from the destination operand leaving the result
in the destination operand.
Example:
Mov ax, 5 ; load 5 into ax
add ax, 3 ; add 3 to the contents of ax. So, ax now contains 8
inc ax ; add 1 to ax. So, ax now contains 9
dec ax ; subtract 1 from ax. So, ax now contains 8
Sub ax, 6 ; subtract 6 from ax. So, ax now contains 2
 NEG: - Negate Makes operand negative (two's complement) Algorithm: Invert all bits of the
operand and Add 1 to inverted operand.
 NOT: - Invert each bit of the operand. Algorithm: if bit is 1 turn it to 0 and if bit is 0 turn it
to 1.
 OR: - Logical OR between all bits of two operands. Result is stored in first operand. These
rules apply: 1 OR 1 = 1, 1 OR 0 = 1, 0 OR 1 = 1 and 0 OR 0 = 0.

8
BULE HORA UNIVERSITY DEPARTEMENTS OF SOFTWARE ENGINEERING
2024

1.6. Program Control Instructions


The jump group: Allows programmer to skip program sections and branch to any part of
memory for the next instruction. The most basic kind of program control instruction is the
unconditional branch or unconditional jump. Branch is usually an indication of a short change
relative to the current program counter. Jump is usually an indication of a change in program
counter that is not directly related to the current program counter (such as a jump to an absolute
memory location or a jump using a dynamic or static table), and is often free of distance limits
from the current program counter. Unconditional Jumps are short jump, near jump, far jump.
The penultimate kind of program control is the conditional branch or conditional jump. This
gives computers their ability to make decisions and implement both loops and algorithms beyond
simple formulas. A conditional jump instruction allows decisions based upon numerical tests.
Results are held in the flag bits, then tested by conditional jump instructions LOOP and
conditional LOOP are also forms of the jump instruction.
Unconditional Jump
 Short Jump
 It is called relative jump. It is a 2-byte instruction that allows jumps or branches to
memory locations within +127 and -128 bytes from the address following the jump.
 The jump address is not stored with the opcode but a distance or displacement follows
the opcode
 Near Jump
 It passes control to an instruction in the current code segment located within ±32K
bytes from the near jump instruction
Distance is ±2G in 80386 and above when operated in protected mode
 It is relocatable known as relative jump. The short and near jumps are often called
intrasegment jumps.
 It is a 3-byte instruction with opcode followed by a signed 16-bit displacement.
80386 - Pentium 4 displacement is 32 bits and the near jump is 5 bytes long
 Far Jump
 It is also called inter-segment jumps. When a jump references an address, a label
normally identifies the address.

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

You might also like