1 ; sped - the stupidly pointless editor
17 banner_str db `SPED - the stupidly pointless editor\n`, 0x00
18 readfile_str db `reading file %s\n`, 0x00
19 nofile_str db `no file provided\n`, 0x00
20 argcount_str db `there are %d args\n`, 0x00
21 wrongfile_str db `unable to open file, error code: %i\n`, 0x00
22 char_str db `read this char: %i\n`, 0x00
23 printfint_str db `int: %i\n`, 0x00
36 ; read command line args
41 ; display error msg if no file
48 mov ebx, DWORD [ebp+_ARGV]
68 ; reads file line by line
71 ; eax - pointer to mem
82 mov DWORD [ebp-FILE_HANDLE], 0x00
86 mov ebx, [ebp+_FILE_NAME]
90 mov [ebp-FILE_HANDLE], eax
92 ; check if file was open successfully
101 push DWORD [ebp-FILE_HANDLE]
109 mov ebx, [ebp-FILE_HANDLE]
120 ; reads a line until newline character is reached
126 %define _FILE_HANDLE 8
133 mov DWORD [ebp-CHAR_PTR], 0x00
137 cmp BYTE [ebp-CHAR_PTR], 64
138 jne _readLine_notfull
142 ; read a single character
144 mov ebx, [ebp+_FILE_HANDLE]
146 add ecx, [ebp-CHAR_PTR]
153 add ecx, [ebp-CHAR_PTR]
159 add eax, [ebp-CHAR_PTR]
160 cmp DWORD [eax], 0x0a
165 add eax, [ebp-CHAR_PTR]
166 cmp DWORD [eax], 0x05
169 add DWORD [ebp-CHAR_PTR], 1