Chinaunix首页 | 论坛 | 博客
  • 博客访问: 178460
  • 博文数量: 89
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 828
  • 用 户 组: 普通用户
  • 注册时间: 2013-10-08 10:44
文章分类
文章存档

2014年(9)

2013年(80)

我的朋友

分类: Web开发

2013-10-08 10:59:45

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  
  
阅读(2086) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~