Subversion Repositories SvarDOS

Rev

Rev 350 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
349 mateuszvis 1
;
2
; rmod - resident module of the SvarCOM command interpreter
3
;
4
; Copyright (C) 2021 Mateusz Viste
5
; MIT license
6
;
7
; this is installed in memory by the transient part of SvarCOM. it has only
8
; two jobs: providing a resident buffer for command history, environment, etc
9
; and respawning COMMAND.COM whenever necessary.
10
 
11
CPU 8086
12
org 0h           ; this is meant to be executed without a PSP
13
 
14
section .text    ; all goes into code segment
15
 
16
jmp short skipsig
17
 
18
SIG1 dw 0x1983
19
SIG2 dw 0x1985
20
SIG3 dw 0x2017
21
SIG4 dw 0x2019
22
 
23
; service routine: used by the transient part of svarcom, returns:
24
; AX = offset of input buffer history block
25
; BX = offset where environment's segment is stored (patched at install time)
26
inputroutine:
27
mov ax, BUF000
28
mov bx, ENVSEG
29
retf
30
 
31
skipsig:
32
 
33
; set up CS=DS=SS and point SP to my private stack buffer
34
mov ax, cs
35
mov ds, ax
36
mov es, ax
37
mov ss, ax
38
mov sp, STACKPTR
39
 
40
; prepare the exec param block
41
;mov [EXEC_PARAM_REC], word 0
42
mov ax, COMSPEC
43
mov [EXEC_PARAM_REC+2], ax
44
mov [EXEC_PARAM_REC+4], ds
45
 
46
; execute command.com
47
mov ax, 0x4B00         ; DOS 2+ - load & execute program
48
mov dx, COMSPEC        ; DS:DX  - ASCIZ program name TODO: use real COMSPEC...
49
mov bx, EXEC_PARAM_REC ; ES:BX  - parameter block pointer
50
int 0x21
51
 
52
; if all went well, jump back to start
53
jnc skipsig
54
 
55
; update error string so it contains the error number
56
add al, '0'
57
mov [ERRLOAD + 4], al
58
 
59
; display error message (with trailing COMSPEC)
60
mov ah, 0x09
61
mov dx, ERRLOAD
62
mov [COMSPCZ], byte '$' ; patch comspec terminator to be $
63
int 0x21
64
mov [COMSPCZ], byte 0   ; restore initial (NULL) compsec terminator
65
 
66
; wait for keypress
67
mov ah, 0x08
68
int 0x21
69
 
70
; back to program start
71
jmp skipsig
72
 
73
; ExecParamRec used by INT 21h, AX=4b00 (load and execute program), 14 bytes:
74
;  offset  size  content
75
;     +0     2   segment of environment for child (0 = current)
76
;     +2     4   address of command line to place at PSP:0080
77
;     +6     4   address of an FCB to be placed at PSP:005c
78
;    +0Ah    4   address of an FCB to be placed at PSP:006c
79
EXEC_PARAM_REC db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
80
 
81
ERRLOAD db "ERR x, FAILED TO LOAD COMMAND.COM FROM:", 13, 10
82
 
83
COMSPEC db "C:\SVN\SVARDOS\SVARCOM\COMMAND.COM"
84
COMSPCZ db 0
85
 
86
; input buffer used for the "previous command" history
87
BUF000 db 128, 0
88
BUF064 db "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF"
89
BUF128 db "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF"
90
 
91
; FreeDOS int 21h functions that I use require at least 32 bytes of stack,
92
; here I allocate 64 bytes to be sure
93
STACKBUF db "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF"
94
STACKPTR db "xx"
95
 
96
; environment segment - this is updated by SvarCOM at init time
97
ENVSEG   dw 0