masm - Assembly print to file from array -


i need program write out file first 47 values of fibonacci series calculated. procedure correctly displays 47 entries using procedures included provided library not print them out file.

im sure storing array in esi, fib.bin file has 1 entry , not beginning of array. i'm need use esi, cant figure out, in advance.

title fibonacci numbers                     (fibnums.asm)  include irvine32.inc  .data filehandle dword ? filename byte "fib.bin",0  fib_count = 47 array dword fib_count dup(?)  .code main proc      ;creates file     mov  edx,offset filename     call createoutputfile     mov  filehandle,eax      ;generates array of values     mov esi,offset array     mov ecx,fib_count     call generate_fibonacci      ;write out file     mov eax,filehandle     mov edx,offset array     mov ecx,sizeof array     call writetofile      ;close file     mov eax,filehandle     call closefile       exit main endp  ;-------------------------------------------------- generate_fibonacci proc uses eax ebx ecx ; ;generates fibonacci values , stores in array ;receives: esi points array, ecx = count ;returns: nothing ;---------------------------------------------------      mov eax,1     mov ebx,0  l1: add eax,ebx     call    writedec     call crlf      mov [esi],eax     xchg    eax,ebx     loop l1     ret generate_fibonacci endp  end main 

you have increment esi:

... l1: add eax,ebx     call writedec     call crlf      mov [esi], eax     xchg eax, ebx     add esi, 4          ; move forward 4 bytes (4*8 bits) = 1 dword (1*32 bits)     loop l1 ... 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -