This commit is contained in:
2025-08-20 18:24:41 +02:00
parent 2b037241d1
commit a1455660e2
3 changed files with 25 additions and 21 deletions
+4
View File
@@ -0,0 +1,4 @@
.equ ENOENT, 0xFFFFFFFE
.equ ENOTDIR, 0xFFFFFFEC
+6 -14
View File
@@ -1,3 +1,6 @@
.include "syscalls.S"
.include "errors.S"
.global _start .global _start
exit: @ r0 should have the status code to exit with exit: @ r0 should have the status code to exit with
@@ -12,7 +15,7 @@ print: @ r1 => buffer to print. r2 => how many bytes to print. clobbers r0
bx lr @ return to caller bx lr @ return to caller
open_fail: open_fail:
push {r0} @ push the result of open() onto the stack before calling print() push {r0}
ldr r1, =OPEN_FAIL ldr r1, =OPEN_FAIL
mov r2, #31 mov r2, #31
bl print bl print
@@ -21,7 +24,7 @@ open_fail:
bl exit bl exit
dir_read_fail: dir_read_fail:
push {r0} @ save the result of open() because print() clobbers r0 push {r0}
ldr r1, =DIR_READ_FAIL ldr r1, =DIR_READ_FAIL
mov r2, #29 mov r2, #29
bl print bl print
@@ -111,6 +114,7 @@ direntry_loop:
b direntry_loop b direntry_loop
@ TODO: alphabetically sort the directory entries before printing them.
_start: _start:
ldr r0, [sp] ldr r0, [sp]
cmp r0, #1 cmp r0, #1
@@ -159,18 +163,6 @@ _start:
FD_NOT_FOUND: .ascii "Failed to open file descriptor: No such file or directory\n" FD_NOT_FOUND: .ascii "Failed to open file descriptor: No such file or directory\n"
NEWLINE: .ascii "\n" NEWLINE: .ascii "\n"
.equ SYS_EXIT, 0x01
.equ SYS_READ, 0x03
.equ SYS_WRITE, 0x04
.equ SYS_OPEN, 0x05
.equ SYS_FSTAT, 0x6C
.equ SYS_GETDENTS, 0x8D
.equ ENOENT, 0xFFFFFFFE
.equ ENOTDIR, 0xFFFFFFEC
.bss .bss
buffer: buffer:
.skip 16384 .skip 16384
name:
.skip 256
+8
View File
@@ -0,0 +1,8 @@
.equ SYS_EXIT, 0x01
.equ SYS_READ, 0x03
.equ SYS_WRITE, 0x04
.equ SYS_OPEN, 0x05
.equ SYS_FSTAT, 0x6C
.equ SYS_GETDENTS, 0x8D