NASM - The Netwide Assembler
NASM Forum => Using NASM => Topic started by: ukko on November 22, 2014, 05:25:40 PM
-
Please help me for my learning case.
I want my assembler program to: first read text from console user input, compare it for a string and goes to OK, or BAD depends on the string user type.
My code now looks something like this:
----------------------------
section .data
pass: db "pass"
yeah: db "GREAT",10
yeahl: equ $-yeah
section .bss
type: resb 255
typel: equ $-type
_start:
xor eax, eax ;clear eax
mov eax, 3 ; read input
mov ebx, 1
mov ecx, type
mov edx, typel
int 0x80
cmp eax, pass
je success
int 0x80
leave:
mov eax, 1
mov ebx, 0
int 0x80
success:
mov eax, 4
mov ebx, 1
mov ecx, yeah
mov edx, yeahl
int 0x80
jmp leave
---------
What ever I change things here, it wont make any compare on between the user inputs and my "pass" string. Could anyone advice? :)
-
Hi ukko,
there isn't a mnemonic/opcode to compare two strings.
cmp eax, pass
that compares eax with the memory address of your string labeled pass
you have to write your own algorithm or you could call a c-library function like strcmp or maybe your os provides an API funtion.
good luck
EDIT: you could use the cmps mnemonic to write your own strcmp algorithm. ;)