显示斐波那契数列的前 24 个值
我该如何编写一个程序,用汇编语言显示斐波那契数列的前 24 个值?
如果有人可以帮助我,我将不胜感激,我对汇编中的代码感到困惑。
How would I write a program that will display the first 24 values in the Fibonacci series in assembly language?
If anyone could help me I would greatly appreciate it, I'm confused with the code in assembly.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
嗯,你的做法与大多数其他语言的方式非常相似,如下所示:
与其他语言的明显区别包括:
Well, you do it pretty similarly to the way you would in most other languages, something like this:
The obvious differences from other languages include:
我留下了两个空格,因为代码取决于它将运行的系统(您没有指定编译器和操作系统)。
我还没有测试过代码,但我认为它会起作用。
希望有帮助。
I left two blank spaces because the code depends on the system where it's going to run (you didn't specify the compiler and operating system).
I haven't tested the code but I think it will work.
Hope it helps.
斐波那契数列中的数字是其前面的两个数字之和。为了简单起见,您可以将这些数字存储在一个数组中,前两个元素设置为 1。 esi 和 edi 可以指向 n-1 和 n-2,所以 fibonacci(n) = [esi] + [edi]] 对?在伪代码中,它看起来像:
您可以将 x 保存在 ecx 寄存器中,将 fibonacci(x) 保存在 eax 寄存器中。
A number in Fibonacci series is the sum by the two numbers preceding it. To keep it simple you can store these numbers in an array with the first two element set to 1. esi and edi could point to n-1 and n-2, so fibonacci(n) = [esi] + [edi]] right? In pseudocode it looks like:
you can keep x in the ecx register and fibonacci(x) in the eax register.
尝试这个代码,它会根据您的要求工作这个答案使用循环运行24次,循环标签是下一个,它首先从ax和bx获取数据,然后将其相加,所有函数都重复24次,直到循环完成。
try this code it would work as per your requirements this answer makes use of a loop running for 24 times and the label looped is next which first takes the data from ax and bx and then adds it up these all functions are repeated for 24 times till the loop is completed.