X-Git-Url: https://git.danieliu.xyz/?p=sped.git;a=blobdiff_plain;f=fileutils.asm;h=0f829f59a2abfde75c95d62b7cd66e2a99dda999;hp=1d96aa05eae9e75b012d83cd66cc094f90113cd3;hb=0af29f26ae69ba0ba9c5088612f0c537a20c0344;hpb=fb894149783dd18e6ecf1271153193a342e80433 diff --git a/fileutils.asm b/fileutils.asm index 1d96aa0..0f829f5 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] @@ -113,6 +114,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 +180,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