     1                                  ;	SCCSID = @(#)misc2.asm	1.1 85/04/10
     2                                  ;TITLE MISC2 - Miscellanious routines for MS-DOS
     3                                  ;NAME  MISC2
     4                                  ;
     5                                  ; Miscellaneous useful routines
     6                                  ;
     7                                  ;   StrCpy
     8                                  ;   StrCmp
     9                                  ;   Ucase
    10                                  ;   StrLen
    11                                  ;   DStrLen
    12                                  ;   Idle
    13                                  ;   TableDispatch
    14                                  ;   FastInit			  ; DOS 4.0
    15                                  ;   FastRet			  ; DOS 4.0
    16                                  ;   NLS_OPEN			  ; DOS 4.0
    17                                  ;   NLS_LSEEK			  ; DOS 4.0
    18                                  ;   Fake_User_Stack		  ; DOS 4.0
    19                                  ;   GetDevList			  ; DOS 4.0
    20                                  ;   NLS_IOCTL			  ; DOS 4.0
    21                                  ;   NLS_GETEXT			  ; DOS 4.0
    22                                  ;   MSG_RETRIEVAL		  ; DOS 4.0
    23                                  ;   Fake_Version		  ; DOS 4.0
    24                                  ;
    25                                  ;   Revision history:
    26                                  ;
    27                                  ;	Created: ARR 30 March 1983
    28                                  ;
    29                                  ;	A000   version 4.0   Jan. 1988
    30                                  ;	A001   DCR 486 - Share installation for >32mb drives
    31                                  ;	A006   DCR 503 - fake version number for IBMCACHE
    32                                  
    33                                  [list -]
    33          ******************       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
    38                                  %include "entrysw.mac"
     1                              <1> 
     2                              <1> %ifndef __ENTRYSW_MAC__
     3                              <1>  %assign __ENTRYSW_MAC__ 1
     4                              <1> 
     5                              <1> %assign _DOSCODEHMA		1
     6                              <1> %assign _RELOCATEDOSCODE	1
     7                              <1> 
     8                              <1> 		; Write a label "%1" (only if DOSCODE isn't relocated) and
     9                              <1> 		; "relocated%1" (always).
    10                              <1> 	%imacro relocated 1-2.nolist
    11                              <1> %ifnidni %2, device
    12                              <1>  %ifnidni %2, amis
    13                              <1>   %ifn _RELOCATEDOSCODE
    14                              <1> %1:
    15                              <1> 	global %1
    16                              <1>   %endif
    17                              <1>  %endif
    18                              <1> %endif
    19                              <1> relocated%1:				; always used for local labels
    20                              <1> 	global relocated%1
    21                              <1> 	%endmacro
    22                              <1> 
    23                              <1> %if _RELOCATEDOSCODE
    24                              <1> DOSENTRYADJUSTSEGMENT equ 60h - 26h
    25                              <1> %else
    26                              <1> DOSENTRYADJUSTSEGMENT equ 0
    27                              <1> %endif
    28                              <1> DOSENTRYADJUSTOFFSET equ DOSENTRYADJUSTSEGMENT * 16
    29                              <1> 
    30                              <1> DOSENTRYDEVICEBASE equ 10h
    31                              <1> 
    32                              <1> %endif
    39                                  %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
    40                                  
    41                                  [list +]
    42                                  
    43                                  section DOSCODECODE
    44                                  [list -]
    44          ******************       warning: out: ... for DOS Version 4.00 ... [-w+user]
    44          ******************       warning: out: BPB.INC... [-w+user]
    44          ******************       warning: out: ... CLONE version build switch on ... [-w+user]
    52                                  
    53                                  	i_need	THISCDS,DWORD
    54                                  	I_Need	RetryLoop,WORD
    55                                  	I_need	fSharing,BYTE		; TRUE => server-issued call
    56                                  	I_need	FastTable,BYTE		;AN000;
    57                                  	I_need	FastFlg,BYTE		;AN000;
    58                                  	I_need	User_SP_2F,WORD 	;AN000;
    59                                  	I_need	User_SP,WORD		;AN000;
    60                                  	I_need	User_SS,WORD		;AN000;
    61                                  	I_need	SysInitTable,BYTE	;AN000;
    62                                  	I_need	EXTERR,WORD		;AN000;
    63                                  	I_need	MSG_EXTERROR,DWORD	;AN000;
    64                                  	I_need	fshare,byte		;AN001;
    65                                  	I_need	Special_version,WORD	;AN006;
    66                                  %if debug
    67                                  	I_need	BugLev,WORD
    68                                  	I_need	BugTyp,WORD
    69                                  %include "bugtyp.nas"
    70                                  %endif
    71                                  
    72                                  Break <STRCMP - compare two ASCIZ strings DS:SI to ES:DI>
    73                                  
    74                                  ;
    75                                  ;   Strcmp - compare ASCIZ DS:SI to ES:DI. Case INSENSITIVE. '/' = '\'
    76                                  ;		Strings of different lengths don't match.
    77                                  ;   Inputs:	DS:SI - pointer to source string  ES:DI - pointer to dest string
    78                                  ;   Outputs:	Z if strings same, NZ if different
    79                                  ;   Registers modified: NONE
    80                                  
    81                                  Procedure   StrCmp,NEAR
    81          ******************       warning: proc StrCmp... [-w+user]
    82                                   ASSUME SS:nothing, DS:NOTHING, ES:NOTHING
    83 00000000 565750                  	SaveReg <SI,DI,AX>
    84                                  Cmplp:
    85 00000003 AC                      	LODSB
    86                                   %IF  DBCS				;AN000;
    87                                  	invoke	testkanj		;AN000;; 2/13/KK
    88                                  	jz	notkanj1		;AN000;; 2/13/KK
    89                                  	dec	si			;AN000;; Do source again 2/13/KK
    90                                  	cmpsb				;AN000;; First byte	 2/13/KK
    91                                  	JNZ	PopRet			;AN000;; Strings dif	 2/13/KK
    92                                  	cmpsb				;AN000;; Second byte of kanji char 2/13/KK
    93                                  	JNZ	PopRet			;AN000;; Strings dif	 2/13/KK
    94                                  	mov	al,byte ptr [SI-1]	;AN000;; Need last byte in AL  2/13/KK
    95                                  	jmp	short Tend		;AN000;
    96                                  notkanj1:				;AN000;; 2/13/KK
    97                                   %ENDIF					;AN000;
    98 00000004 E83300                  	CALL	uCase			; convert to upper case
    99 00000007 E8(0000)                	Invoke	PathChrCmp		; convert / to \.
   100 0000000A 88C4                    	MOV	AH,AL
   101 0000000C 268A05                  	MOV	AL,[ES:DI]
   102 0000000F 47                      	INC	DI
   103 00000010 E82700                  	CALL	uCase			; convert to upper case
   104 00000013 E8(0000)                	Invoke	PathChrCmp		; convert / to \.
   105 00000016 38C4                    	CMP	AH,AL
   106 00000018 7504                    	JNZ	PopRet			; Strings dif
   107                                  Tend:
   108 0000001A 08C0                    	OR	AL,AL
   109 0000001C 75E5                    	JNZ	Cmplp			; More string
   110                                  PopRet:
   111 0000001E 585F5E                  	RestoreReg  <AX,DI,SI>
   112 00000021 C3                      	return
   113                                  EndProc StrCmp
   114                                  
   115                                  Break <STRCPY - copy ASCIZ string from DS:SI to ES:DI>
   116                                  
   117                                  ;
   118                                  ;   Strcpy - copy an ASCIZ string from DS:SI to ES:DI and make uppercase
   119                                  ;   FStrcpy - copy an ASCIZ string from DS:SI to ES:DI.  no modification of
   120                                  ;	characters.
   121                                  ;
   122                                  ;   Inputs:	DS:SI - pointer to source string
   123                                  ;		ES:DI - pointer to destination string
   124                                  ;   Outputs:	ES:DI point byte after nul byte at end of dest string
   125                                  ;		DS:SI point byte after nul byte at end of source string
   126                                  ;   Registers modified: SI,DI
   127                                  
   128                                  Procedure   StrCpy,NEAR
   128          ******************       warning: proc StrCpy... [-w+user]
   129                                   ASSUME SS:nothing, DS:NOTHING,ES:NOTHING
   130 00000022 50                      	SaveReg <AX>
   131                                  CPYLoop:
   132 00000023 AC                      	LODSB
   133                                   %IF  DBCS			;AN000;
   134                                  	invoke	testkanj	;AN000;; 2/13/KK
   135                                  	jz	notkanj2	;AN000;; 2/13/KK
   136                                  	STOSB			;AN000;; 2/13/KK
   137                                  	LODSB			;AN000;; 2/13/KK
   138                                  	STOSB			;AN000;; 2/13/KK
   139                                  	jmp	short CPYLoop	;AN000;; 3/31/KK
   140                                  
   141                                  notkanj2:			;AN000;; 2/13/KK
   142                                   %ENDIF				;AN000;
   143 00000024 E81300                  	CALL	uCase			; convert to upper case
   144 00000027 E8(0000)                	Invoke	PathChrCmp		; convert / to \.
   145 0000002A AA                      	STOSB
   146                                  Tend2:
   147 0000002B 08C0                    	OR	AL,AL
   148 0000002D 75F4                    	JNZ	CPYLoop
   149 0000002F 58                      	RestoreReg  <AX>
   150 00000030 C3                      	return
   151                                  EndProc StrCpy
   152                                  
   153                                  Procedure   FStrCpy,NEAR
   153          ******************       warning: proc FStrCpy... [-w+user]
   154                                   ASSUME SS:nothing, DS:NOTHING,ES:NOTHING
   155 00000031 50                      	SaveReg <AX>
   156                                  FCPYLoop:
   157 00000032 AC                      	LODSB
   158 00000033 AA                      	STOSB
   159 00000034 08C0                    	OR	AL,AL
   160 00000036 75FA                    	JNZ	FCPYLoop
   161 00000038 58                      	RestoreReg  <AX>
   162 00000039 C3                      	return
   163                                  EndProc FStrCpy
   164                                  
   165                                  ;
   166                                  ; Upper case the letter in AL.	Most chars are non lowercase.
   167                                  ;
   168                                  Procedure   uCase,NEAR
   168          ******************       warning: proc uCase... [-w+user]
   169                                  ;	CMP	AL,'a'
   170                                  ;	JAE	Maybe
   171                                  ;	return
   172                                  ;Maybe:
   173                                  ;	CMP	AL,'z'
   174                                  ;	JA	CaseRet
   175                                  ;	ADD	AL,'A'-'a'
   176                                  ;CaseRet:
   177                                  ;;; 10/31/86 let's do file upper case for all DOS file names
   178 0000003A E8(0000)                	invoke	GetLet2
   179                                  ;;; 10/31/86 let's do file upper case for all DOS file names
   180 0000003D C3                      	return
   181                                  EndProc uCase
   182                                  
   183                                  Break <StrLen - compute length of string ES:DI>
   184                                  
   185                                  ;
   186                                  ;   StrLen  - Compute length of string ES:DI
   187                                  ;   Inputs:	ES:DI - pointer to string
   188                                  ;   Outputs:	CX is size of string INCLUDING the NUL
   189                                  ;   Registers modified: CX
   190                                  
   191                                  Procedure   StrLen,NEAR
   191          ******************       warning: proc StrLen... [-w+user]
   192                                   ASSUME SS:nothing, DS:NOTHING,ES:NOTHING
   193 0000003E 57                      	PUSH	DI
   194 0000003F 50                      	PUSH	AX
   195 00000040 B9FFFF                  	MOV	CX,-1
   196 00000043 30C0                    	XOR	AL,AL
   197 00000045 F2AE                    	REPNE	SCASB
   198 00000047 F7D1                    	NOT	CX
   199 00000049 58                      	POP	AX
   200 0000004A 5F                      	POP	DI
   201 0000004B C3                      	return
   202                                  EndProc StrLen
   203                                  
   204                                  ;
   205                                  ;   DStrLen  - Compute length of string DS:SI
   206                                  ;   Inputs:	DS:SI - pointer to string
   207                                  ;   Outputs:	CX is size of string INCLUDING the NUL
   208                                  ;   Registers modified: CX
   209                                  Procedure   DStrLen,NEAR
   209          ******************       warning: proc DStrLen... [-w+user]
   210 0000004C E80700                  	CALL	XCHGP
   211 0000004F E8ECFF                  	CALL	StrLen
   212 00000052 E80100                  	CALL	XCHGP
   213 00000055 C3                      	return
   214                                  EndProc DStrLen
   215                                  
   216                                  Break	<XCHGP - exchange source and destination pointers>
   217                                  
   218                                  Procedure XCHGP,NEAR
   218          ******************       warning: proc XCHGP... [-w+user]
   219 00000056 1E06                    	SaveReg <DS,ES>
   220 00000058 1F07                    	RestoreReg  <DS,ES>
   221 0000005A 87F7                    	XCHG	SI,DI
   222 0000005C C3                      	return
   223                                  EndProc XCHGP
   224                                  
   225                                  Break	<Idle - $wait for a specified amount of time>
   226                                  
   227                                  ;
   228                                  ;   Idle - when retrying an operation due to a lock/sharing violation, we spin
   229                                  ;   until RetryLoop is exhausted.
   230                                  ;
   231                                  ;   Inputs:	RetryLoop is the number of times we spin
   232                                  ;   Outputs:	Wait
   233                                  ;   Registers modified: none
   234                                  
   235                                  Procedure   Idle,NEAR
   235          ******************       warning: proc Idle... [-w+user]
   236                                   ASSUME SS:DOSGROUP,DS:NOTHING,ES:NOTHING
   237 0000005D 36F606[0000]FF          	TEST	byte [ss:fSharing],-1
   238 00000063 75F7                    	retnz
   239 00000065 51                      	SaveReg <CX>
   240 00000066 368B0E[0000]            	MOV	CX,[ss:RetryLoop]
   241 0000006B E308                    	JCXZ	Idle3
   242 0000006D 51                      Idle1:	PUSH	CX
   243 0000006E 31C9                    	XOR	CX,CX
   244 00000070 E2FE                    Idle2:	LOOP	Idle2
   245 00000072 59                      	POP	CX
   246 00000073 E2F8                    	LOOP	Idle1
   247 00000075 59                      Idle3:	RestoreReg  <CX>
   248 00000076 C3                      	return
   249                                  EndProc Idle
   250                                  
   251                                  Break	<TableDispatch - dispatch to a table>
   252                                  
   253                                  ;
   254                                  ;   TableDispatch - given a table and an index, jmp to the approptiate
   255                                  ;   routine.  Preserve all input registers to the routine.
   256                                  ;
   257                                  ;   Inputs:	Push	return address
   258                                  ;		Push	Table address
   259                                  ;		Push	index (byte)
   260                                  ;   Outputs:	appropriate routine gets jumped to.
   261                                  ;		return indicates invalid index
   262                                  ;   Registers modified: none.
   263                                  
   264                                  TableFrame  STRUC
   265 00000000 ????                    OldBP	DW  ?
   266 00000002 ????                    OldRet	DW  ?
   267 00000004 ??                      Index	DB  ?
   268 00000005 ??                      Pad	DB  ?
   268          ******************       warning: multi-line macro `Pad' exists, but not taking 1 parameter [-w+pp-macro-params-multi]
   269 00000006 ????                    Tab	DW  ?
   270 00000008 ????                    NewRet	DW  ?
   271                                  TableFrame  ENDS
   272                                  
   273                                  procedure   TableDispatch,NEAR
   273          ******************       warning: proc TableDispatch... [-w+user]
   274                                   ASSUME DS:NOTHING,ES:NOTHING,SS:NOTHING
   275 00000077 55                      	PUSH	BP
   276 00000078 89E5                    	MOV	BP,SP
   277 0000007A 53                      	PUSH	BX			; save BX
   278 0000007B 8B5E06                  	MOV	BX,[BP + Tab]		; get pointer to table
   279 0000007E 2E8A1F                  	MOV	BL,[CS:BX]		; maximum index
   280 00000081 385E04                  	CMP	[BP + Index],BL		; table error?
   281 00000084 7317                    	JAE	TableError		; yes
   282 00000086 8A5E04                  	MOV	BL,[BP + Index]		; get desired table index
   283 00000089 30FF                    	XOR	BH,BH			; convert to word
   284 0000008B D1E3                    	SHL	BX,1			; convert to word pointer
   285 0000008D 43                      	INC	BX			; point past first length byte
   286 0000008E 035E06                  	ADD	BX,[BP + Tab]		; get real offset
   287 00000091 2E8B1F                  	MOV	BX,[CS:BX]		; get contents of table entry
   288 00000094 895E06                  	MOV	[BP + Tab],BX		; put table entry into return address
   289 00000097 5B                      	POP	BX			; restore BX
   290 00000098 5D                      	POP	BP			; restore BP
   291 00000099 83C404                  	ADD	SP,4			; clean off Index and our return addr
   292 0000009C C3                      	return				; do operation
   293                                  TableError:
   294 0000009D 5B                      	POP	BX			; restore BX
   295 0000009E 5D                      	POP	BP			; restore BP
   296 0000009F C20600                  	RET	6			; clean off Index, Table and RetAddr
   297                                  EndProc TableDispatch
   298                                  
   299                                  Break	<TestNet - determine if a CDS is for the network>
   300                                  
   301                                  ;
   302                                  ;   TestNet - examine CDS pointed to by ThisCDS and see if it indicates a
   303                                  ;	network CDS.  This will handle NULL cds also.
   304                                  ;
   305                                  ;   Inputs:	ThisCDS points to CDS or NULL
   306                                  ;   Outputs:	ES:DI = ThisCDS
   307                                  ;		carry Set => network
   308                                  ;		carry Clear => local
   309                                  ;   Registers modified: none.
   310                                  
   311                                  Procedure   TestNet,NEAR
   311          ******************       warning: proc TestNet... [-w+user]
   312                                   ASSUME DS:NOTHING,ES:NOTHING,SS:NOTHING
   313                                  ThisCDS equ THISCDS	; NASM port label
   314 000000A2 97                      	xchg ax, di
   315                                  extern doscode_getdosdata
   316 000000A3 E8(0000)                	call doscode_getdosdata
   317 000000A6 8EC0                    	mov es, ax
   318                                   assume es:DOSGROUP
   319 000000A8 26C406[0000]            	LES	ax,[es:ThisCDS]
   320                                   assume es:nothing
   321 000000AD 83F8FF                  	CMP	ax,-1
   322 000000B0 97                      	xchg ax, di
   323 000000B1 7408                    	je .CMCRet			; UNC? carry is clear
   324 000000B3 26F745430080            	TEST	word [ES:DI + curdir_flags],curdir_isnet
   325 000000B9 7401                    	jz .ret				; --> NC
   326                                  .CMCRet:
   327 000000BB F5                      	CMC				; CY if networked
   328 000000BC C3                      .ret:	return
   329                                  
   330                                  EndProc TestNet
   331                                  
   332                                  Break	<IsSFTNet - see if an sft is for the network>
   333                                  
   334                                  ;
   335                                  ;   IsSFTNet - examine SF pointed to by ES:DI and see if it indicates a
   336                                  ;	network file.
   337                                  ;
   338                                  ;   Inputs:	ES:DI point to SFT
   339                                  ;   Outputs:	Zero set if not network sft
   340                                  ;		zero reset otherwise
   341                                  ;		Carry CLEAR!!!
   342                                  ;   Registers modified: none.
   343                                  
   344                                  Procedure   IsSFTNet,NEAR
   344          ******************       warning: proc IsSFTNet... [-w+user]
   345                                   ASSUME DS:NOTHING,ES:NOTHING,SS:NOTHING
   346 000000BD 26F745050080            	TEST	word [ES:DI + sf_flags],sf_isnet
   347 000000C3 C3                      	return
   348                                  EndProc IsSFTNet
   349                                  
   350                                  Break	<FastInit - Initialize FastTable entries >
   351                                  
   352                                  ; 2F.122A multDOS function
   353                                  ;   DOS 4.00   2/9/87
   354                                  ;   FastInit  - initialize the FASTXXX routine entry
   355                                  ;		  in the FastTable
   356                                  ;
   357                                  ;   Inputs:	BX = FASTXXX ID ( 1=fastopen, 2=fastseek,,,,)
   358                                  ;		DS:SI = address of FASTXXX routine entry
   359                                  ;		   SI = -1 for query only
   360                                  ;   Outputs:	Carry flag clear, if success
   361                                  ;		Carry flag set,   if failure
   362                                  ;
   363                                  ;
   364                                  
   365                                  extern doscode_getdosdata
   366                                  
   367                                  Procedure   FastInit,NEAR				      ;AN000;
   367          ******************       warning: proc FastInit... [-w+user]
   368                                   ASSUME DS:NOTHING,ES:NOTHING,SS:NOTHING  ;AN000;
   369                                  
   370 000000C4 06                      	push es
   371 000000C5 E8(0000)                	call doscode_getdosdata
   372 000000C8 8EC0                    	mov es, ax
   373                                   assume es:DOSGROUP
   374                                  
   375 000000CA BF[0200]                	MOV	DI,OFFSET FastTable + 2 wrt DOSGROUP   ;AN000;FO. points to fastxxx entry
   376 000000CD 4B                      	DEC	BX		  ;AN000;FO.;; decrement index
   377 000000CE 83FB02                  	cmp bx, 2
   378 000000D1 7317                    	jae fastinitinvalid
   379 000000D3 89DA                    	MOV	DX,BX		  ;AN000;FO.;; save bx
   380 000000D5 D1E3                    	SHL	BX,1		  ;AN000;FO.;; times 4 , each entry is DWORD
   381 000000D7 D1E3                    	SHL	BX,1		  ;AN000;FO.
   382 000000D9 01DF                    	ADD	DI,BX		  ;AN000;FO. index to the entry
   383 000000DB 268B4502                	MOV	AX,WORD PTR [es:DI+2] ;AN000;FO. get entry segment
   384                                  fcheck: 			      ;AN000;
   385 000000DF B9[ssss]                	MOV	CX, DOSENTRY	  ;AN000;FO.;; get DOS segment	; => DOSENTRY
   386 000000E2 39C8                    	CMP	AX,CX		  ;AN000;FO.;; first time installed ?
   387 000000E4 7407                    	JZ	ok_install	  ;AN000;FO.;; yes
   388 000000E6 85C0                    	test ax, ax		  ;AN000;FO.;
   389 000000E8 7403                    	JZ	ok_install	  ;AN000;FO.;
   390                                  fastinitinvalid:
   391 000000EA F9                      	STC			  ;AN000;FO.;; already installed !
   392 000000EB EB19                    	JMP	SHORT FSret	  ;AN000;FO. set carry
   393                                  ok_install:			      ;AN000;
   394 000000ED 83FEFF                  	CMP	SI,-1		      ;AN000;FO.;  Query only ?
   395 000000F0 7414                    	JZ	FSret		      ;AN000;FO.;  yes (NC)
   396 000000F2 8CD9                    	MOV	CX,DS		      ;AN000;FO.;  get FASTXXX entry segment
   397 000000F4 8CD9                    	MOV	CX,DS		      ;AN000;FO.;;  get FASTXXX entry segment
   398 000000F6 26894D02                	MOV	WORD PTR [es:DI+2],CX ;AN000;FO.;;  initialize routine entry
   399 000000FA 268935                  	MOV	WORD PTR [es:DI],SI   ;AN000;FO.;;  initialize routine offset
   400 000000FD BF[0000]                	MOV	DI,OFFSET FastFlg wrt DOSGROUP ;AN000;FO.; get addr of FASTXXX flags
   401 00000100 01D7                    	ADD	DI,DX			   ;AN000;FO.;	index to a FASTXXX flag
   402 00000102 26800D80                	OR	byte ptr [es:DI],Fast_yes  ;AN000;FO.;	indicate installed
   403                                  					; (NC)
   404                                  FSret:					     ;AN000;
   405 00000106 07                      	pop es
   406                                   assume es:nothing
   407 00000107 C3                      	return				     ;AN000;FO.
   408                                  EndProc FastInit			     ;AN000;FO.
   409                                  
   410                                  Break	<FastRet - initial routine in FastOpenTable >
   411                                  
   412                                  ;   DOS 3.3   6/10/86
   413                                  ;   FastRet	- indicate FASTXXXX  not in memory
   414                                  ;
   415                                  ;   Inputs:	None
   416                                  ;   Outputs:	AX = -1 and carry flag set
   417                                  ;
   418                                  ;   Registers modified: none.
   419                                  
   420                                  relocated fastentry
   421                                  Procedure   FastRet,FAR
   421          ******************       warning: proc FastRet... [-w+user]
   422                                   ASSUME DS:NOTHING,ES:NOTHING,SS:NOTHING
   423 00000108 B8FFFF                  	MOV	AX,-1
   424 0000010B F9                      	STC
   425 0000010C CB                      	RET
   426                                  EndProc FastRet
   427                                  
   428                                  Break	<NLS_OPEN - do $open for NLSFUNC   >
   429                                  
   430                                  ;   DOS 3.3   6/10/86
   431                                  ;   NLS_OPEN	- call $OPEN for NLSFUNC
   432                                  ;
   433                                  ;   Inputs:	Same input as $OPEN except CL = mode
   434                                  ;   Outputs:	same output as $OPEN
   435                                  ;
   436                                  
   437                                  Procedure   NLS_OPEN,NEAR
   437          ******************       warning: proc NLS_OPEN... [-w+user]
   438                                   ASSUME DS:NOTHING,ES:NOTHING,SS:DOSGROUP
   439                                  
   440                                  ;	MOV	BL,[CPSWFLAG]	 ; disable code page matching logic
   441                                  ;	MOV	[CPSWFLAG],0
   442                                  ;	PUSH	BX		 ; save current state
   443                                  
   444 0000010D 88C8                    	MOV	AL,CL		 ; set up correct interface for $OPEN
   445 0000010F E8(0000)                	invoke	D_OPEN
   446                                  
   447                                   ;	POP	BX		 ; restore current state
   448                                   ;	MOV	[CPSWFLAG],BL
   449 00000112 C3                      	RET
   450                                  EndProc NLS_OPEN
   451                                  
   452                                  Break	<NLS_LSEEK - do $LSEEK for NLSFUNC   >
   453                                  
   454                                  ;   DOS 3.3   6/10/86
   455                                  ;   NLS_LSEEK	- call $LSEEK for NLSFUNC
   456                                  ;
   457                                  ;   Inputs:	BP = open mode
   458                                  ;   Outputs:	same output as $LSEEK
   459                                  ;
   460                                  
   461                                  Procedure   NLS_LSEEK,NEAR
   461          ******************       warning: proc NLS_LSEEK... [-w+user]
   462                                   ASSUME DS:NOTHING,ES:NOTHING,SS:DOSGROUP
   463                                  
   464                                  user_SP equ User_SP	; NASM port label
   465 00000113 36FF36[0000]            	PUSH	word [ss:user_SP]	 ; save user stack
   466                                  user_SS equ User_SS	; NASM port label
   467 00000118 36FF36[0000]            	PUSH	word [ss:user_SS]
   468 0000011D E81000                  	CALL	Fake_User_Stack
   469 00000120 89E8                    	MOV	AX,BP	     ; set up correct interface for $LSEEK
   470 00000122 E8(0000)                	invoke	D_LSEEK
   471 00000125 368F06[0000]            	POP	word [ss:user_SS]	 ; restore user stack
   472 0000012A 368F06[0000]            	POP	word [ss:user_SP]
   473 0000012F C3                      	RET
   474                                  EndProc NLS_LSEEK
   475                                  
   476                                  
   477                                  Break	<Fake_User_Stack - save uesr stack >
   478                                  
   479                                  
   480                                  ;   DOS 3.3   6/10/86
   481                                  ;   Fake_User_Stack - save user stack pointer
   482                                  ;
   483                                  
   484                                  Procedure   Fake_User_Stack,NEAR
   484          ******************       warning: proc Fake_User_Stack... [-w+user]
   485                                   ASSUME DS:NOTHING,ES:NOTHING,SS:DOSGROUP
   486                                  
   487 00000130 36A1[0000]              	MOV	AX,[ss:User_SP_2F] 	      ; replace with INT 2F stack
   488 00000134 36A3[0000]              	MOV	[ss:user_SP],AX
   489 00000138 368C16[0000]            	MOV	[ss:user_SS],ss		      ; DOSGROUP
   490                                  
   491 0000013D C3                      	RET
   492                                  EndProc Fake_User_Stack
   493                                  
   494                                  ;
   495                                  Break	<GetDevList - get device header list pointer>
   496                                  
   497                                  
   498                                  ;   DOS 3.3   7/25/86
   499                                  ;   GetDevList - get device header list pointer
   500                                  ;
   501                                  ;   Output: AX:BX points to the device header list
   502                                  
   503                                  Procedure   GetDevList,NEAR
   503          ******************       warning: proc GetDevList... [-w+user]
   504                                   ASSUME DS:NOTHING,ES:NOTHING,SS:nothing
   505                                  
   506                                  extern SYSINITVAR
   507                                  
   508 0000013E E8(0000)                	call doscode_getdosdata
   509 00000141 8ED8                    	mov ds, ax
   510                                   assume ds:DOSGROUP
   511 00000143 BE[0000]                	mov si, SYSINITVAR
   512 00000146 8B4422                  	MOV	AX,WORD PTR [SI + SYSI_DEV]
   513 00000149 8B5C24                  	MOV	BX,WORD PTR [SI + SYSI_DEV+2]
   514                                  
   515 0000014C C3                      	RET
   516                                  EndProc GetDevList
   517                                  
   518                                  Break	<NLS_IOCTL - do $IOCTL for NLSFUNC   >
   519                                  
   520                                  ;   DOS 3.3   7/25/86
   521                                  ;   NLS_IOCTL	- call $IOCTL for NLSFUNC
   522                                  ;
   523                                  ;   Inputs:	BP = function code 0CH
   524                                  ;   Outputs:	same output as generic $IOCTL
   525                                  ;
   526                                  
   527                                  Procedure   NLS_IOCTL,NEAR
   527          ******************       warning: proc NLS_IOCTL... [-w+user]
   528                                   ASSUME DS:NOTHING,ES:NOTHING,SS:DOSGROUP
   529                                  
   530 0000014D 36FF36[0000]            	PUSH	word [ss:user_SP]	 ; save user stack
   531 00000152 36FF36[0000]            	PUSH	word [ss:user_SS]
   532 00000157 E8D6FF                  	CALL	Fake_User_Stack
   533 0000015A 89E8                    	MOV	AX,BP	     ; set up correct interface for $LSEEK
   534 0000015C E8(0000)                	invoke	D_IOCTL
   535 0000015F 368F06[0000]            	POP	word [ss:user_SS]	 ; restore user stack
   536 00000164 368F06[0000]            	POP	word [ss:user_SP]
   537 00000169 C3                      	RET
   538                                  EndProc NLS_IOCTL
   539                                  
   540                                  Break	<NLS_GETEXT- get extended error for NLSFUNC>
   541                                  
   542                                  ;   DOS 3.3   7/25/86
   543                                  ;   NLS_GETEXT	-
   544                                  ;
   545                                  ;   Inputs:	none
   546                                  ;   Outputs:	AX = extended error
   547                                  ;
   548                                  
   549                                  Procedure   NLS_GETEXT,NEAR
   549          ******************       warning: proc NLS_GETEXT... [-w+user]
   550                                   ASSUME DS:NOTHING,ES:NOTHING,SS:NOTHING
   551                                  
   552 0000016A 1E                      	push ds
   553 0000016B E8(0000)                	call doscode_getdosdata
   554 0000016E 8ED8                    	mov ds, ax
   555                                   assume ds:DOSGROUP
   556 00000170 A1[0000]                	mov ax, [EXTERR]	 ; return extended error
   557 00000173 1F                      	pop ds
   558                                   assume ds:nothing
   559 00000174 C3                      	RET
   560                                  EndProc NLS_GETEXT
   561                                  
   562                                  Break	<MSG_RETRIEVAL- get beginning addr of system and parser messages>
   563                                  
   564                                  ;   DOS 4.00
   565                                  ;
   566                                  ;   Inputs:	DL=0 get extended error message addr
   567                                  ;		  =1 set extended error message addr
   568                                  ;		  =2 get parser error message addr
   569                                  ;		  =3 set parser error message addr
   570                                  ;		  =4 get critical error message addr
   571                                  ;		  =5 set critical error message addr
   572                                  ;		  =6 get file system error message addr
   573                                  ;		  =7 set file system error message addr
   574                                  ;		  =8 get address for code reduction
   575                                  ;		  =9 set address for code reduction
   576                                  ;   Function:	get/set message address
   577                                  ;   Outputs:	ES:DI points to addr when get
   578                                  ;
   579                                  
   580                                  Procedure   MSG_RETRIEVAL,NEAR					  ;AN000;
   580          ******************       warning: proc MSG_RETRIEVAL... [-w+user]
   581                                   ASSUME DS:NOTHING,ES:NOTHING,SS:NOTHING	  ;AN000;
   582                                  
   583 00000175 50                      	PUSH	AX		    ;AN000;;MS. save regs
   584 00000176 56                      	PUSH	SI		    ;AN000;;MS. save regs
   585 00000177 1E                      	push ds
   586 00000178 E8(0000)                	call doscode_getdosdata
   587 0000017B 8ED8                    	mov ds, ax
   588                                   assume ds:DOSGROUP
   589 0000017D 89D0                    	MOV	AX,DX		    ;AN000;;MS.
   590 0000017F BE[0000]                	MOV	SI,OFFSET MSG_EXTERROR wrt DOSGROUP ;AN000;;MS.
   591 00000182 A801                    	TEST	AL,1		    ;AN000;;MS. get ?
   592 00000184 7401                    	JZ	toget		    ;AN000;;MS. yes
   593 00000186 48                      	DEC	ax		    ;AN000;;MS.
   594                                  toget:				    ;AN000;
   595 00000187 3C0A                    	cmp al, 10
   596 00000189 7312                    	jae .invalid
   597 0000018B D0E0                    	SHL	AL,1		    ;AN000;;MS. times 2
   598 0000018D 30E4                    	XOR	AH,AH		    ;AN000;;MS.
   599 0000018F 01C6                    	ADD	SI,AX		    ;AN000;;MS. position to the entry
   600 00000191 F6C201                  	TEST	DL,1		    ;AN000;;MS. get ? (NC)
   601 00000194 7414                    	JZ	getget			     ;AN000;;MS. yes
   602 00000196 893C                    	MOV	WORD PTR [SI],DI    ;AN000;;MS. set MSG
   603 00000198 8C4402                  	MOV	WORD PTR [SI+2],ES  ;AN000;;MS. address to ES:DI
   604 0000019B EB0F                    	JMP	SHORT MSGret		     ;AN000;;MS. exit
   605                                  .invalid:
   606 0000019D F6C201                  	test dl, 1
   607 000001A0 7505                    	jnz .invalidset
   608 000001A2 BFFFFF                  	mov di, -1
   609 000001A5 8EC7                    	mov es, di
   610                                   assume es:nothing
   611                                  .invalidset:
   612 000001A7 F9                      	stc
   613 000001A8 EB02                    	jmp MSGret
   614                                  getget: 				     ;AN000;
   615 000001AA C43C                    	LES	DI,[SI]			;AN000;;MS. get msg addr
   616                                   assume es:nothing
   617                                  MSGret: 				     ;AN000;
   618 000001AC 1F                      	pop ds
   619                                   assume ds:nothing
   620 000001AD 5E                      	POP	SI			     ;AN000;;MS.
   621 000001AE 58                      	POP	AX			     ;AN000;;MS.
   622 000001AF C3                      	return				     ;AN000;;MS. exit
   623                                  
   624                                  EndProc MSG_RETRIEVAL			     ;AN000;
   625                                  
   626                                  
   627                                  Break	<Fake_version - set/reset version flag>
   628                                  
   629                                  ;
   630                                  ;   Inputs:	DL=0 current version number
   631                                  ;		  <>0  special version number
   632                                  ;   Function:	set special version number
   633                                  ;   Outputs:	version number is changed
   634                                  ;
   635                                  
   636                                  Procedure   Fake_version,NEAR					  ;AN000;
   636          ******************       warning: proc Fake_version... [-w+user]
   637                                   ASSUME DS:NOTHING,ES:NOTHING,SS:NOTHING	  ;AN000;
   638                                  
   639 000001B0 1E                      	push ds
   640 000001B1 50                      	push ax
   641 000001B2 E8(0000)                	call doscode_getdosdata
   642 000001B5 8ED8                    	mov ds, ax
   643                                   assume ds:DOSGROUP
   644 000001B7 58                      	pop ax
   645 000001B8 8916[0000]              	MOV	[Special_version],DX   ;AN006;MS.
   646 000001BC 1F                      	pop ds
   647                                   assume ds:nothing
   648 000001BD C3                      	return			       ;AN006;;MS. exit
   649                                  
   650                                  EndProc Fake_version		       ;AN006;;MS.
   651                                  
   652                                      END
