Experiment 2 Directives - Indicates How An Operand or Section of A Program Is To Be Processed by The
Experiment 2 Directives - Indicates How An Operand or Section of A Program Is To Be Processed by The
Experiment 2 Directives - Indicates How An Operand or Section of A Program Is To Be Processed by The
Interrupts
ex.
mov ah,2
mov dl,41h
int 21h
Interrupt 20h
or
Interrupt 21h, service number 4ch
ah = 4ch – service number to terminate the program properly stored in register ah
ex.
int 20h / mov ah, 4ch
int 21h
Clear screen
ex.
mov ax,03
int 10h
Carriage return
New Line
ex.
mov dl,10
int 21h
Int 21h
Sample program:
.model small
.code
Org 100h
S:
Mov ah,1
Int 21h
Int 20h
End s
Common Instruction
1. Inc
- increment the value of a register by 1
Ex,
Inc dl
2. Dec
- decrement the value of a register by 1
Ex.
Dec dl
3. add
- lets you add a value to your register
Ex.
Add dl,20
Int 21h, service 9
<display string / string manipulation
ah = 9
[ds:dx] = address of the string
ds = address or location of the string
dx = register to hold the string
var_name db “string$”
db = define byte
$ = string terminator
ex.
mess db “hello$”
mess1 db 10,13,”World$”
mess2 db “good day”,10,13,’$’
Syntax:
mov ax,@data
mov ds,ax
mov ah,9
mov dx, offset mess
int 21h
Common Instruction
LEA
Loads effective address
Use register dx to store the effective address
Format:
lea dx,var_name
Ex. Lea dx,mess
Sample program:
.model small
.stack
.code
mess db "hello$",10,13
mess1 db “hello$
org 100h
s:
main proc
mov ax,@data
mov ds,ax
mov ah,9
lea dx,mess
int 21h
mov ah,9
mov dx, offset mess1
int 21h
mov ah,4ch
int 21h
main endp
end s
JMP instructions
JMP stands for jump
Jump to a level
Allows the programmer to skip sections of a program and branch to any part of
the memory for the next instruction
Format:
jmp label
label – refers to the address of an instruction procedure or segment
ex. jmp start
- this instruction will transfer the flow of control to the label start
LOOP
allows a part of a program to be repeated for several times
the number of loops depends upon the value of the CX register
CX takes the number of loops
Each time the loop is encountered the value of CX is decremented
Looping stops when CX becomes zero
Format:
LOOP label
Ex. LOOP start
Sample program:
.model small
.code
Org 100h
S:
Mov ax,03
Int 10h
Mov cx,3
X:
Mov ah,2
Mov dl,’A’
Int 21h
Loop x
Int 20h
End s
Conditional JUMPs
same as JMP instruction but JMP is only taken if the condition is TRUE.
CMP instruction
Cmp stands for compare
Compare bytes or words
Used to compare two numeric data fields, one or both of which are contained in a
register
Format: cmp s1,s2
Takes the relation of s1 and s2
Ex.
cmp dx,00 ;is dx=00?
je L10 ;if yes, jump to L10
L10:……… ;jump point if dx = 00
Sample program:
.model small
.code
Org 100h
S:
Mov ax,03
Int 10h
Mov ah,1
Cmp al,’x’
Int 21h
Int 20h
End s
CALL / RET instruction
Is similar to jump but it allows to return back to the main program.
Syntax :
Call {arguments}
.
.
.
Ret
Ex.
.
.
.
Call down
.
.
.
.
Down proc
.
.
.
ret