     1                                  ;	SCCSID = @(#)ibmctrlc.asm	1.1 85/04/10
     2                                  ;
     3                                  ; ^C and error handler for MSDOS
     4                                  ;
     5                                  
     6                                  [list -]
     6          ******************       warning: out: ... CLONE version build switch on ... [-w+user]
    13                                  
    14                                  ;TITLE	Control C detection, Hard error and EXIT routines
    15                                  ;NAME	IBMCTRLC
    16                                  
    17                                  ;=== Push trace listing source: ctrlc.nas
    18                                  %include "ctrlc.nas" ; NASM included file
     1                              <1> ;	SCCSID = @(#)ctrlc.asm	1.4 85/08/16
     2                              <1> ; Low level routines for detecting special characters on CON input,
     3                              <1> ;	the ^C exit/int code, the Hard error INT 24 code, the
     4                              <1> ;	process termination code, and the INT 0 divide overflow handler.
     5                              <1> ;
     6                              <1> ;   FATAL
     7                              <1> ;   FATAL1
     8                              <1> ;   reset_environment
     9                              <1> ;   DSKSTATCHK
    10                              <1> ;   SPOOLINT
    11                              <1> ;   STATCHK
    12                              <1> ;   CNTCHAND
    13                              <1> ;   DIVOV
    14                              <1> ;   CHARHARD
    15                              <1> ;   HardErr_DOS
    16                              <1> ;
    17                              <1> ;   Revision history:
    18                              <1> ;
    19                              <1> ;	AN000	version 4.0   Jan 1988
    20                              <1> ;	A002	PTM    -- dir >lpt3 hangs
    21                              <1> ;	A003	PTM 3957- fake version for IBMCAHE.COM
    22                              <1> 
    23                              <1> ;
    24                              <1> ; get the appropriate segment definitions
    25                              <1> ;
    26                              <1> [list -]
    26          ******************  <1>  warning: redefining multi-line macro `struc' [-w+pp-macro-redef-multi]
    14                              <4> [list -]
    14                              <3> [list -]
     6                              <2> %include "entrysw.mac"
     1                              <3> 
     2                              <3> %ifndef __ENTRYSW_MAC__
     3                              <3>  %assign __ENTRYSW_MAC__ 1
     4                              <3> 
     5                              <3> %assign _DOSCODEHMA		1
     6                              <3> %assign _RELOCATEDOSCODE	1
     7                              <3> 
     8                              <3> 		; Write a label "%1" (only if DOSCODE isn't relocated) and
     9                              <3> 		; "relocated%1" (always).
    10                              <3> 	%imacro relocated 1-2.nolist
    11                              <3> %ifnidni %2, device
    12                              <3>  %ifnidni %2, amis
    13                              <3>   %ifn _RELOCATEDOSCODE
    14                              <3> %1:
    15                              <3> 	global %1
    16                              <3>   %endif
    17                              <3>  %endif
    18                              <3> %endif
    19                              <3> relocated%1:				; always used for local labels
    20                              <3> 	global relocated%1
    21                              <3> 	%endmacro
    22                              <3> 
    23                              <3> %if _RELOCATEDOSCODE
    24                              <3> DOSENTRYADJUSTSEGMENT equ 60h - 26h
    25                              <3> %else
    26                              <3> DOSENTRYADJUSTSEGMENT equ 0
    27                              <3> %endif
    28                              <3> DOSENTRYADJUSTOFFSET equ DOSENTRYADJUSTSEGMENT * 16
    29                              <3> 
    30                              <3> DOSENTRYDEVICEBASE equ 10h
    31                              <3> 
    32                              <3> %endif
     7                              <2> [list -]
    39                              <2> usesection DOSENTRY
    40                              <2> 
    41                              <2> %endif
    28                              <1> %include "dosseg.nas"
     1                              <2> ;	SCCSID = @(#)dosseg.asm	1.1 85/04/10
     2                              <2> ;	SCCSID = @(#)dosseg.asm	1.1 85/04/10
     3                              <2> ;
     4                              <2> ; segment ordering for MSDOS
     5                              <2> ;
     6                              <2> 
     7                              <2> %include "ddataseg.nas"
     1                              <3> 
     2                              <3> %include "lmacros3.mac"
     1                              <4> [list -]
     3                              <3> 
     4                              <3> addsection DOSSTART, align=16 PUBLIC class=DOSSTART
     5                              <3> ; (no prior section) ; DOSSTART		ENDS
     6                              <3> 
     7                              <3> addsection DOSSTARTJUMP, align=1 PUBLIC class=START
     8                              <3> ; (no prior section) ; DOSSTARTJUMP		ENDS
     9                              <3> 
    10                              <3> addsection CONSTANTS, align=2 PUBLIC class=CONST
    11                              <3> ; (no prior section) ; CONSTANTS	ENDS
    12                              <3> 
    13                              <3> addsection DATA, align=2 PUBLIC class=DATA
    14                              <3> ; (no prior section) ; DATA		ENDS
    15                              <3> 
    16                              <3> addsection TABLE, align=2 PUBLIC class=TABLE
    17                              <3> ; (no prior section) ; TABLE		ENDS
    18                              <3> 
    19                              <3> addsection DOSDATATABLE, align=2 PUBLIC class=DOSDATACODE
    20                              <3> ; (no prior section) ; DOSDATATABLE		ENDS
    21                              <3> 
    22                              <3> addsection DOSDATACODE, align=1 PUBLIC class=DOSDATACODE
    23                              <3> ; (no prior section) ; DOSDATACODE		ENDS
    24                              <3> 
    25                              <3> addsection DOSBIODATA, align=2 PUBLIC class=DOSBIODATA
    26                              <3> 
    27                              <3> addsection LAST, align=16 PUBLIC class=LAST
    28                              <3> ; (no prior section) ; LAST		ENDS
    29                              <3> 
    30                              <3> group DOSGROUP DOSSTART DOSSTARTJUMP CONSTANTS DATA TABLE DOSDATATABLE DOSDATACODE DOSBIODATA LAST
     8                              <2> 
     9                              <2> %include "dcodeseg.nas"
     1                              <3> 
     2                              <3> %ifndef DCODESEGNAS
     3                              <3> %assign DCODESEGNAS 1
     4                              <3> 
     5                              <3> section DOSCODETABLE align=2 PUBLIC class=DOSCODE
     6                              <3> ; (no prior section) ; DOSCODETABLE		ENDS
     7                              <3> section DOSCODECODE align=1 PUBLIC class=DOSCODE
     8                              <3> ; (no prior section) ; DOSCODECODE		ENDS
     9                              <3> section DOSBIOCODE align=2 PUBLIC class=DOSCODE
    10                              <3> section BIOCODE	align=2 PUBLIC class=DOSCODE
    11                              <3> 
    12                              <3> %ifnidni DOSENTRYGROUP, DOSCODEGROUP
    13                              <3>  group DOSCODEGROUP DOSCODETABLE DOSCODECODE DOSBIOCODE BIOCODE
    14                              <3> %endif
    15                              <3> 
    16                              <3> %endif
    10                              <2> 
    11                              <2> section LAST
    12                              <2> ; (no prior section) ; LAST		ENDS
    29                              <1> 
    30                              <1> [list +]
    31                              <1> section DOSCODECODE
    32                              <1> [list -]
    32          ******************  <1>  warning: out: ... for DOS Version 4.00 ... [-w+user]
    32          ******************  <1>  warning: out: BPB.INC... [-w+user]
    32          ******************  <1>  warning: out: ... CLONE version build switch on ... [-w+user]
    32          ******************  <1>  warning: out: DEVSYM.INC... [-w+user]
    32          ******************  <1>  warning: out: ... CLONE version build switch on ... [-w+user]
    41                              <1> section DOSCODECODE
    42                              <1> 
    43                              <1> 	I_need	SFN,WORD
    44                              <1> 	I_NEED	pJFN,DWORD
    45                              <1> 	i_need	DevIOBuf,BYTE
    46                              <1> 	i_need	DidCTRLC,BYTE
    47                              <1> 	i_need	INDOS,BYTE
    48                              <1> 	i_need	DSKSTCOM,BYTE
    49                              <1> 	i_need	DSKSTCALL,BYTE
    50                              <1> 	i_need	DSKSTST,WORD
    51                              <1> 	i_need	BCON,DWORD
    52                              <1> 	i_need	DSKCHRET,BYTE
    53                              <1> 	i_need	DSKSTCNT,WORD
    54                              <1> 	i_need	IDLEINT,BYTE
    55                              <1> 	i_need	CONSWAP,BYTE
    56                              <1> 	i_need	user_SS,WORD
    57                              <1> 	i_need	user_SP,WORD
    58                              <1> 	i_need	User_In_AX,WORD
    59                              <1> 	i_need	ERRORMODE,BYTE
    60                              <1> 	i_need	ConC_spsave,WORD
    61                              <1> 	i_need	Exit_type,BYTE
    62                              <1> 	i_need	PFLAG,BYTE
    63                              <1> 	i_need	ExitHold,DWORD
    64                              <1> 	i_need	WPErr,BYTE
    65                              <1> 	i_need	ReadOp,BYTE
    66                              <1> 	i_need	CONTSTK,WORD
    67                              <1> 	i_need	Exit_Code,WORD
    68                              <1> 	i_need	CurrentPDB,WORD
    69                              <1> 	i_need	DIVMES,BYTE
    70                              <1> 	i_need	DivMesLen,WORD
    71                              <1> 	i_need	ALLOWED,BYTE
    72                              <1> 	i_need	FAILERR,BYTE
    73                              <1> 	i_need	EXTERR,WORD
    74                              <1> 	i_need	ERR_TABLE_24,BYTE
    75                              <1> 	I_need	ErrMap24,BYTE
    76                              <1> 	I_need	ErrMap24End,BYTE
    77                              <1> 	I_need	fAborting,BYTE
    78                              <1> 	I_need	AUXStack,BYTE
    79                              <1> 	I_need	SCAN_FLAG,BYTE
    80                              <1> 	I_need	EXTOPEN_ON,BYTE 	      ;AN000; DOS 4.0
    81                              <1> 	I_need	InterCon,BYTE		      ;AN000; DOS 4.0
    82                              <1> 	I_need	DOS34_FLAG,WORD 	      ;AN000; DOS 4.0
    83                              <1> %ifndef BUF2
    84                              <1> 	I_need	ACT_PAGE,WORD		      ;AN000; DOS 4.0
    85                              <1> %endif
    86                              <1> 	I_need	Special_Version,WORD	      ;AN007; DOS 4.0
    87                              <1> %if debug
    88                              <1> 	I_need	BugLev,WORD
    89                              <1> 	I_need	BugTyp,WORD
    90                              <1> %include "bugtyp.nas"
    91                              <1> %endif
    92                              <1> %ifndef BUF2
    93                              <1> %IF	BUFFERFLAG
    94                              <1> 	extrn	restore_user_map:near
    95                              <1> %ENDIF
    96                              <1> %endif
    97                              <1> 
    98                              <1>  assume nocheck, ss:DOSGROUP
    99                              <1> 
   100                              <1> Break	<Checks for ^C in CON I/O>
   101                              <1> 
   102                              <1> 	procedure   DSKSTATCHK,NEAR	; Check for ^C if only one level in
   102          ******************  <1>  warning: proc DSKSTATCHK... [-w+user]
   103                              <1>  ASSUME DS:NOTHING, ES:NOTHING
   104 00000000 36803E[0000]01      <1> 	CMP	BYTE PTR [ss:INDOS],1
   105 00000006 7401C3              <1> 	retnz				; Do NOTHING
   106 00000009 51                  <1> 	PUSH	CX
   107 0000000A 06                  <1> 	PUSH	ES
   108 0000000B 53                  <1> 	PUSH	BX
   109 0000000C 1E                  <1> 	PUSH	DS
   110 0000000D 56                  <1> 	PUSH	SI
   111 0000000E 16                  <1> 	PUSH	ss
   112 0000000F 07                  <1> 	POP	ES
   113                              <1>  assume es:DOSGROUP
   114 00000010 161F                <1> 	Context DS
   115                              <1> 	DOSAssume   CS,<DS>,"DskStatChk"
   116 00000012 C606[0000]05        <1> 	MOV	BYTE PTR [DSKSTCOM],DEVRDND
   117 00000017 C606[0000]0E        <1> 	MOV	BYTE PTR [DSKSTCALL],DRDNDHL
   118 0000001C C706[0000]0000      <1> 	MOV	word [DSKSTST],0
   119                              <1>  %IF  DBCS				;AN000;
   120                              <1> 	MOV	AL, [InterCon]		;AN000;get type of status read 2/13/KK
   121                              <1> 	MOV	BYTE PTR [DSKCHRET],AL	;AN000; load interim flag into packet
   122                              <1>  %ENDIF					;AN000;
   123 00000022 BB[0000]            <1> 	MOV	BX,OFFSET DSKSTCALL wrt DOSGROUP
   124 00000025 C536[0000]          <1> 	LDS	SI,[BCON]
   125                              <1> ASSUME	DS:NOTHING
   126 00000029 E8(0000)            <1> 	invoke	DEVIOCALL2
   127 0000002C 36F706[0000]0002    <1> 	TEST	word [ss:DSKSTST],STBUI
   128 00000033 7408                <1> 	JZ	GotCh			; No characters available
   129 00000035 30C0                <1> 	XOR	AL,AL			; Set zero
   130                              <1> RET36:
   131 00000037 5E                  <1> 	POP	SI
   132 00000038 1F                  <1> 	POP	DS
   133                              <1>  assume ds:nothing
   134 00000039 5B                  <1> 	POP	BX
   135 0000003A 07                  <1> 	POP	ES
   136                              <1>  assume es:nothing
   137 0000003B 59                  <1> 	POP	CX
   138 0000003C C3                  <1> 	return
   139                              <1> 
   140                              <1> GotCh:
   141 0000003D 36A0[0000]          <1> 	MOV	AL,BYTE PTR [ss:DSKCHRET]
   142                              <1> DSK1:
   143 00000041 3C03                <1> 	CMP	AL,"C"-"@"
   144 00000043 75F2                <1> 	JNZ	RET36
   145 00000045 36C606[0000]04      <1> 	MOV	BYTE PTR [ss:DSKSTCOM],DEVRD
   146 0000004B 36C606[0000]16      <1> 	MOV	BYTE PTR [ss:DSKSTCALL],DRDWRHL
   147 00000051 36880E[0000]        <1> 	MOV	BYTE PTR [ss:DSKCHRET],CL
   148 00000056 36C706[0000]0000    <1> 	MOV	word [ss:DSKSTST],0
   149 0000005D 36C706[0000]0100    <1> 	MOV	word [ss:DSKSTCNT],1
   150 00000064 E8(0000)            <1> 	invoke	DEVIOCALL2		; Eat the ^C
   151 00000067 5E                  <1> 	POP	SI
   152 00000068 1F                  <1> 	POP	DS
   153                              <1>  assume ds:nothing
   154 00000069 5B                  <1> 	POP	BX			; Clean stack
   155 0000006A 07                  <1> 	POP	ES
   156                              <1>  assume es:nothing
   157 0000006B 59                  <1> 	POP	CX
   158 0000006C E9C200              <1> 	JMP	CNTCHAND
   159                              <1> 
   160                              <1> NOSTOP:
   161 0000006F 3C10                <1> 	CMP	AL,"P"-"@"
   162 00000071 7509                <1> 	JNZ	.check_next
   163 00000073 36803E[0000]00      <1> 	CMP	BYTE PTR [ss:SCAN_FLAG],0	      ; ALT_Q ?
   164 00000079 7406                <1> 	JZ	INCHKJ			      ; no
   165 0000007B C3                  <1> 	return
   166                              <1> .check_next:
   167                              <1> 	%IFN TOGLPRN
   168                              <1> 	CMP	AL,"N"-"@"
   169                              <1> 	JZ	INCHKJ
   170                              <1> 	%ENDIF
   171                              <1> 
   172 0000007C 3C03                <1> 	CMP	AL,"C"-"@"
   173 0000007E 7401                <1> 	JZ	INCHKJ
   174                              <1> check_end:
   175 00000080 C3                  <1> 	return
   176                              <1> 
   177                              <1> INCHKJ:
   178 00000081 E99700              <1> 	JMP	INCHK
   179                              <1> 
   180                              <1> EndProc DSKSTATCHK
   181                              <1> 
   182                              <1> ;
   183                              <1> ; SpoolInt - signal processes that the DOS is truly idle.  We are allowed to
   184                              <1> ; do this ONLY if we are working on a 1-12 system call AND if we are not in
   185                              <1> ; the middle of an INT 24.
   186                              <1> ;
   187                              <1> procedure   SPOOLINT,NEAR
   187          ******************  <1>  warning: proc SPOOLINT... [-w+user]
   188 00000084 9C                  <1> 	PUSHF
   189                              <1> IdleInt equ IDLEINT	; NASM port label
   190 00000085 36F606[0000]FF      <1> 	test	byte [ss:IdleInt],-1
   191                              <1> POPFRet equ POPFRET	; NASM port label
   192 0000008B 7414                <1> 	jz	POPFRet
   193                              <1> ErrorMode equ ERRORMODE	; NASM port label
   194 0000008D 36F606[0000]FF      <1> 	test	byte [ss:ErrorMode],-1
   195 00000093 750C                <1> 	jnz	POPFRet
   196                              <1> ;
   197                              <1> ; Note that we are going to allow an external program to issue system calls
   198                              <1> ; at this time.  We MUST preserve IdleInt across this.
   199                              <1> ;
   200 00000095 36FF36[0000]        <1> 	PUSH	WORD [ss:IdleInt]
   201 0000009A CD28                <1> 	INT	int_spooler
   202 0000009C 368F06[0000]        <1> 	POP	WORD [ss:IdleInt]
   203                              <1> POPFRET:
   204 000000A1 9D                  <1> 	POPF
   205 000000A2 C3                  <1> 	return
   206                              <1> EndProc SPOOLINT
   207                              <1> 
   208                              <1> 	procedure   STATCHK,NEAR
   208          ******************  <1>  warning: proc STATCHK... [-w+user]
   209                              <1> 
   210 000000A3 E85AFF              <1> 	invoke	DSKSTATCHK		; Allows ^C to be detected under
   211                              <1> 					; input redirection
   212 000000A6 53                  <1> 	PUSH	BX
   213 000000A7 31DB                <1> 	XOR	BX,BX
   214 000000A9 E8(0000)            <1> 	invoke	GET_IO_SFT
   215 000000AC 5B                  <1> 	POP	BX
   216 000000AD 72F3                <1> 	retc
   217 000000AF B401                <1> 	MOV	AH,1
   218 000000B1 E8(0000)            <1> 	invoke	IOFUNC
   219 000000B4 74CE                <1> 	JZ	SPOOLINT
   220 000000B6 3C13                <1> 	CMP	AL,"S"-"@"
   221 000000B8 75B5                <1> 	JNZ	NOSTOP
   222                              <1> 
   223 000000BA 36803E[0000]00      <1> 	CMP	BYTE PTR [ss:SCAN_FLAG],0	      ;AN000; ALT_R ?
   224 000000C0 75BE                <1> 	JNZ	check_end		      ;AN000; yes
   225 000000C2 30E4                <1> 	XOR	AH,AH
   226 000000C4 E8(0000)            <1> 	invoke	IOFUNC			; Eat Cntrl-S
   227 000000C7 EB4B                <1> 	JMP	SHORT PAUSOSTRT
   228                              <1> PRINTOFF:
   229                              <1> PRINTON:
   230 000000C9 36F616[0000]        <1> 	NOT	BYTE PTR [ss:PFLAG]
   231 000000CE 53                  <1> 	PUSH	BX
   232 000000CF BB0400              <1> 	MOV	BX,4
   233 000000D2 E8(0000)            <1> 	invoke	GET_IO_SFT
   234 000000D5 5B                  <1> 	POP	BX
   235 000000D6 72CA                <1> 	retc
   236 000000D8 06                  <1> 	PUSH	ES
   237 000000D9 57                  <1> 	PUSH	DI
   238 000000DA 1E                  <1> 	PUSH	DS
   239 000000DB 07                  <1> 	POP	ES
   240                              <1>  assume es:nothing
   241 000000DC 89F7                <1> 	MOV	DI,SI			; ES:DI -> SFT
   242 000000DE 26F745050008        <1> 	TEST	word [ES:DI + sf_flags],sf_net_spool
   243 000000E4 7418                <1> 	JZ	NORM_PR 		; Not redirected, echo is OK
   244                              <1> MultNet equ MultNET	; NASM port equate
   245 000000E6 50B82611CD2F58      <1> 	Callinstall NetSpoolEchoCheck,MultNet,38,<AX>,<AX> ; See if allowed
   246 000000ED 730F                <1> 	JNC	NORM_PR 		; Echo is OK
   247 000000EF 36C606[0000]00      <1> 	MOV	BYTE PTR [ss:PFLAG],0	; If not allowed, disable echo
   248 000000F5 50B82411CD2F58      <1> 	Callinstall NetSpoolClose,MultNet,36,<AX>,<AX> ; and close
   249 000000FC EB10                <1> 	JMP	SHORT RETP6
   250                              <1> 
   251                              <1> NORM_PR:
   252 000000FE 36803E[0000]00      <1> 	CMP	BYTE PTR [ss:PFLAG],0
   253 00000104 7505                <1> 	JNZ	PRNOPN
   254 00000106 E8(0000)            <1> 	invoke	DEV_CLOSE_SFT
   255 00000109 EB03                <1> 	JMP	SHORT RETP6
   256                              <1> 
   257                              <1> PRNOPN:
   258 0000010B E8(0000)            <1> 	invoke	DEV_OPEN_SFT
   259                              <1> RETP6:
   260 0000010E 5F                  <1> 	POP	DI
   261 0000010F 07                  <1> 	POP	ES
   262                              <1>  assume es:nothing
   263 00000110 C3                  <1> 	return
   264                              <1> 
   265                              <1> PAUSOLP:
   266 00000111 E870FF              <1> 	CALL	SPOOLINT
   267                              <1> PAUSOSTRT:
   268 00000114 B401                <1> 	MOV	AH,1
   269 00000116 E8(0000)            <1> 	invoke	IOFUNC
   270 00000119 74F6                <1> 	JZ	PAUSOLP
   271                              <1> INCHK:
   272 0000011B 53                  <1> 	PUSH	BX
   273 0000011C 31DB                <1> 	XOR	BX,BX
   274 0000011E E8(0000)            <1> 	invoke	GET_IO_SFT
   275 00000121 5B                  <1> 	POP	BX
   276 00000122 72EC                <1> 	retc
   277 00000124 30E4                <1> 	XOR	AH,AH
   278 00000126 E8(0000)            <1> 	invoke	IOFUNC
   279 00000129 3C10                <1> 	CMP	AL,"P"-"@"
   280                              <1> ;;;;;  7/14/86	ALT_Q key fix
   281                              <1> 
   282 0000012B 749C                <1> 	JZ	PRINTON 		      ; no! must be CTRL_P
   283                              <1> 
   284                              <1> NOPRINT:
   285                              <1> ;;;;;  7/14/86	ALT_Q key fix
   286                              <1> 	%IFN TOGLPRN
   287                              <1> 	CMP	AL,"N"-"@"
   288                              <1> 	JZ	PRINTOFF
   289                              <1> 	%ENDIF
   290 0000012D 3C03                <1> 	CMP	AL,"C"-"@"
   291 0000012F 75DF                <1> 	retnz
   292                              <1> EndProc STATCHK
   293                              <1> 
   294                              <1> 	procedure   CNTCHAND,NEAR
   294          ******************  <1>  warning: proc CNTCHAND... [-w+user]
   295                              <1> ; Ctrl-C handler.
   296                              <1> ; "^C" and CR/LF is printed.  Then the user registers are restored and the
   297                              <1> ; user CTRL-C handler is executed.  At this point the top of the stack has 1)
   298                              <1> ; the interrupt return address should the user CTRL-C handler wish to allow
   299                              <1> ; processing to continue; 2) the original interrupt return address to the code
   300                              <1> ; that performed the function call in the first place.	If the user CTRL-C
   301                              <1> ; handler wishes to continue, it must leave all registers unchanged and RET
   302                              <1> ; (not IRET) with carry CLEAR.	If carry is SET then an terminate system call
   303                              <1> ; is simulated.
   304 00000131 36F706[0000]0002    <1> 	TEST	word [ss:DOS34_FLAG],CTRL_BREAK_FLAG  ;AN002; from RAWOUT
   305 00000138 7508                <1> 	JNZ	around_deadlock 	      ;AN002;
   306 0000013A B003                <1> 	MOV	AL,3			; Display "^C"
   307 0000013C E8(0000)            <1> 	invoke	BUFOUT
   308 0000013F E8(0000)            <1> 	invoke	CRLF
   309                              <1> around_deadlock:			      ;AN002;
   310 00000142 161F                <1> 	Context DS
   311 00000144 803E[0000]00        <1> 	CMP	BYTE PTR [CONSWAP],0
   312 00000149 7403                <1> 	JZ	NOSWAP
   313 0000014B E8(0000)            <1> 	invoke	SWAPBACK
   314                              <1> NOSWAP:
   315 0000014E FA                  <1> 	CLI				; Prepare to play with stack
   316 0000014F 8E16[0000]          <1> 	MOV	SS,[user_SS]		; User stack now restored
   317                              <1> ASSUME	SS:NOTHING
   318 00000153 8B26[0000]          <1> 	MOV	SP,[user_SP]
   319 00000157 E8(0000)            <1> 	invoke	restore_world		; User registers now restored
   320                              <1> ASSUME	DS:NOTHING
   321 0000015A 53                  <1> 	push bx
   322 0000015B 53                  <1> 	push bx
   323 0000015C BB[0000]            <1> 	mov bx, .next
   324                              <1> extern transfer_doscode_to_dosdata
   325 0000015F E9(0000)            <1> 	jmp transfer_doscode_to_dosdata
   326                              <1> 
   327                              <1> section DOSDATACODE	; in DOSDATA
   328                              <1> .next:
   329 00000000 83C406              <1> 	add sp, 6			; discard retn & retf addresses
   330                              <1> 
   331 00000003 2EC606[0000]00      <1> 	MOV	BYTE PTR [cs:INDOS],0	; Go to known state
   332 00000009 2EC606[0000]00      <1> 	MOV	BYTE PTR [cs:ERRORMODE],0
   333 0000000F 2E8926[0000]        <1> 	MOV	[cs:ConC_spsave],SP	; save his SP
   334 00000014 F8                  <1> 	CLC
   335 00000015 CD23                <1> 	INT	int_ctrl_c		; Execute user Ctrl-C handler
   336                              <1> ;
   337                              <1> ; The user has returned to us.	The circumstances we allow are:
   338                              <1> ;
   339                              <1> ;   IRET	We retry the operation by redispatching the system call
   340                              <1> ;   CLC/RETF	POP the stack and retry
   341                              <1> ;   ... 	Exit the current process with ^C exit
   342                              <1> ;
   343                              <1> ; User's may RETURN to us and leave interrupts on.  Turn 'em off just to be
   344                              <1> ; sure
   345                              <1> ;
   346 00000017 FA                  <1> 	CLI
   347                              <1> user_IN_AX equ User_In_AX	; NASM port label
   348 00000018 2EA3[0000]          <1> 	MOV	[cs:user_IN_AX],ax 	; save the AX
   349 0000001C 9C                  <1> 	PUSHF				; and the flags (maybe new call)
   350 0000001D 58                  <1> 	POP	AX
   351                              <1> ;
   352                              <1> ; See if the input stack is identical to the output stack
   353                              <1> ;
   354 0000001E 2E3B26[0000]        <1> 	CMP	SP,[cs:ConC_spsave]
   355 00000023 7506                <1> 	JNZ	ctrlc_try_new		; current SP not the same as saved SP
   356                              <1> ;
   357                              <1> ; Repeat the operation by redispatching the system call.
   358                              <1> ;
   359                              <1> ctrlc_repeat:
   360 00000025 2EA1[0000]          <1> 	MOV	AX,[cs:User_In_AX]
   361 00000029 EB10                <1> 	jmp ctrlc_transfer_COMMAND
   362                              <1> ;
   363                              <1> ; The current SP is NOT the same as the input SP.  Presume that he RETF'd
   364                              <1> ; leaving some flags on the stack and examine the input
   365                              <1> ;
   366                              <1> ctrlc_try_new:
   367 0000002B 83C402              <1> 	ADD	SP,2			; pop those flags
   368 0000002E A801                <1> 	test al, f_Carry		; did they return with carry?
   369 00000030 74F3                <1> 	jz ctrlc_repeat			; no carry set, just retry
   370                              <1> ;
   371                              <1> ; Well...  time to abort the user.  Signal a ^C exit and use the EXIT system
   372                              <1> ; call..
   373                              <1> ;
   374                              <1> ctrlc_abort:
   375                              <1> EXIT equ Exit	; NASM port equate
   376 00000032 B8004C              <1> 	MOV	AX,(EXIT << 8) + 0
   377 00000035 2EC606[0000]FF      <1> 	MOV	byte [cs:DidCTRLC],-1
   378                              <1> 					; give up by faking $EXIT
   379                              <1> ctrlc_transfer_COMMAND:
   380                              <1>  extern i21
   381 0000003B EA[A003][ssss]      <1> 	jmp DOSENTRY - DOSENTRYADJUSTSEGMENT:i21 + DOSENTRYADJUSTOFFSET
   382                              <1> 
   383                              <1> 
   384                              <1> section DOSCODECODE
   385                              <1> 
   386                              <1> extern doscode_getdosdata
   387                              <1> 
   388                              <1> %if _RELOCATEDOSCODE
   389                              <1>  extern relocatedi19
   390                              <1> relocated _i00_i19
   391 00000162 7303E9(0000)        <1> 	jc relocatedi19
   392                              <1> %endif
   393                              <1> relocated i00
   394 00000167 50                  <1> 	push ax
   395 00000168 E8(0000)            <1> 	call doscode_getdosdata
   396 0000016B 50                  <1> 	push ax
   397 0000016C B8[4000]            <1> 	mov ax, DIVOV
   398 0000016F 50                  <1> 	push ax
   399 00000170 CB                  <1> 	retf
   400                              <1> 
   401                              <1> 
   402                              <1> section DOSDATACODE	; in DOSDATA
   403                              <1> 
   404                              <1> Break	<DIVISION OVERFLOW INTERRUPT>
   405                              <1> 
   406                              <1> ; Default handler for division overflow trap
   407                              <1> 	procedure   DIVOV,NEAR
   407          ******************  <1>  warning: proc DIVOV... [-w+user]
   408                              <1>  ASSUME cs:DOSGROUP, DS:NOTHING,ES:NOTHING,SS:NOTHING
   409                              <1>  extern dosdata_to_doscode
   410 00000040 2E8E06[0000]        <1> 	mov es, [cs:dosdata_to_doscode]
   411                              <1>  assume es:DOSCODEGROUP
   412 00000045 BE[0000]            <1> 	MOV	SI,OFFSET DIVMES	; access with es
   413 00000048 268B1E[0000]        <1> 	MOV	BX,[es:DivMesLen]
   414 0000004D 8CC8                <1> 	MOV	AX,CS
   415                              <1> AUXSTACK equ AUXStack	; NASM port label
   416 0000004F 8ED0                <1> 	MOV	SS,AX
   417 00000051 BC[0000]            <1> 	MOV	SP,OFFSET AUXSTACK wrt DOSGROUP ; Enough stack for interrupts
   418                              <1>  assume ss:DOSGROUP
   419 00000054 E80200              <1> 	CALL	OutMes
   420 00000057 EBD9                <1> 	JMP	ctrlc_abort		; Use Ctrl-C abort on divide overflow
   421                              <1> EndProc DIVOV
   422                              <1> 
   423                              <1> ;
   424                              <1> ; OutMes: perform message output
   425                              <1> ; Inputs:   SS:SI points to message
   426                              <1> ;	    BX has message length
   427                              <1> ; Outputs:  message to BCON
   428                              <1> ;
   429                              <1> procedure   OutMes,NEAR
   429          ******************  <1>  warning: proc OutMes... [-w+user]
   430                              <1>  assume ss:DOSGROUP, es:DOSCODEGROUP
   431 00000059 161F                <1> 	Context DS			; get DS addressability
   432                              <1> 
   433                              <1> DskStCom equ DSKSTCOM	; NASM port label
   434                              <1> DevWrt equ DEVWRT	; NASM port equate
   435 0000005B C606[0000]08        <1> 	MOV	BYTE PTR [DskStCom],DevWrt
   436                              <1> DskStCall equ DSKSTCALL	; NASM port label
   437                              <1> DRdWrHL equ DRDWRHL	; NASM port equate
   438 00000060 C606[0000]16        <1> 	MOV	BYTE PTR [DskStCall],DRdWrHL
   439                              <1> DskSTST equ DSKSTST	; NASM port label
   440 00000065 C706[0000]0000      <1> 	MOV	word [DskSTST],0
   441                              <1> DskStCnt equ DSKSTCNT	; NASM port label
   442 0000006B 891E[0000]          <1> 	MOV	[DskStCnt],BX
   443 0000006F BB[0000]            <1> 	MOV	BX,OFFSET DskStCall wrt DOSGROUP
   444                              <1> DskChRet equ DSKCHRET	; NASM port label
   445 00000072 8936[0100]          <1> 	MOV	WORD PTR [DskChRet+1],SI    ; transfer address (need an EQU)
   446 00000076 8C06[0300]          <1> 	MOV	WORD PTR [DskChRet+3], es
   447 0000007A C536[0000]          <1> 	LDS	SI,[BCON]
   448                              <1> ASSUME	DS:NOTHING
   449 0000007E 0E                  <1> 	push cs				; allow far return
   450 0000007F E81400              <1> 	call int0_transfer_deviocall2
   451                              <1>  assume ss:DOSGROUP, es:DOSGROUP
   452 00000082 36C706[0100][0000]  <1> 	MOV	WORD PTR [ss:DskChRet+1], OFFSET DevIOBuf wrt DOSGROUP
   453 00000089 368C16[0300]        <1> 	MOV	WORD PTR [ss:DskChRet+3], ss
   454 0000008E 36C706[0000]0100    <1> 	MOV	word [ss:DskStCnt],1
   455 00000095 C3                  <1> 	return
   456                              <1> EndProc OutMes
   457                              <1> 
   458                              <1> 
   459                              <1> int0_transfer_deviocall2:
   460                              <1>  assume ss:DOSGROUP, es:DOSCODEGROUP
   461 00000096 06                  <1> 	push es
   462 00000097 B8[7101]            <1> 	mov ax, .next			; access with es
   463 0000009A 50                  <1> 	push ax
   464 0000009B 1607                <1> 	Context ES			; get ES addressability
   465 0000009D CB                  <1> 	retf				; branch into DOSCODE
   466                              <1> 
   467                              <1> section DOSCODECODE
   468                              <1> 
   469                              <1> .next:
   470                              <1>  assume ss:DOSGROUP, es:DOSGROUP
   471 00000171 E8(0000)            <1> 	invoke	DEVIOCALL2		; call routine
   472 00000174 CB                  <1> 	retf				; return back to code in DOSDATA
   473                              <1> 
   474                              <1> 
   475                              <1> Break	<CHARHRD,HARDERR_DOS,ERROR -- HANDLE DISK ERRORS AND RETURN TO USER>
   476                              <1> 
   477                              <1> 	procedure   CHARHARD,NEAR
   477          ******************  <1>  warning: proc CHARHARD... [-w+user]
   478                              <1> ASSUME	DS:NOTHING,ES:NOTHING,SS:DOSGROUP
   479                              <1> 
   480                              <1> ; Character device error handler
   481                              <1> ; Same function as HARDERR_DOS
   482                              <1> 
   483                              <1> allowed_FAIL equ Allowed_FAIL	; NASM port equate
   484                              <1> allowed_IGNORE equ Allowed_IGNORE	; NASM port equate
   485                              <1> allowed_RETRY equ Allowed_RETRY	; NASM port equate
   486 00000175 80CC38              <1> 	OR	AH,allowed_FAIL + allowed_IGNORE + allowed_RETRY
   487                              <1> Allowed equ ALLOWED	; NASM port label
   488 00000178 368826[0000]        <1> 	MOV	[ss:Allowed],AH
   489                              <1> EXITHOLD equ ExitHold	; NASM port label
   490 0000017D 368C06[0200]        <1> 	MOV	WORD PTR [ss:EXITHOLD+2],ES
   491 00000182 36892E[0000]        <1> 	MOV	WORD PTR [ss:EXITHOLD],BP
   492 00000187 56                  <1> 	PUSH	SI
   493 00000188 81E7FF00            <1> 	AND	DI,STECODE
   494 0000018C 8CDD                <1> 	MOV	BP,DS			; Device pointer is BP:SI
   495 0000018E E86400              <1> 	CALL	FATALC
   496 00000191 5E                  <1> 	POP	SI
   497 00000192 C3                  <1> 	return
   498                              <1> EndProc CHARHARD
   499                              <1> 
   500                              <1> ; Hard disk error handler. Entry conditions:
   501                              <1> ;	DS:BX = Original disk transfer address
   502                              <1> ;	DX = Original logical sector number
   503                              <1> ;	CX = Number of sectors to go (first one gave the error)
   504                              <1> ;	AX = Hardware error code
   505                              <1> ;	DI = Original sector transfer count
   506                              <1> ;	ES:BP = Base of drive parameters
   507                              <1> ;	[READOP] = 0 for read, 1 for write
   508                              <1> ;	[ALLOWED] Set with allowed responses to this error (other bits MUST BE 0)
   509                              <1> ; Output:
   510                              <1> ;	[FAILERR] will be set if user responded FAIL
   511                              <1> 
   512                              <1> 	procedure   HardErr_DOS,NEAR
   512          ******************  <1>  warning: proc HardErr_DOS... [-w+user]
   513                              <1> 	ASSUME	DS:NOTHING,ES:NOTHING
   514                              <1> 
   515 00000193 97                  <1> 	XCHG	AX,DI			; Error code in DI, count in AX
   516 00000194 81E7FF00            <1> 	AND	DI,STECODE		; And off status bits
   517 00000198 83FF00              <1> 	CMP	DI,error_I24_write_protect ; Write Protect Error?
   518 0000019B 750A                <1> 	JNZ	NOSETWRPERR
   519 0000019D 50                  <1> 	PUSH	AX
   520 0000019E 268A4600            <1> 	MOV	AL,[ES:BP + dpb_drive]
   521                              <1> WPERR equ WPErr	; NASM port label
   522 000001A2 36A2[0000]          <1> 	MOV	BYTE PTR [ss:WPERR],AL	; Flag drive with WP error
   523 000001A6 58                  <1> 	POP	AX
   524                              <1> NOSETWRPERR:
   525 000001A7 29C8                <1> 	SUB	AX,CX			; Number of sectors successfully transferred
   526 000001A9 01C2                <1> 	ADD	DX,AX			; First sector number to retry
   527 000001AB 52                  <1> 	PUSH	DX
   528 000001AC 26F76602            <1> 	MUL	word [ES:BP + dpb_sector_size] ; Number of bytes transferred
   529 000001B0 5A                  <1> 	POP	DX
   530 000001B1 01C3                <1> 	ADD	BX,AX			; First address for retry
   531 000001B3 30E4                <1> 	XOR	AH,AH			; Flag disk section in error
   532 000001B5 263B5606            <1> 	CMP	DX,[ES:BP + dpb_first_FAT]    ; In reserved area?
   533 000001B9 721A                <1> 	JB	ERRINT
   534 000001BB FEC4                <1> 	INC	AH			; Flag for FAT
   535 000001BD 263B5611            <1> 	CMP	DX,[ES:BP + dpb_dir_sector]   ; In FAT?
   536 000001C1 7308                <1> 	JAE	TESTDIR 		; No
   537 000001C3 26C7461FFFFF        <1> 	MOV	word [ES:BP + dpb_free_cnt],-1 ; Err in FAT must force recomp of freespace
   538 000001C9 EB0A                <1> 	JMP	SHORT ERRINT
   539                              <1> 
   540                              <1> TESTDIR:
   541 000001CB FEC4                <1> 	INC	AH
   542 000001CD 263B560B            <1> 	CMP	DX,[ES:BP + dpb_first_sector] ; In directory?
   543 000001D1 7202                <1> 	JB	ERRINT
   544 000001D3 FEC4                <1> 	INC	AH			; Must be in data area
   545                              <1> ERRINT:
   546 000001D5 D0E4                <1> 	SHL	AH,1			; Make room for read/write bit
   547                              <1> READOP equ ReadOp	; NASM port label
   548 000001D7 360A26[0000]        <1> 	OR	AH,BYTE PTR [ss:READOP]	; Set bit 0
   549                              <1> ; If we have a write protect error when writing on a critical area on disk,
   550                              <1> ; do not allow a retry as this may write out garbage on any subsequent disk.
   551                              <1> 	;test	ah,1
   552                              <1> 	;jz	Not_Crit
   553                              <1> 	;cmp	ah,5
   554                              <1> 	;ja	Not_Crit
   555                              <1> 	;and	[ALLOWED],NOT Allowed_RETRY
   556                              <1> Not_Crit:
   557 000001DC 360A26[0000]        <1> 	OR	AH,[ss:ALLOWED]		; Set the allowed_ bits
   558                              <1> 	entry	FATAL
   559 000001E1 268A4600            <1> 	MOV	AL,[ES:BP + dpb_drive]	; Get drive number
   560                              <1> 	entry	FATAL1
   561 000001E5 368C06[0200]        <1> 	MOV	WORD PTR [ss:EXITHOLD+2],ES
   562 000001EA 36892E[0000]        <1> 	MOV	WORD PTR [ss:EXITHOLD],BP	; The only things we preserve
   563 000001EF 26C47613            <1> 	LES	SI,[ES:BP + dpb_driver_addr]
   564 000001F3 8CC5                <1> 	MOV	BP,ES			; BP:SI points to the device involved
   565                              <1> ;
   566                              <1> ; DI has the INT-24-style extended error.  We now map the error code for this
   567                              <1> ; into the normalized get extended error set by using the ErrMap24 table as an
   568                              <1> ; translate table.  Note that we translate ONLY the device returned codes and
   569                              <1> ; leave all others beyond the look up table alone.
   570                              <1> ;
   571                              <1> FATALC:
   572 000001F5 E88F01              <1> 	call	SET_I24_EXTENDED_ERROR
   573 000001F8 83FF0C              <1> 	CMP	DI,error_I24_gen_failure
   574 000001FB 7603                <1> 	JBE	GOT_RIGHT_CODE		; Error codes above gen_failure get
   575 000001FD BF0C00              <1> 	MOV	DI,error_I24_gen_failure ; mapped to gen_failure. Real codes
   576                              <1> 					;  Only come via GetExtendedError
   577                              <1> 
   578                              <1> 	entry	NET_I24_ENTRY
   579                              <1> ; Entry point used by REDIRector on Network I 24 errors.
   580                              <1> ;
   581                              <1>  ASSUME DS:NOTHING, ES:NOTHING, SS:DOSGROUP
   582                              <1> ;
   583                              <1> ; ALL I 24 regs set up. ALL Extended error info SET. ALLOWED Set.
   584                              <1> ;     EXITHOLD set for restore of ES:BP.
   585                              <1> 
   586                              <1> GOT_RIGHT_CODE:
   587 00000200 36803E[0000]00      <1> 	CMP	BYTE PTR [ss:ERRORMODE],0	; No INT 24s if already INT 24
   588 00000206 7405                <1> 	JZ	NoSetFail
   589 00000208 B003                <1> 	MOV	AL,3
   590                              <1> FailRet equ FAILRET	; NASM port label
   591 0000020A EB67                <1> 	JMP	FailRet
   592 0000020C 90                  <1> 	nop	; identicalise
   593                              <1> NoSetFail:
   594 0000020D 368926[0000]        <1> 	MOV	[ss:CONTSTK],SP
   595 00000212 1607                <1> 	Context ES
   596                              <1> 	fmt TypINT24,LevLog,<"INT 24: AX = $x DI = $x\n">,<AX,DI>
   597                              <1> ;
   598                              <1> ; Wango!!!  We may need to free some user state info...  In particular, we
   599                              <1> ; may have locked down a JFN for a user and he may NEVER return to us.	Thus,
   600                              <1> ; we need to free it here and then reallocate it when we come back.
   601                              <1> ;
   602 00000214 36833E[0000]FF      <1> 	CMP	word [ss:SFN],-1
   603 0000021A 740C                <1> 	JZ	NoFree
   604 0000021C 1E56                <1> 	SaveReg <DS,SI>
   605 0000021E 36C536[0000]        <1> 	LDS	SI,[ss:pJFN]
   606 00000223 C604FF              <1> 	MOV	BYTE PTR [SI],0FFH
   607 00000226 5E1F                <1> 	RestoreReg  <SI,DS>
   608                              <1> NoFree:
   609 00000228 FA                  <1> 	CLI				; Prepare to play with stack
   610 00000229 36FE06[0000]        <1> 	INC	BYTE PTR [ss:ERRORMODE]	; Flag INT 24 in progress
   611                              <1> ;; Extended Open hooks
   612 0000022E 36F706[0000]2000    <1> 	TEST	word [ss:DOS34_FLAG],Force_I24_Fail   ;AN000;IFS. form IFS Call Back	      ;AN000;
   613 00000235 7508                <1> 	JNZ	faili24 		      ;AN000;IFS.			      ;AN000;
   614                              <1> EXT_OPEN_I24_OFF equ ext_open_I24_off	; NASM port equate
   615 00000237 36F606[0000]02      <1> 	TEST	byte [ss:EXTOPEN_ON],EXT_OPEN_I24_OFF ;AN000;IFS.I24 error disabled	      ;AN000;
   616 0000023D 7404                <1> 	JZ	i24yes			      ;AN000;IFS.no			      ;AN000;
   617                              <1> faili24:				      ;AN000;
   618 0000023F B003                <1> 	MOV	AL,3			      ;AN000;IFS.fake fail		      ;AN000;
   619 00000241 EB24                <1> 	JMP	passi24 		      ;AN000;IFS.exit			      ;AN000;
   620                              <1> i24yes: 				      ;AN000;
   621                              <1> 
   622                              <1> ;; Extended Open hooks
   623 00000243 368E16[0000]        <1> 	MOV	SS,[ss:user_SS]
   624 00000248 268B26[0000]        <1> 	MOV	SP,[ES:user_SP] 	; User stack pointer restored
   625                              <1>  ASSUME SS:NOTHING
   626 0000024D 26FE0E[0000]        <1> 	DEC	BYTE PTR [es:INDOS]	; INT 24 handler might not return
   627 00000252 CD24                <1> 	INT	int_fatal_abort 	; Fatal error interrupt vector, must preserve ES
   628 00000254 26FE06[0000]        <1> 	INC	BYTE PTR [es:INDOS]	; Back in the DOS
   629 00000259 268926[0000]        <1> 	MOV	[ES:user_SP],SP 	; restore our stack
   630 0000025E 268C16[0000]        <1> 	MOV	[ES:user_SS],SS
   631 00000263 8CC5                <1> 	MOV	BP,ES
   632 00000265 8ED5                <1> 	MOV	SS,BP
   633                              <1> passi24:				;AN000;
   634                              <1>  assume nocheck, ss:DOSGROUP
   635 00000267 368B26[0000]        <1> 	MOV	SP,[ss:CONTSTK]
   636                              <1> ASSUME	SS:DOSGROUP
   637 0000026C 36C606[0000]00      <1> 	MOV	BYTE PTR [ss:ERRORMODE],0	; Back from INT 24
   638 00000272 FB                  <1> 	STI
   639                              <1> ;;	MOV	[ACT_PAGE],-1		;LB. invalidate DOS active page 	;AN000;
   640                              <1> ;;	invoke	SAVE_MAP		;LB. save user's EMS map                ;AN000;
   641                              <1> 	fmt TypINT24,LevLog,<"INT 24: User reply = $x\n">,<AX>
   642                              <1> FAILRET:
   643 00000273 36C42E[0000]        <1> 	LES	BP,[ss:EXITHOLD]
   644                              <1> ASSUME	ES:NOTHING
   645                              <1> ;
   646                              <1> ; Triage the user's reply.
   647                              <1> ;
   648 00000278 3C01                <1> 	CMP	AL,1
   649 0000027A 723E                <1> 	JB	CheckIgnore		; 0 => ignore
   650 0000027C 7446                <1> 	JZ	CheckRetry		; 1 => retry
   651 0000027E 3C03                <1> 	CMP	AL,3			; 3 => fail
   652 00000280 754C                <1> 	JNZ	DoAbort 		; 2, invalid => abort
   653                              <1> ;
   654                              <1> ; The reply was fail.  See if we are allowed to fail.
   655                              <1> ;
   656 00000282 36F606[0000]08      <1> 	TEST	byte [ss:ALLOWED],allowed_FAIL	; Can we?
   657 00000288 7444                <1> 	JZ	DoAbort 		; No, do abort
   658                              <1> DoFail:
   659 0000028A B003                <1> 	MOV	AL,3			; just in case...
   660 0000028C 36F606[0000]02      <1> 	TEST	byte [ss:EXTOPEN_ON],EXT_OPEN_I24_OFF ;AN000;EO. I24 error disabled
   661                              <1> cleanup equ CleanUp	; NASM port label
   662 00000292 7505                <1> 	JNZ	cleanup 		      ;AN000;EO. no
   663 00000294 36FE06[0000]        <1> 	INC	byte [ss:FAILERR]		; Tell everybody
   664                              <1> CleanUp:
   665                              <1> WpErr equ WPErr	; NASM port label
   666 00000299 36C606[0000]FF      <1> 	MOV	byte [ss:WpErr],-1
   667 0000029F 36833E[0000]FF      <1> 	CMP	word [ss:SFN],-1
   668 000002A5 7501C3              <1> 	retz
   669 000002A8 1E5650              <1> 	SaveReg <DS,SI,AX>
   670 000002AB 36A1[0000]          <1> 	MOV	AX,[ss:SFN]
   671 000002AF 36C536[0000]        <1> 	LDS	SI,[ss:pJFN]
   672 000002B4 8804                <1> 	MOV	[SI],AL
   673 000002B6 585E1F              <1> 	RestoreReg  <AX,SI,DS>
   674 000002B9 C3                  <1> 	return
   675                              <1> ;
   676                              <1> ; The reply was IGNORE.  See if we are allowed to ignore.
   677                              <1> ;
   678                              <1> CheckIgnore:
   679 000002BA 36F606[0000]20      <1> 	TEST	byte [ss:ALLOWED],allowed_IGNORE ; Can we?
   680 000002C0 74C8                <1> 	JZ	DoFail			; No, do fail
   681 000002C2 EBD5                <1> 	JMP	CleanUp
   682                              <1> ;
   683                              <1> ; The reply was RETRY.	See if we are allowed to retry.
   684                              <1> ;
   685                              <1> CheckRetry:
   686 000002C4 36F606[0000]10      <1> 	TEST	byte [ss:ALLOWED],allowed_RETRY ; Can we?
   687 000002CA 74BE                <1> 	JZ	DoFail			; No, do fail
   688 000002CC EBCB                <1> 	JMP	CleanUp
   689                              <1> ;
   690                              <1> ; The reply was ABORT.
   691                              <1> ;
   692                              <1> DoAbort:
   693 000002CE 161F                <1> 	Context DS
   694 000002D0 803E[0000]00        <1> 	CMP	BYTE PTR [CONSWAP],0
   695 000002D5 7403                <1> 	JZ	NOSWAP2
   696 000002D7 E8(0000)            <1> 	invoke	SWAPBACK
   697                              <1> NOSWAP2:
   698                              <1> ;
   699                              <1> ; See if we are to truly abort.  If we are in the process of aborting, turn
   700                              <1> ; this abort into a fail.
   701                              <1> ;
   702 000002DA F606[0000]FF        <1> 	TEST	byte [fAborting],-1
   703 000002DF 75A9                <1> 	JNZ	DoFail
   704                              <1> ;
   705                              <1> ; Set return code
   706                              <1> ;
   707                              <1> exit_Type equ Exit_type	; NASM port label
   708                              <1> Exit_hard_error equ Exit_Hard_Error	; NASM port equate
   709 000002E1 C606[0000]02        <1> 	MOV	BYTE PTR [exit_Type],Exit_hard_error
   710 000002E6 30C0                <1> 	XOR	AL,AL
   711                              <1> ;
   712                              <1> ; we are truly aborting the process.  Go restore information from the PDB as
   713                              <1> ; necessary.
   714                              <1> ;
   715 000002E8 E9(0000)            <1> 	Transfer    exit_inner
   716                              <1> ;
   717                              <1> ; reset_environment checks the DS value against the CurrentPDB.  If they are
   718                              <1> ; different, then an old-style return is performed.  If they are the same,
   719                              <1> ; then we release jfns and restore to parent.  We still use the PDB at DS:0 as
   720                              <1> ; the source of the terminate addresses.
   721                              <1> ;
   722                              <1> ; Some subtlety:  We are about to issue a bunch of calls that *may* generate
   723                              <1> ; INT 24s.  We *cannot* allow the user to restart the abort process; we may
   724                              <1> ; end up aborting the wrong process or turn a terminate/stay/resident into a
   725                              <1> ; normal abort and leave interrupt handlers around.  What we do is to set a
   726                              <1> ; flag that will indicate that if any abort code is seen, we just continue the
   727                              <1> ; operation.  In essence, we dis-allow the abort response.
   728                              <1> ;
   729                              <1> ; output:   none.
   730                              <1> ;
   731                              <1> 	entry	reset_environment
   732                              <1> 	ASSUME	DS:NOTHING,ES:NOTHING
   733                              <1> 
   734 000002EB E8(0000)            <1> 	invoke	Reset_Version		;AN007;MS. reset version number
   735 000002EE 1E                  <1> 	PUSH	DS			; save PDB of process
   736                              <1> 
   737                              <1> ;
   738                              <1> ; There are no critical sections in force.  Although we may enter here with
   739                              <1> ; critical sections locked down, they are no longer relevant.  We may safely
   740                              <1> ; free all allocated resources.
   741                              <1> ;
   742 000002EF B482                <1> 	MOV	AH,82h
   743 000002F1 CD2A                <1> 	INT	int_IBM
   744                              <1> 
   745 000002F3 36C606[0000]FF      <1> 	MOV	byte [ss:fAborting],-1		; signal abort in progress
   746                              <1> 
   747                              <1> multNet equ MultNET	; NASM port equate
   748 000002F9 B82211CD2F          <1> 	CallInstall NetResetEnvironment, multNet, 34  ;DOS 4.00 doesn't need it
   749                              <1> 					; Allow REDIR to clear some stuff
   750                              <1> 					;   On process exit.
   751                              <1> int_Terminate equ int_terminate	; NASM port equate
   752 000002FE B022                <1> 	MOV	AL,int_Terminate
   753 00000300 E8(0000)            <1> 	invoke	D_server_Get_interrupt_vector	; and who to go to
   754                              <1> 
   755 00000303 59                  <1> 	POP	CX			; get ThisPDB
   756 00000304 0653                <1> 	SaveReg <ES,BX> 		; save return address
   757                              <1> 
   758 00000306 368B1E[0000]        <1> 	MOV	BX,[ss:CurrentPDB] 	; get currentPDB
   759 0000030B 8EDB                <1> 	MOV	DS,BX
   760                              <1>  assume ds:PSP
   761 0000030D A11600              <1> 	MOV	AX,[PDB_Parent_PID]	; get parentPDB
   762                              <1> 
   763                              <1> ;
   764                              <1> ; AX = parentPDB, BX = CurrentPDB, CX = ThisPDB
   765                              <1> ; Only free handles if AX <> BX and BX = CX and [exit_code].upper is not
   766                              <1> ; Exit_keep_process
   767                              <1> ;
   768 00000310 39D8                <1> 	CMP	AX,BX
   769 00000312 7420                <1> 	JZ	reset_return		; parentPDB = CurrentPDB
   770 00000314 39CB                <1> 	CMP	BX,CX
   771 00000316 751C                <1> 	JNZ	reset_return		; CurrentPDB <> ThisPDB
   772 00000318 50                  <1> 	PUSH	AX			; save parent
   773                              <1> exit_type equ Exit_type	; NASM port label
   774                              <1> Exit_keep_process equ Exit_Keep_process	; NASM port equate
   775 00000319 36803E[0000]03      <1> 	CMP	BYTE PTR [ss:exit_type],Exit_keep_process
   776 0000031F 740E                <1> 	JZ	reset_to_parent 	; keeping this process
   777                              <1> ;
   778                              <1> ; Kill off remainder of this process.  Close file handles and signal to
   779                              <1> ; relevant network folks that this process is dead.  Remember that CurrentPDB
   780                              <1> ; is STILL the current process!
   781                              <1> ;
   782 00000321 53                  <1> 	push bx
   783 00000322 E8(0000)            <1> 	invoke	DOS_ABORT
   784 00000325 5B                  <1> 	pop bx
   785                              <1> 
   786                              <1> 	; lDOS: Free memory last, we don't want to operate on freed memory
   787                              <1> 	;  in DOS_ABORT. It needs to access the old Process Handle Table.
   788                              <1> 	;  (FreeDOS does close the handles before freeing memory too.)
   789                              <1> ; We are truly removing a process.  Free all allocation blocks belonging to
   790                              <1> ; this PDB
   791 00000326 E8(0000)            <1> 	EnterCrit   critMem
   792 00000329 E8(0000)            <1> 	invoke	arena_free_process
   793 0000032C E8(0000)            <1> 	LeaveCrit   critMem
   794                              <1> 
   795                              <1> reset_to_parent:
   796 0000032F 368F06[0000]        <1> 	POP	word [ss:CurrentPDB]		; set up process as parent
   797                              <1> 
   798                              <1> reset_return:				; come here for normal return
   799 00000334 16                  <1> 	PUSH	ss
   800 00000335 1F                  <1> 	POP	DS
   801                              <1> 	ASSUME	DS:DOSGROUP
   802 00000336 B0FF                <1> 	MOV	AL,-1
   803                              <1> ;
   804                              <1> ; make sure that everything is clean In this case ignore any errors, we cannot
   805                              <1> ; "FAIL" the abort, the program being aborted is dead.
   806                              <1> ;
   807 00000338 E8(0000)            <1> 	EnterCrit   critDisk
   808 0000033B E8(0000)            <1> 	invoke	FLUSHBUF
   809 0000033E E8(0000)            <1> 	LeaveCrit   critDisk
   810                              <1> ;
   811                              <1> ; Decrement open ref. count if we had done a virtual open earlier.
   812                              <1> ;
   813 00000341 E8(0000)            <1> 	invoke	CHECK_VIRT_OPEN
   814                              <1> %ifndef BUF2
   815                              <1> %IF	BUFFERFLAG
   816                              <1> RESTORE_USER_MAP equ restore_user_map	; NASM port label
   817                              <1> 	invoke	RESTORE_USER_MAP		;AN000;LB. restore user's EMS map
   818                              <1> %ENDIF
   819                              <1> %endif
   820 00000344 FA                  <1> 	CLI
   821 00000345 C606[0000]FF        <1> 	MOV	BYTE PTR [WPERR],-1	; Forget about WP error
   822 0000034A C606[0000]00        <1> 	MOV	byte [fAborting],0		; let aborts occur
   823                              <1> 
   824                              <1> %if 1
   825 0000034F 8E06[0000]          <1> 	mov es, [CurrentPDB]		; => PSP
   826                              <1>  assume es:PSP
   827 00000353 26C43E2E00          <1> 	les di, [es:PDB_User_stack]	; -> user stack we'll restore
   828                              <1>  assume es:nothing
   829 00000358 83C712              <1> 	add di, user_IP			; -> ip, cs, fl on stack
   830 0000035B 58                  <1> 	pop ax
   831 0000035C AB                  <1> 	stosw				; user_IP = ri22o (PRA)
   832 0000035D A3[0000]            <1> 	mov word [ExitHold], ax		; set compat variable
   833 00000360 58                  <1> 	pop ax
   834 00000361 AB                  <1> 	stosw				; user_CS = ri22s (PRA)
   835 00000362 A3[0200]            <1> 	mov word [ExitHold + 2], ax	; set compat variable
   836 00000365 B802F2              <1> 	MOV	AX,0F202h		; STI, NC
   837 00000368 AB                  <1> 	stosw				; user_F = flags
   838                              <1> 
   839 00000369 268B45E8            <1> 	mov ax, [es:di - (user_F + 2) + user_AX]
   840                              <1> 					; get user ax
   841                              <1> User_SP equ user_SP	; NASM port label
   842 0000036D A3[0000]            <1> 	mov [User_SP], ax		; set compat variable
   843                              <1> 
   844 00000370 8E06[0000]          <1> 	MOV	es,[CurrentPDB]
   845                              <1> 	ASSUME	es:NOTHING
   846                              <1> PDB_user_stack equ PDB_User_stack	; NASM port equate
   847 00000374 268E163000          <1> 	MOV	SS,WORD PTR [es:PDB_user_stack+2]
   848 00000379 268B262E00          <1> 	MOV	SP,WORD PTR [es:PDB_user_stack]
   849                              <1> 					; restore stack for PRA entry
   850                              <1> 	ASSUME	SS:NOTHING
   851 0000037E C606[0000]00        <1> 	MOV	BYTE PTR [INDOS],0	; Go to known state
   852 00000383 E8(0000)            <1> 	invoke	restore_world		; pop our stack frame
   853                              <1> 	ASSUME	ES:NOTHING, ds:nothing
   854                              <1> 
   855 00000386 CF                  <1> 	iret				; iret to PRA
   856                              <1> %else
   857                              <1>  assume ds:DOSGROUP, ss:DOSGROUP
   858                              <1> 	POP	WORD [ExitHold]
   859                              <1> 	POP	WORD [ExitHold+2]
   860                              <1> 
   861                              <1> ;
   862                              <1> ; Snake into multitasking... Get stack from CurrentPDB person
   863                              <1> ;
   864                              <1> 	MOV	DS,[CurrentPDB]
   865                              <1> 	ASSUME	DS:NOTHING
   866                              <1> PDB_user_stack equ PDB_User_stack	; NASM port equate
   867                              <1> 	MOV	SS,WORD PTR [PDB_user_stack+2]
   868                              <1> 	MOV	SP,WORD PTR [PDB_user_stack]
   869                              <1> 
   870                              <1> 	ASSUME	SS:NOTHING
   871                              <1> 	invoke	restore_world
   872                              <1> 	ASSUME	ES:NOTHING
   873                              <1> 
   874                              <1> 	push bx
   875                              <1> 	push bx
   876                              <1> 	mov bx, .next
   877                              <1> 	jmp transfer_doscode_to_dosdata
   878                              <1> 
   879                              <1> section DOSDATACODE	; in DOSDATA
   880                              <1> .next:
   881                              <1> 	add sp, 6			; discard retn & retf addresses
   882                              <1> 
   883                              <1> User_SP equ user_SP	; NASM port label
   884                              <1> 	MOV	[cs:User_SP],AX
   885                              <1> 	POP	AX			; suck off CS:IP of interrupt...
   886                              <1> 	POP	AX
   887                              <1> 	POP	AX
   888                              <1> 	MOV	AX,0F202h		; STI
   889                              <1> 	PUSH	AX
   890                              <1> 	PUSH	WORD PTR [cs:EXITHOLD+2]
   891                              <1> 	PUSH	WORD PTR [cs:EXITHOLD]
   892                              <1> 	MOV	AX,[cs:User_SP]
   893                              <1> 	MOV	BYTE PTR [cs:INDOS], 0	; Go to known state
   894                              <1> 	IRET				; Long return back to user terminate address
   895                              <1> %endif
   896                              <1> 
   897                              <1> 
   898                              <1> EndProc HardErr_DOS
   898          ******************  <1>  warning: ***** Possible stack size error in HardErr_DOS ***** [-w+user]
   899                              <1> 
   900                              <1> 
   901                              <1> section DOSCODECODE
   902                              <1> 
   903                              <1> ;
   904                              <1> ; This routine handles extended error codes.
   905                              <1> ; Input : DI = error code from device
   906                              <1> ; Output: All EXTERR fields are set
   907                              <1> ;
   908                              <1> Procedure SET_I24_EXTENDED_ERROR,NEAR
   908          ******************  <1>  warning: proc SET_I24_EXTENDED_ERROR... [-w+user]
   909                              <1>  assume ss:DOSGROUP
   910 00000387 50                  <1> 	PUSH	AX
   911                              <1> DOSGroup equ DOSGROUP	; NASM port equate
   912 00000388 B8[0000]            <1> 	MOV	AX,OFFSET ErrMap24End
   913 0000038B 2D[0000]            <1> 	SUB	AX,OFFSET ErrMap24
   914                              <1> ;
   915                              <1> ; AX is the index of the first unavailable error.  Do not translate if
   916                              <1> ; greater or equal to AX.
   917                              <1> ;
   918 0000038E 39C7                <1> 	CMP	DI,AX
   919 00000390 89F8                <1> 	MOV	AX,DI
   920 00000392 7307                <1> 	JAE	NoTrans
   921 00000394 2E8A85[0000]        <1> 	MOV	AL,[cs:ErrMap24 + DI]
   922 00000399 30E4                <1> 	XOR	AH,AH
   923                              <1> NoTrans:
   924 0000039B 36A3[0000]          <1> 	MOV	[ss:EXTERR],AX
   925 0000039F 58                  <1> 	POP	AX
   926                              <1> ;
   927                              <1> ; Now Extended error is set correctly.	Translate it to get correct error
   928                              <1> ; locus class and recommended action.
   929                              <1> ;
   930 000003A0 56                  <1> 	PUSH	SI
   931 000003A1 BE[0000]            <1> 	MOV	SI,OFFSET ERR_TABLE_24
   932 000003A4 E8(0000)            <1> 	invoke	CAL_LK			; Set other extended error fields
   933 000003A7 5E                  <1> 	POP	SI
   934 000003A8 C3                  <1> 	ret
   935                              <1> EndProc SET_I24_EXTENDED_ERROR
   936                              <1> 
   937                              <1>     END
   938                              <1> 
   939                              <1> 
    19                                  ;=== Pop trace listing source
    20                                  
