Subversion Repositories SvarDOS

Rev

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

Rev 353 Rev 366
Line 28... Line 28...
28
; input buffer used for the "previous command" history
28
; input buffer used for the "previous command" history
29
BUF000 db 128, 0 ; +0Ch
29
BUF000 db 128, 0 ; +0Ch
30
BUF064 db "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF"
30
BUF064 db "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF"
31
BUF128 db "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF"
31
BUF128 db "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF"
32
 
32
 
-
 
33
; offset of the COMSPEC variable in the environment block, 0 means "use
-
 
34
; boot drive". this value is patched by the transient part of COMMAND.COM
-
 
35
COMSPECPTR dw 0  ; +8Eh
-
 
36
 
-
 
37
; fallback COMSPEC string used if no COMPSEC is present in the environment
-
 
38
; drive. drive is patched by the transient part of COMMAND.COM
-
 
39
COMSPECBOOT db "@:\COMMAND.COM", 0 ; +90h
33
 
40
 
34
skipsig:         ; +8Eh
41
skipsig:         ; +9Fh
35
 
42
 
36
; set up CS=DS=SS and point SP to my private stack buffer
43
; set up CS=DS=SS and point SP to my private stack buffer
37
mov ax, cs
44
mov ax, cs
38
mov ds, ax
45
mov ds, ax
39
mov es, ax
46
mov es, ax
Line 44... Line 51...
44
mov ah, 0x4D
51
mov ah, 0x4D
45
int 0x21
52
int 0x21
46
xor ah, ah          ; clear out termination status, I only want the exit code
53
xor ah, ah          ; clear out termination status, I only want the exit code
47
mov [LEXCODE], ax
54
mov [LEXCODE], ax
48
 
55
 
-
 
56
; preset the default COMSPEC pointer to ES:DX (ES is already set to DS)
-
 
57
mov dx, COMSPECBOOT
-
 
58
 
-
 
59
; do I have a valid COMSPEC?
-
 
60
or [COMSPECPTR], word 0
-
 
61
jz USEDEFAULTCOMSPEC
-
 
62
; set ES:DX to actual COMSPEC
-
 
63
mov es, [ENVSEG]
-
 
64
mov dx, [COMSPECPTR]
-
 
65
USEDEFAULTCOMSPEC:
-
 
66
 
49
; prepare the exec param block
67
; prepare the exec param block
50
mov ax, [ENVSEG]
68
mov ax, [ENVSEG]
51
mov [EXEC_PARAM_REC], ax
69
mov [EXEC_PARAM_REC], ax
52
mov ax, COMSPEC
-
 
53
mov [EXEC_PARAM_REC+2], ax
70
mov [EXEC_PARAM_REC+2], dx
54
mov [EXEC_PARAM_REC+4], ds
71
mov [EXEC_PARAM_REC+4], es
55
 
72
 
56
; execute command.com
73
; execute command.com
57
mov ax, 0x4B00         ; DOS 2+ - load & execute program
74
mov ax, 0x4B00         ; DOS 2+ - load & execute program
-
 
75
push es                ;
-
 
76
pop ds                 ;
58
mov dx, COMSPEC        ; DS:DX  - ASCIZ program name TODO: use real COMSPEC...
77
;mov dx, COMSPEC       ; DS:DX  - ASCIZ program name (preset already)
-
 
78
push cs
-
 
79
pop es
59
mov bx, EXEC_PARAM_REC ; ES:BX  - parameter block pointer
80
mov bx, EXEC_PARAM_REC ; ES:BX  - parameter block pointer
60
int 0x21
81
int 0x21
61
 
82
 
62
; if all went well, jump back to start
83
; if all went well, jump back to start
63
jnc skipsig
84
jnc skipsig
64
 
85
 
-
 
86
; restore DS=CS
-
 
87
mov bx, cs
-
 
88
mov ds, bx
-
 
89
 
65
; update error string so it contains the error number
90
; update error string so it contains the error number
66
add al, '0'
91
add al, '0'
67
mov [ERRLOAD + 4], al
92
mov [ERRLOAD + 4], al
68
 
93
 
69
; display error message (with trailing COMSPEC)
94
; display error message
70
mov ah, 0x09
95
mov ah, 0x09
71
mov dx, ERRLOAD
96
mov dx, ERRLOAD
72
mov [COMSPCZ], byte '$' ; patch comspec terminator to be $
-
 
73
int 0x21
97
int 0x21
74
mov [COMSPCZ], byte 0   ; restore initial (NULL) compsec terminator
-
 
75
 
98
 
76
; wait for keypress
99
; wait for keypress
77
mov ah, 0x08
100
mov ah, 0x08
78
int 0x21
101
int 0x21
79
 
102
 
Line 86... Line 109...
86
;     +2     4   address of command line to place at PSP:0080
109
;     +2     4   address of command line to place at PSP:0080
87
;     +6     4   address of an FCB to be placed at PSP:005c
110
;     +6     4   address of an FCB to be placed at PSP:005c
88
;    +0Ah    4   address of an FCB to be placed at PSP:006c
111
;    +0Ah    4   address of an FCB to be placed at PSP:006c
89
EXEC_PARAM_REC db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
112
EXEC_PARAM_REC db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
90
 
113
 
91
ERRLOAD db "ERR x, FAILED TO LOAD COMMAND.COM FROM:", 13, 10
114
ERRLOAD db "ERR x, FAILED TO LOAD COMMAND.COM", 13, 10, '$'
92
 
-
 
93
COMSPEC db "C:\SVN\SVARDOS\SVARCOM\COMMAND.COM"
-
 
94
COMSPCZ db 0
-
 
95
 
115
 
96
; FreeDOS int 21h functions that I use require at least 32 bytes of stack,
116
; DOS int 21h functions that I use require at least 32 bytes of stack, here I
97
; here I allocate 64 bytes to be sure
117
; allocate 64 bytes to be sure
98
STACKBUF db "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF"
118
STACKBUF db "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF"
99
STACKPTR db "xx"
119
STACKPTR db "xx"