From: Robert Pengelly Date: Wed, 25 Sep 2024 12:07:29 +0000 (+0100) Subject: Execute from PATH when not found in current directory X-Git-Url: https://git.candlhat.org/?a=commitdiff_plain;h=19d949dea229872cdd0d1a97d3e002fc63cf3866;p=chimaera.git Execute from PATH when not found in current directory --- diff --git a/build/chimaera.img b/build/chimaera.img index ee94743..79c30fd 100644 Binary files a/build/chimaera.img and b/build/chimaera.img differ diff --git a/build/chimaera.vhd b/build/chimaera.vhd index f07d833..7c92d87 100644 Binary files a/build/chimaera.vhd and b/build/chimaera.vhd differ diff --git a/src/Makefile.unix b/src/Makefile.unix index db0dd9c..be37d93 100644 --- a/src/Makefile.unix +++ b/src/Makefile.unix @@ -30,7 +30,9 @@ chimaera.img: all utils/dosfstools/mcopy -i $@ boot/freeldr/core/freeldr.sys :: utils/dosfstools/mcopy -i $@ kernel/kernel.sys :: utils/dosfstools/mcopy -i $@ apps/pcomm/pcomm.com ::command.com -# utils/dosfstools/mcopy -i $@ apps/hello/hello.com ::hello.com + +# utils/dosfstools/mmd -i $@ dos +# utils/dosfstools/mcopy -i $@ apps/hello/hello.com ::dos/hello.com chimaera.vhd: all if [ -f $@ ]; then rm -rf $@; fi diff --git a/src/apps/hello/hello.asm b/src/apps/hello/hello.asm index 66c03e0..c6eb2cf 100644 --- a/src/apps/hello/hello.asm +++ b/src/apps/hello/hello.asm @@ -24,14 +24,14 @@ _main: mov bx, offset _msg_hello call _writestr -.L1: - - mov ah, HEX (02) - mov dl, 'A' - int HEX (21) - - jmp .L1 - +;.L1: +; +; mov ah, HEX (02) +; mov dl, 'A' +; int HEX (21) +; +; jmp .L1 +; ; mov bp, sp ; ; mov ax, bp diff --git a/src/apps/pcomm/path.asm b/src/apps/pcomm/path.asm index f540a52..d1aaa6a 100644 --- a/src/apps/pcomm/path.asm +++ b/src/apps/pcomm/path.asm @@ -372,10 +372,214 @@ _handler_path.done: pop ax ret +;****************************************************************************** +; @function _get_paths +;****************************************************************************** +global _get_paths +_get_paths: + + push ax + push bx + push cx + push dx + push si + push di + push es + push ds + + mov ax, cs:[_vec_paths] + + and ax, ax + jz _get_paths.clear + + push ax + + call _free + add sp, 2 + + xor ax, ax + mov cs:[_vec_paths], ax + +_get_paths.clear: + + mov di, offset _vec_paths + xor al, al + + mov cx, 6 + rep stosb + + mov si, cs:[_vec_env] + mov cx, cs:[_vec_env + 4] + + mov es, si + xor di, di + +_get_paths.find: + + and cx, cx + jz _get_paths.done + + push es + mov ax, es:[di] + + mov es, ax + push es + + xor bx, bx + mov ax, es:[bx] + + push cx + push es + push ds + + mov cx, ds + mov es, cx + mov ds, ax + + push es + push di + + mov di, offset _temp + xor al, al + + mov cx, 255 + rep stosb + + pop di + pop es + + xor ax, ax + push ax + + mov ax, offset _temp + push ax + + call _strcpy + add sp, 4 + + pop ds + + mov ax, ds + mov es, ax + + mov ax, offset _var + push ax + + mov ax, offset _temp + push ax + + call _strcmp + add sp, 4 + + pop es + pop cx + + and ax, ax + jz _get_paths.found + + pop ax + pop es + + add di, 2 + dec cx + + jmp _get_paths.find + +_get_paths.found: + + pop si + pop es + + mov es, si + xor bx, bx + + mov ax, es:[bx + 2] + + and ax, ax + jz _get_paths.done + + push cx + push es + push ds + + mov cx, ds + mov es, cx + mov ds, ax + + push es + push di + + mov di, offset _temp + xor al, al + + mov cx, 255 + rep stosb + + pop di + pop es + + xor ax, ax + push ax + + mov ax, offset _temp + push ax + + call _strcpy + add sp, 4 + + pop ds + pop es + pop cx + + mov di, offset _temp + xor bx, bx + + mov ax, ds + mov es, ax + +_get_paths.loop: + + push di + + mov ax, offset _vec_paths + push ax + + call _vec_push + add sp, 4 + + mov ax, ';' + push ax + + push di + + call _strchr + add sp, 4 + + and ax, ax + jz _get_paths.done + + mov di, ax + + xor al, al + stosb + + jmp _get_paths.loop + +_get_paths.done: + + pop ds + pop es + pop di + pop si + pop dx + pop cx + pop bx + pop ax + ret + ;****************************************************************************** ; @function _skip_whitespace ;****************************************************************************** -global _skip_whitespace _skip_whitespace: cmp byte ptr [bx], 0 diff --git a/src/apps/pcomm/pcomm.asm b/src/apps/pcomm/pcomm.asm index 9a59251..8e01127 100644 --- a/src/apps/pcomm/pcomm.asm +++ b/src/apps/pcomm/pcomm.asm @@ -1356,6 +1356,8 @@ _main: xor al, al stosb + push bx + mov dx, offset _app_path inc bx mov di, bx @@ -1367,8 +1369,79 @@ _main: mov ax, HEX (4B00) int HEX (21) + pop bx jnc .L5 + mov ax, '\\' + push ax + + mov ax, offset _app_path + push ax + + call _strrchr + add sp, 4 + + and ax, ax + jnz .L98 + +.L99: + + call _get_paths + + push ax + push bx + push cx + push di + push es + + mov ax, cs:[_vec_paths] + mov es, ax + mov cx, cs:[_vec_paths + 4] + + xor di, di + +.L96: + + and cx, cx + jz .L97 + + mov ax, offset _app_path + push ax + + mov ax, es:[di] + push ax + + call _concat_exec + jnc .L100 + add sp, 4 + + add di, 2 + dec cx + + jmp .L96 + +.L100: + + add sp, 4 + + pop es + pop di + pop cx + pop bx + pop ax + + jmp .L5 + +.L97: + + pop es + pop di + pop cx + pop bx + pop ax + +.L98: + mov bx, offset _err_invalid call _writestr @@ -1543,6 +1616,60 @@ _main: jmp .L11 +;****************************************************************************** +; @function _concat_exec +;****************************************************************************** +_concat_exec: + + push bp + mov bp, sp + + push ax + push bx + push cx + push dx + push si + push di + push es + + mov ax, ds + mov es, ax + + mov di, offset _full_path + + mov si, word ptr [bp + 4] + call _format_path + + mov al, '\\' + stosb + + mov si, word ptr [bp + 6] + call _format_path + + mov dx, offset _full_path + inc bx + mov di, bx + + mov bx, offset _param_blk + + mov word ptr [bx + 2], di + mov word ptr [bx + 4], ds + + mov ax, HEX (4B00) + int HEX (21) + +_concat_exec.done: + + pop es + pop di + pop si + pop dx + pop cx + pop bx + pop ax + pop bp + ret + ;****************************************************************************** ; @function _get_env ;****************************************************************************** @@ -2241,9 +2368,11 @@ _scratch: db 257 dup (0) ;; Variables for executing application. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;_formatted_cmd: db 255 dup (0) -_app_path: db 255 dup (0) +_app_path: db 256 dup (0) _param_blk: db 16 dup (0) +_full_path: db 256 dup (0) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Error messages. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -2268,6 +2397,9 @@ _vec_history: db 6 dup (0) global _vec_env _vec_env: db 6 dup (0) +global _vec_paths +_vec_paths: db 6 dup (0) + global _curr_row _curr_row: db HEX (00) diff --git a/src/apps/pcomm/set.asm b/src/apps/pcomm/set.asm index ff64a39..95049ec 100644 --- a/src/apps/pcomm/set.asm +++ b/src/apps/pcomm/set.asm @@ -354,7 +354,6 @@ _handler_set.done: ;****************************************************************************** ; @function _skip_whitespace ;****************************************************************************** -global _skip_whitespace _skip_whitespace: cmp byte ptr [bx], 0