;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
;; @file hello.asm
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
%ifndef HEX
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:
;
.exit:
+; mov bx, offset _msg_any_key
+; call _writestr
+;
+; xor ax, ax
+; int 0x16
+
xor ax, ax
ret
;_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)
_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
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;db HEX (5B)
;dw _int21_5B
+
+ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+ ;; Get PSP Address.
+ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+ db HEX (62)
+ dw _int21_62
_int21_dispatch.list_end:
;******************************************************************************
_int21_4B:
- and al, al
- jz _int21_4B.arg_ok
+ cmp al, 1
+ jbe _int21_4B.arg_ok
mov ax, 1
stc
_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
_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:
and bl, bl
jz _int21_4B.start
- mov ax, cs
mov ds, ax
-
add di, 14
mov ax, cs:[_child_sssp]
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
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
stc
jmp iretc
+
+;******************************************************************************
+; @function _int21_62
+; @brief Get PSP Address
+;******************************************************************************
+_int21_62:
+
+ mov bx, cs:[_curr_psp]
+ iret
_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.
_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:
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]
push si
iret
- ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Data area.
mov ah, HEX (4C)
int HEX (21)
+
+ jmp .L6
;******************************************************************************
; @function _get_args