我一直在做这个任务,但不能通过第一部分,这应该很简单。我已经和我的教授讨论过了,但他也想不通……我希望在这里能得到一些帮助。我只想输入一个数字,将其推入st0,然后将其弹出并存储到total_mean中。出于测试目的,我在开头注释掉了代码。
extern printf
extern scanf
segment .data
prompt_name db "Please enter you name: ", 0
input_name db "%s %s",0
ready db "Please have your numberic data ready",10,0
get_num db "Enter a floating number: ",0
stringdata db "%s",0
namedata db "%s ",0
display_name db "%s",10,0
floatdata db "%Lf",0
ask db "Are there more numbers (Y or N)? ", 0
mean db "The mean of these %d values is %Lf",10,0
largest db "the largest value is %Lf",10,0
smallest db "the smallest value is %Lf",10,0
more db "Do you have more data to analyze (Y or N)? ",0
bye db "Thank you %s. I hope you enjoyed this program.",10,0
segment .bss
user_float: resq 1
large: resq 1
small: resq 1
total_mean: resq 2
first_name: resb 32
last_name: resq 32
segment .text
global start_loop
start_loop:
; mov rax,0
; mov rdi, stringdata
; mov rsi, prompt_name
; call printf
;
; mov qword rax, 0
; mov rdi, input_name
; mov rsi, first_name
; mov rdx, last_name
; call scanf
;
; mov rax, 0
; mov rdi, namedata
; mov rsi, first_name
; call printf
;
; mov rax, 0
; mov rdi, display_name
; mov rsi, last_name
; call printf
;
; mov rax, 0
; mov rdi, stringdata
; mov rsi, ready
; call printf
;
; mov rax, 0
; mov rdi, stringdata
; mov rsi, get_num
; call printf
mov qword rax, 0
push qword 0
push qword 0
mov rdi, floatdata
mov rsi, rsp
call scanf
push qword 0
push qword 0
fld tword [rsp]
fmul
fstp tword [total_mean]
mov qword rax, 0
mov qword rax,0
mov rdi, floatdata
mov rsi, total_mean
call printf
pop rax
pop rax
pop rax
pop rax
ret
它只是我试图从我遇到问题的键盘输入的下半部分。当我输入一个数字(例如 12.0)并显示它时,它显示 0.00000。任何人都可以帮我找到解决方案吗?