putstr macro aa lea dx,aa mov ah,09 int 21h endm putchar macro rr mov dl,rr mov ah,02 int 21h endm .MODEL SMALL .STACK .DATA msg1 db 'This is a test$' msg2 db 'a tet$' msg3 db ' the second string is a substring of the first string$' msg4 db 'first string --> $' msg5 db 'second string --> $' msg6 db ' the second string is not a substring of the first string$' odoa db 0dh,0ah,'$' len dw ? .CODE MOV AX,@DATA MOV DS,AX MOV ES,AX ; putstr msg4 putstr msg1 putstr odoa putstr msg5 putstr msg2 putstr odoa ; xor si,si xor cx,cx comp: cmp msg2[si],'$' je getcount inc cx inc si jmp comp ; getcount: mov len,cx ; mov al,msg2 ; 1st character of msg2 lea di,msg1 cld mov cx,14 repne scasb ; search 1st character je compstr putstr msg6 ; no such character putstr odoa jmp dos ; compstr: ; cld mov cx,len dec di ; in msg1 lea si,msg2 repe cmpsb ; compare 2 strings jz printeq putstr msg6 ; no such substring putstr odoa jmp dos ; printeq: putstr msg3 ; print equal putstr odoa ; dos: mov ah,4ch int 21h END