Subversion Repositories SvarDOS

Compare Revisions

Ignore whitespace Rev 459 → Rev 460

/svarcom/trunk/rmod.asm
21,8 → 21,10
SIG3 dw 0x2017 ; +4
SIG4 dw 0x2019 ; +6
 
; environment segment - this is updated by SvarCOM at init time
ENVSEG dw 0 ; +8
; offset where a program name to be executed is awaiting (0=none)
; this is set by SvarCOM, after it presets the ExecParamRec struct and
; stores the command to be executed somewhere within rmod's segment.
EXECPROG dw 0 ; +8
 
; exit code of last application
LEXCODE dw 0 ; +0Ah
35,8 → 37,16
; drive. drive is patched by the transient part of COMMAND.COM
COMSPECBOOT db "@:\COMMAND.COM", 0 ; +0Eh
 
skipsig: ; +1Dh
; ExecParamRec used by INT 21h, AX=4b00 (load and execute program), 14 bytes:
; offset size content
; +0 2 segment of environment for child (0 = current)
; +2 4 address of command line to place at PSP:0080
; +6 4 address of an FCB to be placed at PSP:005c
; +0Ah 4 address of an FCB to be placed at PSP:006c
EXEC_PARAM_REC db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ; +1Dh
 
skipsig: ; +2Bh
 
; set up CS=DS=SS and point SP to my private stack buffer
mov ax, cs
mov ds, ax
44,6 → 54,21
mov ss, ax
mov sp, STACKPTR
 
; should I executed command.com or a pre-set application?
or [EXECPROG], byte 0
jz EXEC_COMMAND_COM
 
; TODO: most probably I should call the DOS SetPSP function here
 
; exec an application preset (by SvarCOM) in the ExecParamRec
mov [EXECPROG], byte 0 ; make sure to spawn command.com after app exits
mov ax, 0x4B00 ; DOS 2+ - load & execute program
mov dx, [EXECPROG] ; DS:DX - ASCIZ program name (preset at PSP[already)
mov bx, EXEC_PARAM_REC ; ES:BX - parameter block pointer
int 0x21
 
EXEC_COMMAND_COM:
 
; collect the exit code of previous application
mov ah, 0x4D
int 0x21
50,6 → 75,13
xor ah, ah ; clear out termination status, I only want the exit code
mov [LEXCODE], ax
 
; zero out the exec param block (14 bytes)
mov al, 0 ; byte to write
mov cx, 14 ; how many times
mov di, EXEC_PARAM_REC ; ES:DI = destination
cld ; stosb must move forward
rep stosb ; repeat cx times
 
; preset the default COMSPEC pointer to ES:DX (ES is already set to DS)
mov dx, COMSPECBOOT
 
101,17 → 133,10
; back to program start
jmp skipsig
 
; command.com tail arguments, in PSP format (length byte followed by arg)
CMDTAIL db 0
; command.com tail arguments, in PSP format: length byte followed by args and
; terminated with \r)
CMDTAIL db 0x00, 0x0D
 
; ExecParamRec used by INT 21h, AX=4b00 (load and execute program), 14 bytes:
; offset size content
; +0 2 segment of environment for child (0 = current)
; +2 4 address of command line to place at PSP:0080
; +6 4 address of an FCB to be placed at PSP:005c
; +0Ah 4 address of an FCB to be placed at PSP:006c
EXEC_PARAM_REC db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
 
ERRLOAD db "ERR x, FAILED TO LOAD COMMAND.COM", 13, 10, '$'
 
; DOS int 21h functions that I use require at least 32 bytes of stack, here I
/svarcom/trunk/rmod.h
1,17 → 1,19
const char rmod[] = {
131, 25,133, 25, 23, 32, 25, 32, 0, 0, 0, 0, 0, 0, 64, 58,
92, 67, 79, 77, 77, 65, 78, 68, 46, 67, 79, 77, 0,140,200,142,
216,142,192,142,208,188,234, 1,180, 77,205, 33, 48,228,163, 10,
1,186, 14, 1,131, 14, 12, 1, 0,116, 8,142, 6, 44, 0,139,
22, 12, 1,161, 44, 0,163,120, 1,184,119, 1,163,122, 1,140,
14,124, 1,184, 0, 75, 6, 31, 14, 7,187,120, 1,205, 33,115,
188,140,203,142,219, 4, 48,162,138, 1,180, 9,186,134, 1,205,
33,180, 8,205, 33,235,166, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 69, 82, 82, 32,120, 44, 32, 70, 65, 73,
76, 69, 68, 32, 84, 79, 32, 76, 79, 65, 68, 32, 67, 79, 77, 77,
65, 78, 68, 46, 67, 79, 77, 13, 10, 36, 48, 49, 50, 51, 52, 53,
54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 48, 49, 50, 51, 52, 53,
54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 48, 49, 50, 51, 52, 53,
54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 48, 49, 50, 51, 52, 53,
54, 55, 56, 57, 65, 66, 67, 68, 69, 70,120,120};
#define rmod_len 236
92, 67, 79, 77, 77, 65, 78, 68, 46, 67, 79, 77, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,140,200,142,216,142,
192,142,208,188, 14, 2,128, 14, 8, 1, 0,116, 17,198, 6, 8,
1, 0,184, 0, 75,139, 22, 8, 1,187, 29, 1,205, 33,180, 77,
205, 33, 48,228,163, 10, 1,176, 0,185, 14, 0,191, 29, 1,252,
243,170,186, 14, 1,131, 14, 12, 1, 0,116, 8,142, 6, 44, 0,
139, 22, 12, 1,161, 44, 0,163, 29, 1,184,168, 1,163, 31, 1,
140, 14, 33, 1,184, 0, 75, 6, 31, 14, 7,187, 29, 1,205, 33,
115,153,140,203,142,219, 4, 48,162,174, 1,180, 9,186,170, 1,
205, 33,180, 8,205, 33,235,131, 0, 13, 69, 82, 82, 32,120, 44,
32, 70, 65, 73, 76, 69, 68, 32, 84, 79, 32, 76, 79, 65, 68, 32,
67, 79, 77, 77, 65, 78, 68, 46, 67, 79, 77, 13, 10, 36, 48, 49,
50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 48, 49,
50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 48, 49,
50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 48, 49,
50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70,120,120};
#define rmod_len 272
/svarcom/trunk/rmodinit.h
41,7 → 41,8
#define RMOD_OFFSET_LEXITCODE 0x10A
#define RMOD_OFFSET_COMSPECPTR 0x10C
#define RMOD_OFFSET_BOOTDRIVE 0x10E
#define RMOD_OFFSET_ROUTINE 0x11D
#define RMOD_OFFSET_EXECPARAM 0x11D
#define RMOD_OFFSET_ROUTINE 0x12B
 
struct rmod_props far *rmod_install(unsigned short envsize);
struct rmod_props far *rmod_find(void);