lab4
lab4
in EMU8086
What is a Variable?
A variable is a storage location in a program that holds data. It allows programmers to
store, modify, and retrieve values during program execution.
Key Points:
Name: Each variable has a unique identifier (name) that allows you to reference it in
your code.
Data Type: Variables can hold different types of data, such as integers, characters, or
floating-point numbers.
BYTE:
. DB (define byte)
. 8 bits
. used to store single byte value
WORD:
. DW (define word)
. 16 bits
. used to store 16bit value
Declaring variable:
Syntax:
Example:
myByte DB 10;
myWord DW 1234h;
myDword DD 1234567h
3/1/20XX SAMPLE FOOTER TEXT 4
Write a simple program
Step 1: Basic structure
stack 100h
. Define stack size
data
. Start of data segment
code
. Start of code segment
itle
MOV AX, 4C00h
. 4C Terminates the process
. 00 Return code/ exit code
. DOS function to exit program (disk operting system)
INT 21h
•Code segment
mov ax, @data
mov ds, ax
. loads the address of data segment in AX register
. 00720 DS address
. We load the data in DS so that we can know where our data is located
Actual working :
MOV AH, 09h sets up the function,
LEA DX, message loads the address of the string, and
INT 21h triggers the display action.