zoukankan      html  css  js  c++  java
  • 汇编语言的简答入门--斐波那契数列(递归)

    TITLE Save an array and dispaly
    
    
    INCLUDE Irvine32.inc
    .data
    
    array DWORD 12 DUP (?)   ; define a array for saving Fibonacci numbers
    step = type array
    num DWORD ?
    count DWORD ?
    
    prompt byte "The first twelve fibonacci numbers are ",0
    prompt1 DWORD "  ",0
    		
    .code
    main PROC
    
    	mov edx,offset prompt
    	call writestring
    	
    	mov ebx,0                 ;they are for calculateing the value of array
    	mov edx,1                 ;
    	mov ebp,0                 ;
    	
    	mov ecx,11                ;for outputing
    	mov eax,00h
    display:
    
    	push eax
    	call Fibonacci
    	pop eax
    	call writeint
    	add eax,01h
    	
    loop display
    	
        call crlf
        call waitmsg
              
    		
    
    exit
    main ENDP
    
    Fibonacci proc USES esi eax ebx edx ebp
    	mov esi,esp
    	add esi,24
    	
    	mov eax,[esi]                ;get the value of we have pushed it
    	cmp eax,1
    	jl L1                
    	                         
    	add ebp,ebx                  ;calculate the value of array
    	add ebp,edx                  ;
    	mov ebx,edx                  ;
    	mov edx,ebp                  ;
    	
    	dec eax                      ;the times of recursion
    	call Fibonacci
    L1:	
    		mov [esi],ebp            ;result return address
    		ret
    		loop L1
    Fibonacci ENDP
    END main
    
             
          
          


     

    输出有错误请求各位兄长学长帮忙!感激不尽。

  • 相关阅读:
    HDU5367 思维map // 动态线段树
    CF500C New Year Book Reading
    窗口的星星
    【模板】扫描线
    [JLOI2014]松鼠的新家
    [USACO15DEC]最大流Max Flow
    The Lost House
    介绍 Seq2Seq 模型
    word2vec 和 glove 模型的区别
    关于 word2vec 如何工作的问题
  • 原文地址:https://www.cnblogs.com/suncoolcat/p/3358003.html
Copyright © 2011-2022 走看看