欢迎来到Doc100.Net免费学习资源知识分享平台!
您的位置:首页 > 程序异常 >

编译语言的简单入门-for operating array

更新时间: 2014-01-05 03:16:46 责任编辑: Author_N1

 

汇编语言的简单入门--for operating array

根据函数

F(0)=0;F(1) = 1;F(n) = F(n-2) + F(n-1);

 

TITLE Save an array and dispaly


INCLUDE Irvine32.inc
.data

array DWORD 12 DUP (?)   ; define a array for saving Fibonacci numbers
step = type array

prompt byte "The first twelve 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


 

上一篇:上一篇
下一篇:下一篇

 

随机推荐程序问答结果

 

 

如对文章有任何疑问请提交到问题反馈,或者您对内容不满意,请您反馈给我们DOC100.NET论坛发贴求解。
DOC100.NET资源网,机器学习分类整理更新日期::2014-01-05 03:16:46
如需转载,请注明文章出处和来源网址:http://www.doc100.net/bugs/t/20338/
本文WWW.DOC100.NET DOC100.NET版权所有。