extern memset
global readFile
+global readLine
section .data
wrongfile_str db `unable to open file, error code: %i\n`, 0x00
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]
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
; 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
_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
pop ebp
ret
+; writes contents of string array into file
+; arg: filename, string array
+; writeFile:
+