I'm learning assembly right now and I have a very big problem to solve. (I use x86_64 nasm assembly btw)
So far, I have done this
section .bss
result: resb 10
section .data
num1: db '22'
num2: db '33'
num3: db '44'
section .text
global _start
_start:
mov cl, [num1]
cmp cl, [num2]
jg _check_third_num
mov cl, [num2]
_check_third_num:
cmp cl, [num3]
jg _exit
mov cl, [num3]
_exit:
mov [result], rcx
mov rax, 1
mov rdi, 1
mov rsi, result
mov rdx, 10
syscall
mov rax, 60
mov rdi, 0
syscall
I guess it's worked as I expected, but the output isn't right.
So, I basically compiled like this
$ nasm -f elf64 hello.asm -o hello.o
$ ld -o hello hello.o
$ ./hello
And I get this output 4
, not 44
as I wish to.
So can you help me?