我试图运行此代码,以及发生了什么 -
一个。 scanf想要“epsilon =%lf”
湾由于某种原因,该程序不会继续打印epsilon,但是它再次扫描“order =%d”
℃。在那时打印epsilon
d。再次扫描“order =%d”
即打印第一个订单并退出
我想知道为什么程序输入两次scanf,以及如何修复它=]
(下面有一个终端img,可以看到实际程序中的步骤a-e)
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
编译并运行此代码后的终端图像: