diff --git a/examples/HWA/makefile b/examples/HWA/makefile index 0f22a74..e469b7f 100644 --- a/examples/HWA/makefile +++ b/examples/HWA/makefile @@ -1,9 +1,11 @@ all: main -main: ../../std.o - fasm main.asm +main: ../../std.o main.o ld -m elf_i386 main.o ../../std.o --output main +main.o: + fasm main.asm + ../../std.o: make -C ../../ std.o diff --git a/examples/file/main b/examples/file/main index 2ce060e..3c10d90 100644 Binary files a/examples/file/main and b/examples/file/main differ diff --git a/examples/file/main.asm b/examples/file/main.asm index c1f3e9e..9bdee99 100644 --- a/examples/file/main.asm +++ b/examples/file/main.asm @@ -8,9 +8,14 @@ extrn print.str extrn print.nl extrn exit +macro nl { + call print.nl +} + section '.strtab' filename db "makefile", 0 +error db "An error occurred while opening the file", 0 section '.bss' writeable @@ -22,17 +27,26 @@ _start: push filename call file.open pop eax + + cmp eax, 0 + jne @f + push error + call print.str + nl + call exit + + @@: mov [file_], eax push dword [file_] call print.str - call print.nl - call print.nl + nl + nl push dword [file_] call file.content call print.str - call print.nl + nl push dword [file_] call file.close diff --git a/examples/file/main.o b/examples/file/main.o index 8691127..339c0e4 100644 Binary files a/examples/file/main.o and b/examples/file/main.o differ diff --git a/examples/file/makefile b/examples/file/makefile index 1e9b309..270ac57 100644 --- a/examples/file/makefile +++ b/examples/file/makefile @@ -1,8 +1,10 @@ all: main -main: ../../file.o ../../std.o ../../path.o ../../string.o +main: ../../file.o ../../std.o ../../path.o ../../string.o main.o + ld -m elf_i386 main.o ../../file.o ../../std.o ../../path.o ../../string.o --output main + +main.o: fasm main.asm - ld -m elf_i386 main.o ../../file.o ../../std.o ../../path.o --output main ../../std.o: make -C ../.. std.o diff --git a/examples/network/makefile b/examples/network/makefile index 2973666..b73a1df 100644 --- a/examples/network/makefile +++ b/examples/network/makefile @@ -1,9 +1,11 @@ all: main -main: ../../std.o ../../string.o ../../network.o ../../dns.o ../../dnstoys.o - fasm main.asm +main: ../../std.o ../../string.o ../../network.o ../../dns.o ../../dnstoys.o main.o ld -m elf_i386 main.o ../../std.o ../../string.o ../../network.o ../../dns.o ../../dnstoys.o --output main +main.o: + fasm main.asm + ../../std.o: make -C ../.. std.o @@ -21,4 +23,3 @@ main: ../../std.o ../../string.o ../../network.o ../../dns.o ../../dnstoys.o clear: rm main.o main - diff --git a/file.o b/file.o index 5e89213..c0392e7 100644 Binary files a/file.o and b/file.o differ diff --git a/src/file.asm b/src/file.asm index b80476e..43427cd 100644 --- a/src/file.asm +++ b/src/file.asm @@ -34,6 +34,13 @@ open: mov edx, O_DIRECTORY int 80h + cmp eax, -2 + jne @f + mov [ebp+2*4], dword 0 + postlude + ret + + @@: mov [fd], eax ; fstat