X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=fileutils.asm;h=8596ff381ec87a8885bc3ac4f8cc8203fb2b4b2d;hb=aab6303fb9c43a2d727774c25b3c50a4b1fcae8d;hp=1d96aa05eae9e75b012d83cd66cc094f90113cd3;hpb=fb894149783dd18e6ecf1271153193a342e80433;p=sped.git diff --git a/fileutils.asm b/fileutils.asm index 1d96aa0..8596ff3 100644 --- a/fileutils.asm +++ b/fileutils.asm @@ -6,6 +6,7 @@ extern free extern memset global readFile +global readLine section .data wrongfile_str db `unable to open file, error code: %i\n`, 0x00 @@ -65,8 +66,8 @@ readFile: mov esi, eax mov [ebp-IS_EOF], ebx - push esi - call printf + ; push esi + ; call printf ; make string buffer bigger mov eax, DWORD [ebp-LINES_READ] @@ -79,10 +80,14 @@ readFile: mov DWORD [ebp-BUF_PTR], eax ; write string to buffer - mov eax, DWORD [ebp-BUF_PTR] + mov eax, [ebp-LINES_READ] mov ecx, 4 mul ecx - mov eax, esi + add eax, DWORD [ebp-BUF_PTR] + mov [eax], esi + + ; push DWORD [eax] + ; call printf add DWORD [ebp-LINES_READ], 1 @@ -113,6 +118,7 @@ readFile: ; return: ; eax: location to buffer ; ebx: contains eof +; ecx: number of chars read readLine: %define _FILE_HANDLE 8 %define CHAR_COUNT 4 ; count number of characters read @@ -178,6 +184,12 @@ readLine: _readLine_exit: + mov eax, [ebp-BLOCK_COUNT] + mov ecx, 63 + mul ecx + add eax, [ebp-CHAR_COUNT] + mov ecx,eax + mov eax, DWORD [ebp-STR_PTR] %undef _FILE_HANDLE @@ -189,3 +201,7 @@ readLine: pop ebp ret +; writes contents of string array into file +; arg: filename, string array +; writeFile: +