当前位置: 代码迷 >> 汇编语言 >> 编译语言的简答入门-斐波那契数列(递归)
  详细解决方案

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

热度:280   发布时间:2016-05-02 04:48:48.0
汇编语言的简答入门--斐波那契数列(递归)
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 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,00hdisplay:	push eax	call Fibonacci	pop eax	call writeint	add eax,01h	loop display	    call crlf    call waitmsg          		exitmain ENDPFibonacci 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 FibonacciL1:			mov [esi],ebp            ;result return address		ret		loop L1Fibonacci ENDPEND main                     


 

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

 

  相关解决方案