I just started learning assembly, as a fun challange. I have made the obligatory hello world program as well as a simple one that just asks for input then displays it. Now i think the next step would be a simple 'guess the number i'm thinking of' program, here's the code
section .data
First: db 'Try and guess the number im thinking of',10
Firstlen equ $-First
Correct: db 'YAY! you guessed my number correctly',10
Correctlen equ $-Correct
Fail: db 'You Suck',10
Faillen equ $-Fail
section .bss
num resb 5
section .text
global _start
_start:
mov eax,4
mov ebx,1
mov ecx,First
mov edx,Firstlen
int 80h
;get users number
mov eax,3
mov ebx,2
mov ecx,num
mov edx,5
int 80h
;compare number
mov edx,num
cmp edx,7
je correct; jump if equal
jne fail; jump if not equal to exit
fail:
mov eax,4
mov ebx,1
mov ecx,Fail
mov edx,Faillen
int 80h
;exit
mov eax,1
mov ebx,0
int 80h
correct:
mov eax,4
mov ebx,1
mov ecx,Correct
mov edx,Correctlen
int 80h
;exit agian
mov eax,1
mov ebx,0
int 80h
No matter what i do the fail function is always called. So i assume that i'm not comparing what i think i am, but i cant seem to find any help online. What am i doing wrong?
ps. I am using nasm 2.11.05