如何正确读取汇编中的变量[重复]。

问题描述 投票:1回答:1

经过大量的编辑,研究,我决定做正确的(我希望)。

所以,我想从命令行获取一个浮点数。

下面是代码。

format PE Console
entry start 
include 'INCLUDE/win32ax.inc'
include 'INCLUDE/win_macros.inc'

section '.text' code readable executable

 start:

  finit
  fld [a]
  fld [b]
  fmulp
  fst [a]
  cinvoke printf, '%.2f',dword [a],dword [a+4]
  cinvoke printf,'%s','Begin number: '
  cinvoke printf,'%s','a= '
  cinvoke scanf, '%f',a
  cinvoke printf, '%.2f',dword [a],dword [a+4]
  cinvoke system, 'pause'




section '.data' code readable writeable executable
 a dq 12.11
 b dq 3.0    

乘法是为了测试,并正确显示数字。

36.33

然后,我想扫描一个数字到 a 并将其打印出来,结果是

36.33

如何将这个数字移动到 a?

assembly numerical-integration fasm x87
1个回答
0
投票

在@Peter Cordes的帮助下,我找到了解决方案。

 start:

  finit
  cinvoke printf,'%s','Begin number: '
  cinvoke printf,'%s','a= '
  cinvoke scanf, '%lf', a ;here is the important thing
  fld [a]
  fld [b]
  fmulp
  fst [a]
  cinvoke printf, '%.2f',double [a],double [a+4]
  cinvoke system, 'pause'




section '.data' code readable writeable executable
 a dq 0
 b dq 3.0  
© www.soinside.com 2019 - 2024. All rights reserved.