summaryrefslogtreecommitdiff
path: root/sh.asm
diff options
context:
space:
mode:
authorfaissaloo <faissaloo@gmail.com>2016-07-14 22:17:44 +0100
committerfaissaloo <faissaloo@gmail.com>2016-07-14 22:17:44 +0100
commit6fe5395074c753b3915db9c3ca9da544249d5593 (patch)
treef4df0265c2b08c0013372432f63ba45600318f5f /sh.asm
parent875e9b8008f2d3b0d45adf8bfa70e2a9851478bb (diff)
downloaddbsh-6fe5395074c753b3915db9c3ca9da544249d5593.tar.gz
Added error message for invalid cd attempts
Diffstat (limited to 'sh.asm')
-rw-r--r--sh.asm13
1 files changed, 11 insertions, 2 deletions
diff --git a/sh.asm b/sh.asm
index a239844..81c7977 100644
--- a/sh.asm
+++ b/sh.asm
@@ -7,7 +7,9 @@ section .data
nfe: db "Error: program not found", 0x2e, `\n`
env: db "/etc/environment", 0x0
boem: db "Error: input overflows buffer", 0x2e, `\n`
- invalid_int_str: db "Error: Invalid integer",`\n`
+ no_dir_str: db "cd: Unknown directory",`\n`
+ no_dir_str_len: equ $-no_dir_str
+ invalid_int_str: db "exit: Invalid integer",`\n`
invalid_int_str_len: equ $-invalid_int_str
;Flag indicating ability to execute
X_OK equ 0x1
@@ -431,12 +433,19 @@ _quit:
xor rdi, rdi
syscall
-;cd [dir]
+;cd [dir (rax)]
;changes to the given directory
_builtin_cd:
mov rdi,rax
mov rax, sys_chdir
syscall
+ cmp rax, 0
+ jz _read_loop
+ mov rax, sys_write
+ mov rdi, 0x1
+ mov rsi, no_dir_str
+ mov rdx, no_dir_str_len
+ syscall
jmp _read_loop
;usage: exit [status]
;exits with the given status or 0 if one hasn't been provided