I am trying to compare the values of 2 variables to each other in assembly. I'm moving 3 into both variables. I want to compare the variables to each other. I've tried using brackets on each register and variable when comparing and it will not compile, such as cmp [eax], [ebx] and cmp [num], [num1]. Is there a way to compare them to each other or can you only compare by using cmp [num], byte 3? Thanks for the help.
section .data hello: db 'Hello world!',10 ; 'Hello world!' plus a linefeed character helloLen: equ $-hello ; Length of the 'Hello world!' string section .bss num resb 1 num1 resb 1 section .text global _start _start: mov [num], byte 3 mov [num1], byte 3 mov eax, [num] mov ebx, [num1] cmp eax, ebx jne end add [num], byte '0' mov eax,4 ; The system call for write (sys_write) mov ebx,1 ; File descriptor 1 - standard output mov ecx,num ; Put the offset of hello in ecx mov edx,1 ; helloLen is a constant, so we don't need to say ; mov edx,[helloLen] to get it's actual value int 80h add [num1], byte '0' mov eax,4 ; The system call for write (sys_write) mov ebx,1 ; File descriptor 1 - standard output mov ecx,num1 ; Put the offset of hello in ecx mov edx,1 ; helloLen is a constant, so we don't need to say int 80h end: mov eax,4 ; The system call for write (sys_write) mov ebx,1 ; File descriptor 1 - standard output mov ecx,hello ; Put the offset of hello in ecx mov edx,helloLen ; helloLen is a constant, so we don't need to say int 80h mov eax,1 ; The system call for exit (sys_exit) mov ebx,0 ; Exit with return code of 0 (no error) int 80h;