misc
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
.include "syscalls.S"
|
||||
.include "errors.S"
|
||||
|
||||
.global _start
|
||||
|
||||
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
|
||||
|
||||
open_fail:
|
||||
push {r0} @ push the result of open() onto the stack before calling print()
|
||||
push {r0}
|
||||
ldr r1, =OPEN_FAIL
|
||||
mov r2, #31
|
||||
bl print
|
||||
@@ -21,7 +24,7 @@ open_fail:
|
||||
bl exit
|
||||
|
||||
dir_read_fail:
|
||||
push {r0} @ save the result of open() because print() clobbers r0
|
||||
push {r0}
|
||||
ldr r1, =DIR_READ_FAIL
|
||||
mov r2, #29
|
||||
bl print
|
||||
@@ -111,6 +114,7 @@ direntry_loop:
|
||||
|
||||
b direntry_loop
|
||||
|
||||
@ TODO: alphabetically sort the directory entries before printing them.
|
||||
_start:
|
||||
ldr r0, [sp]
|
||||
cmp r0, #1
|
||||
@@ -159,18 +163,6 @@ _start:
|
||||
FD_NOT_FOUND: .ascii "Failed to open file descriptor: No such file or directory\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
|
||||
buffer:
|
||||
.skip 16384
|
||||
name:
|
||||
.skip 256
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user