Intel汇编写的斐波那契数

includelib kernel32.lib  
includelib user32.lib  
includelib Irvine32.lib 

.386

.model flat,stdcall

.stack 4096
ExitProcess PROTO, dwExitCode:DWORD 
DumpRegs PROTO

.data

first DWORD 1;初始化第一个数为1
two	DWORD 1;初始化第二个数为1

dest  DWORD 12 dup (0);输出前12个斐波那契数

.code
main PROC
	 mov edx, offset dest	; edx是 dest 的偏移地址 
	  
	 mov esi, 0;				; esi 用来做 dest 的索引
	 mov ecx, 10;			  ; 循环10次,因为前两个已经给出来啦
	 
	 mov eax, first;			; eax 存放结果;
	 mov DWORD ptr [edx], eax;
	 
	 mov eax, two;
	 mov DWORD ptr [edx+4], eax;
	 
	 
start:
	 push ecx;
	 
	 mov ecx, DWORD ptr [edx + esi * 4];
	 
	 inc esi;
	 mov eax, DWORD ptr [edx + esi * 4];
	 
	 add eax, ecx;
	 
	 inc esi;
	 mov DWORD ptr [edx + esi * 4], eax;
	 call DumpRegs;
	 dec esi;
	 
	 pop ecx;
	 loop start;
	 
	
	 
    INVOKE ExitProcess, 0

main ENDP
END main


你可能感兴趣的:(汇编,user)