I’m writing a simple calculator in NASM, why when calling
jmp show_operands_message
Is the message printed twice into the terminal?
global _start
section .data
selection_message db "Select operation (add, sub):", 10
operands_message db "Enter operands: ", 10
selection_message_count equ $-selection_message
operands_message_count equ $-operands_message
section .text
_start:
jmp show_selection_message
jmp show_operands_message
jmp exit
show_selection_message:
mov rax, 1
mov rdi, 1
mov rsi, selection_message
mov rdx, selection_message_count
syscall
show_operands_message:
mov rax, 1
mov rdi, 1
mov rsi, operands_message
mov rdx, operands_message_count
syscall
exit:
mov rax, 60
syscall
Output:
Select operation (add, sub):
Enter operands:
Enter operands:
[Execution complete with exit code 1]
The message is displayed twice, I tried setting the register values to zero, but it didn’t help.
I would really appreciate your help!
New contributor
Леонид Яковлев is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.