首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 嵌入开发 > 汇编语言 >

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

2013-10-03 
汇编语言的简单入门--for operating array根据函数F(0)0;F(1) 1;F(n) F(n-2)F(n-1) TITLE Save an a

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

根据函数

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

 

TITLE Save an array and dispalyINCLUDE Irvine32.inc.dataarray DWORD 12 DUP (?)   ; define a array for saving Fibonacci numbersstep = type arrayprompt byte "The first twelve fibonacci numbers are ",0prompt1 DWORD "  ",0.codemain PROCmov 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 EDXcall writestring;output the promptmov edx,offset prompt1;place the zero-ended string's offset in EDXmov edi,0                           ;assign 0 to the first elementmov [esi],edimov eax,[esi]                       ;mov the first element to eax for outpingcall writeintcall writestringmov edi,1;assign 1 to the first element              mov [esi + 4],edimov eax,[esi + 4];mov the second element to eax for outpingcall writeintcall writestringsub 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 elementadd edi,[esi]add esi,step                    ;point to next elementmov [esi],edimov eax,[esi]            ;move an integercall writeintcall writestringsub esi,step;point to last elementloop L1call waitmsgexitmain ENDPEND main


 

热点排行