harmonic series with x86-64 assembly

前端 未结 1 1246
灰色年华
灰色年华 2021-01-28 05:07

Trying to compute a harmonic series.

Right now I\'m entering the number I want the addition to go up to.

When I enter a small number like 1.2, the program just s

相关标签:
1条回答
  • 2021-01-28 05:31

    This line seems suspicious:

    fst qword [currentSum]      ;pop current sum value into currentSum
    

    contrary to the comment, fst stores the top of the stack into memory WITHOUT popping it. You want fstp if you want to pop it.

    Overall, the stack behavior of your program seems suspicious -- it pushes various things onto the fp stack but never pops anything. After a couple of iterations, the stack will overflow and wrap around. Depending on your settings, you'll then either get an exception or get bogus values if you don't have exceptions enabled.

    0 讨论(0)
提交回复
热议问题