Subversion Repositories SvarDOS

Rev

Rev 350 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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