Assembler Directives Programs-SD
Assembler Directives Programs-SD
Assembler Directives Programs-SD
1
Assembler Directives
Assembler directives are the commands to the assembler that direct the assembly process.
They indicate how an operand is treated by the assembler and how assembler handles the
program. They also direct the assembler how program and data should be arranged in the
memory. The important point to be noted here is they do not generate any machine code i.e.
they do not contribute to the final size of machine code. And, they are assembler specific.
Some assembler directives are defined below:
TITLE directive:
This directive is used to give a maximum 60 characters wide title to the assembly language
program. The title immediately follows the directive.
For example, TITLE ALP to find gcd of two numbers
.MODEL directive
This directive is used to specify how many code and data segments are necessary for the
program.
The syntax is: .MODEL memory_model. The memory model can be chosen based on our
requirement as follows:
Model No. of code segments No. of Data Segments
SMALL
MEDIUM
COMPACT
LARGE
1
More than 1
1
More than 1
1
1
More than 1
More than 1
.STACK directive
This directive is optional and is used to define the size of the stack segment.
Syntax: .STACK <size>
For example, we can define a 100 bytes stack segment as .STACK 100d
.DATA directive
This directive is used to define data segment necessary for our program.
Data can be of different types like byte, word, double word or quad word. They can be
declared using directives as follows:
DB Define Byte
DW Define Word
DD Define Double Word
DQ Define Quad Word
DT Define Ten Bytes
There is one special directive to define blocks of larger size. It is DUP.
Syntax: label type size DUP (value to initialize in all locations)
Art of Assembly Language Programming
2
They are all used in data segment as follows:
.data
A DB 10H
X DW 1234H
Y DD 11112222H
Z DQ 10H ; 0 will be stored in higher bytes
STR DB 100 DUP (0) ; 100 bytes are reserved with a value of 0 in each location
.CODE directive
This directive is used to indicate the beginning of instructions i.e. the assembly code.
The assembly language program is end with END directive
ALIGN directive
The ALIGN directive forces the assembler to start the next segment at address which is
divisible by the number mentioned immediately after ALIGN directives.
Number can be 2, 4, 6, 8, or 16
For example, ALIGN 16 forces the assembler to align the next segment at an address that is
divisible by 16.
Assembler fills the unused bytes with 0 for data and NOP instructions for code.
DOS loads CODE segment first and then only it loads DATA segment to memory. Hence
ALIGN directive is used usually at the end of code segment.
ASSUME directive
This is specific to MASM Assembler. It is used to give symbolic names to the different
segments.
For example, Assume cs:code, ds:data, ss:stack at the first line of your program indicates
there are three segments in the program and data is the name given to data segment, code is
the name of code segment and stack is the name for stack segment. Remember data, code and
stack are user given names.
SEGMENT and ENDS directives
They are used to mark the beginning and end of the particular segment.
Syntax:
segment_name SEGMENT
.
.
.
segment_name ENDS
For example, data segment can be declared as:
DATA SEGMENT
X DB 10H
Y DB 20H
Z DB ?
DATA ENDS
Similarly code and data segments can also be declared.
Art of Assembly Language Programming
3
PROC and ENDP directives
They are used to define procedures in assembly language programs. They mark the beginning
and end of the procedure.
Syntax:
Proc_name PROC <NEAR/FAR>
.
.
. body of the procedure
.
.
.
RET
Proc_name ENDP
Observe ENDP is always preceded by either RET or IRET instruction.
MACRO and ENDM directives
They are used to define macros in assembly language programs. MACROS are a set of
instructions which are intended to do a particular task. Where ever assembler finds the name
of the macro in the main program, it replaces the set of instructions present in the macro at
that place.
Syntax:
Macro_name MACRO <set of parameters>
.
. body of the macro
.
.
ENDM
Art of Assembly Language Programming
4
Some Simple Assembly Language Programs:
P1: Write an ALP to find the GCD of two bytes and store the result in a memory location:
START
n1 num1
n2 num2
is
(n1) = (n2)
?
GCD n1
END
yes
(n2) (n2) (n1)
is
(n1) > (n2)
?
yes
no
no
(n1) (n1) (n2)
Art of Assembly Language Programming
5
Assume cs:code, ds:data
data segment
n1 db 1BH ; 27d
n2 db 15H ; 21d
gcd db ? ; byte reserved to store gcd
data ends
code segment
start:
mov ax, data
mov ds, ax ; initializing ds register
mov al, n1
comp_again:
cmp al, n2 ; is (n1) = (n2) ?
je success
jg next ; is (n1) > (n2) ?
sub n2, al ; no!, then do this
jmp comp_again ; compare again to check for equality
sub al, n2
jmp comp_again
success:
mov gcd, al ; store gcd in the byte reserved
code ends
end start
P2: Let us continue the same program to make it find LCM of those numbers.
Logic used is very simple. We will find the product of those numbers whose GCD is to be
found and divide the product by GCD. The quotient we get will be the LCM.
Continued code would be something like this:
mov al, n1 ; take the first byte into al register
mul n2 ; ax (al) x (n1)
div gcd ; (ax)/gcd, (ah) remainder, (al) quotient
mov lcm, al ; so, we have to declare space for lcm in data segment
A1: Write an ALP to find LCM using addition logic.
Art of Assembly Language Programming
6
P3: Lets discuss an ALP to transfer a block of bytes from one memory location to another.
P4: ALP to exchange the contents of two blocks of bytes.
10H
20H
30H
40H
50H
x
y
After execution
Initial Values
Assume cd:code, ds:data
data segment
x db 10h, 20h, 30h, 40h, 50h
y db 5 dup(?)
data ends
code segment
start: mov ax, data
mov ds, ax
mov cx, 05h
lea si, x
lea di, y
rpt: mov al, [si]
mov [di], al
inc si
inc di
loop rpt
mov ah, 4ch ; getting back
; to dos prompt
int 21h ; dos interrupt
code ends
end start
Art of Assembly Language Programming
7
P5: Lets use XCHG instruction to do the same.
The changes in rpt loop are as follows:
mov al, [si]
xchg al, [di] ; exchange (si) with (di). (right now al contains (si))
mov [si], al ; put the (di) at location pointed by si. Now al contains (di)
SI AL
DI
SI
1
2
3
10H
20H
30H
40H
50H
0aaH
0bbH
0ccH
0ddh
0eeh
x
y
After execution
Initial Values
AL
BL
Assume cs:code, ds:data
data segment
x db 10h, 20h, 30h, 40h, 50h
y db 5 dup(?)
data ends
code segment
start: mov ax, data
mov ds, ax
mov cx, 05h
lea si, x
lea di, y
rpt: mov al, [si]
mov bl, [di]
mov [di], al
mov [si], bl
inc si
inc di
loop rpt
mov ah, 4ch ; getting back
; to dos
prompt
int 21h ; dos interrupt
code ends
end start
Art of Assembly Language Programming
8
P6: Write an ALP to search for a byte using linear search
Solution:
Assume cs:code, ds:data
Data segment
a db 10h, 20h, 0ah, 05h, 33h
n dw $-a
key db 0ah
msg1 db Found the key$
msg2 db key Is not found$
data ends
code segment
start:
mov ax, data
mov ds, ax
mov cx, n
lea si, a ; offset of array
mov al, key ; key will be in al reg
cmp al, [si]
je success ; if (al) is equal to contents of location pointed by si, display success
lea dx, msg2 ; else unsuccessful msg
jmp disp
success:
lea dx, msg1
disp:
mov ah,9
int 21h
mov ah, 4ch
int 21h
code ends
end start
P7: Search a key element in a list of n numbers using the Binary Search algorithm
assume cs:code,ds:data
data segment
a db 10h,20h,30h,40h,50h ; Sorting only bytes. Try for words also.
n db n-a
key db 20h
msg1 db "key not found$"
msg2 db "key found at position: "
pos db ?,"$" ; msg2 continues till here!!!
data ends
code segment
Art of Assembly Language Programming
9
start:
mov ax,data
mov ds,ax
mov al,0 ; low
mov dl,n
dec dl ; high
again:
cmp al,dl
ja failed
mov cl,al
add al,dl
shr al,1 ; mid
mov ah,00h
mov si,ax
mov bl,[si] ; [mid] in bl
cmp bl,key
jae loc1 ; [mid] >= key ?
inc al ; no, low = mid+1, to search in second half
jmp again
loc1:
je success ; [mid] = key ?
dec al ; no, high = mid 1, to search in first half
mov dl,al
mov al,cl
jmp again
failed:
lea dx,msg1 ; key not found
jmp display
success:
inc al
add al,30h ; store ASCII value at pos. guess why ????
mov pos,al
lea dx,msg2
display:
mov ah,9
int 21h
mov ah,4ch
int 21h
code ends
end start
Art of Assembly Language Programming
10
P8: Write an ALP to sort the given array using bubble sort
assume cs:code,ds:data
data segment
x db 60h,10h,20h,30h,40h,50h ;array that might get sorted immediately
; after first pass
n dw n-x ; no. of elements
data ends
code segment
start:
mov ax,data
mov ds,ax
mov bx, n
dec bx ; no. of passes needed
next_pass:
mov ah,00 ; a flag. can u guess why?
mov cx,bx ; no. of comparisons = no of passes left
lea si,x
next_comp:
mov al,[si]
cmp al,[si+1] ; [si] Vs [si+1]
jle do_nothing ; ascending order, for descending jge
xchg al,[si+1]
mov [si],al
mov ah,1
do_nothing:
inc si
loop next_comp
cmp ah,00
je finish ; array is already sorted
dec bx
jnz next_pass
finish:
mov ah,4ch
int 21h
code ends
end start
Art of Assembly Language Programming
11
P9: Write an ALP to sort the given array using insertion sort
assume cs:code,ds:data
data segment
a dw 55h,44h,33h,22h,11h
n dw (n-a)/2
data ends
code segment
start:
mov ax,data
mov ds, ax
mov cx,2 ; element at this position to be sorted
next_pass:
mov bx, cx ; no of comparisons needed
dec bx
mov si,bx
add si,si ; offset of number to be sorted
mov ax,a[si]
next_comp:
cmp a[si-2],ax
jbe no_change ; if [si] > [si-2], then pass is over
mov dx,a[si-2]
mov a[si],dx
dec si
dec si
dec bx
jnz next_comp
no_change:
mov a[si],ax
inc cx
cmp cx,n
jbe next_pass
mov ah,4ch
int 21h
code ends
end start
P10: Reverse a given string and check whether it is a palindrome or not.
assume cs:code,ds:data
data segment
str1 db 'madam'
n dw n str
str2 db 5 dup(?)
msg1 db "pallindrome$"
msg2 db "not a palindrome$"
Art of Assembly Language Programming
12
data ends
code segment
start:
mov ax,data
mov ds,ax
mov es,ax ; please observe this !!!!!!
mov cx,n
lea si,n ; a simple trick to make si pointing to last character of main string
dec si
lea di,str2
nextchar:mov al,[si]
mov [di],al
dec si
inc di
loop nextchar
lea si,str1
lea di,str2
cld ; so that si and di will be incremented
mov cx,n
rep cmpsb
jnz unsuccess
lea dx,msg1
jmp disp
unsuccess:lea dx,msg2
disp:mov ah,9h
int 21h
mov ah,07h
int 21h
code ends
end start
Art of Assembly Language Programming
13
MODULAR PROGRAMMING in 8086/8088:
Modularity increases the efficiency of programming. Instead of writing big monolithic
programs, the task can be divided as subtasks and can be developed in parallel which saves
times. And the modules can be used in different programs which reduce even the testing time
since they are all tested with all possible inputs earlier.
Modularity in 8086 is achieved using i) Procedures (Subroutines) and ii) Macros
i) Procedures or subroutines:
Procedure is a group of instructions that usually performs one given task and is important
because it is used many times by a program. But, it is stored only once in the memory. This
saves memory space and also makes the task of programming much simpler because it takes
less time to code a program that contain subroutines.
The only disadvantage with subroutines is that it takes the computer a small amount of time
to link to the subroutine (CALL) and return from it (RET). Stack is used to store the return
address so that subroutine may return to the program at that point after the CALL instruction.
Two new assembler directives appear in the list: PROC and ENDP, they mark the beginning
and end of the procedure. FAR/NEAR is specified along with PROC directive to indicate
whether the procedure is in the different segment or in the same code segment respectively.
Example:
Add_2_nos PROC NEAR
mov ax, bx
add ax, cx
RET
Add_2_nos ENDP
Default access specifier is NEAR.
We can use the above procedure in a main program using CALL instruction as:
.
.
.
CALL Add_2_nos
.
.
If the procedure is present in a different code segment, then it should be declared in the
current code segment using EXTRN directive.
For Example: EXTRN Add_2_nos ; should be present at the beginning of code segment
ii) Macros:
Macro is also a set of instructions that is intended to perform one particular task. The
difference here is unlike procedures which are stored only once in the memory. Macro
definition appears at all the places of its invocation. That is, in entire set of instructions are
will appear in the place its invocation. So, macros take more space in memory. As there is no
Art of Assembly Language Programming
14
need for the control to jump to a different memory location and since there is no need to
remember the return address, macros are bit faster compare to procedure/subroutines.
We use two directives to write macros: MACRO and ENDM
Example:
Display MACRO msg1
mov ah,9
lea dx,msg1
int 21h
ENDM
Here, msg1 is a parameter. The macro can be invoked by simply specifying its name as:
.
.
Display str1
.
.
Differences between Procedures and Macros:
Procedures Macros
1. Use PROC and ENDP directives
2. Stored only once in the memory , hence
take less memory
3. Control is required to be transmitted to the
place where procedure is present, hence
more time needed for execution
4. Makes use of stack to store the return
address
5. Difficult to pass parameters
6. CALL instruction is used to call a
procedure
1. Use MACRO and ENDM directives
2. Instructions replace all invocations
hence more memory
3. Since, instructions are copied at all
invocations, no need to transfer the
control, hence comparatively lee time
is needed
4. No need of stack as no control transfer
5. Easy to pass parameters
6. No instruction is needed to invoke a
macro
Art of Assembly Language Programming
15
P11: Write an ALP to find the factorial of a byte data using recursion.
assume cs:code,ds:data
data segment
x db 5
res db ?
data ends
code segment
start:
mov ax,data
mov ds,ax
mov al,x
call facto
mov ah,4ch
int 21h
; procedure to find factorial of a byte
facto proc
cmp al,00
je finish
push ax
dec al
call facto ; recursively calling facto
pop ax ; first return is to this address
mul res
mov res,al
ret
finish:
mov res,01 ; recursion breaking condition
ret ; first return instruction
facto endp
code ends
end start
P12: Compute nCr using recursive procedure. Assume that n and r are non-negative
integers.
Recurcive procedure: if r = 0 and r = n then nCr = 1
Else if r = 1 and r = n 1, then nCr = n
Else nCr = n-1Cr + n-1Cr-1
Art of Assembly Language Programming
16
assume cs:code,ds:data
data segment
n db 5
r db 5
res db ?
data ends
code segment
start:
mov ax,data
mov ds,ax
mov al,n
mov bl,r
call encear
mov ah,4ch
int 21h
encear proc
cmp bl,00
je ncr_1
cmp bl,al
je ncr_1
cmp bl,01
je ncr_n
dec al
cmp bl,al
je ncr_n_1
push ax
push bx
call encear
pop bx
pop ax
dec bl
push ax
push bx
call encear
Art of Assembly Language Programming
17
pop bx
pop ax
ret
ncr_1:
mov res,01
ret
ncr_n_1:
inc al
ncr_n:
add res,al
ret
encear endp
code ends
end start
DOS And BIOS services
A typical PC system consists of many components besides the 80x86 CPU and memory. MS-
DOS and the PCs BIOS provide a software connection between your application programs
and the underlying hardware. Although it is sometimes necessary to program the hardware
directly yourself, more often than not its best to let the system software (MS-DOS and the
BIOS) handle this for you. Furthermore, its much easier for you to simply call a routine built
into your system than to write the routine yourself.
You can access the IBM PC system hardware at one of three general levels from assembly
language. You can program the hardware directly, you can use ROM BIOS routines to access
the hardware for you, or you can make MS-DOS calls to access the hardware. Each level of
system access has its own set of advantages and disadvantages. Programming the hardware
directly offers two advantages over the other schemes: control and efficiency. If youre
controlling the hardware modes, you can get that last drop of performance out of the system
by taking advantage of special hardware tricks or other details which a general purpose
routine cannot. For some programs, like screen editors which must have high speed access to
the video display), accessing the hardware directly the only way to achieve reasonable
performance levels.
On the other hand, programming the hardware directly has its drawbacks as well. The screen
editor which directly accesses video memory may not work if a new type of video display
card appears for the IBM PC. Multiple display drivers may be necessary for such a program,
increasing the amount of work to create and maintain the program. Furthermore, had you
written several programs which access the screen memory directly and IBM produced a new,
incompatible, display adapter, youd have to rewrite all your programs to work with the new
display card.
Your work load would be reduced tremendously if IBM supplied, in a fixed, known, location,
some routines which did all the screen I/O operations for you. Your programs would all call
these routines. When a manufacturer introduces a new display adapter, it supplies a new set
of video display routines with the adapter card. These new routines would patch into the old
ones (replacing or augmenting them) so that calls to the old routines would now call the new
Art of Assembly Language Programming
18
routines. If the program interface is the same between the two set of routines, your programs
will still work with the new routines. IBM has implemented such a mechanism in the PC
system firmware. Up at the high end of the one megabyte memory space in the PC are some
addresses dedicated to ROM data storage. These ROM memory chips contain special
software called the PC Basic Input Output System, or BIOS. The BIOS routines provide a
hardware-independent interface to various devices in the IBM PC system. For example, one
of the BIOS services is a video display driver. By making various calls to the BIOS video
routines, your software will be able to write characters to the screen regardless of the actual
display board installed.
At one level up is MS-DOS. While the BIOS allow you to manipulate devices in a very low
level fashion, MS-DOS provides a high-level interface to many devices. For example, one of
the BIOS routines allows you to access the floppy disk drive. With this BIOS routine you
may read or write blocks on the diskette. Unfortunately, the BIOS dont know about things
like files and directories. It only knows about blocks. If you want to access a file on the disk
drive using a BIOS call, youll have to know exactly where that file appears on the diskette
surface. On the other hand, calls to MS-DOS allow you to deal with filenames rather than file
disk addresses. MS-DOS keeps track of where files are on the disk surface and makes calls to
the ROM BIOS to read the appropriate blocks for you. This high-level interface greatly
reduces the amount of effort your software need expend in order to access data on the disk
drive.
Some DOS functions:
Function 01: Read a character with echo
Input: AH 01
Returns: AL ASCII value of the key pressed
For Example:
MOV AH, 01H
INT 21H ; (AL) = ASCII value of key pressed
Function 02: Print a character on screen
Input: AH 02
DL ASCII value of character to be printed
Returns: Nothing
For example:
MOV AH, 02
MOV DL, 41H ; ASCII value of a
INT 21H ; prints a on console
Function 07: Read a character without echo
Input: AH 07
DL ASCII value of character read
Returns: Nothing
For example:
MOV AH, 07
Art of Assembly Language Programming
19
INT 21H ; ASCII value of character will be in AL
Function 09: Print a character string
Input: AH 09
DS:DX offset of string
Returns: Nothing
For example:
MOV AH, 09
LEA DX, msg ; msg is the starting offset of msg in data segment
INT 21H ; prints msg on console
Some BIOS functions:
Function 00: setting screen resolution
Input: AH 00
AL 0 to 9, representing video mode
Returns: Nothing
For example:
MOV AH, 00
MOV AL, 02 ; Sets the video mode to 80 X 25 in grey mode ie. 25 lines/screen and
; 80 characters/line
INT 10H ; observe the int number it is 10h not 21h
Function 02: sets the cursor position
Input: AH 02
DH line number i.e. y coordinate
DL character number within line i.e. x coordinate
Returns: Nothing
For example:
MOV AH, 02
MOV DL, 40d ; placing cursor at the center of the screen
MOV DH, 12d
INT 10H
P13: Find out whether a given sub string is present or not in a main string of characters.
assume cs:code,ds:data
data segment
ms db "Angels and demons"
lms db lms-ms
str db "demons"
lss dw lss-str
msg1 db "substring has found$"
msg2 db "substring not found$"
data ends
Art of Assembly Language Programming
20
code segment
start:
mov ax,data
mov ds,ax
mov es,ax
mov dl,lms
lea di,ms
search:
mov bx,di
lea si,str
mov cx,lss
cld
rep cmpsb
jz success
inc bx
mov di,bx
dec dl
jnz search
jmp failure
success:
lea dx,msg1
mov ah,09h
int 21h
jmp exit
failure:
lea dx,msg2
mov ah,09h
int 21h
exit: mov ah,4ch
int 21h
code ends
end start
P14: Program to simulate a Decimal Up-Counter to display 00-99
assume cs:code
code segment
start:
mov cx,100d
mov bl,00
next_digit: mov al,bl
aam
add ax,3030h
Art of Assembly Language Programming
21
mov dl,ah
mov ah,2
push ax
int 21h
pop ax
mov dl,al
mov ah,2
int 21h
mov dl,0dh
mov ah,2
int 21h
call delay
inc bl
loop next_digit
mov ah,4ch
int 21h
delay proc
mov si,02202h
l1:mov di,0ffffh
l2:dec di
jnz l2
dec si
jnz l1
ret
delay endp
code ends
end start
P15: Program to create a file ( input file) and to delete an existing file.
assume cs:code, ds:data
data segment
fname2 db "shashi.txt"
msg1 db "File created successfully$"
fname1 db "emp.dat"
msg2 db "File deleted successfully$"
.code
mov ax,@data
mov ds,ax
mov ah,3ch
mov cx,00
lea dx,fname2
int 21h
Art of Assembly Language Programming
22
jc next
disp msg1
next:
mov ah,41h
lea dx,fname1
int 21h
jc finish
disp msg2
finish:
mov ah,4ch
int 21h
code ends
end start
Timings and delays
- we know that each instruction take some machine cycles to execute
- Each machine cycle has certain number of clock periods
- Each clock period lasts for the period exactly equal to t = 1/f where f is the frequency
with which processor works
- So, finally each instruction take definite amount of time to execute
- We can make use of this time to generate delays in programs
We need not to use more number of instructions to generate required delay. We can make use
of loops which make a set of instructions execute repeatedly to generate delays. In loops,
procedures and interrupt service routines the number of instructions may be less but they
actually have capacity to produce required delays.
We can divide the procedure to find the delay into following convenient steps:
Step 1: Determine the exact delay required. Lets call it as T
d
Step 2: Choose the instructions to be used in delay loop. Care must be taken not to use
instructions or registers that affect the main program calling the delay procedure.
Step 3: Determine the number of clock cycles needed to execute each instruction chosen.
Also calculate the total number of clock cycles required to execute the loop once. Lets call it
n
Step 4: Find t, the time required for one clock period. i.e. t = 1/f
Step 5: Determine the time required to execute the loop once using n * t
Step 6: Find N, number of times the loop has to be executed to generate T
d
delay using
N =
t n
T
d
*
Art of Assembly Language Programming
23
Q: Write a procedure to generate a delay of 100 ms in a microprocessor which works
with 10 MHz frequency.
Step 1: Exact delay needed T
d
= 100ms
Step 2: Instructions chosen
MOV CX, N
NOP
DEC CX
JNZ label
Step 3: The above mentioned instructions take 4, 3, 2 and 16/4 clock period respectively. 16/
4 says if there is jump to label then 16 clock periods else only 4 clock periods.
So, n = 3 + 2 + 16 = 21 (MOV CX, N not included in loop).
Step 4: Here, t = 1/10 MHz = 0.1 sec
Step 5: n * t = 2.1 sec
Step 6:
N = 100ms/2.1 sec = 47619 = BA03H
Now, the procedure
Delay Proc
mov cx, 0ba03h
loc1:
nop
dec cx
jnz loc1
ret
Delay Endp
Lets manually verify whether this procedure is creating 100ms delay:
Exact delay = 4 * 0.1 + (2 + 3 + 16) * 47618 * 0.1 + 4 * 0.1 + 8 * 0.1 (last one is from ret
instruction which consumes 8 clock periods)
= 99.999 ms
Here the error is by 0.1ms which is very small. So, these delays can be practically used
anywhere. If high precision delays are required then can be generated using programmable
timers or counters.
The procedure described above cannot generate delays of the order of minutes. We could
continue the procedure adding more number of instructions. Instead, we can put this loop
inside an outer loop and increase the number of times the instructions are executed. This
gives us a procedure which could generate minutes of delays.
Art of Assembly Language Programming
24
Sample procedure and corresponding calculations are as follows:
Time taken by Inner loop = (3 + 2 + 16) * 65535 * 0.1
= .13762 sec
Time taken to execute outer loop once
= .13762 + (4+2+16)*10
-6
* 0.1
= .13764 sec
No. of times the loop to be executed to generate 10 mins. of delay = 10 * 60 / .13764
N = 4359
Delay proc
mov bx, N
loc2:
mov cx, 0ffffh
loc1:
nop
dec cx
jnz loc1
dec bx
jnz loc2
ret
Delay endp