extern scanf
extern printf
extern strstr
section .bss
s1 resb 1001
s2 resb 1001
section .data
fmt_in db "%s", 0
ans1 db "1 2", 0
ans2 db "2 1", 0
ans0 db "0", 0
section .text
global main
main:
push ebp
mov ebp, esp
and esp, -16 ;выравниваем esp по границе 16 байт
;читаем первую строку scanf("%s", str1)
sub esp, 8
push str1
push fmt_in
call scanf
add esp, 16
;читаем вторую строку scanf("%s", str2)
sub esp, 8
push str2
push fmt_in
call scanf
add esp, 16
;первая строка внутри второй?
;вызов strstr(str2, str1)
sub esp, 8
push str1
push str2
call strstr
add esp, 16
; если eax != 0 -> строка найдена
test eax, eax
jnz .print1_2
;вторая строка внутри первой?
;вызов strstr(str1, str2)
sub esp, 8
push str2
push str1
call strstr
add esp, 16
; если eax != 0 -> строка найдена
test eax, eax
jnz .print2_1
.printf0:
sub esp, 12
push ans0
call printf
add esp, 16
jmp .end
.print1_2:
sub esp, 12
push ans1
call printf
add esp, 16
jmp .end
print2_1:
sub esp, 12
push ans2
call printf
add esp, 16
jmp .end
.end:
xor eax, eax
mov ebp, esp
pop ebp
ret