110bf98378f1bd5e012172bb48a69c768c38c04b
[sped.git] / sped.asm
1 ; sped - the stupidly pointless editor
2 ; written by pinosaur
3
4 %include "fileutils.S"
5
6 global main
7 extern printf
8
9 section .data
10     banner_str db `SPED - the stupidly pointless editor\n`, 0x00
11     nofile_str db `no file provided\n`, 0x00
12
13 section .text
14 main:
15     %define _ARGC 8
16     %define _ARGV 12
17
18     push ebp
19     mov ebp, esp
20
21     ; read command line args
22     mov ecx, [ebp+_ARGC]
23     cmp ecx, 1
24     jg _main_existing
25     
26     ; display error msg if no file
27     push nofile_str
28     call printf
29     mov eax, 1
30     jmp _main_exit
31
32     _main_existing:
33     mov ebx, DWORD [ebp+_ARGV]
34     add ebx, 4 ; first user arg is filename
35     push DWORD [ebx]
36     call readFile
37
38     mov eax, 0
39     jmp _main_exit
40
41     _main_exit:
42     %undef _ARGC
43     %undef _ARGV
44
45     mov esp, ebp
46     pop ebp
47     ret
48