Answer the question
In order to leave comments, you need to log in
How to display the result of addition in Nasm (MACOS, 64bit)?
Good afternoon!
Please tell me, I'm trying to add numbers in NASM. Here is the code:
global start
section .text
start:
mov rax, 90 ; move our first number into eax
add rax, 5
mov [qword msg], rax
call write_result ; Выводим результат
mov rax, 0x02000001 ; Системный вызов для выхода
xor rdi, rdi ; Код - 0
syscall ; Выходим
write_result:
mov rax, 0x02000004
mov rdi, 1
mov rsi, msg
mov rdx, 13
syscall
ret
section .data
a: dw 5
b: dw 30
c: dw 65
d: dw 67
t: dw 0
msg: dw 0, 10
Answer the question
In order to leave comments, you need to log in
How can I make it output a number?
mov rbx, 10
mov rsi, str + 20
l1:
mov rdx, 0
idiv rbx
add dl, '0'
mov byte [rsi], dl
add rsi, -1
test rax, rax
jnz l1
; rsi + 1 указывает на начало строки
; длина строки -- str + 20 - rsi
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question