COA Lab Manual-1
COA Lab Manual-1
COA Lab Manual-1
LAB MANUAL
LIST OF EXPERIMENT
S.NO. NAME OF EXPERIMENTS DATE OF
EXPERIMENTS
25-May-2022
EXPERIMENT-1
Title:
Program using MACRO: Display personal information using MACRO.
Objective:
Implementation of assembly language Program to display Personal information using
MACRO
SOFTWARE REQUIRED: MASM
THEORY:
Macro is the same concept as that of Procedure except that macros are used when the repeated group of
instructions is too short or whenever procedure is not appropriate to written.
In case of Macro, a Macro name or label is assigned with the repeatedly appearing instructions. The
process of assigning a label or Macro name to a sequence of instruction is called as defining a macro. The
Macro name or Macro definition is then used throughout the main program to refer to that of instructions.
CODE SEGMENT
DISPLAY MACRO MAC
LEA DX, MAC
MOV AH, 09H
INT 21H
ENDM
DISPLAY M1
DISPLAY M2
CODE ENDS
From the above code DISPLAY is a Macro name &MAC is a parameter and also the M1 &M2
are the variable names declared in DATA SEGMENT
ALGORITHM:
1) Initialize a Data Segment
2) Declare the variables (Message name first, second and third for display message).
6) Define the MACRO with the Macro name DISPLAY & parameter MAC
8) Ends a MACRO.
EXPERIMENT-2
SOFTWARE REQUIRED:MASM
THEORY:
Manual Conversion 1st no = 18H
2nd no = 15H
Result = 2DH
Near procedure is defined in same code segment where main program is stored. Far procedure is defined in
different code segment where main program is stored.
Syntax:-
a) CODE SEGMENT
-------------
--------------
CALL PROC_NAME
----------------
PROC_ NAME PROC
------------ PROC_NAME ENDP
CODE ENDS
b) CODE SEGMENT
-------------
CALL FAR PTR PROC_NAME
--------------- CODE ENDS CODE1 SEGMENT
-------------
--------------
PROC_ NAME PROC
------------ PROC_NAME ENDP
CODE1 ENDS
ALGORITHM:
a)
1) Initialize a Data Segment
2) Declare the variables (Message name first for o/p message, array name first & second for storing
immediate data.)
3) Ends a Data Segment
9) Mask the content of ALWith 0F0H & shift right 4 times by using instruction SHR.
b)
1) Initialize a Data Segment
2) Declare the variables (Message name first for o/p message, array name first and second for storing
immediate data.)
3) Ends a Data Segment
7) Store the content of array first & second in AL & BL register resp.
9) Mask the content of AL With 0F0H & shift right 4 times by using instruction SHR.
EXPERIMENT-3
Title: Program for Password Verification
Objective:
To write an ALP program for password checking using 8086.
ALGORITHM:
• Create a display micro
• Initialise a counter for max number of attempts available
• In the data segment store the password in a location
• In the code segment accept the string one by one and compare the stored value
• If the strings are equal display “valid password”
• If they are not equal then display invalid password
• Code ends
SOURCE CODE
disp macro x
mov ah,09h
lea dx,x
int 21h
endm
data segment
s db 13,10,"enter string:$"
u db 13,10,"right password $"
r db 13,10,"invalid $"
m1 db '*$'
m2 db 13,10,"try again $"
pwd db "cmt $"
data ends
code segment
assume cs:code,ds:data
start:
mov ax,data
mov ds,ax
mov ax,0003h
int 10h
mov bl,03h
a1:
mov cl,03h
mov si,00h
disp s
a2:
mov ah,08h
int 21h
cmp al,pwd[si]
disp m1
jne l1
inc si
loop a2
disp u
jmp l2
l1: dec bl
disp r
disp m2
cmp bl,00h
je l2
jne a1
l2:
mov ax,4c00h
int 21h
code ends
end start
OUTPUT
enter the password ***
right password
EXPERIMENT-4
SOFTWARE REQUIRED:MASM
THEORY:
Display the system time and date according to given format Time format
hr:min:sec Date format dd/mm/yyyy
ALGORITHM:
1) Initialize a Data Segment
7) Get the current system time by using MOV AH, 2CH INT 21H.
15)MOV AH, 2AH ; Get the current system time INT 21H
19) Procedure
EXPERIMENT-5
Title: Program to sort the given array in ascending and descending order.
OBJECTIVE
To sort the given number in ascending order using 8086.
ALGORITHM
Step 1: Get the input number from memory and move it to AL register
Step2: Move the count value to DX register (outer loop)
Step3: Decrement the value of DX by one and move it to CX register (inner loop)
Step4: Compare the AL and the next element in the memory
Step5: If CY=1 then AL is less than next element
Step6: If CY=0 then AL is greater than next element so exchange both value
Step7: Continue the step3 to step7 until CX and DX goes to zero.
Step8: Store the resultant value
SOURCE CODE
DATA ENDS
CODE SEGMENT
START:
MOV AX, DATA
MOV DS, AX
DEC DX
GO:
MOV CX, DX
NXT_BYTE:
NEXT:
33
INPUT:
50000 81H
50002 82H
50004 93H
50006 95H
50008 10H
5000A 56H
5000C 33H
5000E 99H
50010 13H
50012 44H
OUTPUT:
50000 10H
50002 13H
50004 33H
50006 44H
50008 56H
5000A 81H
5000C 82H
5000E 93H
50010 95H
50012 99H
RESULT
Thus the program to Sort the given array in ascending order was executed successfully.
Experiment-06
Program:
School of Computer Science & Engineering (Sandip University, Sijoul, Madhubani)
11
COA Lab Manual
.MODEL SMALL
.STACK
.DATA .CODE START:
MULTIPLICAND DW 00FFH; FIRST WORD HERE
MULTIPLIER DW 00FFH; SECOND WORD HERE
PRODUCT DW 2 DUP(0); RESULT OF MULIPLICATION HERE
MOV AX, @DATA
MOV DS, AX
MOV AX, MULTIPLICAND MUL MULTIPLIER
MOV PRODUCT, AX
MOV PRODUCT+2, DX
MOV AH, 4CH
INT 21H
END START
Experiment-07
Algorithm:
1. Get the dividend
2. Get the divisor
3. Initialize the quotient to 0.
4. Dividend = dividend – divisor
5. If the divisor is greater, store the quotient. Go to step g.
6. If dividend is greater, quotient = quotient + 1. Repeat from step (d)
7. Store the dividend value as remainder.
Program:
.MODEL SMALL
.DATA
W1 DW 02222H
W2 DW 1111H
Q DW ?
R DW ?
.CODE
MOV AX, @DATA
MOV DS, AX ; INITIALIZE DATA SEGMENT
MOV AX, W1 ; GET DIVIDEND
MOV BX, W2 ; GET DIVISOR
DIV BX ; DIVIDE
MOV Q, AX ; STORE QUOIENT
MOV R, DX ; STORE REMAINDER
MOV AH, 4CH
INT 21H
END ; END PROGRAM
Experiment-08
Title: Program to find out Factorial of any given number using recursive procedure.
Code Segment:
.MODEL SMALL
.DATA
NUM DW 8
RESULT DW (?) ; INITIALIZE MEMORY FOR THE RESULT
.CODE
MAIN PROC