     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	1
     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 -]
    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> 		; note: if running this, word [exec_res_len_para] >= 1000h
   558                              <1> 		;  so that after the next subtraction, >= 20h paragraphs
   559                              <1> 		;  are remaining. if this read is short <= 511 bytes then
   560                              <1> 		;  it won't break out from the cmp cx, 512. afterwards
   561                              <1> 		;  however it will loop back to exec_big_read and then
   562                              <1> 		;  >= 20h paragraphs (>= 512 bytes) are read in the next
   563                              <1> 		;  iteration and a done read count of 0 will always be
   564                              <1> 		;  detected as a read >= 512 bytes short, aborting the load.
   565                              <1> 		; refer to https://github.com/LoopZ/TheList/issues/1#issuecomment-3780971188
   566                              <1> 
   567                              <1> exec_read_ok:
   568 0000024E 295EF4              <1> 	SUB	[exec_res_len_para],BX	; we read (soon) this many
   569 00000251 53                  <1> 	PUSH	BX
   570 00000252 B104                <1> 	MOV	CL,4
   571 00000254 D3E3                <1> 	SHL	BX,CL			; get count in bytes from paras
   572 00000256 89D9                <1> 	MOV	CX,BX			; count in correct register
   573 00000258 1E                  <1> 	PUSH	DS
   574 00000259 8E5EEC              <1> 	MOV	DS,[exec_dma]		; Set up read buffer
   575                              <1> 	ASSUME	DS:NOTHING
   576 0000025C 31D2                <1> 	XOR	DX,DX
   577 0000025E 51                  <1> 	PUSH	CX			; save our count
   578 0000025F E8A802              <1> 	CALL	ExecRead
   579 00000262 59                  <1> 	POP	CX			; get old count to verify
   580 00000263 1F                  <1> 	POP	DS
   581                              <1>  assume ds:DOSGROUP
   582                              <1> exec_bad_fileJ equ exec_bad_filej	; NASM port label
   583 00000264 7248                <1> 	JC	exec_bad_fileJ
   584                              <1> 	DOSAssume   CS,<DS>,"EXEC/exec_read_ok"
   585 00000266 39C1                <1> 	CMP	CX,AX			; did we read enough?
   586 00000268 5B                  <1> 	POP	BX			; get paragraph count back
   587                              <1> execCheckEnd equ ExecCheckEnd	; NASM port label
   588 00000269 7408                <1> 	JZ	execCheckEnd		; and do reloc if no more to read
   589                              <1> ;
   590                              <1> ; The read did not match the request.  If we are off by 512 bytes or more
   591                              <1> ; then the header lied and we have an error.
   592                              <1> ;
   593 0000026B 29C1                <1> 	SUB	CX,AX
   594 0000026D 81F90002            <1> 	CMP	CX,512
   595                              <1> Exec_Bad_fileJ equ exec_bad_filej	; NASM port label
   596 00000271 733B                <1> 	JAE	Exec_Bad_fileJ
   597                              <1> ;
   598                              <1> ; We've read in CX bytes... bump DTA location
   599                              <1> ;
   600                              <1> ExecCheckEnd:
   601 00000273 015EEC              <1> 	ADD	[exec_dma],BX		; bump dma address
   602 00000276 F746F4FFFF          <1> 	TEST	word [exec_res_len_para],-1
   603 0000027B 75C5                <1> 	JNZ	exec_big_read
   604                              <1> ;
   605                              <1> ; The image has now been read in.  We must perform relocation to
   606                              <1> ; the current location.
   607                              <1> ;
   608                              <1> exec_do_reloc:
   609 0000027D 8B4EF6              <1> 	MOV	CX,[exec_rel_fac]
   610 00000280 A1[1600]            <1> 	MOV	AX,[exec_SS]		; get initial SS
   611 00000283 01C8                <1> 	ADD	AX,CX			; and relocate him
   612 00000285 A3[0200]            <1> 	MOV	[exec_init_SS],AX
   613                              <1> 
   614 00000288 A1[1800]            <1> 	MOV	AX,[exec_SP]		; initial SP
   615 0000028B A3[0000]            <1> 	MOV	[exec_init_SP],AX
   616                              <1> 
   617 0000028E C406[1C00]          <1> 	LES	AX,[exec_IP]
   618                              <1>  assume es:nothing
   619 00000292 A3[0400]            <1> 	MOV	[exec_init_IP],AX
   620 00000295 8CC0                <1> 	MOV	AX,ES
   621 00000297 01C8                <1> 	ADD	AX,CX			; relocated...
   622 00000299 A3[0600]            <1> 	MOV	[exec_init_CS],AX
   623                              <1> 
   624 0000029C 31C9                <1> 	XOR	CX,CX
   625 0000029E 8B16[2000]          <1> 	MOV	DX,[exec_rle_table]
   626 000002A2 8B5EF8              <1> 	MOV	BX,[exec_fh]
   627 000002A5 1E                  <1> 	PUSH	DS
   628 000002A6 31C0                <1> 	XOR	AX,AX
   629 000002A8 E8(0000)            <1> 	invoke	D_LSEEK
   630 000002AB 1F                  <1> 	POP	DS
   631                              <1>  assume ds:DOSGROUP
   632                              <1> 
   633 000002AC 7303                <1> 	JNC	exec_get_entries
   634                              <1> exec_bad_filej:
   635 000002AE E9BBFE              <1> 	JMP	exec_bad_file
   636                              <1> 
   637                              <1> exec_get_entries:
   638 000002B1 8B16[0E00]          <1> 	MOV	DX,[exec_rle_count]	; Number of entries left
   639                              <1> 
   640                              <1> exec_read_reloc:
   641                              <1> 	ASSUME	DS:NOTHING
   642 000002B5 52                  <1> 	PUSH	DX
   643 000002B6 BA[0000]            <1> 	MOV	DX,OFFSET exec_internal_buffer wrt DOSGROUP
   644 000002B9 B98C01              <1> 	MOV	CX,((exec_internal_buffer_size)/4)*4
   645 000002BC 1E                  <1> 	PUSH	DS
   646 000002BD E84A02              <1> 	CALL	ExecRead
   647 000002C0 07                  <1> 	POP	ES
   648                              <1>  assume es:nothing
   649 000002C1 5A                  <1> 	POP	DX
   650 000002C2 72EA                <1> 	JC	exec_bad_filej
   651 000002C4 B96300              <1> 	MOV	CX,(exec_internal_buffer_size)/4
   652 000002C7 BF[0000]            <1> 	MOV	DI,OFFSET exec_internal_buffer wrt DOSGROUP ; Pointer to byte location in header
   653                              <1> ;
   654                              <1> ; Relocate a single address
   655                              <1> ;
   656 000002CA 8B76F6              <1> 	MOV	SI,[exec_rel_fac]
   657                              <1> 
   658                              <1> exec_reloc_one:
   659 000002CD 85D2                <1> 	test	DX,DX			; Any more entries?
   660 000002CF 7415                <1> 	JE	exec_set_PDBJ
   661                              <1> 
   662                              <1> exec_get_addr:
   663 000002D1 26C51D              <1> 	LDS	BX,[ES:DI]	; Get ra/sa of entry
   664                              <1>  assume ds:nothing
   665 000002D4 8CD8                <1> 	MOV	AX,DS			; Relocate address of item
   666 000002D6 01F0                <1> 	ADD	AX,SI
   667 000002D8 8ED8                <1> 	MOV	DS,AX
   668                              <1>  assume ds:nothing
   669 000002DA 0137                <1> 	ADD	[BX],SI
   670 000002DC 83C704              <1> 	ADD	DI,4
   671 000002DF 4A                  <1> 	DEC	DX
   672 000002E0 E2EB                <1> 	LOOP	exec_reloc_one		; End of internal buffer?
   673                              <1> 
   674                              <1> ;
   675                              <1> ; We've exhausted a single buffer's worth.  Read in the next piece
   676                              <1> ; of the relocation table.
   677                              <1> ;
   678                              <1> 
   679 000002E2 06                  <1> 	PUSH	ES
   680 000002E3 1F                  <1> 	POP	DS
   681                              <1>  assume ds:nothing
   682 000002E4 EBCF                <1> 	JMP	exec_read_reloc
   683                              <1> 
   684                              <1> exec_set_PDBJ:
   685 000002E6 E9A600              <1> 	JMP	exec_set_PDB
   686                              <1> 
   687                              <1> exec_no_memj:
   688 000002E9 E97CFE              <1> 	JMP	exec_no_mem
   689                              <1> 
   690                              <1> ;
   691                              <1> ; we have a .COM file.	First, determine if we are merely loading an overlay.
   692                              <1> ;
   693                              <1> exec_com_file:
   694 000002EC F646FB02            <1> 	TEST	BYTE [exec_func],exec_func_overlay
   695 000002F0 740C                <1> 	JZ	exec_alloc_com_file
   696 000002F2 C576FC              <1> 	LDS	SI,[exec_blk]		; get arg block
   697 000002F5 AD                  <1> 	LODSW				; get load address
   698 000002F6 8946EC              <1> 	MOV	[exec_dma],AX
   699 000002F9 B8FFFF              <1> 	MOV	AX,0FFFFh
   700 000002FC EB46                <1> 	JMP	SHORT exec_read_block	; read it all!
   701                              <1> 
   702                              <1> ; We must allocate the max possible size block (ick!)  and set up
   703                              <1> ; CS=DS=ES=SS=PDB pointer, IP=100, SP=max size of block.
   704                              <1> ;
   705                              <1> exec_alloc_com_file:
   706                              <1> %ifdef LDOSMEM
   707 000002FE 8B5EF8              <1> 	mov bx, [exec_fh]
   708 00000301 31C9                <1> 	xor cx, cx
   709 00000303 31D2                <1> 	xor dx, dx
   710 00000305 B80200              <1> 	mov ax, 2			; seek to EOF
   711 00000308 E8(0000)            <1> 	invoke D_LSEEK			; get file size
   712 0000030B 85D2                <1> 	test dx, dx			; >= 64 KiB ?
   713 0000030D 75DA                <1> 	jnz exec_no_memj		; yes, too much -->
   714 0000030F 3D00FF              <1> 	cmp ax, 0FF00h			; >= 0FF00h ?
   715 00000312 73D5                <1> 	jae exec_no_memj		; too much -->
   716 00000314 83C00F              <1> 	add ax, 15			; round up
   717 00000317 B104                <1> 	mov cl, 4
   718 00000319 D3E8                <1> 	shr ax, cl			; to paragraphs
   719 0000031B 83C010              <1> 	add ax, 10h			; add in PSP size
   720 0000031E 93                  <1> 	xchg bx, ax			; bx = minimum size
   721 0000031F B8FFFF              <1> 	mov ax, -1			; maximum size = largest
   722 00000322 E85CFE              <1> 	call allocate_largest
   723 00000325 72C2                <1> 	jc exec_no_memj
   724 00000327 895EF0              <1> 	MOV	[exec_size],BX		; save size of allocation block
   725                              <1> %else
   726                              <1> 	MOV	BX,0FFFFh
   727                              <1> 	invoke	D_ALLOC			; largest piece available as error
   728                              <1> 	OR	BX,BX
   729                              <1> 	JZ	exec_no_memj
   730                              <1> 	MOV	[exec_size],BX		; save size of allocation block
   731                              <1> 	PUSH	BX
   732                              <1> 	invoke	D_ALLOC			; largest piece available as error
   733                              <1> 	POP	BX			; get size of block...
   734                              <1> %endif
   735 0000032A 8946EE              <1> 	MOV	[exec_load_block],AX
   736 0000032D 83C010              <1> 	ADD	AX,10h			; increment for header
   737 00000330 8946EC              <1> 	MOV	[exec_dma],AX
   738 00000333 31C0                <1> 	XOR	AX,AX			; presume 64K read...
   739 00000335 81FB0010            <1> 	CMP	BX,1000h		; 64k or more in block?
   740 00000339 7306                <1> 	JAE	exec_read_com		; yes, read only 64k
   741 0000033B 89D8                <1> 	MOV	AX,BX			; convert size to bytes
   742 0000033D B104                <1> 	MOV	CL,4
   743 0000033F D3E0                <1> 	SHL	AX,CL
   744                              <1> exec_read_com:
   745 00000341 2D0001              <1> 	SUB	AX,100h 		; remember size of psp
   746                              <1> exec_read_block:
   747 00000344 50                  <1> 	PUSH	AX			; save number to read
   748 00000345 8B5EF8              <1> 	MOV	BX,[exec_fh]		; of com file
   749 00000348 31C9                <1> 	XOR	CX,CX			; but seek to 0:0
   750 0000034A 89CA                <1> 	MOV	DX,CX
   751 0000034C 31C0                <1> 	XOR	AX,AX			; seek relative to beginning
   752 0000034E E8(0000)            <1> 	invoke	D_LSEEK			; back to beginning of file
   753 00000351 59                  <1> 	POP	CX			; number to read
   754 00000352 8E5EEC              <1> 	MOV	DS,[exec_dma]
   755                              <1>  assume ds:nothing
   756 00000355 31D2                <1> 	XOR	DX,DX
   757 00000357 51                  <1> 	PUSH	CX
   758 00000358 E8AF01              <1> 	CALL	ExecRead
   759 0000035B 5E                  <1> 	POP	SI			; get number of bytes to read
   760 0000035C 7303                <1> 	jnc	OkRead
   761 0000035E E90BFE              <1> 	jmp	exec_bad_file
   762                              <1> OkRead:
   763 00000361 39F0                <1> 	CMP	AX,SI			; did we read them all?
   764 00000363 7484                <1> 	JZ	exec_no_memj		; exactly the wrong number... no memory
   765 00000365 F646FB02            <1> 	TEST	BYTE [exec_func],exec_func_overlay
   766 00000369 7524                <1> 	JNZ	exec_set_PDB		; no starto, chumo!
   767 0000036B 8B46EC              <1> 	MOV	AX,[exec_DMA]
   768 0000036E 83E810              <1> 	SUB	AX,10h
   769 00000371 36A3[0600]          <1> 	MOV	[ss:exec_init_CS],AX
   770 00000375 36C706[0400]0001    <1> 	MOV	word [ss:exec_init_IP],100h	; initial IP is 100
   771                              <1> ;
   772                              <1> ; SI is at most FF00h.	Add FE to account for PSP - word of 0 on stack.
   773                              <1> ;
   774 0000037C 81C6FE00            <1> 	ADD	SI,0FEh 		; make room for stack
   775 00000380 368936[0000]        <1> 	MOV	[ss:exec_init_SP],SI 	; max value for read is also SP!
   776 00000385 36A3[0200]          <1> 	MOV	[ss:exec_init_SS],AX
   777 00000389 8ED8                <1> 	MOV	DS,AX
   778                              <1>  assume ds:nothing
   779 0000038B C7040000            <1> 	MOV	WORD PTR [SI],0 	; 0 for return
   780                              <1> 
   781                              <1> exec_set_PDB:
   782 0000038F 8B5EF8              <1> 	MOV	BX,[exec_fh]		; we are finished with the file.
   783 00000392 E88401              <1> 	CALL	exec_dealloc
   784 00000395 55                  <1> 	PUSH	BP
   785 00000396 E8(0000)            <1> 	invoke	D_CLOSE			; release the jfn
   786 00000399 5D                  <1> 	POP	BP
   787 0000039A E88801              <1> 	CALL	exec_alloc
   788 0000039D F646FB02            <1> 	TEST	BYTE [exec_func],exec_func_overlay
   789 000003A1 740C                <1> 	JZ	exec_build_header
   790 000003A3 E8AC01              <1> 	CALL	Scan_Execname		;MS.;AN007;
   791 000003A6 E8C001              <1> 	CALL	Scan_Special_Entries	;MS.;AN007;
   792 000003A9 89EC5D              <1> 	Leave
   793 000003AC E9(0000)            <1> 	transfer    SYS_RET_OK		; overlay load -> done
   794                              <1> 
   795                              <1> exec_build_header:
   796 000003AF 8B56EE              <1> 	MOV	DX,[exec_load_block]
   797                              <1> ;
   798                              <1> ; assign the space to the process
   799                              <1> ;
   800                              <1> 
   801 000003B2 BE0100              <1> 	MOV	SI,arena_owner		; pointer to owner field
   802                              <1> 
   803 000003B5 8B46F2              <1> 	MOV	AX,[exec_environ] 	; get environ pointer
   804 000003B8 09C0                <1> 	OR	AX,AX
   805 000003BA 7405                <1> 	JZ	NO_OWNER		; no environment
   806 000003BC 48                  <1> 	DEC	AX			; point to header
   807 000003BD 8ED8                <1> 	MOV	DS,AX
   808                              <1>  assume ds:MCB
   809 000003BF 8914                <1> 	MOV	[SI],DX 		; assign ownership
   810                              <1> NO_OWNER:
   811 000003C1 8B46EE              <1> 	MOV	AX,[exec_load_block]	; get load block pointer
   812 000003C4 48                  <1> 	DEC	AX
   813 000003C5 8ED8                <1> 	MOV	DS,AX			; point to header
   814                              <1>  assume ds:MCB
   815 000003C7 8914                <1> 	MOV	[SI],DX 		; assign ownership
   816                              <1> 
   817 000003C9 1E                  <1> 	PUSH	DS			;AN000;MS. make ES=DS
   818 000003CA 07                  <1> 	POP	ES			;AN000;MS.
   819                              <1>  assume es:MCB
   820                              <1> ARENA_NAME equ arena_name	; NASM port equate
   821 000003CB BF0800              <1> 	MOV	DI,ARENA_NAME		;AN000;MS. ES:DI points to destination
   822 000003CE E88101              <1> 	CALL	Scan_Execname		;AN007;MS. parse execname
   823                              <1> 					;	   ds:si->name, cx=name length
   824 000003D1 51                  <1> 	PUSH	CX			;AN007;;MS. save for fake version
   825 000003D2 56                  <1> 	PUSH	SI			;AN007;;MS. save for fake version
   826                              <1> 
   827 000003D3 83F908              <1> 	cmp cx, 8
   828 000003D6 7603                <1> 	jbe @F
   829 000003D8 B90800              <1> 	mov cx, 8
   830                              <1> @@:
   831 000003DB E312                <1> 	jcxz mem_done
   832                              <1> movename:				;AN000;
   833 000003DD AC                  <1> 	LODSB				;AN000;;MS. get char
   834 000003DE 3C2E                <1> 	CMP	AL,'.'                  ;AN000;;MS. is '.' ,may be name.exe
   835 000003E0 740D                <1> 	JZ	mem_done		;AN000;;MS. no, move to header
   836 000003E2 3C61                <1> 	cmp al, 'a'
   837 000003E4 7206                <1> 	jb @F
   838 000003E6 3C7A                <1> 	cmp al, 'z'
   839 000003E8 7702                <1> 	ja @F
   840 000003EA 2C20                <1> 	sub al, 20h
   841                              <1> @@:
   842 000003EC AA                  <1> 	STOSB				;AN000;;MS. move char
   843 000003ED E2EE                <1> 	LOOP	movename		;AN000;;MS. continue
   844                              <1> mem_done:				;AN000;
   845 000003EF 30C0                <1> 	XOR	AL,AL			;AN000;;MS. make ASCIIZ
   846                              <1> ARENA_struc_size equ arena_struc_size	; NASM port equate
   847 000003F1 83FF10              <1> 	CMP	DI,ARENA_struc_size		;AN000;MS. if not all filled
   848 000003F4 7301                <1> 	JAE	fill8			;AN000;MS.
   849 000003F6 AA                  <1> 	STOSB				;AN000;MS.
   850                              <1> fill8:					;AN000;
   851 000003F7 5E                  <1> 	POP    SI			;AN007;MS. ds:si -> file name
   852 000003F8 59                  <1> 	POP    CX			;AN007;MS.
   853                              <1> 
   854 000003F9 E86D01              <1> 	CALL   Scan_Special_Entries	;AN007;MS.
   855                              <1> 
   856 000003FC 52                  <1> 	PUSH	DX
   857 000003FD 8B76F0              <1> 	MOV	SI,[exec_size]
   858 00000400 01D6                <1> 	ADD	SI,DX
   859 00000402 E8(0000)            <1> 	invoke	D_Dup_PDB		; ES is now PDB
   860 00000405 5A                  <1> 	POP	DX
   861                              <1> 
   862 00000406 FF76F2              <1> 	PUSH	word [exec_environ]
   863 00000409 268F062C00          <1> 	POP	word [ES:PDB_environ]
   864                              <1> ;
   865                              <1> ; set up proper command line stuff
   866                              <1> ;
   867 0000040E C576FC              <1> 	LDS	SI,[exec_blk]		; get the block
   868                              <1>  assume ds:nothing
   869 00000411 1E                  <1> 	PUSH	DS			; save its location
   870 00000412 56                  <1> 	PUSH	SI
   871                              <1> exec0_5C_FCB equ Exec0_5C_FCB	; NASM port equate
   872 00000413 C57406              <1> 	LDS	SI,[SI + exec0_5C_FCB]	; get the 5c fcb
   873                              <1>  assume ds:nothing
   874                              <1> ;
   875                              <1> ; DS points to user space 5C FCB
   876                              <1> ;
   877 00000416 B90C00              <1> 	MOV	CX,12			; copy drive, name and ext
   878 00000419 51                  <1> 	PUSH	CX
   879 0000041A BF5C00              <1> 	MOV	DI,5Ch
   880 0000041D 8A1C                <1> 	MOV	BL,[SI]
   881 0000041F F3A4                <1> 	REP	MOVSB
   882                              <1> ;
   883                              <1> ; DI = 5Ch + 12 = 5Ch + 0Ch = 68h
   884                              <1> ;
   885 00000421 31C0                <1> 	XOR	AX,AX			; zero extent, etc for CPM
   886 00000423 AB                  <1> 	STOSW
   887 00000424 AB                  <1> 	STOSW
   888                              <1> ;
   889                              <1> ; DI = 5Ch + 12 + 4 = 5Ch + 10h = 6Ch
   890                              <1> ;
   891 00000425 59                  <1> 	POP	CX
   892 00000426 5E                  <1> 	POP	SI			; get block
   893 00000427 1F                  <1> 	POP	DS
   894                              <1>  assume ds:nothing
   895 00000428 1E                  <1> 	PUSH	DS			; save (again)
   896 00000429 56                  <1> 	PUSH	SI
   897                              <1> exec0_6C_FCB equ Exec0_6C_FCB	; NASM port equate
   898 0000042A C5740A              <1> 	LDS	SI,[SI + exec0_6C_FCB]	; get 6C FCB
   899                              <1>  assume ds:nothing
   900                              <1> ;
   901                              <1> ; DS points to user space 6C FCB
   902                              <1> ;
   903 0000042D 8A3C                <1> 	MOV	BH,[SI] 		; do same as above
   904 0000042F F3A4                <1> 	REP	MOVSB
   905 00000431 AB                  <1> 	STOSW
   906 00000432 AB                  <1> 	STOSW
   907 00000433 5E                  <1> 	POP	SI			; get block (last time)
   908 00000434 1F                  <1> 	POP	DS
   909                              <1>  assume ds:nothing
   910                              <1> exec0_com_line equ Exec0_com_line	; NASM port equate
   911 00000435 C57402              <1> 	LDS	SI,[SI + exec0_com_line]	; command line
   912                              <1>  assume ds:nothing
   913                              <1> ;
   914                              <1> ; DS points to user space 80 command line
   915                              <1> ;
   916 00000438 80C980              <1> 	OR	CL,80h
   917 0000043B 89CF                <1> 	MOV	DI,CX
   918 0000043D F3A4                <1> 	REP	MOVSB			; Wham!
   919                              <1> ;
   920                              <1> ; Process BX into default AX (validity of drive specs on args).  We no longer
   921                              <1> ; care about DS:SI.
   922                              <1> ;
   923 0000043F FEC9                <1> 	DEC	CL			; get 0FFh in CL
   924 00000441 88F8                <1> 	MOV	AL,BH
   925 00000443 30FF                <1> 	XOR	BH,BH
   926 00000445 E8(0000)            <1> 	invoke	GetVisDrv
   927 00000448 7302                <1> 	JNC	exec_BL
   928 0000044A 88CF                <1> 	MOV	BH,CL
   929                              <1> exec_BL:
   930 0000044C 88D8                <1> 	MOV	AL,BL
   931 0000044E 30DB                <1> 	XOR	BL,BL
   932 00000450 E8(0000)            <1> 	invoke	GetVisDrv
   933                              <1> exec_Set_Return equ exec_set_return	; NASM port label
   934 00000453 7302                <1> 	JNC	exec_Set_Return
   935 00000455 88CB                <1> 	MOV	BL,CL
   936                              <1> exec_set_return:
   937 00000457 E8(0000)            <1> 	invoke	get_user_stack		; get his return address
   938 0000045A FF7414              <1> 	PUSH	word [SI + user_CS]		; suck out the CS and IP
   939 0000045D FF7412              <1> 	PUSH	word [SI + user_IP]
   940 00000460 FF7414              <1> 	PUSH	word [SI + user_CS]		; suck out the CS and IP
   941 00000463 FF7412              <1> 	PUSH	word [SI + user_IP]
   942 00000466 268F060A00          <1> 	POP	WORD PTR [ES:PDB_Exit]
   943 0000046B 268F060C00          <1> 	POP	WORD PTR [ES:PDB_Exit+2]
   944 00000470 31C0                <1> 	XOR	AX,AX
   945 00000472 8ED8                <1> 	MOV	DS,AX
   946                              <1>  assume ds:IVT
   947 00000474 8F068800            <1> 	POP	word [addr_int_terminate] ; save them where we can get them later
   948 00000478 8F068A00            <1> 	POP	word [addr_int_terminate+2]   ; when the child exits.
   949 0000047C 36C706[0000]8000    <1> 	MOV	WORD [ss:DMAADD],80h
   950 00000483 368E1E[0000]        <1> 	MOV	DS,[ss:CurrentPDB]
   951                              <1>  assume ds:PSP
   952 00000488 368C1E[0200]        <1> 	MOV	WORD PTR [ss:DMAADD+2],DS
   953                              <1> 
   954                              <1>  extern ReleaseOwnersMCBs, backdoor_free_mcb_exec, backdoor_indicator
   955 0000048D 53                  <1> 	push bx
   956 0000048E E8(0000)            <1> 	EnterCrit   critMem
   957 00000491 31DB                <1> 	xor bx, bx
   958 00000493 36871E[0000]        <1> 	xchg bx, [ss:backdoor_free_mcb_exec]	; get backdoor owner
   959 00000498 E8(0000)            <1> 	call ReleaseOwnersMCBs			; exec success: free it
   960 0000049B E8(0000)            <1> 	LeaveCrit   critMem
   961 0000049E 1E                  <1> 	push ds
   962 0000049F 36C51E[0000]        <1> 	lds bx, [ss:backdoor_indicator]		; -> indicator
   963                              <1>  assume ds:nothing
   964 000004A4 83FBFF              <1> 	cmp bx, -1				; invalid address ?
   965 000004A7 7409                <1> 	je @F					; yes -->
   966 000004A9 C607FF              <1> 	mov byte [bx], -1			; else, set the indicator
   967 000004AC 36830E[0000]FF      <1> 	or word [ss:backdoor_indicator], -1	; and disable indicator after this
   968                              <1> @@:
   969 000004B2 1F                  <1> 	pop ds
   970                              <1>  assume ds:PSP
   971 000004B3 5B                  <1> 	pop bx
   972                              <1> 
   973 000004B4 F646FB01            <1> 	TEST	BYTE [exec_func],exec_func_no_execute
   974 000004B8 7427                <1> 	JZ	exec_go
   975                              <1> 
   976 000004BA 36C536[0000]        <1> 	LDS	SI,[ss:exec_init_SP]   ; get stack
   977                              <1>  assume ds:nothing
   978 000004BF C47EFC              <1> 	LES	DI,[exec_blk]		; and block for return
   979                              <1>  assume es:nothing
   980                              <1> exec1_SS equ Exec1_SS	; NASM port equate
   981 000004C2 268C5D10            <1> 	MOV	[ES:DI + exec1_SS],DS	; return SS
   982                              <1> 
   983 000004C6 4E                  <1> 	DEC	SI			; 'push' default AX
   984 000004C7 4E                  <1> 	DEC	SI
   985 000004C8 891C                <1> 	MOV	[SI],BX 		; save default AX reg
   986                              <1> exec1_SP equ Exec1_SP	; NASM port equate
   987 000004CA 2689750E            <1> 	MOV	[ES:DI + exec1_SP],SI	; return 'SP'
   988                              <1> 
   989 000004CE 36C506[0400]        <1> 	LDS	AX,[ss:exec_init_IP]
   990                              <1>  assume ds:nothing
   991                              <1> exec1_CS equ Exec1_CS	; NASM port equate
   992 000004D3 268C5D14            <1> 	MOV	[ES:DI + exec1_CS],DS	; initial entry stuff
   993                              <1> 
   994                              <1> exec1_IP equ Exec1_IP	; NASM port equate
   995 000004D7 26894512            <1> 	MOV	[ES:DI + exec1_IP],AX
   996 000004DB 89EC5D              <1> 	Leave
   997 000004DE E9(0000)            <1> 	transfer    SYS_RET_OK
   998                              <1> 
   999                              <1> exec_go:
  1000 000004E1 36C536[0400]        <1> 	LDS	SI,[ss:exec_init_IP]   ; get entry point
  1001                              <1>  assume ds:nothing
  1002 000004E6 36C43E[0000]        <1> 	LES	DI,[ss:exec_init_SP]   ; new stack
  1003                              <1>  assume es:nothing
  1004 000004EB 8CC0                <1> 	MOV	AX,ES
  1005                              <1> ;
  1006                              <1> ; DS:SI points to entry point
  1007                              <1> ; AX:DI points to initial stack
  1008                              <1> ; DX has PDB pointer
  1009                              <1> ; BX has initial AX value
  1010                              <1> ;
  1011 000004ED 1607                <1> 	context es
  1012 000004EF FA                  <1> 	CLI
  1013 000004F0 8ED0                <1> 	MOV	SS,AX			; set up user's stack
  1014 000004F2 89FC                <1> 	MOV	SP,DI			; and SP
  1015                              <1> 	ASSUME	SS:NOTHING
  1016 000004F4 FB                  <1> 	STI
  1017 000004F5 90                  <1> 	nop
  1018 000004F6 9C                  <1> 	pushf				; iret frame
  1019 000004F7 1E                  <1> 	PUSH	DS			; fake long call to entry
  1020 000004F8 56                  <1> 	PUSH	SI
  1021 000004F9 26C606[0000]00      <1> 	mov byte [es:INDOS], 0		; clear InDOS upon DOS stack unused
  1022 000004FF 8EC2                <1> 	MOV	ES,DX			; set up proper seg registers
  1023                              <1>  assume es:nothing
  1024 00000501 8EDA                <1> 	MOV	DS,DX
  1025                              <1>  assume ds:nothing
  1026 00000503 53                  <1> 	push bx				; = ax = bx on stack
  1027                              <1> do_a20_off_ax_on_stack:
  1028 00000504 53                  <1> 	push bx				; for both registers
  1029                              <1> %ifndef BUF2
  1030                              <1> %IF	BUFFERFLAG
  1031                              <1> 	invoke	restore_user_map
  1032                              <1> %ENDIF
  1033                              <1> %endif
  1034                              <1> extern a20off_entry
  1035                              <1> 
  1036 00000505 EA[0000][ssss]      <1> 	jmp DOSENTRY:a20off_entry	; must address XMS entry variable with cs
  1037                              <1> 
  1038                              <1> EndProc D_Exec
  1039                              <1> 
  1040                              <1> Procedure   ExecRead,NEAR
  1040          ******************  <1>  warning: proc ExecRead... [-w+user]
  1041                              <1>  assume ss:DOSGROUP
  1042 0000050A E80C00              <1> 	CALL	exec_dealloc
  1043 0000050D 8B5EF8              <1> 	MOV	bx,[exec_fh]
  1044 00000510 55                  <1> 	PUSH	BP
  1045 00000511 E8(0000)            <1> 	invoke	D_READ
  1046 00000514 5D                  <1> 	POP	BP
  1047 00000515 E80D00              <1> 	CALL	exec_alloc
  1048 00000518 C3                  <1> 	return
  1049                              <1> EndProc ExecRead
  1050                              <1> 
  1051                              <1> procedure   exec_dealloc,near
  1051          ******************  <1>  warning: proc exec_dealloc... [-w+user]
  1052                              <1>  assume ss:DOSGROUP
  1053                              <1> 	ASSUME	    DS:NOTHING,ES:NOTHING
  1054 00000519 53                  <1> 	PUSH	    BX
  1055 0000051A BB0000              <1> 	MOV	    BX,arena_owner_system
  1056 0000051D E8(0000)            <1> 	EnterCrit   CritMEM
  1057 00000520 E81000              <1> 	CALL	    ChangeOwners
  1058 00000523 5B                  <1> 	POP	    BX
  1059 00000524 C3                  <1> 	return
  1060                              <1> EndProc exec_dealloc
  1061                              <1> 
  1062                              <1> procedure   exec_alloc,near
  1062          ******************  <1>  warning: proc exec_alloc... [-w+user]
  1063                              <1>  assume ss:DOSGROUP
  1064 00000525 53                  <1> 	PUSH	    BX
  1065 00000526 368B1E[0000]        <1> 	MOV	    BX,[ss:CurrentPDB]
  1066 0000052B E80500              <1> 	CALL	    ChangeOwners
  1067 0000052E E8(0000)            <1> 	LeaveCrit   CritMEM
  1068 00000531 5B                  <1> 	POP	    BX
  1069 00000532 C3                  <1> 	return
  1070                              <1> EndProc exec_alloc
  1071                              <1> 
  1072                              <1> procedure   ChangeOwners,NEAR
  1072          ******************  <1>  warning: proc ChangeOwners... [-w+user]
  1073                              <1>  assume ss:DOSGROUP
  1074 00000533 9C                  <1> 	pushf
  1075 00000534 50                  <1> 	PUSH	AX
  1076 00000535 8B46F2              <1> 	MOV	AX,[exec_environ]
  1077 00000538 E80900              <1> 	CALL	ChangeOwner
  1078 0000053B 8B46EE              <1> 	MOV	AX,[exec_load_block]
  1079 0000053E E80300              <1> 	Call	ChangeOwner
  1080 00000541 58                  <1> 	POP	AX
  1081 00000542 9D                  <1> 	popf
  1082 00000543 C3                  <1> 	return
  1083                              <1> EndProc ChangeOwners
  1084                              <1> 
  1085                              <1> Procedure   ChangeOwner,near
  1085          ******************  <1>  warning: proc ChangeOwner... [-w+user]
  1086                              <1>  assume ss:DOSGROUP
  1087 00000544 09C0                <1> 	OR	AX,AX			; is area allocated?
  1088 00000546 74FB                <1> 	retz				; no, do nothing
  1089 00000548 48                  <1> 	DEC	AX
  1090 00000549 1E                  <1> 	PUSH	DS
  1091 0000054A 8ED8                <1> 	MOV	DS,AX
  1092                              <1>  assume ds:MCB
  1093 0000054C 891E0100            <1> 	MOV	[arena_owner],BX
  1094 00000550 1F                  <1> 	POP	DS
  1095                              <1>  assume ds:nothing
  1096 00000551 C3                  <1> 	return
  1097                              <1> EndProc ChangeOwner
  1098                              <1> 
  1099                              <1> Procedure    Scan_Execname,near 	;AN000;MS.
  1099          ******************  <1>  warning: proc Scan_Execname... [-w+user]
  1100                              <1> 
  1101 00000552 C576E6              <1> 	LDS	SI,[execName]		;AN000;MS. DS:SI points to name
  1102                              <1> save_begin:				;AN000;
  1103 00000555 89F1                <1> 	MOV	CX,SI			;AN000;MS. CX= starting addr
  1104                              <1> scan0:					;AN000;
  1105 00000557 AC                  <1> 	LODSB				;AN000;MS. get char
  1106 00000558 3C3A                <1> 	CMP	AL,':'                  ;AN000;;MS. is ':' , may be A:name
  1107 0000055A 74F9                <1> 	JZ	save_begin		;AN000;;MS. yes, save si
  1108 0000055C 3C5C                <1> 	CMP	AL,'\'                  ;AN000;;MS. is '\', may be A:\name
  1109 0000055E 74F5                <1> 	JZ	save_begin		;AN000;;MS. yes, save si
  1110 00000560 3C00                <1> 	CMP	AL,0			;AN000;;MS. is end of name
  1111 00000562 75F3                <1> 	JNZ	scan0			;AN000;;MS. no, continue scanning
  1112 00000564 29CE                <1> 	SUB	SI,CX			;AN000;;MS. get name's length
  1113 00000566 87F1                <1> 	XCHG	SI,CX			;AN000;;MS. cx= length, si= starting addr
  1114                              <1> 
  1115 00000568 C3                  <1> 	return				;AN000;;MS.
  1116                              <1> EndProc Scan_Execname			;AN000;;MS.
  1117                              <1> 
  1118                              <1> 
  1119                              <1> Procedure    Scan_Special_Entries,near	;AN000;MS.
  1119          ******************  <1>  warning: proc Scan_Special_Entries... [-w+user]
  1120                              <1>  assume ss:DOSGROUP
  1121                              <1> 
  1122 00000569 49                  <1> 	DEC    CX			;AN007;MS. cx= name length
  1123 0000056A 368B3E[0000]        <1> 	MOV    DI,[ss:Special_Entries]	;AN007;MS. es:di -> addr of special entries
  1124 0000056F E83D00              <1> 	CALL   Reset_Version		;AN008;MS.
  1125 00000572 16                  <1> 	PUSH   ss			;AN007;MS.
  1126 00000573 07                  <1> 	POP    ES			;AN007;MS.
  1127                              <1>  assume es:DOSGROUP
  1128                              <1> Getentries:				;AN007;MS.
  1129 00000574 268A05              <1> 	MOV    AL,[ES:DI]		;AN007;MS. end of list
  1130 00000577 08C0                <1> 	OR     AL,AL			;AN007;MS.
  1131 00000579 7433                <1> 	JZ     end_list 		;AN007;MS. yes
  1132 0000057B 36893E[0000]        <1> 	MOV    [ss:Temp_Var2],DI	;AN007;MS. save di
  1133 00000580 38C8                <1> 	CMP    AL,CL			;AN007;MS. same length ?
  1134 00000582 751C                <1> 	JNZ    skipone			;AN007;MS. no
  1135 00000584 47                  <1> 	INC    DI			;AN007;MS. es:di -> special name
  1136 00000585 51                  <1> 	PUSH   CX			;AN007;MS. save length and name addr
  1137 00000586 56                  <1> 	PUSH   SI			;AN007;MS.
  1138 00000587 F3A6                <1> 	REPZ   CMPSB			;AN007;MS. same name ?
  1139 00000589 7513                <1> 	JNZ    not_matched		;AN007;MS. no
  1140 0000058B 268B05              <1> 	MOV    AX,[ES:DI]		;AN007;MS. get special version
  1141 0000058E 36A3[0000]          <1> 	MOV    [ss:Special_Version],AX	;AN007;MS. save it
  1142 00000592 268A4502            <1> 	MOV    AL,[ES:DI+2]		;AN008;MS. get fake count
  1143 00000596 36A2[0000]          <1> 	MOV    [ss:Fake_Count],AL	;AN007;MS. save it
  1144 0000059A 5E                  <1> 	POP    SI			;AN007;MS.
  1145 0000059B 59                  <1> 	POP    CX			;AN007;MS.
  1146 0000059C EB10                <1> 	JMP    SHORT end_list		;AN007;MS.
  1147                              <1> not_matched:				;AN007;MS.
  1148 0000059E 5E                  <1> 	POP    SI			;AN007;MS. restore si,cx
  1149 0000059F 59                  <1> 	POP    CX			;AN007;MS.
  1150                              <1> skipone:				;AN007;MS.
  1151 000005A0 368B3E[0000]        <1> 	MOV    DI,[ss:Temp_Var2]	;AN007;MS. restore old di
  1152 000005A5 30E4                <1> 	XOR    AH,AH			;AN007;MS. position to next entry
  1153 000005A7 01C7                <1> 	ADD    DI,AX			;AN007;MS.
  1154 000005A9 83C704              <1> 	ADD    DI,4			;AN007;MS.
  1155 000005AC EBC6                <1> 	JMP    Getentries		;AN007;MS.
  1156                              <1> 
  1157                              <1> 
  1158                              <1> end_list:				;AN007;MS.
  1159 000005AE C3                  <1> 	return
  1160                              <1> EndProc Scan_Special_Entries		;AN000;;MS.
  1161                              <1> 
  1162                              <1> Procedure    Reset_Version,near 	;AN008;MS.
  1162          ******************  <1>  warning: proc Reset_Version... [-w+user]
  1163                              <1> 
  1164 000005AF 36803E[0000]FF      <1> 	CMP    byte [ss:Fake_Count],0FFH	;AN008;MS.
  1165 000005B5 7507                <1> 	JNZ    dont_reset		;AN008;MS.
  1166 000005B7 36C706[0000]0000    <1> 	MOV    word [ss:Special_Version],0	;AN008;MS. reset to current version
  1167                              <1> dont_reset:
  1168 000005BE C3                  <1> 	return
  1169                              <1> EndProc Reset_Version,near		;AN008;;MS.
  1170                              <1> 
  1171                              <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
