Hi all,
it is required from me to write a program in assembly which inputs 2 strings and outputs 'Found' if the second string is a substring of the first one, and 'Not Found' if it's not.

this my code

please try to test it and tell me if any thing is wrong

you just to copy the following code and paste it in C:\Windows\System32\debug.exe



A 100
DB 'Found$'
DB 'Not Found$'
MOV DX,0
MOV AH,0A
INT 21
mov ah,2
mov dl,0a
int 21
MOV DX,20
MOV AH,0A
INT 21
mov ah,2
mov dl,0a
int 21
MOV BX,0
MOV BP,20
INC BX
INC BP
MOV CL,
MOV CH,
MOV [400],CH
INC BX
INC BP
mov ah,0
CMP CL,CH
JB 18f
; JUMP TO PRINT NOT FOUND
;
MOV AL,
CMP AL,
JNE 166
CMP CH,1
JE 186
MOV AH,1
INC BP
INC BX
DEC CL
CMP CL,0
JE 18f
DEC CH
MOV [450],CL
MOV [480],BX
;JUMP TO FOUND
JMP 143
;JUMP TO LOOP
CMP CL,1
JE 18f
INC BX
DEC CL
MOV CH,[400]
MOV BP,22
CMP AH,1
JNE 184
MOV AH,0
MOV CL,[450]
MOV BX,[480]
JMP 143
; FOUND
MOV AH,9
MOV DX,100
INT 21
JMP 196
MOV AH,9
MOV DX,106
INT 21
INT 3



then enter the first string and press enter and enter the second one.

waiting for your notices.

--
Mina Fouad
3rdyear CSED
Alexandria University.
http://csedawy.blogspot.com
Posted on 2010-11-05 16:09:06 by Mina Fouad
Mina Fouad,

Ahh, debug script! Was that a requirement, or you did it this way just for kicks?

O.K., I'm getting serious. It wouldn't work, anyone could tell you that.

"Found$Not Found$" shouldn't be executed, it's data.

PSP is a valuable resource in DOS land, you shouldn't tamper it.
Posted on 2010-11-06 03:43:07 by baldr
It's required to write a debug script :).
you should run it starting address 110
g=110

you will find some errors in case overlapped strings I handled it with this new version I know my code may be better and optimized and this what I will do before delivering it.

A 100
DB 'Found$'
DB 'Not Found$'
MOV DX,0
MOV AH,0A
INT 21
mov ah,2
mov dl,0a
int 21
MOV DX,20
MOV AH,0A
INT 21
mov ah,2
mov dl,0a
int 21
MOV BX,0
MOV BP,20
INC BX
INC BP
MOV CL,
MOV CH,
MOV [400],CH
INC BX
INC BP
mov ah,0
CMP CL,CH
JB 19C
; JUMP TO PRINT NOT FOUND
;
MOV AL,
CMP AL,
JNE 166
CMP CH,1
JE 193
MOV AH,1
INC BP
INC BX
DEC CL
CMP CL,0
JE 19C
DEC CH
MOV [450],CL
MOV [480],BX
;JUMP TO FOUND
JMP 143
;JUMP TO LOOP
CMP CL,1
JE 19C
INC BX
DEC CL
MOV CH,[400]
CMP AH,1
JNE 18E
MOV AH,0
MOV CL,[450]
MOV BX,[480]
SUB BP,23
MOV [500],BP
ADD CL,[500]
SUB  BX,BP
MOV BP,22
JMP 143
; FOUND
MOV AH,9
MOV DX,100
INT 21
JMP 1A3
MOV AH,9
MOV DX,106
INT 21
INT 3


don't forget run it starting 110 ;)
any way thanks for your post.
Posted on 2010-11-06 09:50:51 by Mina Fouad
here is the final version

A 100
DB 'Found$'
DB 'Not Found$'
MOV DX,0
MOV AH,0A
INT 21
mov ah,2
mov dl,0a
int 21
MOV DX,20
MOV AH,0A
INT 21
mov ah,2
mov dl,0a
int 21
MOV BX,2
MOV BP,22
MOV CL,[1]
MOV CH,[21]
cmp ch,0
je 18f
inc cl
add ch,21
mov ah,0
mov dl,[21]
CMP [1],dl
JB 196
MOV AL,
CMP AL,
JNE 16f
mov [400],bp
CMP CH,[400]
JE 18f
MOV AH,1
INC BP
INC BX
mov [480],bx
CMP [480],cl
Ja 196
JMP 144
mov [440],bx
CMP [440],cl
JE 196
INC BX
CMP AH,1
JNE 18d
MOV AH,0
MOV BX,[480]
SUB BP,23
SUB  BX,BP
MOV BP,22
JMP 144
MOV AH,9
MOV DX,100
JMP 19b
MOV AH,9
MOV DX,106
INT 21
INT 3

Posted on 2010-11-06 17:22:21 by Mina Fouad