如何用汇编语言循环
我如何计算斐波那契数列中的前 12 个值并将其放入 EAX 寄存器中?并显示调用 DumpRegs?使用间接寻址我知道我需要一个 for 循环,但我不知道如何去做。任何帮助或提示表示赞赏。
INCLUDE Irvine32.inc
; (insert symbol definitions here)
.data
; (insert variables here)
Fibonacci BYTE 1, 1, 10 DUP (?)
.code
main PROC
; (insert executable instructions here)
; (This below will show hexa contents of string.)
mov esi, OFFSET Fibonacci ; offset the variables
mov ebx,1 ; byte format
mov ecx, SIZEOF Fibonacci ; counter
call dumpMem
exit ; exit to operating system
main ENDP
; (insert additional procedures here)
END main
How would I calculate the first 12 values in the Fibonacci number sequence and be able to place it in EAX reg. and display calling DumpRegs? Using Indirect addressing I know I need a for loop here but I'm not sure how to even go about this. Any help or tips are appreciated.
INCLUDE Irvine32.inc
; (insert symbol definitions here)
.data
; (insert variables here)
Fibonacci BYTE 1, 1, 10 DUP (?)
.code
main PROC
; (insert executable instructions here)
; (This below will show hexa contents of string.)
mov esi, OFFSET Fibonacci ; offset the variables
mov ebx,1 ; byte format
mov ecx, SIZEOF Fibonacci ; counter
call dumpMem
exit ; exit to operating system
main ENDP
; (insert additional procedures here)
END main
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以创建如下循环:
循环指令递减
ecx
并跳转到指定标签,除非ecx
等于 0。您还可以像这样构建相同的循环:You can make a loop like this:
The loop instruction decrements
ecx
and jumps to the specified label unlessecx
is equal to zero. You could also construct the same loop like this:您确定需要一个 for 循环来实现您的目标,因此也许 for 循环的 C 实现(在汇编中)将帮助您:
来源:eventhelix.com
You determined that you need a for loop to achieve your goal, so maybe the C implementation of the for loop, in assembly, will help you:
SOURCE: eventhelix.com