Skip to content

Str_equchecker_3 #2

@nivedrajeevan68-commits

Description

section .data
prompt1 db "Enter first string: ",0
prompt2 db "Enter second string: ",0
equal_msg db "Strings are equal",10,0
notequal_msg db "Strings are not equal",10,0

section .bss
str1 resb 100
str2 resb 100

section .text
global _start

_start:
mov eax,4
mov ebx,1
mov ecx,prompt1
mov edx,20
int 0x80

mov eax,3
mov ebx,0
mov ecx,str1
mov edx,100
int 0x80

mov eax,4
mov ebx,1
mov ecx,prompt2
mov edx,21
int 0x80

mov eax,3
mov ebx,0
mov ecx,str2
mov edx,100
int 0x80

mov esi,str1
mov edi,str2

compare_loop:
mov al,[esi]
mov bl,[edi]
cmp al,10
je check_end
cmp bl,10
je not_equal
cmp al,bl
jne not_equal
inc esi
inc edi
jmp compare_loop

check_end:
mov bl,[edi]
cmp bl,10
jne not_equal
mov eax,4
mov ebx,1
mov ecx,equal_msg
mov edx,18
int 0x80
jmp exit

not_equal:
mov eax,4
mov ebx,1
mov ecx,notequal_msg
mov edx,23
int 0x80

exit:
mov eax,1
xor ebx,ebx
int 0x80

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions