summaryrefslogtreecommitdiff
path: root/sh.asm
diff options
context:
space:
mode:
authorfaissaloo <faissaloo@gmail.com>2016-06-26 14:44:36 +0100
committerfaissaloo <faissaloo@gmail.com>2016-06-26 14:44:36 +0100
commit040f747ed405dbcb26fe2a30771c4f1c35056fbc (patch)
tree7e7f609b7bfe575825c675e21dd0807f79e000c9 /sh.asm
parent49441d8b2043c9ae4381855e73a3880278ae39f0 (diff)
downloaddbsh-040f747ed405dbcb26fe2a30771c4f1c35056fbc.tar.gz
Added cd
Diffstat (limited to 'sh.asm')
-rw-r--r--sh.asm18
1 files changed, 16 insertions, 2 deletions
diff --git a/sh.asm b/sh.asm
index 4770cac..bc6bea8 100644
--- a/sh.asm
+++ b/sh.asm
@@ -28,6 +28,7 @@ section .data
sys_exit equ 0x3c
sys_wait4 equ 0x3d
sys_kill equ 0x3e
+ sys_chdir equ 0x50
sys_waitid equ 0xf7
@@ -262,10 +263,15 @@ _parse3:
je _parse4
;r15 holds the name that the user entered, so we'll use that for shell builtins
mov rcx,`\0\0\0exit\0`
- mov r13, [r15] ; Add exit codes later
- shl r13, 24 ;Remove the last character
+ mov r13, [r15]
+ shl r13, 24 ;Remove the last character, because it's an arg not the name of it
cmp r13, rcx
je _builtin_exit
+ mov rcx,`\0\0\0\0\0cd\0`
+ shl r13, 16 ;Remove the extra characters for cd, note how we're doing the
+ ;longest function names first then the shorter later
+ cmp r13, rcx
+ je _builtin_cd
;END OF BUILTINS
mov r13, r15
mov rcx, [r9+r8*8]
@@ -425,6 +431,14 @@ _quit:
xor rdi, rdi
syscall
+;cd [dir]
+;changes to the given directory
+_builtin_cd:
+ ;stub atm
+ mov rdi,rax
+ mov rax, sys_chdir
+ syscall
+ jmp _read_loop
;usage: exit [status]
;exits with the given status or 0 if one hasn't been provided
_builtin_exit: