0% found this document useful (0 votes)
4 views5 pages

Expno 4

The document contains two assembly language programs. The first program calculates the length of a user-input string, while the second program searches for a substring within a user-input string. Both programs utilize DOS interrupts for input and output operations.

Uploaded by

aryanrasam01
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views5 pages

Expno 4

The document contains two assembly language programs. The first program calculates the length of a user-input string, while the second program searches for a substring within a user-input string. Both programs utilize DOS interrupts for input and output operations.

Uploaded by

aryanrasam01
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

To find length of string.

.MODEL SMALL
.STACK 100H

DATA_SEG SEGMENT
MSG1 DB 'Enter the string: $'
MSG2 DB 'Length of the string is: $'
STRING DB 100 DUP('$')
LENGTH DB 0
DATA_SEG ENDS

CODE_SEG SEGMENT
ASSUME CS:CODE_SEG, DS:DATA_SEG, ES:DATA_SEG

MAIN PROC
MOV AX, DATA_SEG
MOV DS, AX
MOV ES, AX

MOV AH, 09H


LEA DX, MSG1
INT 21H

LEA DX, STRING


MOV AH, 0AH
INT 21H

LEA SI, STRING + 1


MOV AL, [SI]

MOV AH, 09H


LEA DX, MSG2
INT 21H

ADD AL, '0'


MOV DL, AL
MOV AH, 02H
INT 21H

EXIT:
MOV AH, 4CH
INT 21H

MAIN ENDP
END MAIN

Output:

To search string.

.MODEL SMALL
.STACK 100H

DATA_SEG SEGMENT
MSG1 DB 'Enter the string: $'
MSG2 DB 'Enter the substring to search: $'
MSG3 DB 'Substring Found$'
MSG4 DB 'Substring Not Found$'
STRING DB 100 DUP('$')
SUBSTRING DB 100 DUP('$')
DATA_SEG ENDS
CODE_SEG SEGMENT
ASSUME CS:CODE_SEG, DS:DATA_SEG, ES:DATA_SEG

MAIN PROC
MOV AX, DATA_SEG
MOV DS, AX
MOV ES, AX

MOV AH, 09H


LEA DX, MSG1
INT 21H

LEA DX, STRING


MOV AH, 0AH
INT 21H

MOV AH, 09H


LEA DX, MSG2
INT 21H

LEA DX, SUBSTRING


MOV AH, 0AH
INT 21H

LEA SI, STRING + 2


LEA DI, SUBSTRING + 2

SEARCH_LOOP:
MOV AL, [SI]
MOV BL, [DI]
CMP AL, BL
JNE NOT_MATCH

INC SI
INC DI
MOV DL, [DI]
CMP DL, '$'
JE MATCH_FOUND
JMP SEARCH_LOOP

NOT_MATCH:
INC SI
LEA DI, SUBSTRING + 2
MOV DL, [SI]
CMP DL, '$'
JE SUBSTRING_NOT_FOUND
JMP SEARCH_LOOP

MATCH_FOUND:
MOV AH, 09H
LEA DX, MSG3
INT 21H
JMP EXIT

SUBSTRING_NOT_FOUND:
MOV AH, 09H
LEA DX, MSG4
INT 21H

EXIT:
MOV AH, 4CH
INT 21H

MAIN ENDP
END MAIN
OUTPUT:

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy