Author Topic: Basics, please help...  (Read 1836 times)

Offline ukko

  • New Member
  • Posts: 1
Basics, please help...
« 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? :)

Offline gammac

  • Jr. Member
  • *
  • Posts: 71
  • Country: 00
Re: Basics, please help...
« Reply #1 on: November 22, 2014, 09:17:51 PM »
Hi ukko,

there isn't a mnemonic/opcode to compare two strings.

Code: [Select]
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. ;)
« Last Edit: November 23, 2014, 11:53:16 PM by gammac »
Please comment your code! It helps to help you.