From: Robert Pengelly Date: Wed, 14 Aug 2024 08:58:48 +0000 (+0100) Subject: Load programs only X-Git-Url: https://git.candlhat.org/?a=commitdiff_plain;h=c1e17503d12375aa2ce3e32fff0cf3d624f19f13;p=chimaera.git Load programs only --- diff --git a/build/chimaera.img b/build/chimaera.img index a28c536..b3e0a5e 100644 Binary files a/build/chimaera.img and b/build/chimaera.img differ diff --git a/build/chimaera.vhd b/build/chimaera.vhd index 2321841..26c7b5c 100644 Binary files a/build/chimaera.vhd and b/build/chimaera.vhd differ diff --git a/src/apps/hello/hello.asm b/src/apps/hello/hello.asm index 6180d5f..bba6775 100644 --- a/src/apps/hello/hello.asm +++ b/src/apps/hello/hello.asm @@ -1,4 +1,5 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + ;; @file hello.asm ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; %ifndef HEX @@ -16,8 +17,166 @@ global _main _main: +; mov ax, HEX (2522) +; mov dx, offset _int22_handler +; int HEX (21) + mov bx, offset _msg_hello call _writestr + +; mov bp, sp +; +; mov ax, bp +; call _writehex +; call _crlf +; +; mov ax, word ptr [bp] +; call _writehex +; call _crlf +; +; mov ax, word ptr [bp + 2] +; call _writehex +; call _crlf +; +; mov ax, word ptr [bp + 4] +; call _writehex +; call _crlf +; +; mov ax, word ptr [bp + 6] +; call _writehex +; call _crlf +; +; cli +; hlt +; +; mov ah, HEX (62) +; int HEX (21) +; +; mov ax, bx +; call _writehex +; call _crlf +; +; mov ax, ss +; call _writehex +; call _crlf +; +; mov ax, sp +; call _writehex +; call _crlf +; +; mov bp, sp +; +; mov ax, [bp] +; call _writehex +; call _crlf +; +; mov ax, HEX (4B01) +; mov bx, offset _param_blk +; mov dx, offset _app_name +; int HEX (21) +; +; mov ah, HEX (62) +; int HEX (21) +; +; mov ax, bx +; call _writehex +; call _crlf +; +; mov ax, ss +; call _writehex +; call _crlf +; +; mov ax, sp +; call _writehex +; call _crlf +; +; call _writehex +; call _crlf +; +; mov bp, sp +; +; mov ax, bp +; call _writehex +; call _crlf +; +; mov ax, word ptr [bp] +; call _writehex +; call _crlf +; +; mov ax, word ptr [bp + 2] +; call _writehex +; call _crlf +; +; mov ax, word ptr [bp + 4] +; call _writehex +; call _crlf +; +; mov ax, word ptr [bp + 6] +; call _writehex +; call _crlf +; +; mov bp, sp +; +; mov ax, [bp + 0] +; call _writehex +; call _crlf +; +; mov ax, [bp + 2] +; call _writehex +; call _crlf +; +; mov ax, [bp + 4] +; call _writehex +; call _crlf +; +; mov bx, offset _param_blk +; mov cx, 11 +; +;.loop: +; +; mov ax, es:[bx] +; call _writehex +; call _crlf +; +; add bx, 2 +; loop .loop +; +; call _writehex +; call _crlf + +; mov ax, cs +; call _writehex +; call _crlf +; +; mov ax, es:[bx + 18] +; call _writehex +; call _crlf +; +; mov ah, HEX (62) +; int HEX (21) +; +; mov ax, bx +; call _writehex +; call _crlf +; +; xor ax, ax +; int 0x16 +; +; mov ax, es:[bx + 14] +; call _writehex +; call _crlf +; +; mov ax, es:[bx + 16] +; call _writehex +; call _crlf +; +; mov ax, es:[bx + 18] +; call _writehex +; call _crlf +; +; mov ax, es:[bx + 20] +; call _writehex +; call _crlf ;.console_loop: ; @@ -322,6 +481,12 @@ _main: .exit: +; mov bx, offset _msg_any_key +; call _writestr +; +; xor ax, ax +; int 0x16 + xor ax, ax ret @@ -338,3 +503,7 @@ _msg_hello: db "Hello, world!", HEX (0D), HEX ;_flags: db "w+b", HEX (00) ;_buffer: db 512 dup (0) ;_to_write: dw HEX (0000) +;_app_name: db "\\command.com", HEX (00) +;_param_blk: db 22 dup (0) +; +;_msg_any_key: db "Press any key to exit...", HEX (0D), HEX (0A), HEX (00) diff --git a/src/kernel/int21.asm b/src/kernel/int21.asm index 257d2b7..2b2e5e1 100644 --- a/src/kernel/int21.asm +++ b/src/kernel/int21.asm @@ -647,12 +647,10 @@ _int21_dispatch.check: _int21_dispatch.no_key: cld ; Make sure direction flag is always clean + push bx push bp - ;mov bp, sp - ;mov word ptr [bp + 2], bx - mov bp, offset _int21_dispatch.list mov bx, offset _int21_dispatch.list_end @@ -941,6 +939,12 @@ _int21_dispatch.list: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;db HEX (5B) ;dw _int21_5B + + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + ;; Get PSP Address. + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + db HEX (62) + dw _int21_62 _int21_dispatch.list_end: @@ -3976,8 +3980,8 @@ _int21_4A: ;****************************************************************************** _int21_4B: - and al, al - jz _int21_4B.arg_ok + cmp al, 1 + jbe _int21_4B.arg_ok mov ax, 1 stc @@ -3987,13 +3991,15 @@ _int21_4B: _int21_4B.arg_ok: push bp + mov bp, sp + + push ds push bx push cx push dx push si push di push es - push ds push ax push bx @@ -4040,16 +4046,17 @@ _int21_4B.disk_error: _int21_4B.error: - pop ds pop es pop di pop si pop dx pop cx pop bx - pop bp + pop ds + pop bp stc + jmp iretc _int21_4B.load_ok: @@ -4079,9 +4086,7 @@ _int21_4B.copy_cmd_line: and bl, bl jz _int21_4B.start - mov ax, cs mov ds, ax - add di, 14 mov ax, cs:[_child_sssp] @@ -4096,28 +4101,45 @@ _int21_4B.copy_cmd_line: mov ax, cs:[_child_csip + 2] stosw - jmp short _int21_4B.ret_ok + pop es + pop di + pop si + pop dx + pop cx + + lea bx, [bp + 8] + mov [HEX (42)], bx + + mov [HEX (44)], ss + + pop bx + pop ds + pop bp + + mov ax, HEX (0100) + clc + + jmp iretc _int21_4B.start: + push cs call _start_program mov al, cs:[_last_ret_val] -_int21_4B.ret_ok: - - clc - _int21_4B.done: - pop ds pop es pop di pop si pop dx pop cx pop bx + pop ds + pop bp + clc jmp iretc @@ -4259,12 +4281,7 @@ _int21_4C.done: mov cs:[_curr_psp], bx call _free_mem - - xor bx, bx - mov es, bx - - mov bx, HEX (22) * 4 - jmp far ptr es:[bx] + retf ;****************************************************************************** ; @function _int21_4E @@ -4754,3 +4771,12 @@ _int21_4F.error: stc jmp iretc + +;****************************************************************************** +; @function _int21_62 +; @brief Get PSP Address +;****************************************************************************** +_int21_62: + + mov bx, cs:[_curr_psp] + iret diff --git a/src/kernel/kernel.asm b/src/kernel/kernel.asm index 331a054..70afdd2 100644 --- a/src/kernel/kernel.asm +++ b/src/kernel/kernel.asm @@ -852,7 +852,7 @@ _setup_interrupts: _app_errmsg: db "Bad or missing Command Interpreter", HEX (00) _app_name: db "\\command.com", HEX (00) -_param_blk: db 16 dup (0) +_param_blk: db 22 dup (0) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Data area. diff --git a/src/kernel/prog.asm b/src/kernel/prog.asm index 6e76d5a..9c42bbe 100644 --- a/src/kernel/prog.asm +++ b/src/kernel/prog.asm @@ -122,15 +122,13 @@ _load_program.got_size: _load_program.no_mem: - push ax - mov ax, cs mov ds, ax mov bx, offset _load_program.errmsg call _writestr - pop ax + mov ax, 8 jmp _load_program.error _load_program.mem_ok: @@ -352,12 +350,11 @@ _start_program: cli mov ds, ax - - mov [HEX (42)], sp - mov [HEX (44)], ss - mov es, ax + mov es:[HEX (42)], sp + mov es:[HEX (44)], ss + mov ss, cs:[_child_sssp + 2] mov sp, cs:[_child_sssp] @@ -377,7 +374,6 @@ _start_program: push si iret - ret ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Data area. diff --git a/src/lib/crt/crt0.asm b/src/lib/crt/crt0.asm index 7b22d2d..7e9ecfe 100644 --- a/src/lib/crt/crt0.asm +++ b/src/lib/crt/crt0.asm @@ -157,6 +157,8 @@ _start: mov ah, HEX (4C) int HEX (21) + + jmp .L6 ;****************************************************************************** ; @function _get_args