Logo 
Search:

Assembly Language Forum

Ask Question   UnAnswered
Home » Forum » Assembly Language       RSS Feeds

code to find substring in main string

  Asked By: Sahar    Date: Mar 27    Category: Assembly Language    Views: 3434
  

hi all , i new here but u have a fantastic web and i need help .

if i have to write 2 string ,
m db 30h ; the long
n db 3h ; the short

print on screen to get two string from the user
one long and one short ,
in real time , if i enter the short string and
the all string found on the long string i need to
write massage "string found"
we continu until the long string come to end.

exemple : m=adfrabcfe...
n=abc
print="found string"

thank for all that helping me .

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Abhishek Singh     Answered On: May 14

[org 0x0100]

02

03 jmp start

04

05 message1: dw 'abcdefg',0

06

07 message2: dw 'def',0

08

09 strlength:

10

11 push bp

12 push bp,sp

13 push ax

14 push di

15 push es

16 push ds

17 xor al,al

18

19

20 les di,[bp+4]

21 mov cx, 0xffff

22 xor al,al

23 repne SCAS

24 mov ax, 0xffff

25 sub ax, cx

26 dec ax

27 mov cx, ax

28

29 pop ds

30 pop es

31 pop di

32 pop ax

33 pop bp

34

35

36

37 start:

38

39 mov ax, message1

40 push ax

41 mov ax, message2

42 push ax

43 call strlength

44

45 CompareString:

46

47 push cx

48

49 lds si, [bp+2]

50 les di, [bp+4]

51 repne CMPS

52 dec di

53 dec si

54 cmp si,0

55 je exit

56 mov ax,1

57

58 pop cx

59

60 SubstringCompare:

61

62 repe CMPS

63 cmp cx,0

64 jne exit

65 mov ax,1

66

67 exit:

68 mov ax,0

69 mov ax, 0x4c00

70 int 0x21

 
Didn't find what you were looking for? Find more on code to find substring in main string Or get search suggestion and latest updates.




Tagged: