0% found this document useful (0 votes)
20 views8 pages

Assembly Addressing Mode Protected Direct

By sir wasi

Uploaded by

jk716773
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
0% found this document useful (0 votes)
20 views8 pages

Assembly Addressing Mode Protected Direct

By sir wasi

Uploaded by

jk716773
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/ 8

Computer organization and Assembly language programming

Department of Information Technology Hazara


University
Teacher : Mir Muhammad Wasiq

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

We have to add two numbers

4+2

CPU find the numbers where they are to perform addition

4 and 2 are operands and + is OP-Code or operational code. In assembly


language like other languages we need to keep 2 and 4 somewhere in
registers (general purpose)
Opcode register, memory address

 How CPU access the data


Any program first load in RAM then it goes to Register, from
where CPU Pick it and run it

Most assembly language instructions require operands to be processed.


An operand address provides the location, where the data to be
processed is stored. Some instructions do not require an operand,
whereas some other instructions may require one, two, or three
operands.

When an instruction requires two operands, the first operand is generally


the destination, which contains data in a register or memory location and
the second operand is the source. Source contains either the data to be
delivered (immediate addressing) or the address (in register or memory)
of the data. Generally, the source data remains unaltered after the
operation.

The three basic modes of addressing are

 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,

MOV DX, TAX_RATE ; Register in first operand


MOV COUNT, CX ; Register in second operand
MOV EAX, EBX ; Both the operands are in registers

As processing data between registers does not involve memory, it provides


fastest processing of data.

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

Add 3, DL ….its wrong

When a constant value like 3 is directly assign to a register we call it immediate


addressing

For example,

BYTE_VALUE DB 150 ; A byte value is defined


WORD_VALUE DW 300 ; A word value is defined
ADD BYTE_VALUE, 65 ; An immediate operand 65 is added
MOV AX, 45H ; Immediate constant 45H is transferred to AX
Direct Memory Addressing
Memory addressing

Accessing static data directly is called memory addressing

If we don’t want to give 3 direct instead its in memory

Add Dl, [address]

This scheme is called Memory addressing

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

DATA TRANSFER INSTRUCTIONS


The MOV Instruction
We have already used the MOV instruction that is used for moving data from one
storage space to another. The MOV instruction takes two operands.
Syntax

The syntax of the MOV instruction is −

MOV destination, source

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

Please note that −

 Both the operands in MOV operation should be of same size


 The value of source operand remains unchanged

4ch=Exit
EXAMPLE

4+2 CODE

BY USING IMMEDIATE ADDRESSING

Mov Dl,4 samelike Mov Dl, ‘a’

To print it on screen we use accumulator register and we pass service routine


2

Mov Ah, 2

The MOV instruction causes ambiguity at times. For example, look at the
statements −

MOV EBX, [MY_TABLE] ; Effective Address of MY_TABLE


in EBX
MOV [EBX], 110 ; MY_TABLE[0] = 110

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.

Following table shows some of the common type specifiers −

Type Specifier Bytes addressed

BYTE 1

WORD 2

DWORD 4

QWORD 8
TBYTE 10

ASCII Codes ???

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

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy