本文介绍了汇编语言中的斐波那契数列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

或多或少需要一些帮助来理解这一点.我们刚刚进入循环和偏移量操作数,希望对您有所帮助.所以这是我的指示:

Need some help understanding this more or less. We are just getting into loops and OFFSET operands and would appreciate some help. So here are my instructions:

使用具有间接寻址模式的LOOP指令编写汇编语言程序,该程序将计算斐波纳契数列{1、1、2、3、5、8、13,...}中的前12个值.将每个值放在EAX寄存器中,并在循环内通过调用DumpRegs语句显示它.

Write an assembly language program using the LOOP instruction with indirect addressing mode that calculating the first 12 values in the Fibonacci number sequence, {1, 1, 2, 3, 5, 8, 13, …}. Place each value in the EAX register and display it with a call DumpRegs statement inside the loop.

请使用以下变量定义:斐波那契BYTE 1,1,10 DUP(?)

Please use the following variable definition: Fibonacci BYTE 1, 1, 10 DUP (?)

在循环后立即插入以下语句.它们将显示目标字符串的十六进制内容:mov esi,抵消斐波那契;抵消变量mov ebx,1;字节格式mov ecx,SIZEOF斐波那契;柜台调用dumpMem;在内存中显示数据

Insert the following statements immediately after the loop. They will display the hexadecimal contents of the target string: mov esi, OFFSET Fibonacci ; offset the variables mov ebx,1 ; byte format mov ecx, SIZEOF Fibonacci ; counter call dumpMem ; display the data in the memory

如果程序正常运行,则在程序运行时,您将在屏幕上看到以下十六进制字节序列:01 01 02 03 05 08 0D 15 22 37 59 90

If your program works correctly, you will see the following sequence of hexadecimal bytes on the screen when the program runs:01 01 02 03 05 08 0D 15 22 37 59 90

    .data

Fibonacci BYTE 1, 1, 10 DUP (?)

.code
main PROC

  L1:

  mov   esi, OFFSET Fibonacci       ; offset the variables
  mov   ebx,1               ; byte format
  mov   ecx, SIZEOF Fibonacci       ; counter
  call  dumpMem             ; display the data in the memory


    exit                    ;exits to Operating System
    main ENDP

END main


所以我知道我需要做一个循环语句,但是完全不知道如何开始.任何建议将不胜感激!


So I know I need to make a loop statement, but am completely stuck on how to begin it. Any advice will be greatly appreciated!

推荐答案

我相信您只是想知道如何在程序集中创建循环.请参见下面的示例:

I believe you just want to know how to create a loop in assembly. See the below for some examples:

带有x86程序集的循环ecx和循环指令与jmp + j< condition>

这篇关于汇编语言中的斐波那契数列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-17 15:57