I'v tried to run this code, and that what happend -
a. scanf want "epsilon = %lf"
b. for some reason, the program does not continue to print epsilon, but insted it's scan again for "order = %d"
c. print epsilon at that point
d. scanf again for "order = %d"
e. print the first order and exit
I would like to know why the program entered twice to scanf, and how to fix it =]
(there is a terminal img below, to see steps a-e in the actual program)
global main
extern printf
extern scanf
section .data
epsilon_formatIN: db "epsilon = %lf",10,0
epsilon_formatOUT: db "epsilon = %lf",10,0
order_formatIN: db "order = %d",10,0
order_formatOUT: db "order = %d",10,0
section .bss
epsilon: resq 1
order: resb 1
section .text
main:
push rbp
mov rbp, rsp
mov rax, 0
.get_epsilon:
mov rdi, epsilon_formatIN
mov rsi, epsilon
mov rax, 0
call scanf
.print_epsilon:
mov rdi, epsilon_formatOUT
movsd xmm0, qword [epsilon]
mov rax, 1
call printf
.get_order:
mov rdi, order_formatIN
mov rsi, order
mov rax, 0
call scanf
.print_order:
mov rdi, order_formatOUT
mov rsi, [order]
mov rax, 0
call printf
pop rbp
ret
terminal image after compiling and run this code: