CSE2006 (Lab Assignment 4)
Fall Semester 2021-22
Course Name: Microprocessor and Interfacing Laboratory
Name : Prashaman Pokharel
Register no : 20BCE2931
Slot/Batch timing : L23+L24
Lab faculty Name : RAJKISHOR KUMAR
Theory Faculty Name : RAJKISHOR KUMAR
1. AIM: To write an ALP program to reverse the given
string for 8086 microprocessors.
Tool Requirements: 8086
Emulator
Algorithm
Step1: Start
Step2: Create a string
Step3: Traverse through the string
Step4: Push the characters in the
stack
Step5: Count the number of
characters
Step 6: Load the starting address of the string
Step7: POP the top character of the stack until count is not equal
to zero
Step 8: Put the character and reduce the count and increase the
address
Step9: Continue until the count is greater than zero
Step10: Load the effective address of the string in dx using LEA
command
Step11: Print the sting by calling the interrupt with 9H in AH
Step12: The string must be terminated by ‘$’ sign
Step13: Stop
Flow Chart
ALP Program
. MODEL SMALL
. STACK 100H
.DATA
; The string to be printed
STRING DB 'This is a sample string', '$'
. CODE
MAIN PROC
FAR MOV AX,
@DATA MOV
DS, AX
; call reverse
function CALL
REVERSE
; load address of the
string LEA DX, STRING
; output the string
; loaded in
dx MOV AH,
09H INT
21H
; interrupt to
exit MOV AH,
4CH INT 21H
MAIN ENDP
REVERSE
PROC
; load the offset of
; the string
MOV SI, OFFSET STRING
; count of characters of the;
; string
MOV CX,
0H
LOOP1:
; compare if this is;
; the last
character MOV
AX, [SI]
CMP AL,
'$' JE
LABEL1
; else push it in the;
; stack
PUSH
[SI]
; increment the pointer;
; and count
INC SI
INC CX
JMP LOOP1
LABEL1:
; again, load the starting;
; address of the string
MOV SI, OFFSET STRING
LOOP2:
; if count not equal to zero
CMP CX,0
JE EXIT
; pop the top of
stack POP DX
; make dh, 0
XOR DH, DH
; put the character of the;
; reversed
string MOV
[SI], DX
; increment si and;
; decrement count
INC SI
DEC CX
JMP
LOOP2
EXIT:
; add $ to the end of string
MOV [SI],'$ '
RET
REVERSE
ENDP
END MAIN
OUTPUT
INFERENCE
String can be reversed by using 8086 microprocessors.
2. AIM: To write an Assembly Language Program to find number of
times letter “e” exist in the string “exercise”, Store the count at
memory using 8086 microprocessors.
ALGORITHM
Step1: Start
Step2: Load the data in data segment
Step3: Load the address of message to enter the
characters Step4: Input the character by using 9H with 21H
interrupt in AH Step5: Store the input in SI
Step6: Increase SI pointer
Step7: Compare content of SI with letter ‘e’
Step8: Go to step9 if not equal otherwise increase
counter Step9: Repeat from the step6
Step10: Display the result in the CRT screen by using 2H
system call Step11: Stop
FLOWCHART
ALP PROGRAM
DATA SEGMENT
MSG1 DB "ENTER THE STRING: $"
MSG2 DB "NO OF OCCURRENCES
OF e: $" NEWLINE DB 10, 13, "$"
STR1 DB 80 DUP ("$")
CNT DB 0
DATA ENDS
CODE
SEGMENT
ASSUME DS: DATA, CS: CODE
START:
MOV AX, DATA
MOV DS, AX
MOV AH, 09H
LEA DX, MSG1
INT 21H
MOV AH, 0AH
LEA DX, STR1
INT 21H
MOV AH, 09H
LEA DX,
NEWLINE INT
21H
LEA SI, STR1+1
MOV CL, BYTE
PTR[SI] MOV CH, 00H
L1: INC SI
CMP BYTE PTR[SI], 'e'
JNE L2
INC CNT
L2: LOOP L1
ADD CNT, '0'
MOV AH,
09H LEA
DX, MSG2
INT 21H
MOV AH,
02H MOV
DH, 00H
MOV DL,
CNT INT
21H
MOV AH,
4CH INT
21H
CODE
ENDS
END
START
OUTPUT
INFERENCE
Any letter can be found in string by using 8086 microprocessors.
3. AIM: To write an Assembly Language Program to display string
“Computer Science and Engineering” for 8086.
Tool Requirements: 8086
Emulator ALGORITHM
Step1: Start
Step2: Load the address into data
segment Step3: Load the address of
string into DX
Step4: Print the sting by calling the interrupt with 9H in AH
Step5: Stop
FLOWCHART
ALP PROGRAM
ASSUME DS:DATA, CS: CODE
DATA SEGMENT
STR DB "Computer Science and Engineering","$"
DATA ENDS
CODE SEGMENT
START:MOV AX,
DATA MOV DS,
AX
LEA DX, STR; LOAD ADDRESS OF STRING
MOV AH,09H; OUTPUT THE STRING LOADED
IN DX INT 21H
MOV AH,4CH; RETURN TO DOS
PROMPT INT 21H
CODE
ENDS END
START
OUTPUT
INFERENCE
Any String can be displayed by using 8086 microprocessors.