0% found this document useful (0 votes)
15 views

Variable Data Types Offset Anf LEA

The document discusses variables in assembly language. It explains that variables are defined in the .data directive and initialized using directives like DB, DW, DD etc along with a data type and value. It provides examples of initializing different variables like characters, strings and numbers. The dollar sign ($) is used to terminate strings. The LEA instruction is introduced as an indirect pointer to other variables. Escape sequences for newline and carriage return are also explained.

Uploaded by

Hammad Mughal
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

Variable Data Types Offset Anf LEA

The document discusses variables in assembly language. It explains that variables are defined in the .data directive and initialized using directives like DB, DW, DD etc along with a data type and value. It provides examples of initializing different variables like characters, strings and numbers. The dollar sign ($) is used to terminate strings. The LEA instruction is introduced as an indirect pointer to other variables. Escape sequences for newline and carriage return are also explained.

Uploaded by

Hammad Mughal
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 14

Computer Organization and

Assembly language
Prof Hashim Javed
Objectives
Variables
Data types
Offset
LEA (load effective Address)
Introduction
Till now we have placed the characters in the Register so today we will
discuss about the Variables that how can we place the characters in the
variables
Question?

Q:Where to initialize the variables in program?


.data segment

Variables are defined in the .data directive of program structure


How to initialize variable and what is the syntax

Variable name Data size/Data type value

Var1 db 49(ASCII for 1)


Initializer directive

DB Define btye 1byte,8bits


DW define word 2 bytes, 16 bits
DD define Double word 4 bytes ,32 bits
DQ Define Quadword 8 bytes,64 bits
DT Define 10bytes 10 bytes,80 bits
If you haven’t remember the ASCII value then you can use this

Var db ‘1’
Var db ? ; For the user defined Input

Var db ‘A’

If you want to print the couple of characters then you can initialize them as

Var1 db ‘12345$’
Var1 db ‘Hello World$’
Why Dollar sign is used
To terminate the String we have to add the Dollar($) sign Right After
the string to tell the string we want to print out string over there

Dollar ($) = Terminator End point of String

Note:
Dollar ($) must be used in end of the String
Let start with the program to implement the
Above Discussion

.data
Var1 bd ‘1’
Var2 db ?
Var 3 db ‘12345$’
Understanding the Logic
.code
Main proc
Mov ax,@data .Data

Mov ds,ax
.Code
Mov ax,@data
It moves the memory location of @data into
The AX Register (16 bit register)

Mov ds,ax
Moves data Address to DS so that the data segment gets initialized as
heap memory to Access variable fast
What is load Effective Address (LEA)

It is as indirect instruction used as a pointer in which first variable


points to the Address of the Second variable
Escape Sequences
Hello
World New line Feed

Hello
Carriage Return
World
For new line 10
For carriage return 13

Mov dx,10
Mov ah,2
Int 21h
Mov dx,13
Mov ah,2
Int 21h

You might also like