CSE2006 Lab Assignment 4 (20BCE2931)
CSE2006 Lab Assignment 4 (20BCE2931)
Register no : 20BCE2931
Algorithm
Step1: Start
Step2: Create a string
Step3: Traverse through the string
Step4: Push the characters in the
stack
Step 8: Put the character and reduce the count and increase the
address
Flow Chart
ALP Program
. MODEL SMALL
. STACK 100H
.DATA
; call reverse
function CALL
REVERSE
; 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
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
; make dh, 0
XOR DH, DH
; 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.
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.