读书人

编译语言的简答入门-斐波那契数列(递

发布时间: 2013-10-09 22:26:11 作者: rapoo

汇编语言的简答入门--斐波那契数列(递归)

TITLE Save an array and dispalyINCLUDE Irvine32.inc.dataarray DWORD 12 DUP (?)   ; define a array for saving Fibonacci numbersstep = type arraynum DWORD ?count DWORD ?prompt byte "The first twelve fibonacci numbers are ",0prompt1 DWORD "  ",0.codemain PROCmov edx,offset promptcall writestringmov ebx,0                 ;they are for calculateing the value of arraymov edx,1                 ;mov ebp,0                 ;mov ecx,11                ;for outputingmov eax,00hdisplay:push eaxcall Fibonaccipop eaxcall writeintadd eax,01hloop display    call crlf    call waitmsg          exitmain ENDPFibonacci proc USES esi eax ebx edx ebpmov esi,espadd esi,24mov eax,[esi]                ;get the value of we have pushed itcmp eax,1jl L1                                         add ebp,ebx                  ;calculate the value of arrayadd ebp,edx                  ;mov ebx,edx                  ;mov edx,ebp                  ;dec eax                      ;the times of recursioncall FibonacciL1:mov [esi],ebp            ;result return addressretloop L1Fibonacci ENDPEND main                     


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

读书人网 >汇编语言

热点推荐