section .data
wrongfile_str db `unable to open file, error code: %i\n`, 0x00
+ returnvalue_str db `system call return was %i\n`, 0x00
section .text
push DWORD [ebp-FILE_HANDLE]
call readLine
-
mov esi, eax
mov [ebp-IS_EOF], ebx
; check if eof was reached
cmp DWORD [ebp-IS_EOF], 1
je _readFile_exit
+
; push esi
; call printf
; check if file was open successfully
cmp eax, 0
- jge _writeFile_loop
- push eax
- push wrongfile_str
- call printf
- jmp _writeFile_exit
+ jl _writeFile_error
+
+ ; truncate file
+ mov eax, 93
+ mov ebx, [ebp-FILE_HANDLE]
+ mov ecx, 1
+ int 0x80
_writeFile_loop:
jmp _writeFile_loop
+ _writeFile_error:
+ push eax
+ push wrongfile_str
+ call printf
+ jmp _writeFile_exit
+
_writeFile_exit:
; close file