     1                                  ;	SCCSID = @(#)proc.asm	1.1 85/04/10
     2                                  ;TITLE	IBMPROC - process maintenance
     3                                  ;NAME	IBMPROC
     4                                  
     5                                  ;
     6                                  ; Process related system calls and low level routines for DOS 2.X.
     7                                  ; I/O specs are defined in DISPATCH.
     8                                  ;
     9                                  ;   $WAIT
    10                                  ;   $EXEC
    11                                  ;   $Keep_process
    12                                  ;   Stay_resident
    13                                  ;   $EXIT
    14                                  ;   $ABORT
    15                                  ;   abort_inner
    16                                  ;
    17                                  ;   Modification history:
    18                                  ;
    19                                  ;	Created: ARR 30 March 1983
    20                                  ;
    21                                  
    22                                  [list -]
    22          ******************       warning: redefining multi-line macro `struc' [-w+pp-macro-redef-multi]
    14                              <3> [list -]
    14                              <2> [list -]
     6                              <1> %include "entrysw.mac"
     1                              <2> 
     2                              <2> %ifndef __ENTRYSW_MAC__
     3                              <2>  %assign __ENTRYSW_MAC__ 1
     4                              <2> 
     5                              <2> %assign _DOSCODEHMA		1
     6                              <2> %assign _RELOCATEDOSCODE	0
     7                              <2> 
     8                              <2> 		; Write a label "%1" (only if DOSCODE isn't relocated) and
     9                              <2> 		; "relocated%1" (always).
    10                              <2> 	%imacro relocated 1-2.nolist
    11                              <2> %ifnidni %2, device
    12                              <2>  %ifnidni %2, amis
    13                              <2>   %ifn _RELOCATEDOSCODE
    14                              <2> %1:
    15                              <2> 	global %1
    16                              <2>   %endif
    17                              <2>  %endif
    18                              <2> %endif
    19                              <2> relocated%1:				; always used for local labels
    20                              <2> 	global relocated%1
    21                              <2> 	%endmacro
    22                              <2> 
    23                              <2> %if _RELOCATEDOSCODE
    24                              <2> DOSENTRYADJUSTSEGMENT equ 60h - 26h
    25                              <2> %else
    26                              <2> DOSENTRYADJUSTSEGMENT equ 0
    27                              <2> %endif
    28                              <2> DOSENTRYADJUSTOFFSET equ DOSENTRYADJUSTSEGMENT * 16
    29                              <2> 
    30                              <2> DOSENTRYDEVICEBASE equ 10h
    31                              <2> 
    32                              <2> %endif
     7                              <1> [list -]
    23                              <1>  %define DOSENTRYGROUP DOSCODEGROUP
    24                              <1>  [list -]
    39                              <1> usesection DOSENTRY
    40                              <1> 
    41                              <1> %endif
    27                                  %include "dosseg.nas"
     1                              <1> ;	SCCSID = @(#)dosseg.asm	1.1 85/04/10
     2                              <1> ;	SCCSID = @(#)dosseg.asm	1.1 85/04/10
     3                              <1> ;
     4                              <1> ; segment ordering for MSDOS
     5                              <1> ;
     6                              <1> 
     7                              <1> %include "ddataseg.nas"
     1                              <2> 
     2                              <2> %include "lmacros3.mac"
     1                              <3> [list -]
     3                              <2> 
     4                              <2> addsection DOSSTART, align=16 PUBLIC class=DOSSTART
     5                              <2> ; (no prior section) ; DOSSTART		ENDS
     6                              <2> 
     7                              <2> addsection DOSSTARTJUMP, align=1 PUBLIC class=START
     8                              <2> ; (no prior section) ; DOSSTARTJUMP		ENDS
     9                              <2> 
    10                              <2> addsection CONSTANTS, align=2 PUBLIC class=CONST
    11                              <2> ; (no prior section) ; CONSTANTS	ENDS
    12                              <2> 
    13                              <2> addsection DATA, align=2 PUBLIC class=DATA
    14                              <2> ; (no prior section) ; DATA		ENDS
    15                              <2> 
    16                              <2> addsection TABLE, align=2 PUBLIC class=TABLE
    17                              <2> ; (no prior section) ; TABLE		ENDS
    18                              <2> 
    19                              <2> addsection DOSDATATABLE, align=2 PUBLIC class=DOSDATACODE
    20                              <2> ; (no prior section) ; DOSDATATABLE		ENDS
    21                              <2> 
    22                              <2> addsection DOSDATACODE, align=1 PUBLIC class=DOSDATACODE
    23                              <2> ; (no prior section) ; DOSDATACODE		ENDS
    24                              <2> 
    25                              <2> addsection DOSBIODATA, align=2 PUBLIC class=DOSBIODATA
    26                              <2> 
    27                              <2> addsection LAST, align=16 PUBLIC class=LAST
    28                              <2> ; (no prior section) ; LAST		ENDS
    29                              <2> 
    30                              <2> group DOSGROUP DOSSTART DOSSTARTJUMP CONSTANTS DATA TABLE DOSDATATABLE DOSDATACODE DOSBIODATA LAST
     8                              <1> 
     9                              <1> %include "dcodeseg.nas"
     1                              <2> 
     2                              <2> %ifndef DCODESEGNAS
     3                              <2> %assign DCODESEGNAS 1
     4                              <2> 
     5                              <2> section DOSCODETABLE align=2 PUBLIC class=DOSCODE
     6                              <2> ; (no prior section) ; DOSCODETABLE		ENDS
     7                              <2> section DOSCODECODE align=1 PUBLIC class=DOSCODE
     8                              <2> ; (no prior section) ; DOSCODECODE		ENDS
     9                              <2> section DOSBIOCODE align=2 PUBLIC class=DOSCODE
    10                              <2> section BIOCODE	align=2 PUBLIC class=DOSCODE
    11                              <2> 
    12                              <2> %ifnidni DOSENTRYGROUP, DOSCODEGROUP
    13                              <2>  group DOSCODEGROUP DOSCODETABLE DOSCODECODE DOSBIOCODE BIOCODE
    14                              <2> %endif
    15                              <2> 
    16                              <2> %endif
    10                              <1> 
    11                              <1> section LAST
    12                              <1> ; (no prior section) ; LAST		ENDS
    28                                  
    29                                  [list +]
    30                                  section DOSCODECODE
    31                                  [list -]
    31          ******************       warning: out: ... for DOS Version 4.00 ... [-w+user]
    31          ******************       warning: out: BPB.INC... [-w+user]
    31          ******************       warning: out: ... CLONE version build switch on ... [-w+user]
    31          ******************       warning: out: DEVSYM.INC... [-w+user]
    38                                  
    39                                  SAVEXIT 	EQU	10
    40                                  
    41                                      i_need  CurrentPDB,WORD
    42                                      i_need  CreatePDB,BYTE
    43                                      i_need  Exit_type,BYTE
    44                                      i_need  INDOS,BYTE
    45                                      i_need  DMAADD,DWORD
    46                                      i_need  DidCTRLC,BYTE
    47                                      i_need  exit_type,BYTE
    48                                      i_need  exit_code,WORD
    49                                      i_need  OpenBuf,128
    50                                      I_need  EXTERR_LOCUS,BYTE		; Extended Error Locus
    51                                  
    52                                  ;SUBTTL $WAIT - return previous process error code
    53                                  ;PAGE
    54                                  ;
    55                                  ; process control data
    56                                  ;
    57                                  	i_need	exit_code,WORD		; code of exit
    58                                  
    59                                   assume nocheck, ss:DOSGROUP
    60                                  
    61                                  ;
    62                                  ;   Assembler usage:
    63                                  ;	    MOV     AH, WaitProcess
    64                                  ;	    INT     int_command
    65                                  ;	  AX has the exit code
    66                                  	procedure   D_WAIT,NEAR
    66          ******************       warning: proc D_WAIT... [-w+user]
    67                                  	ASSUME	DS:NOTHING,ES:NOTHING
    68 00000000 31C0                    	XOR	AX,AX
    69 00000002 368706[0000]            	XCHG	AX,[ss:exit_code]
    70 00000007 E9(0000)                	transfer    SYS_RET_OK
    71                                  EndProc D_WAIT
    72                                  
    73                                  ;=== Push trace listing source: exec.nas
    74                                  %include "exec.nas" ; NASM included file
     1                              <1> ;	SCCSID = @(#)exec.asm	1.3 85/08/13
     2                              <1> ;	SCCSID = @(#)exec.asm	1.3 85/08/13
     3                              <1> ;    AN000 version 4.0 jan. 1988
     4                              <1> ;    A007  PTM 3957 - fake vesrion for IBMCACHE.COM
     5                              <1> ;    A008  PTM 4070 - fake version for MS WINDOWS
     6                              <1> 
     7                              <1> ;SUBTTL $exec - load/go a program
     8                              <1> ;PAGE
     9                              <1> ;
    10                              <1> ; Assembler usage:
    11                              <1> ;	    LDS     DX, name
    12                              <1> ;	    LES     BX, blk
    13                              <1> ;	    MOV     AH, Exec
    14                              <1> ;	    MOV     AL, func
    15                              <1> ;	    INT     int_command
    16                              <1> ;
    17                              <1> ;	AL  Function
    18                              <1> ;	--  --------
    19                              <1> ;	 0  Load and execute the program.
    20                              <1> ;	 1  Load, create  the  program	header	but  do  not
    21                              <1> ;	    begin execution.
    22                              <1> ;	 3  Load overlay. No header created.
    23                              <1> ;
    24                              <1> ;	    AL = 0 -> load/execute program
    25                              <1> ;
    26                              <1> ;	    +---------------------------+
    27                              <1> ;	    | WORD segment address of	|
    28                              <1> ;	    | environment.		|
    29                              <1> ;	    +---------------------------+
    30                              <1> ;	    | DWORD pointer to ASCIZ	|
    31                              <1> ;	    | command line at 80h	|
    32                              <1> ;	    +---------------------------+
    33                              <1> ;	    | DWORD pointer to default	|
    34                              <1> ;	    | FCB to be passed at 5Ch	|
    35                              <1> ;	    +---------------------------+
    36                              <1> ;	    | DWORD pointer to default	|
    37                              <1> ;	    | FCB to be passed at 6Ch	|
    38                              <1> ;	    +---------------------------+
    39                              <1> ;
    40                              <1> ;	    AL = 1 -> load program
    41                              <1> ;
    42                              <1> ;	    +---------------------------+
    43                              <1> ;	    | WORD segment address of	|
    44                              <1> ;	    | environment.		|
    45                              <1> ;	    +---------------------------+
    46                              <1> ;	    | DWORD pointer to ASCIZ	|
    47                              <1> ;	    | command line at 80h	|
    48                              <1> ;	    +---------------------------+
    49                              <1> ;	    | DWORD pointer to default	|
    50                              <1> ;	    | FCB to be passed at 5Ch	|
    51                              <1> ;	    +---------------------------+
    52                              <1> ;	    | DWORD pointer to default	|
    53                              <1> ;	    | FCB to be passed at 6Ch	|
    54                              <1> ;	    +---------------------------+
    55                              <1> ;	    | DWORD returned value of	|
    56                              <1> ;	    | CS:IP			|
    57                              <1> ;	    +---------------------------+
    58                              <1> ;	    | DWORD returned value of	|
    59                              <1> ;	    | SS:IP			|
    60                              <1> ;	    +---------------------------+
    61                              <1> ;
    62                              <1> ;	    AL = 3 -> load overlay
    63                              <1> ;
    64                              <1> ;	    +---------------------------+
    65                              <1> ;	    | WORD segment address where|
    66                              <1> ;	    | file will be loaded.	|
    67                              <1> ;	    +---------------------------+
    68                              <1> ;	    | WORD relocation factor to |
    69                              <1> ;	    | be applied to the image.	|
    70                              <1> ;	    +---------------------------+
    71                              <1> ;
    72                              <1> ; Returns:
    73                              <1> ;	    AX = error_invalid_function
    74                              <1> ;	       = error_bad_format
    75                              <1> ;	       = error_bad_environment
    76                              <1> ;	       = error_not_enough_memory
    77                              <1> ;	       = error_file_not_found
    78                              <1> ;
    79                              <1> ;   Revision history:
    80                              <1> ;
    81                              <1> ;	 A000	version 4.00  Jan. 1988
    82                              <1> ;
    83                              <1> %include "ea.mac"
     1                              <2> 
     2                              <2> ;Get/Set Extended Attrbute Equates
     3                              <2> 
     4                              <2> ;The following equates are for EA types
     5                              <2> 
     6                              <2> EAISUNDEF	      equ  00H	     ; undefined
     7                              <2> EAISLOGICAL	      equ  01H	     ; logical (0 or 1), 1 byte
     8                              <2> EAISBINARY	      equ  02H	     ; binary integer 1, 2, or 4 bytes
     9                              <2> EAISASCII	      equ  03H	     ; ASCII , 0 to 128 bytes
    10                              <2> EAISDATE	      equ  04H	     ; DOS file date format, 2 bytes
    11                              <2> EAISTIME	      equ  05H	     ; DOS file time format, 2 bytes
    12                              <2> 
    13                              <2> ;The following equates are for EA flags
    14                              <2> 
    15                              <2> EASYSTEM	      equ  8000H     ; system defined, bultin
    16                              <2> EAREADONLY	      equ  4000H     ; read-only , cannot be changed
    17                              <2> EAHIDDEN	      equ  2000H     ; hidden from ATTRIB
    18                              <2> EACREATEONLY	      equ  1000H     ; settable only at create time
    19                              <2> 
    20                              <2> ;The following equates are for EA failure reason code (set by DOS)
    21                              <2> 
    22                              <2> EARCSUCCESS	      equ  00H	     ; success
    23                              <2> EARCNOTFOUND	      equ  01H	     ; name not found
    24                              <2> EARCNOSPACE	      equ  02H	     ; no space to hold name or value
    25                              <2> EARCNOTNOW	      equ  03H	     ; name can't be set on this function
    26                              <2> EARCNOTEVER	      equ  04H	     ; name can't be set
    27                              <2> EARCUNDEF	      equ  05H	     ; name known to IFS but not supported
    28                              <2> EARCDEFBAD	      equ  06H	     ; EA definition bad (type,length, etc)
    29                              <2> EARCACCESS	      equ  07H	     ; EA access denied
    30                              <2> EARCBADVAL	      equ  08H	     ; bad value
    31                              <2> EARCDEVERROR	      equ  09H	     ; device error
    32                              <2> EARCUNKNOWN	      equ  0FFFFH    ; unknown cause
    33                              <2> 
    34                              <2> 
    35                              <2> ;The following equates are for EA file type
    36                              <2> 
    37                              <2> EAEXISTING	     equ  00H	    ; existing file
    38                              <2> EARTL		     equ  02H	    ; right to left
    39                              <2> EAEXECUTABLE	     equ  03H	    ; executable program
    40                              <2> EAINSTALLABLE	     equ  04H	    ; installable executable program
    41                              <2> EAOVERLAY	     equ  05H	    ; program overlay
    42                              <2> EADEV_DRIVER	     equ  06H	    ; device driver
    43                              <2> EAIFS_DRIVER	     equ  07H	    ; ifs deriver
    44                              <2> 
    45                              <2> 
    46                              <2> 
    47                              <2> 
    48                              <2> By_Create	      equ  0000010B	     ; set by Extended Open (create)
    49                              <2> BY_XA		      equ  0000100B	     ; set by Get/Set XA by Handle
    50                              <2> 
    51                              <2> ;Extended Attribute Structure
    52                              <2> 
    53                              <2> EA	    STRUC			      ; extended attribute list
    54 00000000 ??                  <2> EA_TYPE     DB	      ? 		      ; type
    55 00000001 ????                <2> EA_FLAGS    DW	      ? 		      ; flags
    56 00000003 ??                  <2> EA_RC	    DB	      ? 		      ; reason code
    57 00000004 ??                  <2> EA_NAMELEN  DB	      ? 		      ; name length
    58 00000005 ????                <2> EA_VALLEN   DW	      ? 		      ; value length
    59 00000007 ??                  <2> EA_NAME     DB	      ? 		      ; name
    60                              <2> EA	    ENDS
    61                              <2> 
    62                              <2> 
    63                              <2> ;Query Extended Attribute list
    64                              <2> 
    65                              <2> QEA	     STRUC			       ; extended attribute list
    66 00000000 ??                  <2> QEA_TYPE     DB        ?		       ; type
    67 00000001 ????                <2> QEA_FLAGS    DW        ?		       ; flags
    68 00000003 ??                  <2> QEA_NAMELEN  DB        ?		       ; name length
    69 00000004 ??                  <2> QEA_NAME     DB        ?		       ; name
    70                              <2> QEA	     ENDS
    71                              <2> 
    84                              <1> %include "version.mac"
     1                              <2> ; Some modules really want TRUE to be 0FFH.  Best to let them have their way.
     2                              <2> 	TRUE	   EQU	   0FFFFh
     3                              <2> 	TRUEBYTE   EQU     0FFh
     4                              <2> 	FALSE	   EQU	   0
     5                              <2> 
     6                              <2> ;
     7                              <2> ; Use the following switches to control cmacros.inc
     8                              <2> ;
     9                              <2> ?PLM       equ       0
    10                              <2> ?WIN       equ       0
    11                              <2> 
    12                              <2> memS       EQU     1			; Small model
    13                              <2> ;
    14                              <2> ; Use the switches below to produce the standard Microsoft version or the IBM
    15                              <2> ; version of the operating system
    16                              <2> ;
    17                              <2> ; The below chart will indicate how to set the switches to build the various
    18                              <2> ; versions
    19                              <2> ;
    20                              <2> ;                     IBMVER          IBMCOPYRIGHT
    21                              <2> ; --------------------------------------------------------
    22                              <2> ;  IBM Version   |     TRUE              TRUE
    23                              <2> ; --------------------------------------------------------
    24                              <2> ;  MS Version    |     FALSE             FALSE
    25                              <2> ; --------------------------------------------------------
    26                              <2> ;  Clone Version |     TRUE              FALSE
    27                              <2> ;
    28                              <2> IBMVER     EQU     TRUE
    29                              <2> IBMCOPYRIGHT EQU   FALSE
    30                              <2> 
    31                              <2> BUFFERFLAG	EQU	~ IBMCOPYRIGHT
    32                              <2> 
    33                              <2> %ifndef	MSVER	
    34                              <2> MSVER      EQU     ~ IBMVER
    35                              <2> %endif
    36                              <2> IBM	   EQU	   IBMVER
    37                              <2> ;
    38                              <2> ;
    39                              <2> 	%IF IBMVER
    40                              <2> 	    %IF IBMCOPYRIGHT
    41                              <2>               %warning out: ... IBM version build switch on ...
    42                              <2> 	    %ELSE
    43                              <2> 	      %warning out: ... CLONE version build switch on ...
    43          ******************  <2>  warning: out: ... CLONE version build switch on ... [-w+user]
    44                              <2> 	    %ENDIF
    45                              <2> 	%ELSE
    46                              <2> 	    %IFN IBMCOPYRIGHT
    47                              <2> 	      %warning out: ... MS version build switch on ...
    48                              <2> 	    %ELSE
    49                              <2> 	      %warning out: !!!!!!!!!  VERSION SWITCHES SET INCORECTLY  !!!!!!!!!
    50                              <2> 	      %warning out: !!!!!!!!! CHECK SETTINGS IN INC\VERSION.INC !!!!!!!!!
    51                              <2> 	    %ENDIF
    52                              <2> 	%ENDIF   
    53                              <2> ;
    54                              <2> ;
    55                              <2> ;***************************************************************************
    56                              <2> ;*          The following switches are for DBCS or SBCS support            *
    57                              <2> ;*                                                                         *
    58                              <2> ;*                     Set INTERNAT EQU TRUE FOR DBCS                      *
    59                              <2> ;*                     Set INTERNAT EQU FALSE FOR SBCS                     *
    60                              <2> ;*                                                                         *
    61                              <2> ;***************************************************************************
    62                              <2> ;
    63                              <2> IBMJAPVER  EQU	   FALSE		;If TRUE set KANJI true also
    64                              <2> 
    65                              <2> ;
    66                              <2> ; Switch INTERNAT for DBCS support
    67                              <2> ;
    68                              <2> INTERNAT   EQU	   FALSE
    69                              <2> ;
    70                              <2> 	%IF INTERNAT
    71                              <2> %ifndef KANJI
    72                              <2> KANJI	   EQU	   TRUE
    73                              <2> %endif
    74                              <2> IBMJAPAN   EQU	   TRUE
    75                              <2> 	%ELSE
    76                              <2> %ifndef KANJI
    77                              <2> KANJI	   EQU	   FALSE
    78                              <2> %endif
    79                              <2> IBMJAPAN   EQU	   FALSE
    80                              <2> 	%ENDIF
    81                              <2> 
    82                              <2> %ifndef altvect				; avoid jerking off vector.inc
    83                              <2> ALTVECT    EQU	   FALSE		;Switch to build ALTVECT version
    84                              <2> %endif
    85                              <2> 
    86                              <2> ;
    87                              <2> ; Country code switches
    88                              <2> ; The default contry code is assumed as USA.
    89                              <2> ;
    90                              <2> 	%IF INTERNAT
    91                              <2>  KOREA	   EQU	   TRUE
    92                              <2>  JAPAN	   EQU	   FALSE
    93                              <2> 	%ELSE
    94                              <2>  KOREA	   EQU	   FALSE
    95                              <2>  JAPAN	   EQU	   FALSE
    96                              <2> 	%ENDIF
    97                              <2> ;
    98                              <2> 		%IF INTERNAT
    99                              <2> %warning out: Internat(ECS) version build switch on
   100                              <2> 		%ENDIF
    85                              <1> %include "lmacros2.mac"
     1                              <2> [list -]
    86                              <1> %include "memsw.mac"
     1                              <2> %define LDOSMEM 1
    87                              <1> %include "entryseg.nas"
     1                              <2> 
     2                              <2> %ifndef ENTRYSEGNAS
     3                              <2> %define ENTRYSEGNAS 1
     4                              <2> 
     5                              <2> %include "lmacros3.mac"
     6                              <2> %include "entrysw.mac"
     7                              <2> [list -]
     8                              <2> 
     9                              <2> %define HARDALIGN 2
    10                              <2> %ifdef MSHARD
    11                              <2>  %define HARDALIGN 16
    12                              <2> %endif
    13                              <2> 
    14                              <2> %if _RELOCATEDOSCODE
    15                              <2>  %define DOSENTRYCLASS DOSENTRY
    16                              <2> %else
    17                              <2>  %define DOSENTRYCLASS DOSCODE
    18                              <2> %endif
    19                              <2> 
    20                              <2> addsection DOSENTRY, class=%[DOSENTRYCLASS]
    21                              <2> %ifn _RELOCATEDOSCODE
    22                              <2>  [list +]
    23                              <2>  %define DOSENTRYGROUP DOSCODEGROUP
    24                              <2>  [list -]
    25                              <2>  %include "dcodeseg.nas"
    26                              <2> %endif
    27                              <2> addsection DOSENTRYHARD, class=%[DOSENTRYCLASS] align=HARDALIGN
    28                              <2> addsection DOSENTRYINIT, class=%[DOSENTRYCLASS] align=2
    29                              <2> 
    30                              <2> %if _RELOCATEDOSCODE
    31                              <2> group DOSENTRYGROUP DOSENTRY DOSENTRYHARD DOSENTRYINIT
    32                              <2> %else
    33                              <2>  group DOSCODEGROUP DOSENTRY 	DOSCODETABLE DOSCODECODE DOSBIOCODE BIOCODE 	DOSENTRYHARD DOSENTRYINIT
    36                              <2> %endif
    37                              <2> 
    38                              <2> [list +]
    39                              <2> usesection DOSENTRY
    40                              <2> 
    41                              <2> %endif
    88                              <1> 
    89                              <1> 	I_Need	   Temp_Var2,WORD	     ;AN000;file type from $open
    90                              <1> 	I_Need	   Special_Entries,WORD      ;AN007;address of special entries
    91                              <1> 	I_Need	   Special_Version,WORD      ;AN007;special version number
    92                              <1> 	I_Need	   Fake_Count,BYTE	     ;AN008;fake version count
    93                              <1>         I_need  User_SS,WORD
    94                              <1>         I_need  User_SP,WORD
    95                              <1>         I_need  NSS,WORD
    96                              <1>         I_need  NSP,WORD
    97                              <1> 	extern	restore_world
    98                              <1> 
    99                              <1> %ifndef BUF2
   100                              <1> %IF	BUFFERFLAG
   101                              <1> 	extrn	restore_user_map:near
   102                              <1> %ENDIF
   103                              <1> %endif
   104                              <1> 
   105                              <1> section DOSDATATABLE	; in DOSDATA
   106                              <1> 
   107                              <1> 	align 2, db ?
   108 00000000 ????                <1> exec_init_SP	    DW	?
   109 00000002 ????                <1> exec_init_SS	    DW	?
   110 00000004 ????                <1> exec_init_IP	    DW	?
   111 00000006 ????                <1> exec_init_CS	    DW	?
   112                              <1> 
   113                              <1> exec_internal_buffer	EQU OpenBuf
   114                              <1> 
   115 00000008 ????                <1> exec_signature	    DW	?		; must contain 4D5A  (yay zibo!)
   116 0000000A ????                <1> exec_len_mod_512    DW	?		; low 9 bits of length
   117 0000000C ????                <1> exec_pages	    DW	?		; number of 512b pages in file
   118 0000000E ????                <1> exec_rle_count	    DW	?		; count of reloc entries
   119 00000010 ????                <1> exec_par_dir	    DW	?		; number of paragraphs before image
   120 00000012 ????                <1> exec_min_BSS	    DW	?		; minimum number of para of BSS
   121 00000014 ????                <1> exec_max_BSS	    DW	?		; max number of para of BSS
   122 00000016 ????                <1> exec_SS 	    DW	?		; stack of image
   123 00000018 ????                <1> exec_SP 	    DW	?		; SP of image
   124 0000001A ????                <1> exec_chksum	    DW	?		; checksum  of file (ignored)
   125 0000001C ????                <1> exec_IP 	    DW	?		; IP of entry
   126 0000001E ????                <1> exec_CS 	    DW	?		; CS of entry
   127 00000020 ????                <1> exec_rle_table	    DW	?		; byte offset of reloc table
   128                              <1> Exec_Signature equ exec_signature	; NASM port label
   129                              <1> Exec_header_len     EQU $-Exec_Signature
   130                              <1> 
   131                              <1> curdirLEN equ curdirLen	; NASM port equate
   132                              <1> exec_internal_buffer_size   EQU (128+128+53+curdirLEN)
   133                              <1> %warning out: Please make sure that the following are contiguous and of the
   133          ******************  <1>  warning: out: Please make sure that the following are contiguous and of the [-w+user]
   134                              <1> %warning out: following sizes:
   134          ******************  <1>  warning: out: following sizes: [-w+user]
   135                              <1> %warning out:
   135          ******************  <1>  warning: out: [-w+user]
   136                              <1> %warning out: OpenBuf     128
   136          ******************  <1>  warning: out: OpenBuf 128 [-w+user]
   137                              <1> %warning out: RenBuf	    128
   137          ******************  <1>  warning: out: RenBuf 128 [-w+user]
   138                              <1> %warning out: SearchBuf    53
   138          ******************  <1>  warning: out: SearchBuf 53 [-w+user]
   139                              <1> %warning out: DummyCDS    CurDirLen
   139          ******************  <1>  warning: out: DummyCDS CurDirLen [-w+user]
   140                              <1> 
   141                              <1> section DOSCODECODE	; TABLE	ENDS
   142                              <1> 
   143                              <1> ;.sall
   144                              <1> 
   145                              <1>  assume nocheck, ss:DOSGROUP
   146                              <1> 
   147                              <1> procedure   D_Exec,NEAR
   147          ******************  <1>  warning: proc D_Exec... [-w+user]
   148 0000000A 3C85                <1> 	cmp al, 85h
   149 0000000C 7404                <1> 	je .state
   150 0000000E 3C05                <1> 	cmp al, 5
   151 00000010 752C                <1> 	jne @F
   152                              <1> .state:
   153 00000012 E8(0000)            <1> 	call SYS_RET_OK			; NC in iret fl
   154                              <1> 
   155                              <1> 		; the following copied from disp.nas
   156 00000015 FA                  <1> 	CLI
   157 00000016 16                  <1> 	push ss
   158 00000017 1F                  <1> 	pop ds				; ds => DOSDATA, overwritten soon
   159                              <1>  assume ds:DOSGROUP
   160                              <1> user_SP equ User_SP	; NASM port label
   161                              <1> user_SS equ User_SS	; NASM port label
   162 00000018 8B2E[0000]          <1> 	MOV BP, [user_SP]		; -> user stack
   163 0000001C 8E16[0000]          <1> 	MOV SS, [user_SS]
   164 00000020 89EC                <1> 	MOV SP, bp			; restore user stack
   165                              <1>  assume ss:nothing
   166 00000022 884600              <1> 	MOV BYTE PTR [BP + user_AX],AL
   167 00000025 A1[0000]            <1> 	MOV AX, [NSP]
   168 00000028 A3[0000]            <1> 	MOV [user_SP], AX
   169 0000002B A1[0000]            <1> 	MOV AX, [NSS]
   170 0000002E A3[0000]            <1> 	MOV [user_SS], AX
   171 00000031 FE0E[0000]          <1>         DEC byte [INDOS]
   172 00000035 E8(0000)            <1> 	CALL restore_world		; restore all registers
   173                              <1>  assume ds:nothing, es:nothing
   174 00000038 31C0                <1> 	xor ax, ax
   175 0000003A 50                  <1> 	push ax
   176 0000003B E9C604              <1> 	jmp do_a20_off_ax_on_stack
   177                              <1> 
   178                              <1> @@:
   179                              <1>  assume ss:DOSGROUP
   180                              <1> 	ASSUME	DS:NOTHING, ES:NOTHING
   181                              <1> PUBLIC EXEC001S,EXEC001E
   182                              <1> EXEC001S:
   183                              <1> 	LocalVar    exec_blk,DWORD
   184                              <1> 	LocalVar    exec_func,BYTE
   185                              <1> 	LocalVar    exec_load_high,BYTE
   186                              <1> 	LocalVar    exec_fh,WORD
   187                              <1> 	LocalVar    exec_rel_fac,WORD
   188                              <1> 	LocalVar    exec_res_len_para,WORD
   189                              <1> 	LocalVar    exec_environ,WORD
   190                              <1> 	LocalVar    exec_size,WORD
   191                              <1> 	LocalVar    exec_load_block,WORD
   192                              <1> 	LocalVar    exec_dma,WORD
   193                              <1> 	LocalVar    execNameLen,WORD
   194                              <1> 	LocalVar    execName,DWORD
   195                              <1> EXEC001E:
   196 0000003E 5589E583EC1A        <1> 	Enter
   197                              <1> ;
   198                              <1> ; validate function
   199                              <1> ;
   200                              <1> 
   201 00000044 8846FB              <1> 	MOV	[exec_func],AL
   202                              <1> 
   203 00000047 247F                <1> 	and al, 7Fh			; normalise from FreeDOS extension
   204 00000049 3C03                <1> 	CMP	AL,3			; only 0, 1 or 3 are allowed
   205 0000004B 760E                <1> 	Jbe	exec_check_2
   206                              <1> 
   207                              <1> exec_bad_fun:
   208 0000004D 36C606[0000]01      <1> 	MOV	byte [ss:EXTERR_LOCUS],errLOC_Unk ; Extended Error Locus
   209 00000053 B001                <1> 	mov	al,error_invalid_function
   210                              <1> 
   211                              <1> exec_ret_err:
   212 00000055 89EC5D              <1> 	Leave
   213 00000058 E9(0000)            <1> 	transfer    SYS_RET_ERR
   214                              <1> 
   215                              <1> exec_check_2:
   216 0000005B 3C02                <1> 	CMP	AL,2
   217 0000005D 74EE                <1> 	je	exec_bad_fun
   218                              <1> 
   219 0000005F 895EFC              <1> 	MOV	[exec_blkL],BX		; stash args
   220 00000062 8C46FE              <1> 	MOV	[exec_blkH],ES
   221 00000065 C646FA00            <1> 	MOV	byte [exec_load_high],0
   222                              <1> ;
   223                              <1> ; set up length of exec name
   224                              <1> ;
   225 00000069 8956E6              <1> 	MOV	[execNameL],DX
   226 0000006C 8C5EE8              <1> 	MOV	[execNameH],DS
   227 0000006F 89D6                <1> 	MOV	SI,DX			; move pointer to convenient place
   228 00000071 E8(0000)            <1> 	invoke	DStrLen
   229 00000074 894EEA              <1> 	MOV	[ExecNameLen],CX		; save length
   230                              <1> 
   231 00000077 30C0                <1> 	XOR	AL,AL			; open for reading
   232 00000079 55                  <1> 	PUSH	BP
   233 0000007A E8(0000)            <1> 	invoke	D_OPEN			; is the file there?
   234 0000007D 5D                  <1> 	POP	BP
   235 0000007E 72D5                <1> 	JC	exec_ret_err
   236                              <1> ;File Type Checking
   237                              <1> ;	CMP	BYTE PTR [Temp_Var2],EAEXISTING      ;AN000;;FT.  old file ?
   238                              <1> ;	JZ	oldexf				     ;AN000;;FT.  yes
   239                              <1> ;	TEST	BYTE PTR EXEC_FUNC,EXEC_FUNC_OVERLAY ;AN000;;FT.  exec overlay?
   240                              <1> ;	JNZ	exovrly 			     ;AN000;;FT.  yes
   241                              <1> ;	CMP	BYTE PTR [Temp_Var2],EAEXECUTABLE    ;AN000;;FT.  only file type
   242                              <1> ;	JZ	oldexf				     ;AN000;;FT.  3 & 4 will pass
   243                              <1> ;	CMP	BYTE PTR [Temp_Var2],EAINSTALLABLE   ;AN000;;FT.
   244                              <1> ;	JZ	oldexf				     ;AN000;;FT.
   245                              <1> ;exerr: 					      ;AN000;;FT.
   246                              <1> ;	MOV	AL,error_access_denied		     ;AN000;;FT.  error
   247                              <1> ;	JMP	exec_ret_err			     ;AN000;;FT.
   248                              <1> ;exovrly:					      ;AN000;;FT.
   249                              <1> ;	CMP	BYTE PTR [Temp_Var2],EAOVERLAY	     ;AN000;;FT.  only 5,6,7  pass
   250                              <1> ;	JZ	oldexf				     ;AN000;;FT.
   251                              <1> ;	CMP	BYTE PTR [Temp_Var2],EADEV_DRIVER    ;AN000;;FT.
   252                              <1> ;	JZ	oldexf				     ;AN000;;FT.
   253                              <1> ;	CMP	BYTE PTR [Temp_Var2],EAIFS_DRIVER    ;AN000;;FT.
   254                              <1> ;	JNZ	exerr				     ;AN000;;FT.
   255                              <1> ;
   256                              <1> ;oldexf:					      ;AN000;
   257                              <1> ;File Type Checking
   258                              <1> 
   259 00000080 8946F8              <1> 	MOV	[exec_fh],AX
   260 00000083 89C3                <1> 	MOV	BX,AX
   261 00000085 30C0                <1> 	XOR	AL,AL
   262 00000087 E8(0000)            <1> 	invoke	D_IOCTL
   263 0000008A 7207                <1> 	JC	Exec_bombJ
   264 0000008C F6C280              <1> 	TEST	DL,devid_ISDEV
   265 0000008F 740A                <1> 	JZ	exec_check_environ
   266 00000091 B002                <1> 	MOV	AL,error_file_not_found
   267                              <1> Exec_bombJ:
   268                              <1> Exec_Bomb equ exec_bomb	; NASM port label
   269 00000093 E9D800              <1> 	JMP	Exec_Bomb
   270                              <1> 
   271                              <1> BadEnv:
   272 00000096 B00A                <1> 	MOV	AL,error_bad_environment
   273 00000098 E9D300              <1> 	JMP	exec_bomb
   274                              <1> 
   275                              <1> exec_check_environ:
   276 0000009B 8366EE00            <1> 	and	word [exec_load_block],0
   277 0000009F 8366F200            <1> 	and	word [exec_environ],0
   278                              <1> 
   279 000000A3 F646FB02            <1> 	TEST	BYTE [exec_func],exec_func_overlay	; overlays... no environment
   280 000000A7 7561                <1> 	JNZ	exec_read_header
   281 000000A9 C576FC              <1> 	LDS	SI,[exec_blk]		; get block
   282                              <1>  assume ds:nothing
   283 000000AC 8B04                <1> 	MOV	AX,[SI + Exec1_environ]	; address of environ
   284 000000AE 09C0                <1> 	OR	AX,AX
   285 000000B0 750F                <1> 	JNZ	exec_scan_env
   286 000000B2 368E1E[0000]        <1> 	MOV	DS,[ss:CurrentPDB]
   287                              <1>  assume ds:PSP
   288 000000B7 A12C00              <1> 	MOV	AX,[PDB_environ]
   289 000000BA 8946F2              <1> 	MOV	[exec_environ],AX
   290 000000BD 09C0                <1> 	OR	AX,AX
   291 000000BF 7449                <1> 	JZ	exec_read_header
   292                              <1> 
   293                              <1> exec_scan_env:
   294 000000C1 8EC0                <1> 	MOV	ES,AX
   295                              <1>  assume es:nothing
   296 000000C3 31FF                <1> 	XOR	DI,DI
   297 000000C5 B9FF7F              <1> 	MOV	CX,07FFFh		; at most 32k of environment
   298 000000C8 30C0                <1> 	XOR	AL,AL
   299                              <1> 
   300                              <1> exec_get_environ_len:
   301 000000CA F2AE                <1> 	REPNZ	SCASB			; find that nul byte
   302 000000CC 75C8                <1> 	JNZ	BadEnv
   303 000000CE 49                  <1> 	DEC	CX			; Dec CX for the next nul byte test
   304 000000CF 74C5                <1> 	jz	BadEnv			; gone beyond the end of the environment
   305 000000D1 AE                  <1> 	SCASB				; is there another nul byte?
   306 000000D2 75F6                <1> 	JNZ	exec_get_environ_len	; no, scan some more
   307 000000D4 57                  <1> 	PUSH	DI
   308 000000D5 8D5D11              <1> 	LEA	BX,[DI+0Fh+2]
   309 000000D8 035EEA              <1> 	ADD	BX,[ExecNameLen]		; BX <- length of environment
   310                              <1> 					; remember argv[0] length
   311                              <1> 					; round up and remember argc
   312 000000DB B104                <1> 	MOV	CL,4
   313 000000DD D3EB                <1> 	SHR	BX,CL			; number of paragraphs needed
   314 000000DF 06                  <1> 	PUSH	ES
   315                              <1> %ifdef LDOSMEM
   316 000000E0 E8(0000)            <1> 	EnterCrit   critMem
   317 000000E3 E8AF00              <1> 	call get_flags
   318 000000E6 E8(0000)            <1> 	call AllocateMCBCompatible.flags_cx
   319 000000E9 E8(0000)            <1> 	LeaveCrit   critMem
   320                              <1> %else
   321                              <1> 	invoke	D_ALLOC			; can we get the space?
   322                              <1> %endif
   323 000000EC 1F                  <1> 	POP	DS
   324                              <1>  assume ds:nothing
   325 000000ED 59                  <1> 	POP	CX
   326 000000EE 7303                <1> 	JNC	exec_save_environ
   327 000000F0 EB76                <1> 	JMP	exec_no_mem		; nope... cry and sob
   328 000000F2 90                  <1> 	nop	; identicalise
   329                              <1> 
   330                              <1> exec_save_environ:
   331 000000F3 8EC0                <1> 	MOV	ES,AX
   332                              <1>  assume es:nothing
   333 000000F5 8946F2              <1> 	MOV	[exec_environ],AX 	; save him for a rainy day
   334 000000F8 31F6                <1> 	XOR	SI,SI
   335 000000FA 89F7                <1> 	MOV	DI,SI
   336 000000FC F3A4                <1> 	REP	MOVSB			; copy the environment
   337 000000FE B80100              <1> 	MOV	AX,1
   338 00000101 AB                  <1> 	STOSW
   339 00000102 C576E6              <1> 	LDS	SI,[execName]
   340 00000105 8B4EEA              <1> 	MOV	CX,[execNameLen]
   341 00000108 F3A4                <1> 	REP	MOVSB
   342                              <1> 
   343                              <1> exec_read_header:
   344                              <1> ;
   345                              <1> ; We read in the program header into the above data area and determine
   346                              <1> ; where in this memory the image will be located.
   347                              <1> ;
   348 0000010A 161F                <1> 	Context DS
   349                              <1> exec_header_len equ Exec_header_len	; NASM port equate
   350 0000010C B91A00              <1> 	MOV	CX,exec_header_len	; header size
   351 0000010F BA[0800]            <1> 	MOV	DX,OFFSET exec_signature wrt DOSGROUP
   352 00000112 06                  <1> 	PUSH	ES
   353 00000113 1E                  <1> 	PUSH	DS
   354 00000114 E8F303              <1> 	CALL	ExecRead
   355 00000117 1F                  <1> 	POP	DS
   356 00000118 07                  <1> 	POP	ES
   357                              <1>  assume ds:DOSGROUP, es:nothing
   358 00000119 7251                <1> 	JC	exec_bad_file
   359 0000011B 85C0                <1> 	test	AX,AX
   360 0000011D 744D                <1> 	JZ	exec_bad_file
   361 0000011F 83F81A              <1> 	CMP	AX,exec_header_len	; did we read the right number?
   362 00000122 7519                <1> 	JNZ	exec_com_filej		; yep... continue
   363 00000124 F706[1400]FFFF      <1> 	TEST	word [exec_max_BSS],-1 	; indicate load high?
   364 0000012A 7504                <1> 	JNZ	exec_check_sig
   365 0000012C C646FAFF            <1> 	MOV	byte [exec_load_high],-1
   366                              <1> exec_check_sig:
   367 00000130 A1[0800]            <1> 	MOV	AX,[exec_signature]
   368 00000133 3D4D5A              <1> 	CMP	AX,exe_valid_signature	; zibo arises!
   369 00000136 7408                <1> 	JZ	exec_save_start 	; assume com file if no signature
   370 00000138 3D5A4D              <1> 	CMP	AX,exe_valid_old_signature  ; zibo arises!
   371 0000013B 7403                <1> 	JZ	exec_save_start 	; assume com file if no signature
   372                              <1> 
   373                              <1> exec_com_filej:
   374 0000013D E9AC01              <1> 	JMP	exec_com_file
   375                              <1> 
   376                              <1> ;
   377                              <1> ; We have the program header... determine memory requirements
   378                              <1> ;
   379                              <1> exec_save_start:
   380 00000140 A1[0C00]            <1> 	MOV	AX,[exec_pages]		; get 512-byte pages
   381 00000143 B105                <1> 	MOV	CL,5			; convert to paragraphs
   382 00000145 D3E0                <1> 	SHL	AX,CL
   383 00000147 2B06[1000]          <1> 	SUB	AX,[exec_par_dir] 	; AX = size in paragraphs
   384 0000014B 8946F4              <1> 	MOV	[exec_res_len_para],AX
   385                              <1> 
   386                              <1> ;
   387                              <1> ; Do we need to allocate memory?  Yes if function is not load-overlay
   388                              <1> ;
   389 0000014E F646FB02            <1> 	TEST	BYTE [exec_func],exec_func_overlay
   390 00000152 7452                <1> 	JZ	exec_allocate		; allocation of space
   391                              <1> ;
   392                              <1> ; get load address from block
   393                              <1> ;
   394 00000154 C47EFC              <1> 	LES	DI,[exec_blk]
   395                              <1> exec3_load_addr equ Exec3_load_addr	; NASM port equate
   396 00000157 268B05              <1> 	MOV	AX,[ES:DI + exec3_load_addr]
   397 0000015A 8946EC              <1> 	MOV	[exec_dma],AX
   398                              <1> exec3_reloc_fac equ Exec3_reloc_fac	; NASM port equate
   399 0000015D 268B4502            <1> 	MOV	AX,[ES:DI + exec3_reloc_fac]
   400 00000161 8946F6              <1> 	MOV	[exec_rel_fac],AX
   401 00000164 E9BC00              <1> 	JMP	exec_find_res
   402                              <1> 
   403                              <1> exec_no_mem_pop:
   404 00000167 58                  <1> 	pop ax
   405                              <1> exec_no_mem:
   406 00000168 B008                <1> 	MOV	AL,error_not_enough_memory
   407 0000016A EB02                <1> 	JMP	SHORT exec_bomb
   408                              <1> 
   409                              <1> exec_bad_file:
   410 0000016C B00B                <1> 	MOV	AL,error_bad_format
   411                              <1> 
   412                              <1> exec_bomb:
   413                              <1> 	ASSUME	DS:NOTHING,ES:NOTHING
   414 0000016E 8B5EF8              <1> 	MOV	BX,[exec_fh]
   415 00000171 E8A503              <1> 	CALL	exec_dealloc
   416 00000174 E8(0000)            <1> 	LeaveCrit   CritMem
   417 00000177 5055                <1> 	SaveReg <AX,BP>
   418 00000179 E8(0000)            <1> 	invoke	D_CLOSE
   419 0000017C 5D58                <1> 	RestoreReg  <BP,AX>
   420                              <1> Exec_Ret_Err equ exec_ret_err	; NASM port label
   421 0000017E E9D4FE              <1> 	JMP	Exec_Ret_Err
   422                              <1> 
   423                              <1> %ifdef LDOSMEM
   424                              <1> extern GetMCBOwner, GetMCBFlags, AllocateLargestMCBRandom, GetRawMCBFlags
   425                              <1> extern AllocateMCBCompatible.flags_cx
   426                              <1> 
   427                              <1> allocate_largest:
   428 00000181 E8(0000)            <1> 	EnterCrit   critMem
   429 00000184 51                  <1> 	push cx
   430 00000185 52                  <1> 	push dx
   431 00000186 E8(0000)            <1> 	call GetMCBOwner			; dx = owner
   432 00000189 E80900              <1> 	call get_flags
   433 0000018C E8(0000)            <1> 	call AllocateLargestMCBRandom		; call two-area allocation
   434 0000018F 5A                  <1> 	pop dx
   435 00000190 59                  <1> 	pop cx
   436 00000191 E8(0000)            <1> 	LeaveCrit   critMem
   437 00000194 C3                  <1> 	retn
   438                              <1> 
   439                              <1> get_flags:
   440 00000195 E8(0000)            <1> 	call GetMCBFlags			; cx = fixed flags
   441 00000198 F646FB80            <1> 	test byte [exec_func], 80h		; FreeDOS extension to use UMA ?
   442 0000019C 7407                <1> 	jz .not_force_uma			; no, use current flags -->
   443 0000019E E8(0000)            <1> 	call GetRawMCBFlags
   444 000001A1 81C98001            <1> 	or cx, 180h				; 100h = ignore UMB link status,
   445                              <1> 						;  80h = UMA then LMA, dual areas
   446                              <1> 						;  (80h overrides all lesser areas)
   447                              <1> .not_force_uma:
   448 000001A5 C3                  <1> 	retn
   449                              <1> %endif
   450                              <1> 
   451                              <1> exec_allocate:
   452                              <1> 	DOSAssume   CS,<DS>,"EXEC/exec_allocate"
   453                              <1> %ifdef LDOSMEM
   454 000001A6 50                  <1> 	push ax
   455 000001A7 83C010              <1> 	add ax, 10h
   456 000001AA 89C3                <1> 	mov bx, ax
   457 000001AC 720C                <1> 	jc .max_ffff
   458 000001AE F646FAFF            <1> 	TEST byte [exec_load_high],-1	; if load high, use max
   459 000001B2 7506                <1> 	JNZ .max_ffff		; use max
   460 000001B4 0306[1400]          <1> 	add ax, [exec_max_BSS]
   461 000001B8 7303                <1> 	jnc @F
   462                              <1> .max_ffff:
   463 000001BA B8FFFF              <1> 	mov ax, -1
   464                              <1> @@:
   465 000001BD 031E[1200]          <1> 	add bx, [exec_min_BSS]
   466 000001C1 7303                <1> 	jnc @F
   467 000001C3 BBFFFF              <1> 	mov bx, -1
   468                              <1> @@:
   469 000001C6 1E                  <1> 	push ds
   470 000001C7 E8B7FF              <1> 	call allocate_largest
   471 000001CA 1F                  <1> 	pop ds
   472                              <1>  assume ds:DOSGROUP
   473 000001CB 729A                <1> 	jc exec_no_mem_pop
   474 000001CD 8946EE              <1> 	MOV	[exec_load_block],AX
   475 000001D0 58                  <1> 	pop ax
   476                              <1> %else
   477                              <1> 	PUSH	AX
   478                              <1> 	MOV	BX,0FFFFh		; see how much room in arena
   479                              <1> 	PUSH	DS
   480                              <1> 	invoke	D_ALLOC			; should have carry set and BX has max
   481                              <1> 	POP	DS
   482                              <1>  assume ds:DOSGROUP
   483                              <1> 	POP	AX
   484                              <1> %endif
   485 000001D1 83C010              <1> 	ADD	AX,10h			; room for header
   486 000001D4 83FB11              <1> 	CMP	BX,11h			; enough room for a header
   487 000001D7 728F                <1> 	JB	exec_no_mem
   488 000001D9 39D8                <1> 	CMP	AX,BX			; is there enough for bare image?
   489 000001DB 778B                <1> 	JA	exec_no_mem
   490 000001DD F646FAFF            <1> 	TEST	byte [exec_load_high],-1	; if load high, use max
   491 000001E1 751E                <1> 	JNZ	exec_BX_max		; use max
   492 000001E3 0306[1200]          <1> 	ADD	AX,[exec_min_BSS] 	; go for min allocation
   493 000001E7 7303E97CFF          <1> 	JC	exec_no_mem		; oops! carry
   494 000001EC 39D8                <1> 	CMP	AX,BX			; enough space?
   495 000001EE 7603E975FF          <1> 	JA	exec_no_mem		; nope...
   496 000001F3 2B06[1200]          <1> 	SUB	AX,[exec_min_BSS]
   497 000001F7 0306[1400]          <1> 	ADD	AX,[exec_max_BSS] 	; go for the MAX
   498 000001FB 7204                <1> 	JC	exec_BX_max
   499 000001FD 39D8                <1> 	CMP	AX,BX
   500 000001FF 7602                <1> 	JBE	exec_got_block
   501                              <1> 
   502                              <1> exec_BX_max:
   503 00000201 89D8                <1> 	MOV	AX,BX
   504                              <1> 
   505                              <1> exec_got_block:
   506 00000203 89C3                <1> 	MOV	BX,AX
   507 00000205 895EF0              <1> 	MOV	[exec_size],BX
   508                              <1> %ifdef LDOSMEM
   509 00000208 8B46EE              <1> 	MOV	ax, [exec_load_block]
   510                              <1> %else
   511                              <1> 	PUSH	DS
   512                              <1> 	invoke	D_ALLOC			; get the space
   513                              <1> 	POP	DS
   514                              <1> 	JC	exec_no_mem
   515                              <1> 	MOV	[exec_load_block],AX
   516                              <1> %endif
   517 0000020B 83C010              <1> 	ADD	AX,10h
   518 0000020E F646FAFF            <1> 	TEST	byte [exec_load_high],-1
   519 00000212 7409                <1> 	JZ	exec_use_ax		; use ax for load info
   520 00000214 0346F0              <1> 	ADD	AX,[exec_size]		; go to end
   521 00000217 2B46F4              <1> 	SUB	AX,[exec_res_len_para]	; drop off header
   522 0000021A 83E810              <1> 	SUB	AX,10h			; drop off pdb
   523                              <1> exec_use_ax:
   524 0000021D 8946F6              <1> 	MOV	[exec_rel_fac],AX 	; new segment
   525 00000220 8946EC              <1> 	MOV	[exec_dma],AX		; beginning of dma
   526                              <1> 
   527                              <1> ;
   528                              <1> ; Determine the location in the file of the beginning of the resident
   529                              <1> ;
   530                              <1> exec_find_res:
   531 00000223 8B16[1000]          <1> 	MOV	DX,[exec_par_dir]
   532 00000227 52                  <1> 	PUSH	DX
   533 00000228 B104                <1> 	MOV	CL,4
   534 0000022A D3E2                <1> 	SHL	DX,CL			; low word of location
   535 0000022C 58                  <1> 	POP	AX
   536 0000022D B10C                <1> 	MOV	CL,12
   537 0000022F D3E8                <1> 	SHR	AX,CL			; high word of location
   538 00000231 89C1                <1> 	MOV	CX,AX			; CX <- high
   539                              <1> 
   540                              <1> ;
   541                              <1> ; Read in the resident image (first, seek to it)
   542                              <1> ;
   543 00000233 8B5EF8              <1> 	MOV	BX,[exec_fh]
   544 00000236 1E                  <1> 	PUSH	DS
   545 00000237 30C0                <1> 	XOR	AL,AL
   546 00000239 E8(0000)            <1> 	invoke	D_LSEEK			; seek to resident
   547 0000023C 1F                  <1> 	POP	DS
   548                              <1>  assume ds:DOSGROUP
   549 0000023D 7303                <1> 	jnc	exec_big_read
   550 0000023F E92CFF              <1> 	jmp	exec_bomb
   551                              <1> 
   552                              <1> exec_big_read:				; Read resident into memory
   553 00000242 8B5EF4              <1> 	MOV	BX,[exec_res_len_para]
   554 00000245 81FB0010            <1> 	CMP	BX,1000h		; too many bytes to read?
   555 00000249 7203                <1> 	JB	exec_read_ok
   556 0000024B BBE00F              <1> 	MOV	BX,0FE0h		; max in one chunk FE00 bytes
   557                              <1> 
   558                              <1> exec_read_ok:
   559 0000024E 295EF4              <1> 	SUB	[exec_res_len_para],BX	; we read (soon) this many
   560 00000251 53                  <1> 	PUSH	BX
   561 00000252 B104                <1> 	MOV	CL,4
   562 00000254 D3E3                <1> 	SHL	BX,CL			; get count in bytes from paras
   563 00000256 89D9                <1> 	MOV	CX,BX			; count in correct register
   564 00000258 1E                  <1> 	PUSH	DS
   565 00000259 8E5EEC              <1> 	MOV	DS,[exec_dma]		; Set up read buffer
   566                              <1> 	ASSUME	DS:NOTHING
   567 0000025C 31D2                <1> 	XOR	DX,DX
   568 0000025E 51                  <1> 	PUSH	CX			; save our count
   569 0000025F E8A802              <1> 	CALL	ExecRead
   570 00000262 59                  <1> 	POP	CX			; get old count to verify
   571 00000263 1F                  <1> 	POP	DS
   572                              <1>  assume ds:DOSGROUP
   573                              <1> exec_bad_fileJ equ exec_bad_filej	; NASM port label
   574 00000264 7248                <1> 	JC	exec_bad_fileJ
   575                              <1> 	DOSAssume   CS,<DS>,"EXEC/exec_read_ok"
   576 00000266 39C1                <1> 	CMP	CX,AX			; did we read enough?
   577 00000268 5B                  <1> 	POP	BX			; get paragraph count back
   578                              <1> execCheckEnd equ ExecCheckEnd	; NASM port label
   579 00000269 7408                <1> 	JZ	execCheckEnd		; and do reloc if no more to read
   580                              <1> ;
   581                              <1> ; The read did not match the request.  If we are off by 512 bytes or more
   582                              <1> ; then the header lied and we have an error.
   583                              <1> ;
   584 0000026B 29C1                <1> 	SUB	CX,AX
   585 0000026D 81F90002            <1> 	CMP	CX,512
   586                              <1> Exec_Bad_fileJ equ exec_bad_filej	; NASM port label
   587 00000271 733B                <1> 	JAE	Exec_Bad_fileJ
   588                              <1> ;
   589                              <1> ; We've read in CX bytes... bump DTA location
   590                              <1> ;
   591                              <1> ExecCheckEnd:
   592 00000273 015EEC              <1> 	ADD	[exec_dma],BX		; bump dma address
   593 00000276 F746F4FFFF          <1> 	TEST	word [exec_res_len_para],-1
   594 0000027B 75C5                <1> 	JNZ	exec_big_read
   595                              <1> ;
   596                              <1> ; The image has now been read in.  We must perform relocation to
   597                              <1> ; the current location.
   598                              <1> ;
   599                              <1> exec_do_reloc:
   600 0000027D 8B4EF6              <1> 	MOV	CX,[exec_rel_fac]
   601 00000280 A1[1600]            <1> 	MOV	AX,[exec_SS]		; get initial SS
   602 00000283 01C8                <1> 	ADD	AX,CX			; and relocate him
   603 00000285 A3[0200]            <1> 	MOV	[exec_init_SS],AX
   604                              <1> 
   605 00000288 A1[1800]            <1> 	MOV	AX,[exec_SP]		; initial SP
   606 0000028B A3[0000]            <1> 	MOV	[exec_init_SP],AX
   607                              <1> 
   608 0000028E C406[1C00]          <1> 	LES	AX,[exec_IP]
   609                              <1>  assume es:nothing
   610 00000292 A3[0400]            <1> 	MOV	[exec_init_IP],AX
   611 00000295 8CC0                <1> 	MOV	AX,ES
   612 00000297 01C8                <1> 	ADD	AX,CX			; relocated...
   613 00000299 A3[0600]            <1> 	MOV	[exec_init_CS],AX
   614                              <1> 
   615 0000029C 31C9                <1> 	XOR	CX,CX
   616 0000029E 8B16[2000]          <1> 	MOV	DX,[exec_rle_table]
   617 000002A2 8B5EF8              <1> 	MOV	BX,[exec_fh]
   618 000002A5 1E                  <1> 	PUSH	DS
   619 000002A6 31C0                <1> 	XOR	AX,AX
   620 000002A8 E8(0000)            <1> 	invoke	D_LSEEK
   621 000002AB 1F                  <1> 	POP	DS
   622                              <1>  assume ds:DOSGROUP
   623                              <1> 
   624 000002AC 7303                <1> 	JNC	exec_get_entries
   625                              <1> exec_bad_filej:
   626 000002AE E9BBFE              <1> 	JMP	exec_bad_file
   627                              <1> 
   628                              <1> exec_get_entries:
   629 000002B1 8B16[0E00]          <1> 	MOV	DX,[exec_rle_count]	; Number of entries left
   630                              <1> 
   631                              <1> exec_read_reloc:
   632                              <1> 	ASSUME	DS:NOTHING
   633 000002B5 52                  <1> 	PUSH	DX
   634 000002B6 BA[0000]            <1> 	MOV	DX,OFFSET exec_internal_buffer wrt DOSGROUP
   635 000002B9 B98C01              <1> 	MOV	CX,((exec_internal_buffer_size)/4)*4
   636 000002BC 1E                  <1> 	PUSH	DS
   637 000002BD E84A02              <1> 	CALL	ExecRead
   638 000002C0 07                  <1> 	POP	ES
   639                              <1>  assume es:nothing
   640 000002C1 5A                  <1> 	POP	DX
   641 000002C2 72EA                <1> 	JC	exec_bad_filej
   642 000002C4 B96300              <1> 	MOV	CX,(exec_internal_buffer_size)/4
   643 000002C7 BF[0000]            <1> 	MOV	DI,OFFSET exec_internal_buffer wrt DOSGROUP ; Pointer to byte location in header
   644                              <1> ;
   645                              <1> ; Relocate a single address
   646                              <1> ;
   647 000002CA 8B76F6              <1> 	MOV	SI,[exec_rel_fac]
   648                              <1> 
   649                              <1> exec_reloc_one:
   650 000002CD 85D2                <1> 	test	DX,DX			; Any more entries?
   651 000002CF 7415                <1> 	JE	exec_set_PDBJ
   652                              <1> 
   653                              <1> exec_get_addr:
   654 000002D1 26C51D              <1> 	LDS	BX,[ES:DI]	; Get ra/sa of entry
   655                              <1>  assume ds:nothing
   656 000002D4 8CD8                <1> 	MOV	AX,DS			; Relocate address of item
   657 000002D6 01F0                <1> 	ADD	AX,SI
   658 000002D8 8ED8                <1> 	MOV	DS,AX
   659                              <1>  assume ds:nothing
   660 000002DA 0137                <1> 	ADD	[BX],SI
   661 000002DC 83C704              <1> 	ADD	DI,4
   662 000002DF 4A                  <1> 	DEC	DX
   663 000002E0 E2EB                <1> 	LOOP	exec_reloc_one		; End of internal buffer?
   664                              <1> 
   665                              <1> ;
   666                              <1> ; We've exhausted a single buffer's worth.  Read in the next piece
   667                              <1> ; of the relocation table.
   668                              <1> ;
   669                              <1> 
   670 000002E2 06                  <1> 	PUSH	ES
   671 000002E3 1F                  <1> 	POP	DS
   672                              <1>  assume ds:nothing
   673 000002E4 EBCF                <1> 	JMP	exec_read_reloc
   674                              <1> 
   675                              <1> exec_set_PDBJ:
   676 000002E6 E9A600              <1> 	JMP	exec_set_PDB
   677                              <1> 
   678                              <1> exec_no_memj:
   679 000002E9 E97CFE              <1> 	JMP	exec_no_mem
   680                              <1> 
   681                              <1> ;
   682                              <1> ; we have a .COM file.	First, determine if we are merely loading an overlay.
   683                              <1> ;
   684                              <1> exec_com_file:
   685 000002EC F646FB02            <1> 	TEST	BYTE [exec_func],exec_func_overlay
   686 000002F0 740C                <1> 	JZ	exec_alloc_com_file
   687 000002F2 C576FC              <1> 	LDS	SI,[exec_blk]		; get arg block
   688 000002F5 AD                  <1> 	LODSW				; get load address
   689 000002F6 8946EC              <1> 	MOV	[exec_dma],AX
   690 000002F9 B8FFFF              <1> 	MOV	AX,0FFFFh
   691 000002FC EB46                <1> 	JMP	SHORT exec_read_block	; read it all!
   692                              <1> 
   693                              <1> ; We must allocate the max possible size block (ick!)  and set up
   694                              <1> ; CS=DS=ES=SS=PDB pointer, IP=100, SP=max size of block.
   695                              <1> ;
   696                              <1> exec_alloc_com_file:
   697                              <1> %ifdef LDOSMEM
   698 000002FE 8B5EF8              <1> 	mov bx, [exec_fh]
   699 00000301 31C9                <1> 	xor cx, cx
   700 00000303 31D2                <1> 	xor dx, dx
   701 00000305 B80200              <1> 	mov ax, 2			; seek to EOF
   702 00000308 E8(0000)            <1> 	invoke D_LSEEK			; get file size
   703 0000030B 85D2                <1> 	test dx, dx			; >= 64 KiB ?
   704 0000030D 75DA                <1> 	jnz exec_no_memj		; yes, too much -->
   705 0000030F 3D00FF              <1> 	cmp ax, 0FF00h			; >= 0FF00h ?
   706 00000312 73D5                <1> 	jae exec_no_memj		; too much -->
   707 00000314 83C00F              <1> 	add ax, 15			; round up
   708 00000317 B104                <1> 	mov cl, 4
   709 00000319 D3E8                <1> 	shr ax, cl			; to paragraphs
   710 0000031B 83C010              <1> 	add ax, 10h			; add in PSP size
   711 0000031E 93                  <1> 	xchg bx, ax			; bx = minimum size
   712 0000031F B8FFFF              <1> 	mov ax, -1			; maximum size = largest
   713 00000322 E85CFE              <1> 	call allocate_largest
   714 00000325 72C2                <1> 	jc exec_no_memj
   715 00000327 895EF0              <1> 	MOV	[exec_size],BX		; save size of allocation block
   716                              <1> %else
   717                              <1> 	MOV	BX,0FFFFh
   718                              <1> 	invoke	D_ALLOC			; largest piece available as error
   719                              <1> 	OR	BX,BX
   720                              <1> 	JZ	exec_no_memj
   721                              <1> 	MOV	[exec_size],BX		; save size of allocation block
   722                              <1> 	PUSH	BX
   723                              <1> 	invoke	D_ALLOC			; largest piece available as error
   724                              <1> 	POP	BX			; get size of block...
   725                              <1> %endif
   726 0000032A 8946EE              <1> 	MOV	[exec_load_block],AX
   727 0000032D 83C010              <1> 	ADD	AX,10h			; increment for header
   728 00000330 8946EC              <1> 	MOV	[exec_dma],AX
   729 00000333 31C0                <1> 	XOR	AX,AX			; presume 64K read...
   730 00000335 81FB0010            <1> 	CMP	BX,1000h		; 64k or more in block?
   731 00000339 7306                <1> 	JAE	exec_read_com		; yes, read only 64k
   732 0000033B 89D8                <1> 	MOV	AX,BX			; convert size to bytes
   733 0000033D B104                <1> 	MOV	CL,4
   734 0000033F D3E0                <1> 	SHL	AX,CL
   735                              <1> exec_read_com:
   736 00000341 2D0001              <1> 	SUB	AX,100h 		; remember size of psp
   737                              <1> exec_read_block:
   738 00000344 50                  <1> 	PUSH	AX			; save number to read
   739 00000345 8B5EF8              <1> 	MOV	BX,[exec_fh]		; of com file
   740 00000348 31C9                <1> 	XOR	CX,CX			; but seek to 0:0
   741 0000034A 89CA                <1> 	MOV	DX,CX
   742 0000034C 31C0                <1> 	XOR	AX,AX			; seek relative to beginning
   743 0000034E E8(0000)            <1> 	invoke	D_LSEEK			; back to beginning of file
   744 00000351 59                  <1> 	POP	CX			; number to read
   745 00000352 8E5EEC              <1> 	MOV	DS,[exec_dma]
   746                              <1>  assume ds:nothing
   747 00000355 31D2                <1> 	XOR	DX,DX
   748 00000357 51                  <1> 	PUSH	CX
   749 00000358 E8AF01              <1> 	CALL	ExecRead
   750 0000035B 5E                  <1> 	POP	SI			; get number of bytes to read
   751 0000035C 7303                <1> 	jnc	OkRead
   752 0000035E E90BFE              <1> 	jmp	exec_bad_file
   753                              <1> OkRead:
   754 00000361 39F0                <1> 	CMP	AX,SI			; did we read them all?
   755 00000363 7484                <1> 	JZ	exec_no_memj		; exactly the wrong number... no memory
   756 00000365 F646FB02            <1> 	TEST	BYTE [exec_func],exec_func_overlay
   757 00000369 7524                <1> 	JNZ	exec_set_PDB		; no starto, chumo!
   758 0000036B 8B46EC              <1> 	MOV	AX,[exec_DMA]
   759 0000036E 83E810              <1> 	SUB	AX,10h
   760 00000371 36A3[0600]          <1> 	MOV	[ss:exec_init_CS],AX
   761 00000375 36C706[0400]0001    <1> 	MOV	word [ss:exec_init_IP],100h	; initial IP is 100
   762                              <1> ;
   763                              <1> ; SI is at most FF00h.	Add FE to account for PSP - word of 0 on stack.
   764                              <1> ;
   765 0000037C 81C6FE00            <1> 	ADD	SI,0FEh 		; make room for stack
   766 00000380 368936[0000]        <1> 	MOV	[ss:exec_init_SP],SI 	; max value for read is also SP!
   767 00000385 36A3[0200]          <1> 	MOV	[ss:exec_init_SS],AX
   768 00000389 8ED8                <1> 	MOV	DS,AX
   769                              <1>  assume ds:nothing
   770 0000038B C7040000            <1> 	MOV	WORD PTR [SI],0 	; 0 for return
   771                              <1> 
   772                              <1> exec_set_PDB:
   773 0000038F 8B5EF8              <1> 	MOV	BX,[exec_fh]		; we are finished with the file.
   774 00000392 E88401              <1> 	CALL	exec_dealloc
   775 00000395 55                  <1> 	PUSH	BP
   776 00000396 E8(0000)            <1> 	invoke	D_CLOSE			; release the jfn
   777 00000399 5D                  <1> 	POP	BP
   778 0000039A E88801              <1> 	CALL	exec_alloc
   779 0000039D F646FB02            <1> 	TEST	BYTE [exec_func],exec_func_overlay
   780 000003A1 740C                <1> 	JZ	exec_build_header
   781 000003A3 E8AC01              <1> 	CALL	Scan_Execname		;MS.;AN007;
   782 000003A6 E8C001              <1> 	CALL	Scan_Special_Entries	;MS.;AN007;
   783 000003A9 89EC5D              <1> 	Leave
   784 000003AC E9(0000)            <1> 	transfer    SYS_RET_OK		; overlay load -> done
   785                              <1> 
   786                              <1> exec_build_header:
   787 000003AF 8B56EE              <1> 	MOV	DX,[exec_load_block]
   788                              <1> ;
   789                              <1> ; assign the space to the process
   790                              <1> ;
   791                              <1> 
   792 000003B2 BE0100              <1> 	MOV	SI,arena_owner		; pointer to owner field
   793                              <1> 
   794 000003B5 8B46F2              <1> 	MOV	AX,[exec_environ] 	; get environ pointer
   795 000003B8 09C0                <1> 	OR	AX,AX
   796 000003BA 7405                <1> 	JZ	NO_OWNER		; no environment
   797 000003BC 48                  <1> 	DEC	AX			; point to header
   798 000003BD 8ED8                <1> 	MOV	DS,AX
   799                              <1>  assume ds:MCB
   800 000003BF 8914                <1> 	MOV	[SI],DX 		; assign ownership
   801                              <1> NO_OWNER:
   802 000003C1 8B46EE              <1> 	MOV	AX,[exec_load_block]	; get load block pointer
   803 000003C4 48                  <1> 	DEC	AX
   804 000003C5 8ED8                <1> 	MOV	DS,AX			; point to header
   805                              <1>  assume ds:MCB
   806 000003C7 8914                <1> 	MOV	[SI],DX 		; assign ownership
   807                              <1> 
   808 000003C9 1E                  <1> 	PUSH	DS			;AN000;MS. make ES=DS
   809 000003CA 07                  <1> 	POP	ES			;AN000;MS.
   810                              <1>  assume es:MCB
   811                              <1> ARENA_NAME equ arena_name	; NASM port equate
   812 000003CB BF0800              <1> 	MOV	DI,ARENA_NAME		;AN000;MS. ES:DI points to destination
   813 000003CE E88101              <1> 	CALL	Scan_Execname		;AN007;MS. parse execname
   814                              <1> 					;	   ds:si->name, cx=name length
   815 000003D1 51                  <1> 	PUSH	CX			;AN007;;MS. save for fake version
   816 000003D2 56                  <1> 	PUSH	SI			;AN007;;MS. save for fake version
   817                              <1> 
   818 000003D3 83F908              <1> 	cmp cx, 8
   819 000003D6 7603                <1> 	jbe @F
   820 000003D8 B90800              <1> 	mov cx, 8
   821                              <1> @@:
   822 000003DB E312                <1> 	jcxz mem_done
   823                              <1> movename:				;AN000;
   824 000003DD AC                  <1> 	LODSB				;AN000;;MS. get char
   825 000003DE 3C2E                <1> 	CMP	AL,'.'                  ;AN000;;MS. is '.' ,may be name.exe
   826 000003E0 740D                <1> 	JZ	mem_done		;AN000;;MS. no, move to header
   827 000003E2 3C61                <1> 	cmp al, 'a'
   828 000003E4 7206                <1> 	jb @F
   829 000003E6 3C7A                <1> 	cmp al, 'z'
   830 000003E8 7702                <1> 	ja @F
   831 000003EA 2C20                <1> 	sub al, 20h
   832                              <1> @@:
   833 000003EC AA                  <1> 	STOSB				;AN000;;MS. move char
   834 000003ED E2EE                <1> 	LOOP	movename		;AN000;;MS. continue
   835                              <1> mem_done:				;AN000;
   836 000003EF 30C0                <1> 	XOR	AL,AL			;AN000;;MS. make ASCIIZ
   837                              <1> ARENA_struc_size equ arena_struc_size	; NASM port equate
   838 000003F1 83FF10              <1> 	CMP	DI,ARENA_struc_size		;AN000;MS. if not all filled
   839 000003F4 7301                <1> 	JAE	fill8			;AN000;MS.
   840 000003F6 AA                  <1> 	STOSB				;AN000;MS.
   841                              <1> fill8:					;AN000;
   842 000003F7 5E                  <1> 	POP    SI			;AN007;MS. ds:si -> file name
   843 000003F8 59                  <1> 	POP    CX			;AN007;MS.
   844                              <1> 
   845 000003F9 E86D01              <1> 	CALL   Scan_Special_Entries	;AN007;MS.
   846                              <1> 
   847 000003FC 52                  <1> 	PUSH	DX
   848 000003FD 8B76F0              <1> 	MOV	SI,[exec_size]
   849 00000400 01D6                <1> 	ADD	SI,DX
   850 00000402 E8(0000)            <1> 	invoke	D_Dup_PDB		; ES is now PDB
   851 00000405 5A                  <1> 	POP	DX
   852                              <1> 
   853 00000406 FF76F2              <1> 	PUSH	word [exec_environ]
   854 00000409 268F062C00          <1> 	POP	word [ES:PDB_environ]
   855                              <1> ;
   856                              <1> ; set up proper command line stuff
   857                              <1> ;
   858 0000040E C576FC              <1> 	LDS	SI,[exec_blk]		; get the block
   859                              <1>  assume ds:nothing
   860 00000411 1E                  <1> 	PUSH	DS			; save its location
   861 00000412 56                  <1> 	PUSH	SI
   862                              <1> exec0_5C_FCB equ Exec0_5C_FCB	; NASM port equate
   863 00000413 C57406              <1> 	LDS	SI,[SI + exec0_5C_FCB]	; get the 5c fcb
   864                              <1>  assume ds:nothing
   865                              <1> ;
   866                              <1> ; DS points to user space 5C FCB
   867                              <1> ;
   868 00000416 B90C00              <1> 	MOV	CX,12			; copy drive, name and ext
   869 00000419 51                  <1> 	PUSH	CX
   870 0000041A BF5C00              <1> 	MOV	DI,5Ch
   871 0000041D 8A1C                <1> 	MOV	BL,[SI]
   872 0000041F F3A4                <1> 	REP	MOVSB
   873                              <1> ;
   874                              <1> ; DI = 5Ch + 12 = 5Ch + 0Ch = 68h
   875                              <1> ;
   876 00000421 31C0                <1> 	XOR	AX,AX			; zero extent, etc for CPM
   877 00000423 AB                  <1> 	STOSW
   878 00000424 AB                  <1> 	STOSW
   879                              <1> ;
   880                              <1> ; DI = 5Ch + 12 + 4 = 5Ch + 10h = 6Ch
   881                              <1> ;
   882 00000425 59                  <1> 	POP	CX
   883 00000426 5E                  <1> 	POP	SI			; get block
   884 00000427 1F                  <1> 	POP	DS
   885                              <1>  assume ds:nothing
   886 00000428 1E                  <1> 	PUSH	DS			; save (again)
   887 00000429 56                  <1> 	PUSH	SI
   888                              <1> exec0_6C_FCB equ Exec0_6C_FCB	; NASM port equate
   889 0000042A C5740A              <1> 	LDS	SI,[SI + exec0_6C_FCB]	; get 6C FCB
   890                              <1>  assume ds:nothing
   891                              <1> ;
   892                              <1> ; DS points to user space 6C FCB
   893                              <1> ;
   894 0000042D 8A3C                <1> 	MOV	BH,[SI] 		; do same as above
   895 0000042F F3A4                <1> 	REP	MOVSB
   896 00000431 AB                  <1> 	STOSW
   897 00000432 AB                  <1> 	STOSW
   898 00000433 5E                  <1> 	POP	SI			; get block (last time)
   899 00000434 1F                  <1> 	POP	DS
   900                              <1>  assume ds:nothing
   901                              <1> exec0_com_line equ Exec0_com_line	; NASM port equate
   902 00000435 C57402              <1> 	LDS	SI,[SI + exec0_com_line]	; command line
   903                              <1>  assume ds:nothing
   904                              <1> ;
   905                              <1> ; DS points to user space 80 command line
   906                              <1> ;
   907 00000438 80C980              <1> 	OR	CL,80h
   908 0000043B 89CF                <1> 	MOV	DI,CX
   909 0000043D F3A4                <1> 	REP	MOVSB			; Wham!
   910                              <1> ;
   911                              <1> ; Process BX into default AX (validity of drive specs on args).  We no longer
   912                              <1> ; care about DS:SI.
   913                              <1> ;
   914 0000043F FEC9                <1> 	DEC	CL			; get 0FFh in CL
   915 00000441 88F8                <1> 	MOV	AL,BH
   916 00000443 30FF                <1> 	XOR	BH,BH
   917 00000445 E8(0000)            <1> 	invoke	GetVisDrv
   918 00000448 7302                <1> 	JNC	exec_BL
   919 0000044A 88CF                <1> 	MOV	BH,CL
   920                              <1> exec_BL:
   921 0000044C 88D8                <1> 	MOV	AL,BL
   922 0000044E 30DB                <1> 	XOR	BL,BL
   923 00000450 E8(0000)            <1> 	invoke	GetVisDrv
   924                              <1> exec_Set_Return equ exec_set_return	; NASM port label
   925 00000453 7302                <1> 	JNC	exec_Set_Return
   926 00000455 88CB                <1> 	MOV	BL,CL
   927                              <1> exec_set_return:
   928 00000457 E8(0000)            <1> 	invoke	get_user_stack		; get his return address
   929 0000045A FF7414              <1> 	PUSH	word [SI + user_CS]		; suck out the CS and IP
   930 0000045D FF7412              <1> 	PUSH	word [SI + user_IP]
   931 00000460 FF7414              <1> 	PUSH	word [SI + user_CS]		; suck out the CS and IP
   932 00000463 FF7412              <1> 	PUSH	word [SI + user_IP]
   933 00000466 268F060A00          <1> 	POP	WORD PTR [ES:PDB_Exit]
   934 0000046B 268F060C00          <1> 	POP	WORD PTR [ES:PDB_Exit+2]
   935 00000470 31C0                <1> 	XOR	AX,AX
   936 00000472 8ED8                <1> 	MOV	DS,AX
   937                              <1>  assume ds:IVT
   938 00000474 8F068800            <1> 	POP	word [addr_int_terminate] ; save them where we can get them later
   939 00000478 8F068A00            <1> 	POP	word [addr_int_terminate+2]   ; when the child exits.
   940 0000047C 36C706[0000]8000    <1> 	MOV	WORD [ss:DMAADD],80h
   941 00000483 368E1E[0000]        <1> 	MOV	DS,[ss:CurrentPDB]
   942                              <1>  assume ds:PSP
   943 00000488 368C1E[0200]        <1> 	MOV	WORD PTR [ss:DMAADD+2],DS
   944                              <1> 
   945                              <1>  extern ReleaseOwnersMCBs, backdoor_free_mcb_exec, backdoor_indicator
   946 0000048D 53                  <1> 	push bx
   947 0000048E E8(0000)            <1> 	EnterCrit   critMem
   948 00000491 31DB                <1> 	xor bx, bx
   949 00000493 36871E[0000]        <1> 	xchg bx, [ss:backdoor_free_mcb_exec]	; get backdoor owner
   950 00000498 E8(0000)            <1> 	call ReleaseOwnersMCBs			; exec success: free it
   951 0000049B E8(0000)            <1> 	LeaveCrit   critMem
   952 0000049E 1E                  <1> 	push ds
   953 0000049F 36C51E[0000]        <1> 	lds bx, [ss:backdoor_indicator]		; -> indicator
   954                              <1>  assume ds:nothing
   955 000004A4 83FBFF              <1> 	cmp bx, -1				; invalid address ?
   956 000004A7 7409                <1> 	je @F					; yes -->
   957 000004A9 C607FF              <1> 	mov byte [bx], -1			; else, set the indicator
   958 000004AC 36830E[0000]FF      <1> 	or word [ss:backdoor_indicator], -1	; and disable indicator after this
   959                              <1> @@:
   960 000004B2 1F                  <1> 	pop ds
   961                              <1>  assume ds:PSP
   962 000004B3 5B                  <1> 	pop bx
   963                              <1> 
   964 000004B4 F646FB01            <1> 	TEST	BYTE [exec_func],exec_func_no_execute
   965 000004B8 7427                <1> 	JZ	exec_go
   966                              <1> 
   967 000004BA 36C536[0000]        <1> 	LDS	SI,[ss:exec_init_SP]   ; get stack
   968                              <1>  assume ds:nothing
   969 000004BF C47EFC              <1> 	LES	DI,[exec_blk]		; and block for return
   970                              <1>  assume es:nothing
   971                              <1> exec1_SS equ Exec1_SS	; NASM port equate
   972 000004C2 268C5D10            <1> 	MOV	[ES:DI + exec1_SS],DS	; return SS
   973                              <1> 
   974 000004C6 4E                  <1> 	DEC	SI			; 'push' default AX
   975 000004C7 4E                  <1> 	DEC	SI
   976 000004C8 891C                <1> 	MOV	[SI],BX 		; save default AX reg
   977                              <1> exec1_SP equ Exec1_SP	; NASM port equate
   978 000004CA 2689750E            <1> 	MOV	[ES:DI + exec1_SP],SI	; return 'SP'
   979                              <1> 
   980 000004CE 36C506[0400]        <1> 	LDS	AX,[ss:exec_init_IP]
   981                              <1>  assume ds:nothing
   982                              <1> exec1_CS equ Exec1_CS	; NASM port equate
   983 000004D3 268C5D14            <1> 	MOV	[ES:DI + exec1_CS],DS	; initial entry stuff
   984                              <1> 
   985                              <1> exec1_IP equ Exec1_IP	; NASM port equate
   986 000004D7 26894512            <1> 	MOV	[ES:DI + exec1_IP],AX
   987 000004DB 89EC5D              <1> 	Leave
   988 000004DE E9(0000)            <1> 	transfer    SYS_RET_OK
   989                              <1> 
   990                              <1> exec_go:
   991 000004E1 36C536[0400]        <1> 	LDS	SI,[ss:exec_init_IP]   ; get entry point
   992                              <1>  assume ds:nothing
   993 000004E6 36C43E[0000]        <1> 	LES	DI,[ss:exec_init_SP]   ; new stack
   994                              <1>  assume es:nothing
   995 000004EB 8CC0                <1> 	MOV	AX,ES
   996                              <1> ;
   997                              <1> ; DS:SI points to entry point
   998                              <1> ; AX:DI points to initial stack
   999                              <1> ; DX has PDB pointer
  1000                              <1> ; BX has initial AX value
  1001                              <1> ;
  1002 000004ED 1607                <1> 	context es
  1003 000004EF FA                  <1> 	CLI
  1004 000004F0 8ED0                <1> 	MOV	SS,AX			; set up user's stack
  1005 000004F2 89FC                <1> 	MOV	SP,DI			; and SP
  1006                              <1> 	ASSUME	SS:NOTHING
  1007 000004F4 FB                  <1> 	STI
  1008 000004F5 90                  <1> 	nop
  1009 000004F6 9C                  <1> 	pushf				; iret frame
  1010 000004F7 1E                  <1> 	PUSH	DS			; fake long call to entry
  1011 000004F8 56                  <1> 	PUSH	SI
  1012 000004F9 26C606[0000]00      <1> 	mov byte [es:INDOS], 0		; clear InDOS upon DOS stack unused
  1013 000004FF 8EC2                <1> 	MOV	ES,DX			; set up proper seg registers
  1014                              <1>  assume es:nothing
  1015 00000501 8EDA                <1> 	MOV	DS,DX
  1016                              <1>  assume ds:nothing
  1017 00000503 53                  <1> 	push bx				; = ax = bx on stack
  1018                              <1> do_a20_off_ax_on_stack:
  1019 00000504 53                  <1> 	push bx				; for both registers
  1020                              <1> %ifndef BUF2
  1021                              <1> %IF	BUFFERFLAG
  1022                              <1> 	invoke	restore_user_map
  1023                              <1> %ENDIF
  1024                              <1> %endif
  1025                              <1> extern a20off_entry
  1026                              <1> 
  1027 00000505 EA[0000][ssss]      <1> 	jmp DOSENTRY:a20off_entry	; must address XMS entry variable with cs
  1028                              <1> 
  1029                              <1> EndProc D_Exec
  1030                              <1> 
  1031                              <1> Procedure   ExecRead,NEAR
  1031          ******************  <1>  warning: proc ExecRead... [-w+user]
  1032                              <1>  assume ss:DOSGROUP
  1033 0000050A E80C00              <1> 	CALL	exec_dealloc
  1034 0000050D 8B5EF8              <1> 	MOV	bx,[exec_fh]
  1035 00000510 55                  <1> 	PUSH	BP
  1036 00000511 E8(0000)            <1> 	invoke	D_READ
  1037 00000514 5D                  <1> 	POP	BP
  1038 00000515 E80D00              <1> 	CALL	exec_alloc
  1039 00000518 C3                  <1> 	return
  1040                              <1> EndProc ExecRead
  1041                              <1> 
  1042                              <1> procedure   exec_dealloc,near
  1042          ******************  <1>  warning: proc exec_dealloc... [-w+user]
  1043                              <1>  assume ss:DOSGROUP
  1044                              <1> 	ASSUME	    DS:NOTHING,ES:NOTHING
  1045 00000519 53                  <1> 	PUSH	    BX
  1046 0000051A BB0000              <1> 	MOV	    BX,arena_owner_system
  1047 0000051D E8(0000)            <1> 	EnterCrit   CritMEM
  1048 00000520 E81000              <1> 	CALL	    ChangeOwners
  1049 00000523 5B                  <1> 	POP	    BX
  1050 00000524 C3                  <1> 	return
  1051                              <1> EndProc exec_dealloc
  1052                              <1> 
  1053                              <1> procedure   exec_alloc,near
  1053          ******************  <1>  warning: proc exec_alloc... [-w+user]
  1054                              <1>  assume ss:DOSGROUP
  1055 00000525 53                  <1> 	PUSH	    BX
  1056 00000526 368B1E[0000]        <1> 	MOV	    BX,[ss:CurrentPDB]
  1057 0000052B E80500              <1> 	CALL	    ChangeOwners
  1058 0000052E E8(0000)            <1> 	LeaveCrit   CritMEM
  1059 00000531 5B                  <1> 	POP	    BX
  1060 00000532 C3                  <1> 	return
  1061                              <1> EndProc exec_alloc
  1062                              <1> 
  1063                              <1> procedure   ChangeOwners,NEAR
  1063          ******************  <1>  warning: proc ChangeOwners... [-w+user]
  1064                              <1>  assume ss:DOSGROUP
  1065 00000533 9C                  <1> 	pushf
  1066 00000534 50                  <1> 	PUSH	AX
  1067 00000535 8B46F2              <1> 	MOV	AX,[exec_environ]
  1068 00000538 E80900              <1> 	CALL	ChangeOwner
  1069 0000053B 8B46EE              <1> 	MOV	AX,[exec_load_block]
  1070 0000053E E80300              <1> 	Call	ChangeOwner
  1071 00000541 58                  <1> 	POP	AX
  1072 00000542 9D                  <1> 	popf
  1073 00000543 C3                  <1> 	return
  1074                              <1> EndProc ChangeOwners
  1075                              <1> 
  1076                              <1> Procedure   ChangeOwner,near
  1076          ******************  <1>  warning: proc ChangeOwner... [-w+user]
  1077                              <1>  assume ss:DOSGROUP
  1078 00000544 09C0                <1> 	OR	AX,AX			; is area allocated?
  1079 00000546 74FB                <1> 	retz				; no, do nothing
  1080 00000548 48                  <1> 	DEC	AX
  1081 00000549 1E                  <1> 	PUSH	DS
  1082 0000054A 8ED8                <1> 	MOV	DS,AX
  1083                              <1>  assume ds:MCB
  1084 0000054C 891E0100            <1> 	MOV	[arena_owner],BX
  1085 00000550 1F                  <1> 	POP	DS
  1086                              <1>  assume ds:nothing
  1087 00000551 C3                  <1> 	return
  1088                              <1> EndProc ChangeOwner
  1089                              <1> 
  1090                              <1> Procedure    Scan_Execname,near 	;AN000;MS.
  1090          ******************  <1>  warning: proc Scan_Execname... [-w+user]
  1091                              <1> 
  1092 00000552 C576E6              <1> 	LDS	SI,[execName]		;AN000;MS. DS:SI points to name
  1093                              <1> save_begin:				;AN000;
  1094 00000555 89F1                <1> 	MOV	CX,SI			;AN000;MS. CX= starting addr
  1095                              <1> scan0:					;AN000;
  1096 00000557 AC                  <1> 	LODSB				;AN000;MS. get char
  1097 00000558 3C3A                <1> 	CMP	AL,':'                  ;AN000;;MS. is ':' , may be A:name
  1098 0000055A 74F9                <1> 	JZ	save_begin		;AN000;;MS. yes, save si
  1099 0000055C 3C5C                <1> 	CMP	AL,'\'                  ;AN000;;MS. is '\', may be A:\name
  1100 0000055E 74F5                <1> 	JZ	save_begin		;AN000;;MS. yes, save si
  1101 00000560 3C00                <1> 	CMP	AL,0			;AN000;;MS. is end of name
  1102 00000562 75F3                <1> 	JNZ	scan0			;AN000;;MS. no, continue scanning
  1103 00000564 29CE                <1> 	SUB	SI,CX			;AN000;;MS. get name's length
  1104 00000566 87F1                <1> 	XCHG	SI,CX			;AN000;;MS. cx= length, si= starting addr
  1105                              <1> 
  1106 00000568 C3                  <1> 	return				;AN000;;MS.
  1107                              <1> EndProc Scan_Execname			;AN000;;MS.
  1108                              <1> 
  1109                              <1> 
  1110                              <1> Procedure    Scan_Special_Entries,near	;AN000;MS.
  1110          ******************  <1>  warning: proc Scan_Special_Entries... [-w+user]
  1111                              <1>  assume ss:DOSGROUP
  1112                              <1> 
  1113 00000569 49                  <1> 	DEC    CX			;AN007;MS. cx= name length
  1114 0000056A 368B3E[0000]        <1> 	MOV    DI,[ss:Special_Entries]	;AN007;MS. es:di -> addr of special entries
  1115 0000056F E83D00              <1> 	CALL   Reset_Version		;AN008;MS.
  1116 00000572 16                  <1> 	PUSH   ss			;AN007;MS.
  1117 00000573 07                  <1> 	POP    ES			;AN007;MS.
  1118                              <1>  assume es:DOSGROUP
  1119                              <1> Getentries:				;AN007;MS.
  1120 00000574 268A05              <1> 	MOV    AL,[ES:DI]		;AN007;MS. end of list
  1121 00000577 08C0                <1> 	OR     AL,AL			;AN007;MS.
  1122 00000579 7433                <1> 	JZ     end_list 		;AN007;MS. yes
  1123 0000057B 36893E[0000]        <1> 	MOV    [ss:Temp_Var2],DI	;AN007;MS. save di
  1124 00000580 38C8                <1> 	CMP    AL,CL			;AN007;MS. same length ?
  1125 00000582 751C                <1> 	JNZ    skipone			;AN007;MS. no
  1126 00000584 47                  <1> 	INC    DI			;AN007;MS. es:di -> special name
  1127 00000585 51                  <1> 	PUSH   CX			;AN007;MS. save length and name addr
  1128 00000586 56                  <1> 	PUSH   SI			;AN007;MS.
  1129 00000587 F3A6                <1> 	REPZ   CMPSB			;AN007;MS. same name ?
  1130 00000589 7513                <1> 	JNZ    not_matched		;AN007;MS. no
  1131 0000058B 268B05              <1> 	MOV    AX,[ES:DI]		;AN007;MS. get special version
  1132 0000058E 36A3[0000]          <1> 	MOV    [ss:Special_Version],AX	;AN007;MS. save it
  1133 00000592 268A4502            <1> 	MOV    AL,[ES:DI+2]		;AN008;MS. get fake count
  1134 00000596 36A2[0000]          <1> 	MOV    [ss:Fake_Count],AL	;AN007;MS. save it
  1135 0000059A 5E                  <1> 	POP    SI			;AN007;MS.
  1136 0000059B 59                  <1> 	POP    CX			;AN007;MS.
  1137 0000059C EB10                <1> 	JMP    SHORT end_list		;AN007;MS.
  1138                              <1> not_matched:				;AN007;MS.
  1139 0000059E 5E                  <1> 	POP    SI			;AN007;MS. restore si,cx
  1140 0000059F 59                  <1> 	POP    CX			;AN007;MS.
  1141                              <1> skipone:				;AN007;MS.
  1142 000005A0 368B3E[0000]        <1> 	MOV    DI,[ss:Temp_Var2]	;AN007;MS. restore old di
  1143 000005A5 30E4                <1> 	XOR    AH,AH			;AN007;MS. position to next entry
  1144 000005A7 01C7                <1> 	ADD    DI,AX			;AN007;MS.
  1145 000005A9 83C704              <1> 	ADD    DI,4			;AN007;MS.
  1146 000005AC EBC6                <1> 	JMP    Getentries		;AN007;MS.
  1147                              <1> 
  1148                              <1> 
  1149                              <1> end_list:				;AN007;MS.
  1150 000005AE C3                  <1> 	return
  1151                              <1> EndProc Scan_Special_Entries		;AN000;;MS.
  1152                              <1> 
  1153                              <1> Procedure    Reset_Version,near 	;AN008;MS.
  1153          ******************  <1>  warning: proc Reset_Version... [-w+user]
  1154                              <1> 
  1155 000005AF 36803E[0000]FF      <1> 	CMP    byte [ss:Fake_Count],0FFH	;AN008;MS.
  1156 000005B5 7507                <1> 	JNZ    dont_reset		;AN008;MS.
  1157 000005B7 36C706[0000]0000    <1> 	MOV    word [ss:Special_Version],0	;AN008;MS. reset to current version
  1158                              <1> dont_reset:
  1159 000005BE C3                  <1> 	return
  1160                              <1> EndProc Reset_Version,near		;AN008;;MS.
  1161                              <1> 
  1162                              <1> 
    75                                  ;=== Pop trace listing source
    76                                  
    77                                  ;SUBTTL Terminate and stay resident handler
    78                                  ;PAGE
    79                                  ;
    80                                  ; Input:    DX is  an  offset  from  CurrentPDB  at which to
    81                                  ;	    truncate the current block.
    82                                  ;
    83                                  ; output:   The current block is truncated (expanded) to be [DX+15]/16
    84                                  ;	    paragraphs long.  An exit is simulated via resetting CurrentPDB
    85                                  ;	    and restoring the vectors.
    86                                  ;
    87                                  	procedure   D_Keep_process,NEAR
    87          ******************       warning: proc D_Keep_process... [-w+user]
    88                                  	ASSUME DS:NOTHING,ES:NOTHING,SS:DOSGROUP
    89                                  
    90 000005BF 50                      	PUSH	AX			; keep exit code around
    91                                  Exit_keep_process equ Exit_Keep_process	; NASM port equate
    92 000005C0 36C606[0000]03          	MOV	BYTE PTR [ss:Exit_type],Exit_keep_process
    93 000005C6 368E06[0000]            	MOV	ES,[ss:CurrentPDB]
    94                                   assume es:PSP
    95 000005CB 83FA06                  	CMP	DX,6h			; keep enough space around for system
    96                                  Keep_shrink equ keep_shrink	; NASM port label
    97 000005CE 7303                    	JAE	Keep_shrink		; info
    98 000005D0 BA0600                  	MOV	DX,6h
    99                                  keep_shrink:
   100 000005D3 89D3                    	MOV	BX,DX
   101 000005D5 53                      	PUSH	BX
   102 000005D6 06                      	PUSH	ES
   103 000005D7 E8(0000)                	invoke	D_SETBLOCK		; ignore return codes.
   104 000005DA 1F                      	POP	DS
   105                                   assume ds:PSP
   106 000005DB 5B                      	POP	BX
   107 000005DC 7207                    	JC	keep_done		; failed on modification
   108 000005DE 8CD8                    	MOV	AX,DS
   109 000005E0 01D8                    	ADD	AX,BX
   110 000005E2 A30200                  	MOV	[PDB_block_len],AX
   111                                  
   112                                  keep_done:
   113 000005E5 58                      	POP	AX
   114                                  exit_inner equ Exit_inner	; NASM port label
   115 000005E6 EB26                    	JMP	SHORT exit_inner	; and let abort take care of the rest
   116                                  
   117                                  EndProc D_Keep_process
   118                                  
   119                                  relocated i27
   120                                  	procedure   Stay_resident,NEAR
   120          ******************       warning: proc Stay_resident... [-w+user]
   121                                  	ASSUME	DS:NOTHING,ES:NOTHING,SS:NOTHING
   122                                  Keep_process equ Keep_Process	; NASM port equate
   123 000005E8 B80031                  	MOV	AX,(Keep_process << 8) + 0 ; Lower part is return code
   124 000005EB 83C20F                  	ADD	DX,15
   125 000005EE D1DA                    	RCR	DX,1
   126 000005F0 B103                    	MOV	CL,3
   127 000005F2 D3EA                    	SHR	DX,CL
   128                                  
   129 000005F4 E9(0000)                	transfer    COMMAND
   130                                  EndProc Stay_resident
   131                                  
   132                                  ;SUBTTL $EXIT - return to parent process
   133                                  ;PAGE
   134                                  ;
   135                                  ;   Assembler usage:
   136                                  ;	    MOV     AL, code
   137                                  ;	    MOV     AH, Exit
   138                                  ;	    INT     int_command
   139                                  ;   Error return:
   140                                  ;	    None.
   141                                  ;
   142                                  	procedure   D_EXIT,NEAR
   142          ******************       warning: proc D_EXIT... [-w+user]
   143                                  	ASSUME	DS:NOTHING,ES:NOTHING,SS:DOSGROUP
   144 000005F7 30E4                    	XOR	AH,AH
   145 000005F9 368626[0000]            	XCHG	AH,BYTE PTR [ss:DidCTRLC]
   146 000005FE 08E4                    	OR	AH,AH
   147                                  exit_terminate equ Exit_terminate	; NASM port equate
   148 00000600 36C606[0000]00          	MOV	BYTE PTR [ss:Exit_type],exit_terminate
   149 00000606 7406                    	JZ	exit_inner
   150                                  exit_ctrl_c equ Exit_Ctrl_C	; NASM port equate
   151 00000608 36C606[0000]01          	MOV	BYTE PTR [ss:Exit_type],exit_ctrl_c
   152                                  
   153                                  	entry	Exit_inner
   154                                  
   155 0000060E E8(0000)                	invoke	get_user_stack
   156 00000611 36FF36[0000]            	PUSH	word [ss:CurrentPDB]
   157 00000616 8F4414                  	POP	word [SI + user_CS]
   158 00000619 EB08                    	JMP	SHORT abort_inner
   159                                  EndProc D_EXIT
   160                                  
   161                                  BREAK <$ABORT -- Terminate a process>
   162                                  
   163                                  ; Inputs:
   164                                  ;	user_CS:00 must point to valid program header block
   165                                  ; Function:
   166                                  ;	Restore terminate and Cntrl-C addresses, flush buffers and transfer to
   167                                  ;	the terminate address
   168                                  ; Returns:
   169                                  ;	TO THE TERMINATE ADDRESS
   170                                  
   171                                  	procedure   D_ABORT,NEAR
   171          ******************       warning: proc D_ABORT... [-w+user]
   172                                  ASSUME	DS:NOTHING,ES:NOTHING, ss:DOSGROUP
   173                                  
   174 0000061B 30C0                    	XOR	AL,AL
   175                                  exit_abort equ Exit_abort	; NASM port equate
   176 0000061D 36C606[0000]00          	MOV	byte [ss:exit_type],exit_abort
   177                                  
   178                                  ;
   179                                  ; abort_inner must have AL set as the exit code!  The exit type is retrieved
   180                                  ; from exit_type.  Also, the PDB at user_CS needs to be correct as the one
   181                                  ; that is terminating.
   182                                  ;
   183                                  	entry	abort_inner
   184                                  
   185 00000623 368A26[0000]            	MOV	AH,[ss:exit_type]
   186 00000628 36A3[0000]              	MOV	[ss:exit_code],AX
   187 0000062C E8(0000)                	invoke	Get_user_stack
   188 0000062F 8E5C14                  	MOV	DS,[SI + user_CS] 	; set up old interrupts
   189                                   assume ds:PSP
   190 00000632 31C0                    	XOR	AX,AX
   191 00000634 8EC0                    	MOV	ES,AX
   192                                   assume es:IVT
   193 00000636 BE0A00                  	MOV	SI,SAVEXIT
   194 00000639 BF8800                  	MOV	DI,addr_int_terminate
   195 0000063C A5                      	MOVSW
   196 0000063D A5                      	MOVSW
   197 0000063E A5                      	MOVSW
   198 0000063F A5                      	MOVSW
   199 00000640 A5                      	MOVSW
   200 00000641 A5                      	MOVSW
   201 00000642 E9(0000)                	transfer    $reset_environment
   202                                  EndProc D_ABORT
   203                                  
   204                                      END
