[go: up one dir, main page]

100% found this document useful (1 vote)
63 views9 pages

Addressing Modes

The document provides an overview of addressing modes in assembly language, detailing immediate, direct, indirect, indexed, and relative addressing modes, along with their characteristics and applications. It also covers instruction grouping, including data movement, I/O operations, arithmetic operations, control flow instructions, and comparison instructions, emphasizing their significance in programming. Additionally, it discusses key registers, numbering systems, and register transfer notation, highlighting their roles in assembly language programming.

Uploaded by

japneet kaur
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
63 views9 pages

Addressing Modes

The document provides an overview of addressing modes in assembly language, detailing immediate, direct, indirect, indexed, and relative addressing modes, along with their characteristics and applications. It also covers instruction grouping, including data movement, I/O operations, arithmetic operations, control flow instructions, and comparison instructions, emphasizing their significance in programming. Additionally, it discusses key registers, numbering systems, and register transfer notation, highlighting their roles in assembly language programming.

Uploaded by

japneet kaur
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

Addressing Modes

Addressing modes in assembly language programming are methods


used to specify operands for an instruction. These modes determine
how the assembler interprets the operand part of an instruction,
whether it’s a direct value, a memory address, or a reference to a
location determined by other means. Understanding these modes is
essential for efficient programming and manipulating data
effectively in assembly language.

Immediate Addressing Mode

 Immediate addressing mode involves embedding the


Definition:
operand value directly within the instruction. It is the simplest form
of addressing.
 Characteristics:
 Offers high speed as the operand is directly available.
 Limits flexibility, as the value is fixed and cannot be changed
dynamically.
 Example: MOV A, #5 - This instruction moves the value 5 directly into
the accumulator A.
 Application: Typically used for initialising registers or for simple
arithmetic operations.

Direct Addressing Mode

 In direct addressing, the operand is a memory address. The


Definition:
instruction directly points to the location of the data.
 Characteristics:
 More flexible than immediate addressing, as the memory content
can change.
 Slightly slower than immediate addressing due to the need to
access memory.
 Example: LOAD A, 2000H - Loads the value from the memory address
2000H into register A.
 Application: Commonly
used for accessing global variables or constants
stored in specific memory locations.

Indirect Addressing Mode

 Definition: Indirect
addressing uses a register to hold the memory
address of the operand. The register indirectly points to the
operand.
 Characteristics:
 Provides dynamic operand referencing, ideal for working with
changing data locations.
 Slightly slower due to the additional step of dereferencing the
register to access the operand.
 Example: MOV A, [BX] - Moves the value from the memory location
pointed to by register BX into register A.
 Application: Essential for implementing pointers, dynamic data
structures, and handling arrays.

Indexed Addressing Mode

 Indexed addressing combines a base address, usually in a


Definition:
register, with an index value to calculate the actual address of the
operand.
 Characteristics:
 Highly versatile, allowing for easy manipulation of data structures
like arrays.
 The index can be changed, making it dynamic and flexible for
various applications.
 Example: LOAD A, B[IX] - Loads a value from an array B at a position
indicated by the index register IX into A.
 Application: Ideal for iterating over arrays and complex data
structures.

Relative Addressing Mode


 Definition: Relative
addressing mode bases the operand's address on its
position relative to the current instruction.
 Characteristics:
 Primarily used for program control instructions like jumps and
branches.
 Offers flexibility in code relocation and dynamic execution flow.
 Example: JMP +10 - Jumps to an instruction 10 bytes forward from the
current instruction.
 Application: Crucial for implementing loops, conditional execution, and
handling program flow control.

Comparative Analysis of Addressing Modes

 Impact on Operand Interpretation:


 Immediate Mode: Quick but rigid, used for simple, unchanging values.
 Direct Mode: More flexible, allows accessing global data but requires a
fixed memory address.
 Indirect Mode: Highly flexible, ideal for variable data locations and
advanced data structures.
 Indexed Mode: Combines base address stability with index flexibility,
perfect for data arrays.
 Relative Mode: Essential for control flow, adapting the program
execution based on conditions.

Practical Examples in Assembly Language

 Immediate Mode: ADD A, #10 - Adds the number 10 to the current value
in register A, useful for quick arithmetic adjustments.
 Direct Mode: STO 3000H, B - Stores the content of register B into the
memory address 3000H, used for updating global variables.
 Indirect Mode: MOV A, [DI] - Moves data from the location pointed by DI
register into A, used for accessing dynamically changing data.
 Indexed Mode: MOV C, A[SI] - Moves data from an array A at an index SI
into register C, used for array manipulation.
 Relative Mode: JPE +20 - Jumps 20 bytes ahead in the program if the zero
flag is set, used in conditional branching.

Instruction Grouping

Assembly language instructions are the primary tools for


implementing logic and control in software at the hardware level.
These instructions can be grouped based on their functionality, such
as data movement, arithmetic operations, and control flow
management. A thorough grasp of these categories is essential for
developing efficient and effective assembly programs.

Data Movement Instructions


The transfer and manipulation of data within a computer system are
fundamental operations in assembly language. Data movement
instructions manage the flow of data between various components
of the computer, such as registers, memory, and the accumulator.
Key instructions in this category include:

 MOV: The most common instruction, used for moving data between
registers, from memory to registers, and vice versa.
 PUSH and PULL: These instructions manage data on the stack, a
