Hello!
I've recently started learning assembly so I can begin writing full-fledged languages instead of wrappers. Today, while trying to learn the cmp function, and using je and jne, I've came upon a problem. I tried using cmp to compare two values, and then je and jne to jump to the two cases.
However , the only output it prints is "A is not equal to B", no matter what values I choose. Here is the code I wrote to so far :
section .data
text1: db 'A is equal to B',10
text2: db 'A is not equal to B',10
text1s: equ $-text1
text2s: equ $-text2
section .bss
a: resb 2
as: equ $-a
b: resb 2
bs: equ $-b
section .text
global _start
_start:
mov eax,3
mov ebx,1
mov ecx,a
mov edx,as
int 80h
mov eax,3
mov ebx,1
mov ecx,b
mov edx,bs
int 80h
mov eax,[a]
mov ebx,[b]
cmp eax,ebx
je truea
jne falseb
truea:
mov eax,4
mov ebx,1
mov ecx,text1
mov edx,text1s
int 80h
jmp endexit
falseb:
mov eax,4
mov ebx,1
mov ecx,text2
mov edx,text2s
int 80h
jmp endexit
endexit:
mov eax,1
mov ebx,1
int 80h
As far as I can see, it just always goes to falseb. I'm using Linux, x86 version with nasm(using -f elf) and linking it with ld -s -o <name> <name.o>.
I'd really appreciate any post on what I've done wrong.