just667
just667
2016-10-25 01:55
采纳率: 0%
浏览 2.4k

急!!!汇编语言求超过25项的斐波那契数列

汇编语言求超过25项的斐波那契数列汇编语言求超过25项的斐波那契数列汇编语言求超过25项的斐波那契数列

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

3条回答 默认 最新

  • qq_34770510
    曹大仙呀 2016-10-25 02:33
    点赞 评论
  • caozhy
     INCLUDE Irvine32.inc
    .data
    
    array DWORD 25 DUP (?)   ; define a array for saving Fibonacci numbers
    step = type array
    
    prompt byte "The first 25 fibonacci numbers are ",0
    prompt1 DWORD "  ",0
    
    .code
    main PROC
    
    mov esi,OFFSET array                ;edi = address of array
    
    mov ecx,lengthof array              ;initialize loop conuter
    
    
    mov edx,offset prompt               ;place the zero-ended string's offset in EDX
    call writestring                    ;output the prompt
    
    mov edx,offset prompt1              ;place the zero-ended string's offset in EDX
    
    mov edi,0                           ;assign 0 to the first element
    mov [esi],edi
    
    mov eax,[esi]                       ;mov the first element to eax for outping
    call writeint
    call writestring
    
    mov edi,1                           ;assign 1 to the first element              
    mov [esi + 4],edi
    
    mov eax,[esi + 4]                   ;mov the second element to eax for outping
    call writeint
    call writestring
    
    sub ecx,2                           ;because we have output two element in array so we just need to the remain of element . 
    
    L1:     
    
        mov edi,0                       ;every time we use this register,we need to clear it.
        add edi,[esi]
        add esi,step                    ;point to next element
    
        add edi,[esi]
        add esi,step                    ;point to next element
    
        mov [esi],edi
        mov eax,[esi]                   ;move an integer
    
        call writeint
        call writestring
        sub esi,step                    ;point to last element
        loop L1
    
        call waitmsg
    exit
    main ENDP
    END main
    

    是32bit汇编,用masm32编译

    点赞 评论
  • WuZian_CSU
    wu zi an 2020-07-18 19:48
    点赞 评论

相关推荐