Professional Documents
Culture Documents
Hari K.C.
Introduction
• Addressing mode is also known as memory addressing.
• It is the technique of specifying the operands for any instructions.
• It specifies the address of the data to be operated.
• Advantages:
1) provide flexibility in programming ( pointer to memory, counters for
loop control, indexing of data, program relocation)
2) reduce the number of bits in the addressing field of the instructions
Types of addressing modes
• Each instruction of a computer specifies an operation on certain data.
The most common addressing modes are:
• Immediate addressing mode
• Direct addressing mode
• Indirect addressing mode
• Register addressing mode
• Register indirect addressing mode
• Displacement addressing mode
• Stack addressing mode
Immediate Addressing:
• This is the simplest form of addressing. Here, the operand is given in
the instruction itself.
• This mode is used to define a constant or set initial values of
variables.
• The advantage of this mode is that no memory reference other than
instruction fetch is required to obtain operand.
• The disadvantage is that the size of the number is limited to the size
of the address field, which most instruction sets is small compared to
word length. e.g:-MVI A,32H
Direct Addressing:
• In direct addressing mode, effective address of the operand is given in
the address field of the instruction.
• It requires one memory reference to read the operand from the
given location and provides only a limited address space.
• Length of the address field is usually less than the word length.
• Eg: Move P, Ro, Add Q, Ro P and Q are the address of operand.
Indirect Addressing:
• Indirect addressing mode, the address field of the instruction refers to
the address of a word in memory, which in turn contains the full
length address of the operand.
• The advantage of this mode is that for the word length of N, an
address space of 2N can be addressed.
• The disadvantage is that instruction execution requires two memory
reference to fetch the operand Multilevel or cascaded indirect
addressing can also be used.
Register Addressing:
• Register addressing mode is similar to direct addressing.
• The only difference is that the address field of the instruction refers to
a register rather than a memory location 3 or 4 bits are used as
address field to reference 8 to 16 generate purpose registers.
• The advantages of register addressing are Small address field is
needed in the instruction.
Register Indirect Addressing:
• This mode is similar to indirect addressing. The address field of the
instruction refers to a register.
• The register contains the effective address of the operand. This mode
uses one memory reference to obtain the operand.
• The address space is limited to the width of the registers available to
store the effective address.
Displacement Addressing:
• In displacement addressing mode there are 3 types of addressing mode. They are :
1) Relative addressing
3) Indexing addressing.
3) Input/Output Instructions:
- for input output operations
Instruction Types for basic computer
1) Functional instructions
- Arithmetic, logic, and shift instructions
- ADD, CMA, INC, CIR, CIL, AND
2) Transfer instructions
- Data transfers between the main memory and the processor registers
- LDA, STA
3) Control instructions
- Program sequencing and control
- JMP, JNZ, JC
4) Input and output instructions
- Input and output operations
- INP, OUT
Computer Registers for basic computer
• Register are used to quickly accept, store, and transfer data and
instructions that are being used immediately by the CPU, there are
various types of registers those are used for various purpose.
• Among of the some mostly used registers named as Accumulator,
Data Register, Address Register, Program Counter, Memory Data
Register, Index register, Memory Buffer Register.
Types of registers
Instruction Register (IR)
• Instruction Register (16 bits) holds the instruction code of the instruction currently executing.
• Outputs of this register are hardwired to specific logic in the control unit, which interprets the bits to
generate control signals.
Address Register (AR)
• Address Register (12 bits) is used to interface with the memory unit. All memory-references are
• initiated by loading the memory address into AR.
Temporary Register (TR)
• Temporary Register (16 bits) is an extra register for storing data or addresses.
Input and Output Registers
• The Basic Computer has one input device and one output device. The Input Register (INPR) holds an
• 8 bit character gotten from an input device.
• The Output Register (OUTR) holds an 8 bit character to be send to an output device.
Program Counter (PC)
• The program counter (PC) is commonly called the instruction pointer (IP) in
Intel x86
• microprocessors, and sometimes called the Instruction Address Register
(IAR), or just part of the instruction sequencer in some computers, is a
processor register.
• Program Counter (12 bits) holds memory address of current/next
instruction to be executed.
• Updated as part of the instruction cycle. Usually incremented, but may be
parallel loaded by jump/branch instructions.
• It keeps track of the next memory address of the instruction that is to be
executed once the execution of the current instruction is completed.
In other words, it holds the address of the memory location of the next
instruction when the current instruction is executed by the microprocessor.
Accumulator Register (AC)
• This Register is used for storing the Results those are produced by the
System. When the CPU will generate Some Results after the
Processing then all the Results will be Stored into the AC Register.
• Accumulator (16 bits) is used for all mathematical, logic, and shift
operations except incrementing and clearing other registers (most
have built-in increment and clear capability).
• It is the destination for all ALU operations, and a source for all dyadic
(two-operand) operations.
Data Register (DR)
• A register used in microcomputers to temporarily store data being
transmitted to or from a
• peripheral device. Data Register (16 bits) is used to contain a second
operand for dyadic operations such as Add, Sub, AND, OR.
Instruction cycle for basic computer
• The CPU performs a sequence of micro-operations for each instruction.
• The sequence for each instruction of the Basic Computer can be refined
into 4 abstract phases:
1) Fetch an instruction from memory
2) Decode the instruction
3) Read the effective address from memory if the instruction has an indirect
address
4) Execute the instruction
After an instruction is executed, the cycle starts again at step 1, for the next
instruction.
Instruction Fetch and Decode
• Program execution begins with: PC ← address of first instruction, SC ← 0
• After this, the SC is incremented at each clock cycle until an instruction is
completed, and then it is cleared to begin the next instruction.
• This process repeats until a HLT instruction is executed, or until the power
is shut off.
• Everything that happens in this phase is driven entirely by timing variables
T0, T1 and T2.
• Hence, all control inputs in the CPU during fetch and decode are functions
of these three variables alone.
Determining the Instruction Type
Memory-Reference Instructions
• Each memory ref instruction is indicated by a unique Di signal.
1) AND operation
2) ADD operation
4) Store operation(STA)
5) Branch unconditionally (BUN)