Floating point 在NASM中使用atof

Floating point 在NASM中使用atof,floating-point,command-line-arguments,nasm,fpu,atof,Floating Point,Command Line Arguments,Nasm,Fpu,Atof,我试图在NASM中实现一个简单的程序,它从命令行参数中获取未知数量的浮点值,并将它们相加。这似乎对我不起作用,我想可能是因为我错误地使用了atof调用。我在atof调用后输出浮点数,以查看它们是否工作,但我没有得到输入的数字。此外,我甚至没有得到这些印刷数字的总和,所以那里也有问题。我寻找过类似代码的示例,但遗憾的是,NASM的在线文档记录不如Java 这是我的密码: extern atof extern printf extern exit global main section .dat

我试图在NASM中实现一个简单的程序,它从命令行参数中获取未知数量的浮点值,并将它们相加。这似乎对我不起作用,我想可能是因为我错误地使用了atof调用。我在atof调用后输出浮点数,以查看它们是否工作,但我没有得到输入的数字。此外,我甚至没有得到这些印刷数字的总和,所以那里也有问题。我寻找过类似代码的示例,但遗憾的是,NASM的在线文档记录不如Java

这是我的密码:

extern atof
extern printf
extern exit

global main

section .data
formats: db "%s", 10, 0
formatd: db "%d", 10, 0
formatf: db "%f", 10, 0

debug1: db "fell through copy loop.", 10, 0
debug2: db "fell through location.", 10, 0

section .bss
floatAvg: resq 1
numArgs: resd 1


tempFlt1: resq 1
tempFlt2: resq 1

section .text
main:


mov ecx, [esp + 4]
dec ecx
mov dword [numArgs], ecx

mov ebx, [esp + 8]
add ebx, 4


;no output if no args
cmp ecx, 0
je endProg


;find the sum
dec ecx

FINIT
FLDZ ; sum is zero

sumLoop:
push ecx ;preserve

push dword [ebx]
call atof
add esp, 4
FSTP qword [tempFlt1]

;debug
FLD dword [tempFlt1]
sub esp, 8
FSTP qword [esp]
push formatf
call printf
add esp, 12


FADD qword [tempFlt1]

pop ecx ;restore
dec ecx
add ebx, 4

cmp ecx, 0
jge sumLoop

FSTP qword [tempFlt2]

FLD dword [tempFlt2]
sub esp, 8
FSTP qword [esp]
push formatf
call printf
add esp, 12


endProg:
call exit
输入/输出示例:

In:47889

输出:0.0.0.0.0,和0.0

In:7.36.9

输出:0.0-0.0,总和272008302207532160516096.0

In:8.86.33.98


Out:-0.0.0 0.058750,sum-230215375187831947264.0

你能举例说明你输入的数字和得到的结果吗?这些信息添加在我问题的底部。如您所见,atof和sum似乎都不能正常工作。这不可能给出正确的结果:
FSTP qword[tempFlt1]/FLD dword[tempFlt1]
。对存储和加载使用相同的大小(
dword
qword
),我对dword进行了所有引用。调试打印似乎不起作用,但总数现在是正确的。。。。。。