Assembly Addressing Mode Protected Direct
Assembly Addressing Mode Protected Direct
Addressing Modes
Ways to access the data is called Addressing
modes
We need an address to access memory or a register. Each memory or
register has an address
Example
4+2
Register addressing
Immediate addressing
Memory addressing
Register Addressing
In this addressing mode, a register contains the operand. Depending
upon the instruction, the register may be the first operand, the second
operand or both.
; Dl=4
; Al=2
Add Dl, Al
; When both operands are register we call it registers addressing, where CPU
picks data directly from registers
For example,
Immediate Addressing
An immediate operand has a constant value or an expression. When an
instruction with two operands uses immediate addressing, the first
operand may be a register or memory location, and the second operand
is an immediate constant. The first operand defines the length of the
data.
Immediate addressing
Add Dl, 3
For example,
When operands are specified in memory addressing mode, direct access to main
memory, usually to the data segment, is required. This way of addressing results in
slower processing of data. To locate the exact location of data in memory, we need
the segment start address, which is typically found in the DS register and an offset
value. This offset value is also called effective address.
In direct addressing mode, the offset value is specified directly as part of the
instruction, usually indicated by the variable name. The assembler calculates the
offset value and maintains a symbol table, which stores the offset values of all the
variables used in the program.
In direct memory addressing, one of the operands refers to a memory location and
the other operand references a register.
For example,
ADD BYTE_VALUE, DL ; Adds the register in the memory location
MOV BX, WORD_VALUE ; Operand from the memory is added to register
The MOV instruction may have one of the following five forms −
MOV register, register
MOV register, immediate
MOV memory, immediate
MOV register, memory
MOV memory, register
4ch=Exit
EXAMPLE
4+2 CODE
Mov Ah, 2
The MOV instruction causes ambiguity at times. For example, look at the
statements −
It is not clear whether you want to move a byte equivalent or word equivalent of
the number 110. In such cases, it is wise to use a type specifier.
BYTE 1
WORD 2
DWORD 4
QWORD 8
TBYTE 10
Lab task: Program to take input a character from user and print it on
screen in assembly language programming
dosseg
.model small
.stack 100h
.data
.code
Main proc
Mov ah,1
Int 21h
Mov dl,al
Mov ah,2
Int 21h
Mov ah,4ch
Int 21h
main endp
End main