Subversion Repositories SvarDOS

Rev

Rev 547 | Rev 576 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 547 Rev 548
Line 43... Line 43...
43
;     +2     4   address of command line to place at PSP:0080
43
;     +2     4   address of command line to place at PSP:0080
44
;     +6     4   address of an FCB to be placed at PSP:005c
44
;     +6     4   address of an FCB to be placed at PSP:005c
45
;    +0Ah    4   address of an FCB to be placed at PSP:006c
45
;    +0Ah    4   address of an FCB to be placed at PSP:006c
46
EXEC_PARAM_REC db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0   ; +5Ch
46
EXEC_PARAM_REC db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0   ; +5Ch
47
 
47
 
48
; Program to execute, preset by SvarCOM (128 bytes, ASCIIZ)  ; +6Ah
48
; Program to execute, preset by SvarCOM (128 bytes, ASCIIZ)
49
EXECPROG dd 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
49
EXECPROG: times 128 db 0                                     ; +6Ah
50
 
50
 
51
; offset within EXECPROG for out and in filenames in case stdin or stdout
-
 
52
; needs to be redirected (0xffff=no redirection)
51
; File where stdin and stdout should be redirected (0 = no redirection)
53
REDIR_OUTFIL dw 0xffff    ; +EAh
52
REDIR_INFIL:     times 128 db 0     ; +EAh
54
REDIR_INFIL dw 0xffff     ; +ECh
53
REDIR_OUTFIL:    times 128 db 0     ; +16Ah
55
REDIR_OUTAPPEND dw 0      ; +EEh
54
REDIR_OUTAPPEND: dw 0               ; +1EAh
56
 
55
 
57
; CTRL+BREAK (int 23h) handler
56
; CTRL+BREAK (int 23h) handler
58
; According to the TechHelp! Manual: "If you want to abort (exit to the parent
57
; According to the TechHelp! Manual: "If you want to abort (exit to the parent
59
; process), then set the carry flag and return via a FAR RET. This causes DOS
58
; process), then set the carry flag and return via a FAR RET. This causes DOS
60
; to perform normal cleanup and exit to the parent." (otherwise use iret)
59
; to perform normal cleanup and exit to the parent." (otherwise use iret)
61
BREAK_HANDLER:            ; +F0h
60
BREAK_HANDLER:            ; +1ECh
62
stc
61
stc
63
retf
62
retf
64
 
63
 
65
 
64
 
66
skipsig:                  ; +F2h
65
skipsig:                  ; +1EEh
67
 
66
 
68
; set up CS=DS=SS and point SP to my private stack buffer
67
; set up CS=DS=SS and point SP to my private stack buffer
69
mov ax, cs
68
mov ax, cs
70
mov ds, ax
69
mov ds, ax
71
mov es, ax
70
mov es, ax
Line 221... Line 220...
221
 
220
 
222
 
221
 
223
; ----------------------------------------------------------------------------
222
; ----------------------------------------------------------------------------
224
; redirect stdout if REDIR_OUTFIL points to something
223
; redirect stdout if REDIR_OUTFIL points to something
225
REDIR_INOUTFILE_IF_REQUIRED:
224
REDIR_INOUTFILE_IF_REQUIRED:
226
mov si, [REDIR_OUTFIL]
225
cmp [REDIR_OUTFIL], byte 0
227
cmp si, 0xffff
-
 
228
je NO_STDOUT_REDIR
226
je NO_STDOUT_REDIR
229
add si, EXECPROG       ; si=output file
227
mov si, REDIR_OUTFIL   ; si = output file
230
mov ax, 0x6c00         ; Extended Open/Create
228
mov ax, 0x6c00         ; Extended Open/Create
231
mov bx, 1              ; access mode (0=read, 1=write, 2=r+w)
229
mov bx, 1              ; access mode (0=read, 1=write, 2=r+w)
232
xor cx, cx             ; file attribs when(if) file is created (0=normal)
230
xor cx, cx             ; file attribs when(if) file is created (0=normal)
233
mov dx, [REDIR_OUTAPPEND] ; action if file exist (0x11=open, 0x12=truncate)
231
mov dx, [REDIR_OUTAPPEND] ; action if file exist (0x11=open, 0x12=truncate)
234
int 0x21               ; ax=handle on success (CF clear)
232
int 0x21               ; ax=handle on success (CF clear)
235
mov [REDIR_OUTFIL], word 0xffff
233
mov [REDIR_OUTFIL], byte 0
236
jc NO_STDOUT_REDIR     ; TODO: abort with an error message instead
234
jc NO_STDOUT_REDIR     ; TODO: abort with an error message instead
237
 
235
 
238
; jump to end of file if flag was 0x11 (required for >> redirections)
236
; jump to end of file if flag was 0x11 (required for >> redirections)
239
cmp [REDIR_OUTAPPEND], word 0x11
237
cmp [REDIR_OUTAPPEND], word 0x11
240
jne SKIP_JMPEOF
238
jne SKIP_JMPEOF
Line 263... Line 261...
263
mov ah, 0x3e           ; close a file handle (handle in BX)
261
mov ah, 0x3e           ; close a file handle (handle in BX)
264
int 0x21
262
int 0x21
265
NO_STDOUT_REDIR:
263
NO_STDOUT_REDIR:
266
 
264
 
267
; *** redirect stdin if REDIR_INFIL points to something ***
265
; *** redirect stdin if REDIR_INFIL points to something ***
268
mov dx, [REDIR_INFIL]
266
cmp [REDIR_INFIL], byte 0
269
cmp dx, 0xffff
-
 
270
je NO_STDIN_REDIR
267
je NO_STDIN_REDIR
271
add dx, EXECPROG       ; ds:dx=file
268
mov dx, REDIR_INFIL    ; dx:dx = file
272
mov ax, 0x3d00         ; open file for read
269
mov ax, 0x3d00         ; open file for read
273
int 0x21               ; ax=handle on success (CF clear)
270
int 0x21               ; ax=handle on success (CF clear)
274
mov [REDIR_INFIL], word 0xffff
271
mov [REDIR_INFIL], byte 0
275
jc NO_STDIN_REDIR      ; TODO: abort with an error message instead
272
jc NO_STDIN_REDIR      ; TODO: abort with an error message instead
276
 
273
 
277
; duplicate current stdin so I can revert it later
274
; duplicate current stdin so I can revert it later
278
push ax                ; save my file handle in stack
275
push ax                ; save my file handle in stack
279
mov ah, 0x45           ; duplicate file handle BX
276
mov ah, 0x45           ; duplicate file handle BX