You are not logged in.
Pages: 1
section .data
_execve equ 59
_passwd db 'hi', 0x00
_passwdlen equ $-_passwd
_wrong db 'WRONG',10,0
_wronglen equ $-_wrong
_right db 'RIGHT!!!',10,0
_rightlen equ $-_right
_write equ 4
_stdout equ 1
_exit equ 1
section .text
global _start
_start:
pop eax
pop ebx
pop ebx
cmp eax, 2
jne _die
mov eax, 0
jmp _checkpasswdstart
_checkpasswdstart:
cmp ebx[eax], _passwd[eax]
jne _wrongpasswd
cmp eax, _passwdlen
je _winner
inc eax
jmp _checkpasswdstart
_wrongpasswd:
mov eax, _write
mov ebx, _stdout
mov ecx, _wrong
mov edx, _wronglen
int 0x80
jmp _die
_winner:
mov eax, _write
mov ebx, _stdout
mov ecx, _right
mov edx, _rightlen
int 0x80
jmp _die
_die:
mov eax, _exit
xor ebx, ebx
int 0x80
I've tried google, but found nothing on what im trying to do.
I want to compare byte by byte to see if the passwords are right. I'm just starting out on ASM so constructive criticism and useful pointers will be much appriciated.
rawr
Offline
First off I want to say this: if you are learning x86 assembly because it's "faster", you will NEVER be able to write assembly as well as gcc can.
That said, there is no generic "asm" - I'm going to guess you're using nasm though.
In nasm, and most assembly, you cannot index a variable with a register. What you need to do is "Load the Effective Address" (lea):
lea ecx, [ebx+eax]
lea edx, [passwd+eax]
cmp ecx, edx
Offline
If you still have problems, then write implementation in C and use gcc -S
Offline
If you still have problems, then write implementation in C and use gcc -S
That is well cool, never knew about that.
Anyway, just to say that I agree, there is little point learning assembler, unless (like me) you use it to program PICs (and such like) to simplify circuits. High level languages are there to make life easy
Desktop: AMD Athlon64 3800+ Venice Core, 2GB PC3200, 2x160GB Maxtor DiamondMax 10, 2x320GB WD Caviar RE, Nvidia 6600GT 256MB
Laptop: Intel Pentium M, 512MB PC2700, 60GB IBM TravelStar, Nvidia 5200Go 64MB
Offline
Anyway, just to say that I agree, there is little point learning assembler, unless (like me) you use it to program PICs (and such like) to simplify circuits.
I disagree. I think it's very good for those who want to know _how_ things work. But writing actual programs in assembly is not a very good idea, unless it NEEDS to be assembly (see lrmi)
Offline
I disagree. I think it's very good for those who want to know _how_ things work. But writing actual programs in assembly is not a very good idea, unless it NEEDS to be assembly (see lrmi)
Sorry, I actually meant "using" instead of "learning". I've been getting my words muddled all day...
Desktop: AMD Athlon64 3800+ Venice Core, 2GB PC3200, 2x160GB Maxtor DiamondMax 10, 2x320GB WD Caviar RE, Nvidia 6600GT 256MB
Laptop: Intel Pentium M, 512MB PC2700, 60GB IBM TravelStar, Nvidia 5200Go 64MB
Offline
Pages: 1