如何循环使用汇编语言 [英] How to loop in assembly language

查看:239
本文介绍了如何循环使用汇编语言的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将如何计算斐波那契数列的前12个值,并可以将其放置在EAX章。和显示主叫姆preGS?采用间接寻址,我知道我需要一个for循环在这里,但我不知道怎么去甚至这个。任何帮助或提示是AP preciated。

 包括Irvine32.inc; (插入符号定义在这里)。数据; (此处插入变量)
   斐波纳契字节1,1,10 DUP(?)。code
主要PROC; (此处插入可执行指令)
    ; (这将在下面显示的字符串六内容。)
      MOV ESI,OFFSET斐波那契;抵消变量
      MOV EBX,1;字节格式
      MOV ECX,SIZEOF斐波那契;计数器
      调用dumpMem
    出口 ;退出到操作系统
主要ENDP; (此处插入附加程序)主要END


解决方案

您可以让这样一个循环:

  MOV ECX,12
your_label:
;您code
环your_label

循环指令递减 ECX 并跳转到指定的标签,除非 ECX 等于零。您也可以构建同一个循环是这样的:

  MOV ECX,12
your_label:
;您code
十二月ECX
JNZ your_label

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

解决方案

You can make a loop like this:

mov ecx,12
your_label:
; your code
loop your_label

The loop instruction decrements ecx and jumps to the specified label unless ecx is equal to zero. You could also construct the same loop like this:

mov ecx,12
your_label:
; your code
dec ecx
jnz your_label

这篇关于如何循环使用汇编语言的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