Basically I am trying to compare two strings in assembly, see code below:
global _start
section .data
hello: db "Enter Message> ", 15
pass: db "password", 8
section .bss
input: resq 100
section .text
mov eax, 4
mov ecx, hello
mov edx, 15
int 0x80
mov eax, 3
mov ecx, input
mov edx, 100
int 0x80
mov esi, input
mov edi, pass
cmp esi, edi
jne nprinting
je printing
printing:
mov eax, 4
mov ecx, input
mov edx, 100
int 0x80
mov eax, 1
int 0x80
nprinting:
mov eax, 1
int 0x80
either way if I enter incorrect
or password
in my input prompt, the program exits without prompting me anything. I also tried something like:
mov bh, "a"
mov bl, "a"
cmp bh, bl
je printing
jne nprinting
but still didn't get to print me my input
value. not sure if the problem is null-terminated or something else.
I am using Kali-Linux x64: Linux kali 4.19.0-kali3-amd64 #1 SMP Debian 4.19.20-1kali1 (2019-02-14) x86_64 GNU/Linux
.
And compile the program as following: nasm -f elf64 -g ./hello.asm && ld -s -o hello ./hello.o
Appreciate a little help.