crucial area in memory for temporary data storage and retrieval
during function calls.
 LOAD and STORE: Specifically designed for data transfer between
registers and memory, these instructions are pivotal in managing
data during program execution.

Understanding and efficiently using these instructions are vital for


maintaining data integrity and ensuring the correct data is available
for processing when needed.
I/O Operations
Input/Output operations in assembly language facilitate the
interaction between the computer and its external environment,
including hardware devices like keyboards, displays, and storage
units. I/O instructions are specialised for handling this data
exchange. The primary instructions include:

 IN: Reads data from an input device or a specified port, transferring


it to a register or memory location for processing.
 OUT: Sends data from the computer to an output device or a port,
enabling external representation or storage of processed data.

I/O operations are essential for real-world applications of computers,


enabling them to respond to user input and display results.

Arithmetic Operations
Arithmetic instructions are at the heart of computational processes
in assembly language. These instructions perform basic
mathematical operations and are crucial for any algorithmic
processing. The main arithmetic instructions include:

 ADD and SUB: Execute addition and subtraction, fundamental for


numerical calculations.
 MUL and DIV: Handle multiplication and division, expanding the
scope of computational capabilities.
 INC and DEC: Increment and decrement instructions, useful for
loops and iterative processes.

Arithmetic instructions are integral to problem-solving and


algorithmic implementation in assembly language programming.
Unconditional and Conditional
Instructions
Control flow in assembly language is managed through a
combination of unconditional and conditional instructions. These
instructions determine the execution sequence of a program based
on various conditions:

 JMP (Jump): An unconditional instruction that alters the flow of


execution to a specified address, regardless of any conditions.
 Conditional instructions like JE (Jump if Equal), JNE (Jump if Not
Equal), JG (Jump if Greater), and JL (Jump if Less), modify the
program’s flow based on the evaluation of specific conditions.

These instructions introduce logic and decision-making capabilities


into assembly programs, allowing for more complex and dynamic
software design.

Comparison Instructions
Comparison instructions in assembly language are used to compare
values and set flags in the processor's status register based on the
outcomes. These flags can then influence the flow of the program
through conditional instructions. Important comparison instructions
include:

Opcodes and Operands

 Opcodes (Operation Codes): Mnemonic codes representing


machine-level instructions. They dictate the operation the CPU
should perform.
 Operands: The entities on which the operations are performed.
These can be registers, constants, or memory addresses.
Comprehensive Examination
of Instructions
Data Movement Instructions

 LDM (Load Memory): Transfers data from a memory location to


the accumulator (ACC). Essential for operations requiring data
manipulation.
 LDD (Load Direct): Loads a value from a specified memory
address directly into ACC. Used for accessing specific data points.
 LDI (Load Immediate): Directly loads an immediate value into
ACC, bypassing memory access. Efficient for small constant values.
 LDX (Load Index): Assigns a value to the index register (IX). Vital
for operations involving indexed addressing.
 LDR (Load Register): Enables data transfer between registers,
facilitating internal CPU data handling.
 MOV (Move): Copies data from one register or memory location to
another. Fundamental for data repositioning.
 STO (Store): Places the content of ACC into a specified memory
location. Crucial for preserving computed results.

Arithmetic Instructions

 ADD: Adds a specified value or register content to ACC. Central to


mathematical computations.
 SUB: Subtracts a specified value or register content from ACC. Key
for arithmetic calculations.
 INC (Increment): Increases the value in a specified register by
one. Useful for loops and counters.
 DEC (Decrement): Decreases the value in a specified register by
one. Important for decrementing counters and loops.
Control Flow Instructions

 JMP (Jump): Alters program execution flow to another instruction.


Essential for implementing loops and conditional operations.
 CMP (Compare): Compares two values, often setting flags based
on the outcome (equal, greater, or less). Fundamental in decision-
making structures.
 CMI (Compare Immediate): Directly compares an immediate
value with ACC, setting flags similar to CMP.
 JPE (Jump if Equal): Directs program flow to another instruction if
the last comparison result was equal.
 JPN (Jump if Not Equal): Redirects program execution if the last
comparison result was not equal.

Input/Output Instructions

 IN: Reads data from an input device (like a keyboard) into ACC. Vital
for interactive programs.
 OUT: Outputs data from ACC to a device (like a screen). Key for
displaying results or messages.

Termination Instruction

 END: Marks the end of the assembly program. Instructs the


assembler that the program's instructions have concluded.

Role of Key Registers


 Accumulator (ACC): A primary register used for arithmetic and
logical operations. Acts as a default location for many operations.
 Index Register (IX): Facilitates indirect addressing and array
traversals. Enhances the flexibility of data access.
Numbering Systems in
Assembly Language
 Denary (#): Represents numbers in the base-10 system, familiar in
everyday use.
 Binary (B): Reflects the base-2 system, mirroring how computers
internally represent data.
 Hexadecimal (&): Base-16 system, offering a more compact
representation of binary values, easing readability.

Register Transfer Notation


(RTN)
RTN is a symbolic representation of the effects of instructions on
CPU registers.

 Example: ACC <- IX + #10 indicates adding 10 to the content of


the index register and storing the result in ACC.

 CMP: Compares two values, setting flags in the status register


based on the result (equal, greater, less, etc.).
 TEST: Performs a bitwise AND operation between two values,
setting flags based on the result, often used for conditional checks.

These instructions are fundamental for logical decision-making and


control flow in assembly language programs.

You might also like