1 Replies - 1052 Views - Last Post: 28 March 2013 - 06:18 AM Rate Topic: -----

#1 tshahar  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 27-March 13

please help - if sub-str found in str and print "found"

Posted 27 March 2013 - 11:36 PM

DATA SEGMENT
STR1 db "ENTER YOUR STRING HERE = $"
STR2 db 0ah,0dh,"ENTER THE SHORT STRING = $"
FOUND db 0ah,0dh,"FOUND STRING$"
NOTFOUND db 0ah,0dh,"NOT FOUND ANY STRING$"
M DB 15 DUP("$")
N DB 3 DUP("$")
MONE EQU 15
COUNT DB 1
DATA ENDS
sseg segment stack
dw 100h dup(?)
sseg ends

CODE SEGMENT
ASSUME DS:DATA,CS:CODE
START:

MOV AX,DATA
MOV DS,AX

LEA SI,M
LEA DI,N
MOV COUNT,0h

;----GET STRING
MOV AH,09H
LEA DX,STR1
INT 21H

MOV AH,0AH
MOV DX,SI
INT 21H

;----GET SHORT STRING
MOV AH,09
LEA DX,STR2
INT 21H

MOV AH,0AH
MOV DX,DI
INT 21H

mov ah,00
int 16h

;START TO CMP STRINGS
MOV CL,MONE
l1: MOV AX,M[SI]
MOV BX,N[DI]
CMP AX,BX
JE L2
JMP L3

;----EQUAL------------
L2: INC COUNT
CMP COUNT,3
JZ PRINTSTR
INC SI
INC DI
DEC CL
CMP CL,0
JNZ L1
JMP L4
;-------NOT EQUAL------
L3: MOV COUNT,0
INC AX
DEC CL,1
CMP CL,0
JNZ L1
JMP L4
;------PRINT THE STRING-----

PRINTSTR:MOV AH,09H
LEA DX,FOUND
INT 21H

MOV COUNT,0
INC SI
MOV BX,COUNT
DEC CL
JNZ L1
JMP L4

mov ah,00
int 16h

L4: MOV AH,09H
LEA DX,NOTFOUND
INT 21H

SOF:
MOV AH,4CH
INT 21H
CODE ENDS
END START

Is This A Good Question/Topic? 0
  • +

Replies To: please help - if sub-str found in str and print "found"

#2 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5529
  • View blog
  • Posts: 11,839
  • Joined: 02-June 10

Re: please help - if sub-str found in str and print "found"

Posted 28 March 2013 - 06:18 AM

This is a duplicate of
http://www.dreaminco...nd-print-found/

In the future please do not open multiple threads for the same question.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1