Category : Assembly Language Source Code
Archive   : EXECDE.ZIP
Filename : EXECDE.ASM

 
Output of file : EXECDE.ASM contained in archive : EXECDE.ZIP
;***********************************************************************;
; ;
; EXECDEMO ;
; ;
; This program demonstrates the DOS EXEC call (function 4BH). ;
; Based on a program in PC MAGAZINE, p. 256, April 16, 1985. ;
; ;
; If PARAMS begins with a "/C", the rest of PARAMS is a ;
; command to the 2nd COMMAND.COM, which executes the command ;
; and exits. If not, the 2nd COMMAND.COM is started up, ;
; and you type "EXIT" to end it. (Note that changing the ;
; PROMPT or any environment variables in the 2nd COMMAND ;
; does not change the environment variables in the default ;
; COMMAND. ;
; ;
; John Graybill, 71001,1475 ;
; ;
;***********************************************************************;

;***********************************************************************;
; STACK ;
;***********************************************************************;
;
STACK SEGMENT PARA STACK 'STACK'
DB 32 DUP ("STACK ") ; 256-byte stack
STACK ENDS

;***********************************************************************;
; DATA ;
;***********************************************************************;
;
DSEG SEGMENT PARA PUBLIC 'DATA'
;
PROG_TO_EXEC DB "C:\COMMAND.COM",0 ; could be any program
;
PROGRAM_PARAMS DB LEN_PARAMS ; parameters for PROG_TO_EXEC
PARAMS DB " " ; no params to run 2nd COMMAND.COM
;;;;PARAMS DB "/C DIR" ; params to run DIR under COMMAND.COM
LEN_PARAMS EQU $-PARAMS
CR_CHAR EQU 0DH
DB CR_CHAR,0 ; finish off command line
;
FCB DB 16 DUP (0) ; unused here, so set to zero
FCB2 DB 16 DUP (0)
;
EXEC_PARAMS DW ? ; seg address of environment
DW PROGRAM_PARAMS,DSEG ; command line for the program
DW FCB,DSEG ; FCB #1
DW FCB2,DSEG ; FCB #2
;
WHATZIS DB "This program demonstrates the DOS EXEC (4B) call."
DB 0AH,0DH,"$"
;
DONE_2ND DB "Now the 2nd program has finished."
DB 0AH,0DH,"$"
;
DSEG ENDS

;***********************************************************************;
; CODE ;
;***********************************************************************;
;
CSEG SEGMENT PARA PUBLIC 'CODE'
ASSUME CS:CSEG,DS:DSEG,ES:DSEG
START_PROG:
MOV AX,DSEG
MOV DS,AX
MOV AH,4AH ; Modify Allocated Memory Blocks
MOV BX,0100H ; (shrink us to run COMMAND.COM)
INT 21H ; (ES still points to PSP)
JNC SHRINK_OK ; shrink worked, continue
MOV AL,2 ; didn't shrink memory, set ERRORLEVEL
JMP EXIT_PROG
SHRINK_OK:
LEA DX,WHATZIS
MOV AH,9 ; print a string
INT 21H
MOV AX,ES:2CH ; get environment segment from PSP
LEA BX,EXEC_PARAMS ; save it into parameter block in DSEG
MOV [BX],AX
PUSH DS
POP ES ; now both point to DSEG
LEA DX,PROG_TO_EXEC ; BX still points to EXEC_PARAMS
MOV AL,0 ; subtype - load and run
MOV AH,4BH ; EXEC
INT 21H
JNC EXEC_WORKED
MOV AL,1 ; error in EXEC - set ERRORLEVEL
EXEC_WORKED:
MOV AL,0 ; errorlevel 0 (no error)
LEA DX,DONE_2ND
MOV AH,9 ; print a string
INT 21H
DONE_EXEC:
EXIT_PROG:
MOV AH,4CH
INT 21H


CSEG ENDS
END START_PROG


  3 Responses to “Category : Assembly Language Source Code
Archive   : EXECDE.ZIP
Filename : EXECDE.ASM

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/