Subversion Repositories SvarDOS

Rev

Rev 1713 | Rev 1846 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1713 Rev 1730
Line 1... Line 1...
1
;
1
;
2
; rmod - resident module of the SvarCOM command interpreter (NASM code)
2
; rmod - resident module of the SvarCOM command interpreter (NASM code)
3
;
3
;
4
; Copyright (C) 2021-2022 Mateusz Viste
4
; Copyright (C) 2021-2024 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.
Line 63... Line 63...
63
REDIR_DEL_STDIN: db 0               ; +270h  indicates that the stdin file
63
REDIR_DEL_STDIN: db 0               ; +270h  indicates that the stdin file
64
                                    ;        should be deleted (pipes). This
64
                                    ;        should be deleted (pipes). This
65
                                    ;        MUST contain the 1st char of
65
                                    ;        MUST contain the 1st char of
66
                                    ;        REDIR_INFIL!
66
                                    ;        REDIR_INFIL!
67
 
67
 
-
 
68
EXEC_LH: db 0                       ; +271h  EXECPROG to be loaded high?
-
 
69
ORIG_UMBLINKSTATE: db 0             ; +272h
-
 
70
ORIG_ALLOCSTRAT: db 0               ; +273h
-
 
71
 
68
; CTRL+BREAK (int 23h) handler
72
; CTRL+BREAK (int 23h) handler
69
; According to the TechHelp! Manual: "If you want to abort (exit to the parent
73
; According to the TechHelp! Manual: "If you want to abort (exit to the parent
70
; process), then set the carry flag and return via a FAR RET. This causes DOS
74
; process), then set the carry flag and return via a FAR RET. This causes DOS
71
; to perform normal cleanup and exit to the parent." (otherwise use iret)
75
; to perform normal cleanup and exit to the parent." (otherwise use iret)
72
BREAK_HANDLER:            ; +271h
76
BREAK_HANDLER:            ; +274h
73
stc
77
stc
74
retf
78
retf
75
 
79
 
76
; INT 0x2E handler
80
; INT 0x2E handler
77
INT2E:
81
INT2E:
78
xor ax, ax
82
xor ax, ax
79
iret
83
iret
80
 
84
 
81
skipsig:                  ; +276h
85
skipsig:                  ; +279h
82
 
86
 
83
; set up CS=DS=SS and point SP to my private stack buffer
87
; set up CS=DS=SS and point SP to my private stack buffer
84
mov ax, cs
88
mov ax, cs
85
mov ds, ax
89
mov ds, ax
86
mov es, ax
90
mov es, ax
Line 111... Line 115...
111
;       int 21h, ah=50h call freezes...
115
;       int 21h, ah=50h call freezes...
112
;mov ah, 0x50           ; DOS 2+ -- Set PSP
116
;mov ah, 0x50           ; DOS 2+ -- Set PSP
113
;mov bx, cs
117
;mov bx, cs
114
;int 0x21
118
;int 0x21
115
 
119
 
-
 
120
 
-
 
121
; LOADHIGH?
-
 
122
cmp [EXEC_LH], byte 0
-
 
123
je NO_LOADHIGH
-
 
124
; SAVE CURRENT UMB LINK STATE
-
 
125
mov ax, 0x5802  ; GET UMB LINK STATE
-
 
126
int 0x21
-
 
127
mov [ORIG_UMBLINKSTATE], al
-
 
128
; SAVE CURRENT ALLOCATION STRATEGY
-
 
129
mov ax, 0x5800
-
 
130
int 0x21
-
 
131
mov [ORIG_ALLOCSTRAT], al
-
 
132
 
-
 
133
; LOADHIGH: link in the UMB memory chain for enabling high-memory allocation
-
 
134
;           (and save initial status on stack)
-
 
135
mov ax, 0x5803  ; SET UMB LINK STATE */
-
 
136
mov bx, 1
-
 
137
int 0x21
-
 
138
; set strategy to 'last fit, try high then low memory'
-
 
139
mov ax, 0x5801
-
 
140
mov bx, 0x0082
-
 
141
int 0x21
-
 
142
NO_LOADHIGH:
-
 
143
 
116
; exec an application preset (by SvarCOM) in the ExecParamRec
144
; exec an application preset (by SvarCOM) in the ExecParamRec
117
mov ax, 0x4B00         ; DOS 2+ - load & execute program
145
mov ax, 0x4B00         ; DOS 2+ - load & execute program
118
mov dx, EXECPROG       ; DS:DX  - ASCIZ program name (preset at PSP[already)
146
mov dx, EXECPROG       ; DS:DX  - ASCIZ program name (preset at PSP[already)
119
mov bx, EXEC_PARAM_REC ; ES:BX  - parameter block pointer
147
mov bx, EXEC_PARAM_REC ; ES:BX  - parameter block pointer
120
int 0x21
148
int 0x21
121
mov [cs:EXECPROG], byte 0 ; do not run app again (+DS might have been changed)
149
mov [cs:EXECPROG], byte 0 ; do not run app again (+DS might have been changed)
122
 
150
 
-
 
151
; go to start if nothing else to do (this will enforce valid ds/ss/etc)
-
 
152
cmp [cs:EXEC_LH], byte 0
-
 
153
je skipsig
-
 
154
 
-
 
155
; restore UMB link state and alloc strategy to original values (but make sure
-
 
156
; to base it on CS since DS might have been trashed by the program)
-
 
157
mov ax, 0x5803
-
 
158
xor bx, bx
-
 
159
mov bl, [cs:ORIG_UMBLINKSTATE]
-
 
160
int 0x21
-
 
161
; restore original memory allocation strategy
-
 
162
mov ax, 0x5801
-
 
163
mov bl, [cs:ORIG_ALLOCSTRAT]
-
 
164
int 0x21
-
 
165
; turn off the LH flag
-
 
166
mov [cs:EXEC_LH], byte 0
-
 
167
 
-
 
168
 
123
jmp short skipsig      ; enforce valid ds/ss/etc (can be lost after int 21,4b)
169
jmp skipsig      ; enforce valid ds/ss/etc (can be lost after int 21,4b)
124
 
170
 
125
EXEC_COMMAND_COM:
171
EXEC_COMMAND_COM:
126
 
172
 
127
; collect the exit code of previous application
173
; collect the exit code of previous application
128
mov ah, 0x4D
174
mov ah, 0x4D
Line 134... Line 180...
134
mov cx, 14             ; how many times
180
mov cx, 14             ; how many times
135
mov di, EXEC_PARAM_REC ; ES:DI = destination
181
mov di, EXEC_PARAM_REC ; ES:DI = destination
136
cld                    ; stosb must move forward
182
cld                    ; stosb must move forward
137
rep stosb              ; repeat cx times
183
rep stosb              ; repeat cx times
138
 
184
 
-
 
185
; zero out the LH flag
-
 
186
mov [EXEC_LH], byte 0
-
 
187
 
139
; preset the default COMSPEC pointer to ES:DX (ES is already set to DS)
188
; preset the default COMSPEC pointer to ES:DX (ES is already set to DS)
140
mov dx, COMSPECBOOT
189
mov dx, COMSPECBOOT
141
 
190
 
142
; do I have a valid COMSPEC?
191
; do I have a valid COMSPEC?
143
or [COMSPECPTR], word 0
192
or [COMSPECPTR], word 0