     1                                  ;	SCCSID = @(#)getset.asm 1.2 85/07/23
     2                                  ;TITLE  GETSET - GETting and SETting MS-DOS system calls
     3                                  ;NAME   GETSET
     4                                  ;
     5                                  ; System Calls which get and set various things
     6                                  ;
     7                                  ;   $GET_VERSION
     8                                  ;   $GET_VERIFY_ON_WRITE
     9                                  ;   $SET_VERIFY_ON_WRITE
    10                                  ;   $INTERNATIONAL
    11                                  ;   $GET_DRIVE_FREESPACE
    12                                  ;   $GET_DMA
    13                                  ;   $SET_DMA
    14                                  ;   $GET_DEFAULT_DRIVE
    15                                  ;   $SET_DEFAULT_DRIVE
    16                                  ;   $GET_INTERRUPT_VECTOR
    17                                  ;   $SET_INTERRUPT_VECTOR
    18                                  ;   RECSET
    19                                  ;   $CHAR_OPER
    20                                  ;   $GetExtendedError		       DOS 3.3
    21                                  ;   Get_Global_CdPg		       DOS 4.0
    22                                  ;   $ECS_CALL			       DOS 4.0
    23                                  ;
    24                                  ;   Revision history:
    25                                  ;
    26                                  ;	Created: ARR 30 March 1983
    27                                  ;
    28                                  ;	A000   version 4.0   Jan. 1988
    29                                  ;	A006   D503-- fake version for IBMCACHE
    30                                  ;	A008   P4070- faske version for MS WINDOWS
    31                                  
    32                                  [list -]
    32          ******************       warning: redefining multi-line macro `struc' [-w+pp-macro-redef-multi]
    14                              <4> [list -]
    14                              <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
    37                                  
    38                                  %ifndef	ALTVECT
    39                                   %iassign ALTVECT 0			; FALSE
    40                                  %endif
    41                                  
    42                                  [list +]
    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]
    44          ******************       warning: out: DEVSYM.INC... [-w+user]
    52                                  
    53                                  	i_need	USERNUM,WORD
    54                                  	i_need	MSVERS,WORD
    55                                  	I_need	doslocation3001, byte
    56                                  	i_need	VERFLG,BYTE
    57                                  	i_need	CNTCFLAG,BYTE
    58                                  	i_need	DMAADD,DWORD
    59                                  	i_need	CURDRV,BYTE
    60                                  	i_need	chSwitch,BYTE
    61                                  	i_need	COUNTRY_CDPG,byte	      ;DOS 3.3
    62                                  	I_need	CDSCount,BYTE
    63                                  	I_need	ThisCDS,DWORD
    64                                  	i_need	EXTERR,WORD
    65                                  	i_need	EXTERR_ACTION,BYTE
    66                                  	i_need	EXTERR_CLASS,BYTE
    67                                  	i_need	EXTERR_LOCUS,BYTE
    68                                  	i_need	EXTERRPT,DWORD
    69                                  	i_need	UCASE_TAB,BYTE
    70                                  	i_need	FILE_UCASE_TAB,BYTE
    71                                  	i_need	InterCon,BYTE
    72                                  	i_need	CURRENTPDB,WORD
    73                                  	i_need	DBCS_TAB,BYTE			   ;AN000;
    74                                  	i_need	Special_version,WORD		   ;AN006;
    75                                  	i_need	Fake_Count,BYTE 		   ;AN008;
    76                                  	i_need	NLS_YES,BYTE			   ;AN000;
    77                                  	i_need	NLS_yes2,BYTE			   ;AN000;
    78                                  	i_need	NLS_NO,BYTE			   ;AN000;
    79                                  	i_need	NLS_no2,BYTE			   ;AN000;
    80                                  
    81                                  
    82                                   assume nocheck, ss:DOSGROUP
    83                                  
    84                                  BREAK <$Get_Version -- Return DOS version number>
    85                                  	procedure   D_GET_VERSION,NEAR
    85          ******************       warning: proc D_GET_VERSION... [-w+user]
    86                                  ASSUME	DS:NOTHING,ES:NOTHING
    87                                  
    88                                  ; Inputs:
    89                                  ;	None
    90                                  ; Function:
    91                                  ;	Return DOS version number
    92                                  ; Outputs:
    93                                  ;	OEM number in BH
    94                                  ;	User number in BL:CX (24 bits)
    95                                  ;	Version number as AL.AH in binary
    96                                  ;	NOTE: On pre 1.28 DOSs AL will be zero
    97                                  
    98 00000000 161F                    	context DS
    99 00000002 8B1E[0200]              	MOV	BX,[USERNUM + 2]
   100 00000006 8B0E[0000]              	MOV	CX,[USERNUM]
   101 0000000A 3C01                    	cmp al, 1
   102 0000000C 7504                    	jne .use_oem_id
   103 0000000E 8A3E[0000]              	mov bh, [doslocation3001]
   104                                  .use_oem_id:
   105 00000012 A1[0000]                	MOV	AX,[MSVERS]
   106 00000015 E8(0000)                	invoke	get_user_stack
   107                                  ASSUME	DS:NOTHING
   108 00000018 895C02                  	MOV	[SI + user_BX],BX
   109 0000001B 894C04                  	MOV	[SI + user_CX],CX
   110 0000001E 36803E[0000]FF          	CMP	byte [ss:Fake_Count],0FFH		   ;AN008;
   111 00000024 740D                    	JZ	reg				   ;AN008;
   112 00000026 36803E[0000]00          	CMP	byte [ss:Fake_Count],0		   ;AN008;
   113 0000002C 7411                    	JZ	usual				   ;AN008;
   114 0000002E 36FE0E[0000]            	DEC	byte [ss:Fake_Count] 		   ;AN008;
   115                                  reg:						   ;AN008;
   116 00000033 36833E[0000]00          	CMP	word [ss:Special_version],0		   ;AN006;
   117 00000039 7404                    	JZ	usual				   ;AN006;
   118 0000003B 36A1[0000]              	MOV	AX,[ss:Special_version] 	   ;AN006;
   119                                  usual:						   ;AN006;
   120 0000003F 8904                    	MOV	[SI + user_AX],AX 	; Really only sets AH
   121 00000041 C3                      	return
   122                                  EndProc D_GET_VERSION
   123                                  
   124                                  BREAK <$Get_Verify_on_Write - return verify-after-write flag>
   125                                  	procedure   D_GET_VERIFY_ON_WRITE,NEAR
   125          ******************       warning: proc D_GET_VERIFY_ON_WRITE... [-w+user]
   126                                  ASSUME	DS:NOTHING,ES:NOTHING
   127                                  
   128                                  ; Inputs:
   129                                  ;	none.
   130                                  ; Function:
   131                                  ;	returns flag
   132                                  ; Returns:
   133                                  ;	AL = value of VERIFY flag
   134                                  
   135 00000042 36A0[0000]              	MOV	AL,[ss:VERFLG]
   136 00000046 C3                      	return
   137                                  EndProc D_GET_VERIFY_ON_WRITE
   138                                  
   139                                  BREAK <$Set_Verify_on_Write - Toggle verify-after-write flag>
   140                                  	procedure   D_SET_VERIFY_ON_WRITE,NEAR
   140          ******************       warning: proc D_SET_VERIFY_ON_WRITE... [-w+user]
   141                                  ASSUME	DS:NOTHING,ES:NOTHING
   142                                  
   143                                  ; Inputs:
   144                                  ;	AL = desired value of VERIFY flag
   145                                  ; Function:
   146                                  ;	Sets flag
   147                                  ; Returns:
   148                                  ;	None
   149                                  
   150 00000047 2401                    	AND	AL,1
   151 00000049 36A2[0000]              	MOV	[ss:VERFLG],AL
   152 0000004D C3                      	return
   153                                  EndProc D_SET_VERIFY_ON_WRITE
   154                                  
   155                                  BREAK <$International - return country-dependent information>
   156                                  ;
   157                                  ; Inputs:
   158                                  ;	MOV	AH,International
   159                                  ;	MOV	AL,country	(al = 0 => current country)
   160                                  ;      [MOV	BX,country]
   161                                  ;	LDS	DX,block
   162                                  ;	INT	21
   163                                  ; Function:
   164                                  ;	give users an idea of what country the application is running
   165                                  ; Outputs:
   166                                  ;	IF DX != -1 on input (get country)
   167                                  ;	  AL = 0 means return current country table.
   168                                  ;	  0<AL<0FFH means return country table for country AL
   169                                  ;	  AL = 0FF means return country table for country BX
   170                                  ;	  No Carry:
   171                                  ;	     Register BX will contain the 16-bit country code.
   172                                  ;	     Register AL will contain the low 8 bits of the country code.
   173                                  ;	     The block pointed to by DS:DX is filled in with the information
   174                                  ;	     for the particular country.
   175                                  ;		BYTE  Size of this table excluding this byte and the next
   176                                  ;		BYTE  Country code represented by this table
   177                                  ;			A sequence of n bytes, where n is the number specified
   178                                  ;			by the first byte above and is not > internat_block_max,
   179                                  ;			in the correct order for being returned by the
   180                                  ;			INTERNATIONAL call as follows:
   181                                  ;		WORD	Date format 0=mdy, 1=dmy, 2=ymd
   182                                  ;		5 BYTE	Currency symbol null terminated
   183                                  ;		2 BYTE	thousands separator null terminated
   184                                  ;		2 BYTE	Decimal point null terminated
   185                                  ;		2 BYTE	Date separator null terminated
   186                                  ;		2 BYTE	Time separator null terminated
   187                                  ;		1 BYTE	Bit field.  Currency format.
   188                                  ;			Bit 0.	=0 $ before #  =1 $ after #
   189                                  ;			Bit 1.	no. of spaces between # and $ (0 or 1)
   190                                  ;		1 BYTE	No. of significant decimal digits in currency
   191                                  ;		1 BYTE	Bit field.  Time format.
   192                                  ;			Bit 0.	=0 12 hour clock  =1 24 hour
   193                                  ;		DWORD	Call address of case conversion routine
   194                                  ;		2 BYTE	Data list separator null terminated.
   195                                  ;	  Carry:
   196                                  ;	     Register AX has the error code.
   197                                  ;	IF DX = -1 on input (set current country)
   198                                  ;	  AL = 0 is an error
   199                                  ;	  0<AL<0FFH means set current country to country AL
   200                                  ;	  AL = 0FF means set current country to country BX
   201                                  ;	  No Carry:
   202                                  ;	    Current country SET
   203                                  ;	    Register AL will contain the low 8 bits of the country code.
   204                                  ;	  Carry:
   205                                  ;	     Register AX has the error code.
   206                                  
   207                                  
   208                                  	procedure   D_INTERNATIONAL,NEAR   ; DOS 3.3
   208          ******************       warning: proc D_INTERNATIONAL... [-w+user]
   209                                  ASSUME	DS:NOTHING,ES:NOTHING
   210 0000004E 3CFF                    	CMP	AL,0FFH
   211 00000050 7404                    	JZ	BX_HAS_CODE		; -1 means country code is in BX
   212 00000052 88C3                    	MOV	BL,AL			; Put AL country code in BX
   213 00000054 30FF                    	XOR	BH,BH
   214                                  BX_HAS_CODE:
   215 00000056 1E                      	PUSH	DS
   216 00000057 07                      	POP	ES
   217                                   assume es:nothing
   218 00000058 52                      	PUSH	DX
   219 00000059 5F                      	POP	DI			; User buffer to ES:DI
   220 0000005A 161F                    	context DS
   221 0000005C 83FFFF                  	CMP	DI,-1
   222 0000005F 7461                    	JZ	international_set
   223 00000061 09DB                    	OR	BX,BX
   224 00000063 7505                    	JNZ	international_find
   225 00000065 BE[0000]                	MOV	SI,OFFSET COUNTRY_CDPG wrt DOSGROUP
   226 00000068 EB42                    	JMP	SHORT international_copy
   227                                  
   228                                  international_find:
   229 0000006A BD0000                  	MOV	BP,0			 ; flag it for GetCntry only
   230 0000006D E80B00                  	CALL	international_get
   231 00000070 7258                    	JC	errtn
   232 00000072 83FB00                  	CMP	BX,0			 ; nlsfunc finished it ?
   233 00000075 7535                    	JNZ	SHORT international_copy ; no, copy by myself
   234 00000077 89D3                    	MOV	BX,DX			 ; put country back
   235 00000079 EB3C                    	JMP	SHORT international_ok3
   236                                  
   237                                  international_get:
   238 0000007B BE[0000]                	MOV	SI,OFFSET COUNTRY_CDPG wrt DOSGROUP
   239 0000007E 3B5C68                  	CMP	BX,[SI + ccDosCountry]	 ; = current country id
   240 00000081 74CA                    	retz				 ; return if equal
   241 00000083 89DA                    	MOV	DX,BX
   242 00000085 31DB                    	XOR	BX,BX			 ; bx = 0, default code page
   243 00000087 B80014CD2F              	CallInstall NLSInstall,NLSFUNC,0 ; check if NLSFUNC in memory
   244 0000008C 3CFF                    	CMP	AL,0FFH
   245 0000008E 7518                    	JNZ	interr			   ; not in memory
   246 00000090 83FD00                  	CMP	BP,0			 ; GetCntry ?
   247 00000093 7508                    	JNZ	stcdpg
   248 00000095 B80414CD2F              	CallInstall GetCntry,NLSFUNC,4	 ; get country info
   249 0000009A EB06                    	JMP	chkok
   250 0000009C 90                      	nop	; identicalise
   251                                  stcdpg:
   252 0000009D B80314CD2F              	CallInstall SetCodePage,NLSFUNC,3  ; set country info
   253                                  chkok:
   254 000000A2 3C00                    	CMP	AL,0			   ; success ?
   255 000000A4 74A7                    	retz				   ; yes
   256                                  setcarry:
   257 000000A6 F9                      	STC				 ; set carry
   258 000000A7 C3                      	ret
   259                                  interr:
   260 000000A8 B0FF                    	MOV	AL,0FFH 		   ; flag nlsfunc error
   261 000000AA EBFA                    	JMP	setcarry
   262                                  
   263                                  international_copy:
   264 000000AC 8B5C68                  	MOV	BX,[SI + ccDosCountry]	 ; = current country id
   265 000000AF BE[6C00]                	MOV	SI,OFFSET COUNTRY_CDPG + ccDFormat wrt DOSGROUP
   266 000000B2 B91800                  	MOV	CX,OLD_COUNTRY_SIZE
   267 000000B5 F3A4                    	REP	MOVSB			 ;copy country info
   268                                  international_ok3:
   269 000000B7 E8(0000)                	invoke	get_user_stack
   270                                  ASSUME	DS:NOTHING
   271 000000BA 895C02                  	MOV	[SI + user_BX],BX
   272                                  international_ok:
   273 000000BD 89D8                    	MOV	AX,BX		     ; Return country code in AX too.
   274 000000BF E9(0000)                	transfer SYS_RET_OK
   275                                  
   276                                  international_set:
   277                                  ASSUME	DS:DOSGROUP
   278 000000C2 BD0100                  	MOV	BP,1		     ; flag it for SetCodePage only
   279 000000C5 E8B3FF                  	CALL	international_get
   280 000000C8 73F3                    	JNC	international_ok
   281                                  errtn:
   282 000000CA 3CFF                    	CMP	AL,0FFH
   283 000000CC 7403                    	JZ	errtn2
   284 000000CE E9(0000)                	transfer SYS_RET_ERR	     ; return what we got from NLSFUNC
   285                                  errtn2:
   286                                  error_Invalid_Function equ error_invalid_function	; NASM port equate
   287 000000D1 B001EBF9                	error	error_Invalid_Function	; NLSFUNC not existent
   288                                  
   289                                  
   290                                  EndProc D_INTERNATIONAL
   291                                  
   292                                  
   293                                  
   294                                  BREAK <$GetExtCntry - return extended country-dependent information>
   295                                  ;
   296                                  ; Inputs:
   297                                  ;	if AL >= 20H
   298                                  ;	  AL= 20H    capitalize single char, DL= char
   299                                  ;	      21H    capitalize string ,CX= string length
   300                                  ;	      22H    capitalize ASCIIZ string
   301                                  ;	      23H    YES/NO check, DL=1st char DH= 2nd char (DBCS)
   302                                  ;	      80H bit 0 = use normal upper case table
   303                                  ;		      1 = use file upper case table
   304                                  ;	   DS:DX points to string
   305                                  ;
   306                                  ;	else
   307                                  ;
   308                                  ;	MOV	AH,GetExtCntry	 ; DOS 3.3
   309                                  ;	MOV	AL,INFO_ID	( info type,-1	selects all)
   310                                  ;	MOV	BX,CODE_PAGE	( -1 = active code page )
   311                                  ;	MOV	DX,COUNTRY_ID	( -1 = active country )
   312                                  ;	MOV	CX,SIZE 	( amount of data to return)
   313                                  ;	LES	DI,COUNTRY_INFO ( buffer for returned data )
   314                                  ;	INT	21
   315                                  ; Function:
   316                                  ;	give users extended country dependent information
   317                                  ;	or capitalize chars
   318                                  ; Outputs:
   319                                  ;	  No Carry:
   320                                  ;	     extended country info is succesfully returned
   321                                  ;	  Carry:
   322                                  ;	     Register AX has the error code.
   323                                  ;	     AX=0, NO	 for YES/NO CHECK
   324                                  ;		1, YES
   325                                  
   326                                  
   327                                  	procedure   D_GetExtCntry,NEAR	; DOS 3.3
   327          ******************       warning: proc D_GetExtCntry... [-w+user]
   328                                  ASSUME	DS:NOTHING,ES:NOTHING
   329 000000D5 3C20                    	CMP	AL,CAP_ONE_CHAR 	;AN000;MS. < 20H ?
   330 000000D7 7303                    	JAE	capcap			;AN000;MS.
   331 000000D9 EB6B                    	JMP	notcap			;AN000;MS. yes
   332 000000DB 90                      	nop	; identicalise
   333                                  capcap: 				;AN000;
   334 000000DC A880                    	TEST	AL,UPPER_TABLE		;AN000;MS. which upper case table
   335 000000DE 7505                    	JNZ	fileupper		;AN000;MS. file upper case
   336 000000E0 BB[0200]                	MOV	BX,OFFSET UCASE_TAB+2 wrt DOSGROUP ;AN000;MS. get normal upper case
   337 000000E3 EB03                    	JMP	SHORT capit			   ;AN000;MS.
   338                                  fileupper:					   ;AN000;
   339 000000E5 BB[0200]                	MOV	BX,OFFSET FILE_UCASE_TAB+2 wrt DOSGROUP;AN000;MS. get file upper case
   340                                  capit:					;AN000;
   341 000000E8 3C20                    	CMP	AL,CAP_ONE_CHAR 	;AN000;;MS.cap one char ?
   342 000000EA 750D                    	JNZ	chkyes			;AN000;;MS. no
   343 000000EC 88D0                    	MOV	AL,DL			;AN000;;MS. set up AL
   344 000000EE E8(0000)                	invoke	GETLET3 		;AN000;;MS. upper case it
   345 000000F1 E8(0000)                	invoke	get_user_stack		;AN000;;MS. get user stack
   346 000000F4 884406                  	MOV	byte ptr [SI + user_DX],AL;AN000;;MS. user's DL=AL
   347 000000F7 EB24                    	JMP	SHORT nono		;AN000;;MS. done
   348                                  chkyes: 				;AN000;
   349 000000F9 3C23                    	CMP	AL,CHECK_YES_NO 	;AN000;;MS. check YES or NO ?
   350 000000FB 7522                    	JNZ	capstring		;AN000;;MS. no
   351 000000FD 31C0                    	XOR	AX,AX			;AN000;;MS. presume NO
   352                                  %IF  DBCS				;AN000;
   353                                  	PUSH	AX			;AN000;;MS.
   354                                  	MOV	AL,DL			;AN000;;MS.
   355                                  	invoke	TESTKANJ		;AN000;;MS. DBCS ?
   356                                  	POP	AX			;AN000;;MS.
   357                                  	JNZ	dbcs_char		;AN000;;MS. yes, return error
   358                                  %ENDIF					;AN000;
   359                                  					;AN000;
   360 000000FF 363A16[0000]            	CMP	DL,[ss:NLS_YES]		;AN000;;MS. is 'Y' ?
   361 00000104 7416                    	JZ	yesyes			;AN000;;MS. yes
   362 00000106 363A16[0000]            	CMP	DL,[ss:NLS_yes2]		;AN000;;MS. is 'y' ?
   363 0000010B 740F                    	JZ	yesyes			;AN000;;MS. yes
   364 0000010D 363A16[0000]            	CMP	DL,[ss:NLS_NO]		;AN000;;MS. is	'N'?
   365 00000112 7409                    	JZ	nono			;AN000;;MS. no
   366 00000114 363A16[0000]            	CMP	DL,[ss:NLS_no2]		;AN000;;MS. is 'n' ?
   367 00000119 7402                    	JZ	nono			;AN000;;MS. no
   368                                  dbcs_char:				;AN000;
   369 0000011B 40                      	INC	AX			;AN000;;MS. not YES or NO
   370                                  yesyes: 				;AN000'
   371 0000011C 40                      	INC	AX			;AN000;;MS. return 1
   372                                  nono:					;AN000;
   373 0000011D EBA0                    	transfer SYS_RET_OK		;AN000;;MS. done
   374                                  capstring:				;AN000;
   375 0000011F 89D6                    	MOV	SI,DX			;AN000;;MS. si=dx
   376 00000121 3C21                    	CMP	AL,CAP_STRING		;AN000;;MS. cap string ?
   377 00000123 7510                    	JNZ	capascii		;AN000;;MS. no
   378 00000125 83F900                  	CMP	CX,0			;AN000;;MS. check count 0
   379 00000128 74F3                    	JZ	nono			;AN000;;MS. yes finished
   380                                  concap: 				;AN000;
   381 0000012A AC                      	LODSB				;AN000;;MS. get char
   382                                   %IF  DBCS				;AN000;;MS.
   383                                  	invoke	TESTKANJ		;AN000;;MS. DBCS ?
   384                                  	JZ	notdbcs 		;AN000;;MS. no
   385                                  	INC	SI			;AN000;;MS. skip 2 chars
   386                                  	DEC	CX			;AN000;;MS. bad input, one DBCS char at end
   387                                  	JZ	nono			;AN000;;MS. yes
   388                                  	JMP	SHORT next99		;AN000;;MS.
   389                                  notdbcs:				;AN000;
   390                                   %ENDIF					;AN000;
   391                                  
   392 0000012B E8(0000)                	invoke	GETLET3 		;AN000;;MS. upper case it
   393 0000012E 8844FF                  	MOV	byte ptr [SI-1],AL	;AN000;;MS. store back
   394                                  next99: 				;AN000;
   395 00000131 E2F7                    	LOOP	concap			;AN000;;MS. continue
   396 00000133 EBE8                    	JMP	nono			;AN000;;MS. done
   397                                  capascii:				;AN000;
   398 00000135 3C22                    	CMP	AL,CAP_ASCIIZ		;AN000;;MS. cap ASCIIZ string ?
   399 00000137 7545                    	JNZ	capinval		;AN000;;MS. no
   400                                  concap2:				;AN000;
   401 00000139 AC                      	LODSB				;AN000;;MS. get char
   402 0000013A 3C00                    	CMP	AL,0			;AN000;;MS. end of string ?
   403 0000013C 74DF                    	JZ	nono			;AN000;;MS. yes
   404                                   %IF  DBCS				;AN000;;MS.
   405                                  	invoke	TESTKANJ		;AN000;;MS. DBCS ?
   406                                  	JZ	notdbcs2		;AN000;;MS. no
   407                                  	CMP	BYTE PTR [SI],0 	;AN000;;MS. bad input, one DBCS char at end
   408                                  	JZ	nono			;AN000;;MS. yes
   409                                  	INC	SI			;AN000;;MS. skip 2 chars
   410                                  	JMP	concap2 		;AN000;;MS.
   411                                  notdbcs2:				;AN000;
   412                                   %ENDIF					;AN000;
   413 0000013E E8(0000)                	invoke	GETLET3 		;AN000;;MS. upper case it
   414 00000141 8844FF                  	MOV	byte ptr [SI-1],AL	;AN000;;MS. store back
   415 00000144 EBF3                    	JMP	concap2 		;AN000;;MS. continue
   416                                  
   417                                  
   418                                  notcap:
   419 00000146 83F905                  	CMP	CX,5			; minimum size is 5
   420 00000149 7278                    	JB	sizeerror
   421 0000014B 161F                    	context DS
   422 0000014D BE[0000]                	MOV	SI,OFFSET COUNTRY_CDPG wrt DOSGROUP
   423 00000150 83FAFF                  	CMP	DX,-1			; active country ?
   424 00000153 7503                    	JNZ	GETCDPG 		; no
   425 00000155 8B5468                  	MOV	DX,[SI + ccDosCountry]	; get active country id
   426                                  GETCDPG:
   427 00000158 83FBFF                  	CMP	BX,-1			; active code page?
   428 0000015B 7503                    	JNZ	CHKAGAIN		; no, check again
   429 0000015D 8B5C6A                  	MOV	BX,[SI + ccDosCodePage]	; get active code page id
   430                                  CHKAGAIN:
   431 00000160 3B5468                  	CMP	DX,[SI + ccDosCountry]	; same as active country id?
   432 00000163 7551                    	JNZ	CHKNLS			; no
   433 00000165 3B5C6A                  	CMP	BX,[SI + ccDosCodePage]	; same as active code page id?
   434 00000168 754C                    	JNZ	CHKNLS			; no
   435                                  CHKTYPE:
   436 0000016A 8B5C48                  	MOV	BX,[SI + ccSysCodePage]	; bx = sys code page id
   437                                  ;	CMP	AL,SetALL		; select all?
   438                                  ;	JNZ	SELONE
   439                                  ;	MOV	SI,OFFSET COUNTRY_CDPG + ccNumber_of_entries wrt DOSGROUP
   440                                  SELONE:
   441 0000016D 51                      	PUSH	CX			; save cx
   442 0000016E 8B4C4A                  	MOV	CX,[SI + ccNumber_of_entries]
   443 00000171 BE[4C00]                	MOV	SI,OFFSET COUNTRY_CDPG + ccSetUcase wrt DOSGROUP
   444                                  NXTENTRY:
   445 00000174 3A04                    	CMP	AL,[SI] 		; compare info type
   446 00000176 740B                    	JZ	FOUNDIT
   447 00000178 83C605                  	ADD	SI,5			; next entry
   448 0000017B E2F7                    	LOOP	NXTENTRY
   449 0000017D 59                      	POP	CX
   450                                  capinval:
   451 0000017E B001E9(0000)            	error	error_Invalid_Function	; info type not found
   452                                  FOUNDIT:
   453 00000183 A4                      	MOVSB				; move info id byte
   454 00000184 59                      	POP	CX			; retsore char count
   455 00000185 3C01                    	CMP	AL,SetCountryInfo	; select country info type ?
   456 00000187 7414                    	JZ	setsize
   457 00000189 B90400                  	MOV	CX,4			; 4 bytes will be moved
   458 0000018C B80500                  	MOV	AX,5			; 5 bytes will be returned in CX
   459                                  OK_RETN:
   460 0000018F F3A4                    	REP	MOVSB			; copy info
   461 00000191 89C1                    	MOV	CX,AX			; CX = actual length returned
   462 00000193 89D8                    	MOV	AX,BX			; return sys code page in ax
   463                                  GETDONE:
   464 00000195 E8(0000)                	invoke	get_user_stack		; return actual length to user's CX
   465 00000198 894C04                  	MOV	[SI + user_CX],CX
   466 0000019B EB80                    	transfer SYS_RET_OK
   467                                  setsize:
   468 0000019D 83E903                  	SUB	CX,3			; size after length field
   469 000001A0 390C                    	CMP	WORD PTR [SI],CX	; less than table size
   470 000001A2 7302                    	JAE	setsize2		; no
   471 000001A4 8B0C                    	MOV	CX,WORD PTR [SI]	; truncate to table size
   472                                  setsize2:
   473 000001A6 26890D                  	MOV	[ES:DI],CX		; copy actual length to user's
   474 000001A9 83C702                  	ADD	DI,2			; update index
   475 000001AC 83C602                  	ADD	SI,2
   476 000001AF 89C8                    	MOV	AX,CX
   477 000001B1 83C003                  	ADD	AX,3			; AX has the actual length
   478 000001B4 EBD9                    	JMP	OK_RETN 		; go move it
   479                                  CHKNLS:
   480 000001B6 30E4                    	XOR	AH,AH
   481 000001B8 50                      	PUSH	AX			   ; save info type
   482 000001B9 5D                      	POP	BP			   ; bp = info type
   483 000001BA B80014CD2F              	CallInstall NLSInstall,NLSFUNC,0 ; check if NLSFUNC in memory
   484 000001BF 3CFF                    	CMP	AL,0FFH
   485 000001C1 7404                    	JZ	NLSNXT			   ;	 in memory
   486                                  sizeerror:
   487 000001C3 B001EBB9                	error	error_Invalid_Function
   488 000001C7 B80214CD2F              NLSNXT: CallInstall GetExtInfo,NLSFUNC,2  ;get extended info
   489 000001CC 3C00                    	CMP	AL,0			   ; success ?
   490 000001CE 7505                    	JNZ	NLSERROR
   491 000001D0 8B4448                  	MOV	AX,[SI + ccSysCodePage]	; ax = sys code page id
   492 000001D3 EBC0                    	JMP	GETDONE
   493                                  NLSERROR:
   494 000001D5 EBEE                    	transfer SYS_RET_ERR		; return what is got from NLSFUNC
   495                                  
   496                                  EndProc D_GetExtCntry
   497                                  
   498                                  BREAK <$GetSetCdPg - get or set global code page>
   499                                  ;
   500                                  ; Inputs:
   501                                  ;	MOV	AH,GetSetCdPg	; DOS 3.3
   502                                  ;	MOV	AL,n		; n = 1 : get code page, n = 2 : set code page
   503                                  ;	MOV	BX,CODE_PAGE	( set code page only)
   504                                  ;	INT	21
   505                                  ; Function:
   506                                  ;	get or set the global code page
   507                                  ; Outputs:
   508                                  ;	  No Carry:
   509                                  ;	     global code page is set	(set global code page)
   510                                  ;	     BX = active code page id	(get global code page)
   511                                  ;	     DX = system code page id	(get global code page)
   512                                  ;	  Carry:
   513                                  ;	     Register AX has the error code.
   514                                  
   515                                  
   516                                  	procedure   D_GetSetCdPg,NEAR   ; DOS 3.3
   516          ******************       warning: proc D_GetSetCdPg... [-w+user]
   517                                  ASSUME	DS:NOTHING,ES:NOTHING
   518 000001D7 161F                    	context DS
   519 000001D9 BE[0000]                	MOV	SI,OFFSET COUNTRY_CDPG wrt DOSGROUP
   520 000001DC 3C01                    	CMP	AL,1		       ; get global code page
   521 000001DE 7511                    	JNZ	setglpg 	       ; set global cod epage
   522 000001E0 8B5C6A                  	MOV	BX,[SI + ccDosCodePage]  ; get active code page id
   523 000001E3 8B5448                  	MOV	DX,[SI + ccSysCodePage]  ; get sys code page id
   524 000001E6 E8(0000)                	invoke	get_user_stack
   525                                  ASSUME DS:NOTHING
   526 000001E9 895C02                  	MOV	[SI + user_BX],BX        ; update returned bx
   527 000001EC 895406                  	MOV	[SI + user_DX],DX        ; update returned dx
   528                                  OK_RETURN:
   529 000001EF EBAA                    	transfer SYS_RET_OK
   530                                  ASSUME DS:DOSGROUP
   531                                  setglpg:
   532 000001F1 3C02                    	CMP	AL,2
   533 000001F3 7533                    	JNZ	nomem
   534                                  ;;;;;;; CMP	BX,[SI.ccDosCodePage]  ; same as active code page
   535                                  ;;;;;;; JZ	OK_RETURN	       ; yes
   536 000001F5 8B5468                  	MOV	DX,[SI + ccDosCountry]
   537 000001F8 B80014CD2F              	CallInstall NLSInstall,NLSFUNC,0 ; check if NLSFUNC in memory
   538 000001FD 3CFF                    	CMP	AL,0FFH
   539 000001FF 7527                    	JNZ	nomem			   ; not in memory
   540 00000201 B80114CD2F              	CallInstall SetCodePage,NLSFUNC,1  ;set the code page
   541 00000206 3C00                    	CMP	AL,0			   ; success ?
   542 00000208 74E5                    	JZ	OK_RETURN		   ; yes
   543 0000020A 3C41                    	CMP	AL,65			   ; set device code page failed
   544 0000020C 7518                    	JNZ	.seterr
   545 0000020E B84100                  	MOV	AX,65
   546 00000211 A3[0000]                	MOV	[EXTERR],AX
   547 00000214 C606[0000]06            	MOV	byte [EXTERR_ACTION],errACT_Ignore
   548 00000219 C606[0000]05            	MOV	byte [EXTERR_CLASS],errCLASS_HrdFail
   549 0000021E C606[0000]04            	MOV	byte [EXTERR_LOCUS],errLOC_SerDev
   550 00000223 E9(0000)                	transfer   From_GetSet
   551                                  
   552                                  .seterr:
   553 00000226 EBAD                    	transfer  SYS_RET_ERR
   554                                  nomem:
   555 00000228 B001EBFA                	error	error_Invalid_Function ; function not defined
   556                                  ;
   557                                  EndProc D_GetSetCdPg
   558                                  
   559                                  
   560                                  
   561                                  
   562                                  BREAK <$Get_Drive_Freespace -- Return bytes of free disk space on a drive>
   563                                  	procedure   D_GET_DRIVE_FREESPACE,NEAR
   563          ******************       warning: proc D_GET_DRIVE_FREESPACE... [-w+user]
   564                                  ASSUME	DS:NOTHING,ES:NOTHING
   565                                  
   566                                  ; Inputs:
   567                                  ;	DL = Drive number
   568                                  ; Function:
   569                                  ;	Return number of free allocation units on drive
   570                                  ; Outputs:
   571                                  ;	BX = Number of free allocation units
   572                                  ;	DX = Total Number of allocation units on disk
   573                                  ;	CX = Sector size
   574                                  ;	AX = Sectors per allocation unit
   575                                  ;	   = -1 if bad drive specified
   576                                  ; This call returns the same info in the same registers (except for FAT pointer)
   577                                  ;      as the old FAT pointer calls
   578                                  
   579 0000022C 161F                    	context DS
   580 0000022E 88D0                    	MOV	AL,DL
   581 00000230 E8(0000)                	invoke	GetThisDrv		; Get drive
   582                                  SET_AX_RET:
   583 00000233 721A                    	JC	BADFDRV
   584 00000235 E8(0000)                	invoke	DISK_INFO
   585 00000238 87D3                    	XCHG	DX,BX
   586 0000023A 72F7                    	JC	SET_AX_RET		; User FAILed to I 24
   587 0000023C 48                      	dec ax
   588 0000023D 30E4                    	XOR	AH,AH			; Chuck Fat ID byte
   589 0000023F 40                      	inc ax				; translate EDR-DOS 0 to 256
   590                                  DoSt:
   591 00000240 E8(0000)                	invoke	get_user_stack
   592                                  ASSUME	DS:NOTHING
   593 00000243 895406                  	MOV	[SI + user_DX],DX
   594 00000246 894C04                  	MOV	[SI + user_CX],CX
   595 00000249 895C02                  	MOV	[SI + user_BX],BX
   596 0000024C 8904                    	MOV	[SI + user_AX],AX
   597 0000024E C3                      	return
   598                                  BADFDRV:
   599                                  ;	MOV	AL,error_invalid_drive	; Assume error
   600 0000024F E8(0000)                	invoke	FCB_RET_ERR
   601 00000252 B8FFFF                  	MOV	AX,-1
   602 00000255 EBE9                    	JMP	DoSt
   603                                  EndProc D_GET_DRIVE_FREESPACE
   604                                  
   605                                  BREAK <$Get_DMA, $Set_DMA -- Get/Set current DMA address>
   606                                  	procedure   D_GET_DMA,NEAR
   606          ******************       warning: proc D_GET_DMA... [-w+user]
   607                                  ASSUME	DS:NOTHING,ES:NOTHING
   608                                  
   609                                  ; Inputs:
   610                                  ;	None
   611                                  ; Function:
   612                                  ;	Get DISK TRANSFER ADDRESS
   613                                  ; Returns:
   614                                  ;	ES:BX is current transfer address
   615                                  
   616 00000257 368B1E[0000]            	MOV	BX,WORD PTR [ss:DMAADD]
   617 0000025C 368B0E[0200]            	MOV	CX,WORD PTR [ss:DMAADD+2]
   618 00000261 E8(0000)                	invoke	get_user_stack
   619 00000264 895C02                  	MOV	[SI + user_BX],BX
   620 00000267 894C10                  	MOV	[SI + user_ES],CX
   621 0000026A C3                      	return
   622                                  EndProc D_GET_DMA
   623                                  
   624                                  	procedure   D_SET_DMA,NEAR
   624          ******************       warning: proc D_SET_DMA... [-w+user]
   625                                  ASSUME	DS:NOTHING,ES:NOTHING
   626                                  
   627                                  ; Inputs:
   628                                  ;	DS:DX is desired new disk transfer address
   629                                  ; Function:
   630                                  ;	Set DISK TRANSFER ADDRESS
   631                                  ; Returns:
   632                                  ;	None
   633                                  
   634 0000026B 368916[0000]            	MOV	WORD PTR [ss:DMAADD],DX
   635 00000270 368C1E[0200]            	MOV	WORD PTR [ss:DMAADD+2],DS
   636 00000275 C3                      	return
   637                                  EndProc D_SET_DMA
   638                                  
   639                                  BREAK <$Get_Default_Drive, $Set_Default_Drive -- Set/Get default drive>
   640                                  	procedure   D_GET_DEFAULT_DRIVE,NEAR
   640          ******************       warning: proc D_GET_DEFAULT_DRIVE... [-w+user]
   641                                  ASSUME	DS:NOTHING,ES:NOTHING
   642                                  
   643                                  ; Inputs:
   644                                  ;	None
   645                                  ; Function:
   646                                  ;	Return current drive number
   647                                  ; Returns:
   648                                  ;	AL = drive number
   649                                  
   650 00000276 36A0[0000]              	MOV	AL,[ss:CURDRV]
   651 0000027A C3                      	return
   652                                  EndProc D_GET_DEFAULT_DRIVE
   653                                  
   654                                  	procedure   D_SET_DEFAULT_DRIVE,NEAR
   654          ******************       warning: proc D_SET_DEFAULT_DRIVE... [-w+user]
   655                                  ASSUME	DS:NOTHING,ES:NOTHING
   656                                  
   657                                  ; Inputs:
   658                                  ;	DL = Drive number for new default drive
   659                                  ; Function:
   660                                  ;	Set the default drive
   661                                  ; Returns:
   662                                  ;	AL = Number of drives, NO ERROR RETURN IF DRIVE NUMBER BAD
   663                                  
   664 0000027B 88D0                    	MOV	AL,DL
   665 0000027D FEC0                    	INC	AL			; A=1, b=2...
   666 0000027F E8(0000)                	invoke	GetVisDrv		; see if visible drive
   667 00000282 7204                    	JC	SETRET			; errors do not set
   668                                  ;	LDS	SI,ThisCDS		; get CDS
   669                                  ;	TEST	[SI].curdir_flags,curdir_splice ; was it spliced?
   670                                  ;	JNZ	SetRet			; yes, do not set
   671 00000284 36A2[0000]              	MOV	[ss:CURDRV],AL		; no, set
   672                                  SETRET:
   673                                  CDSCOUNT equ CDSCount	; NASM port label
   674 00000288 36A0[0000]              	MOV	AL,[ss:CDSCOUNT]		; let user see what the count really is
   675 0000028C C3                      RET17:	return
   676                                  EndProc D_SET_DEFAULT_DRIVE
   677                                  
   678                                  BREAK <$Get_Interrupt_Vector - Get/Set interrupt vectors>
   679                                  	procedure   D_server_GET_INTERRUPT_VECTOR,NEAR
   679          ******************       warning: proc D_server_GET_INTERRUPT_VECTOR... [-w+user]
   680                                  ASSUME	DS:NOTHING,ES:NOTHING
   681                                  
   682                                  ; Inputs:
   683                                  ;	AL = interrupt number
   684                                  ; Function:
   685                                  ;	Get the interrupt vector
   686                                  ; Returns:
   687                                  ;	ES:BX is current interrupt vector
   688                                  
   689 0000028D E81A00                  	CALL	RECSET
   690 00000290 26C41F                  	LES	BX,[ES:BX]
   691                                   assume es:nothing
   692 00000293 E8(0000)                	invoke	get_user_stack
   693 00000296 895C02                  	MOV	[SI + user_BX],BX
   694 00000299 8C4410                  	MOV	[SI + user_ES],ES
   695 0000029C C3                      	return
   696                                  EndProc D_server_GET_INTERRUPT_VECTOR
   697                                  
   698                                  	procedure   D_server_SET_INTERRUPT_VECTOR,NEAR
   698          ******************       warning: proc D_server_SET_INTERRUPT_VECTOR... [-w+user]
   699                                  ASSUME	DS:NOTHING,ES:NOTHING
   700                                  
   701                                  ; Inputs:
   702                                  ;	AL = interrupt number
   703                                  ;	DS:DX is desired new interrupt vector
   704                                  ; Function:
   705                                  ;	Set the interrupt vector
   706                                  ; Returns:
   707                                  ;	None
   708                                  
   709 0000029D E80A00                  	CALL	RECSET
   710 000002A0 FA                      	CLI				; Watch out!!!!! Folks sometimes use
   711 000002A1 268917                  	MOV	[ES:BX],DX		;   this for hardware ints (like timer).
   712 000002A4 268C5F02                	MOV	[ES:BX+2],DS
   713 000002A8 FB                      	STI
   714 000002A9 C3                      	return
   715                                  EndProc D_server_SET_INTERRUPT_VECTOR
   716                                  
   717                                  	%IF	ALTVECT
   718                                  invalid instruction fixme
   719                                  ; ldos: section ?
   720                                  
   721                                  section TABLE
   722                                  VECIN:
   723                                  ; INPUT VECTORS
   724                                  Public GSET001S,GSET001E
   725                                  GSET001S  label byte
   726                                  	DB	22H			; Terminate
   727                                  	DB	23H			; ^C
   728                                  	DB	24H			; Hard error
   729                                  	DB	28H			; Spooler
   730                                  LSTVEC	DB	?			; ALL OTHER
   731                                  
   732                                  VECOUT:
   733                                  ; GET MAPPED VECTOR
   734                                  	DB	int_terminate
   735                                  	DB	int_ctrl_c
   736                                  	DB	int_fatal_abort
   737                                  	DB	int_spooler
   738                                  LSTVEC2 DB	?			; Map to itself
   739                                  
   740                                  NUMVEC	equ	VECOUT-VECIN
   741                                  GSET001E label byte
   742                                  TABLE	ENDS
   743                                  	%ENDIF
   744                                  
   745                                  procedure   RECSET,NEAR
   745          ******************       warning: proc RECSET... [-w+user]
   746                                  
   747                                  	%IF	ALTVECT
   748                                  	context ES
   749                                  	MOV	[LSTVEC],AL		; Terminate list with real vector
   750                                  	MOV	[LSTVEC2],AL		; Terminate list with real vector
   751                                  	MOV	CX,NUMVEC		; Number of possible translations
   752                                  	MOV	DI,OFFSET VECIN wrt DOSGROUP    ; Point to vectors
   753                                  	REPNE	SCASB
   754                                  	MOV	AL,[ES:DI+NUMVEC-1]	; Get translation
   755                                  	%ENDIF
   756                                  
   757                                  entry get_esbx_ivt_from_al
   758 000002AA 31DB                    	XOR	BX,BX
   759 000002AC 8EC3                    	MOV	ES,BX
   760                                   assume es:IVT
   761 000002AE 88C3                    	MOV	BL,AL
   762 000002B0 D1E3                    	SHL	BX,1
   763 000002B2 D1E3                    	SHL	BX,1
   764 000002B4 C3                      	return
   765                                  EndProc recset
   766                                  
   767                                  BREAK <$Char_Oper - hack on paths, switches so that xenix can look like PCDOS>
   768                                  ;
   769                                  ; input:    AL = function:
   770                                  ;		    0 - read switch char
   771                                  ;		    1 - set switch char (char in DL)
   772                                  ;		    2 - read device availability
   773                                  ;			Always returns available
   774                                  ;		    3 - set device availability
   775                                  ;			No longer supported (NOP)
   776                                  ; output:   (get) DL - character/flag
   777                                  ;
   778                                  	procedure   D_CHAR_OPER,NEAR
   778          ******************       warning: proc D_CHAR_OPER... [-w+user]
   779                                  	ASSUME	DS:NOTHING,ES:NOTHING
   780 000002B5 161F                    	context DS
   781 000002B7 3C01                    	CMP	AL,1
   782 000002B9 720B                    	JB	CharGetSw
   783 000002BB 740F                    	JZ	CharSetSw
   784 000002BD 3C03                    	CMP	AL,3
   785 000002BF 7210                    	JB	CharGetDev
   786 000002C1 7416                    	JZ	CharSetDev
   787 000002C3 B0FF                    	MOV	AL,-1
   788 000002C5 C3                      	return
   789                                  CharGetSw:
   790 000002C6 8A16[0000]              	MOV	DL,[chSwitch]
   791 000002CA EB07                    	JMP	SHORT CharSet
   792                                  CharSetSw:
   793 000002CC 8816[0000]              	MOV	[chSwitch],DL
   794 000002D0 C3                      	return
   795                                  CharGetDev:
   796 000002D1 B2FF                    	MOV	DL,-1
   797                                  CharSet:
   798 000002D3 E8(0000)                	Invoke	Get_User_Stack
   799                                  	ASSUME	DS:NOTHING
   800                                  User_DX equ user_DX	; NASM port label
   801 000002D6 895406                  	MOV	[SI + User_DX],DX
   802                                  CharSetDev:
   803 000002D9 C3                      	return
   804                                  EndProc D_CHAR_OPER
   805                                  
   806                                  BREAK <$GetExtendedError - Return Extended DOS error code>
   807                                  ;
   808                                  ; input:    None
   809                                  ; output:   AX = Extended error code (0 means no extended error)
   810                                  ;	    BL = recommended action
   811                                  ;	    BH = class of error
   812                                  ;	    CH = locus of error
   813                                  ;	    ES:DI = may be pointer
   814                                  ;
   815                                  	procedure   D_GetExtendedError,NEAR
   815          ******************       warning: proc D_GetExtendedError... [-w+user]
   816                                  	ASSUME	DS:NOTHING,ES:NOTHING
   817 000002DA 161F                    	Context DS
   818 000002DC A1[0000]                	MOV	AX,[EXTERR]
   819 000002DF C43E[0000]              	LES	DI,[EXTERRPT]
   820 000002E3 8B1E[0000]              	MOV	BX,WORD PTR [EXTERR_ACTION]	; BL = Action, BH = Class
   821 000002E7 8A2E[0000]              	MOV	CH,[EXTERR_LOCUS]
   822 000002EB E8(0000)                	invoke	get_user_stack
   823                                  ASSUME	DS:NOTHING
   824 000002EE 897C0A                  	MOV	[SI + user_DI],DI
   825 000002F1 8C4410                  	MOV	[SI + user_ES],ES
   826 000002F4 895C02                  	MOV	[SI + user_BX],BX
   827 000002F7 894C04                  	MOV	[SI + user_CX],CX
   828 000002FA E9(0000)                	transfer SYS_RET_OK
   829                                  EndProc D_GetExtendedError
   830                                  
   831                                  BREAK <$Get_Global_CdPg  - Return Global Code Page>
   832                                  ;
   833                                  ; input:    None
   834                                  ; output:   AX = Global Code Page
   835                                  ;
   836                                  	procedure   Get_Global_CdPg,NEAR
   836          ******************       warning: proc Get_Global_CdPg... [-w+user]
   837                                  	ASSUME	DS:NOTHING,ES:NOTHING
   838 000002FD 56                      	PUSH	SI
   839 000002FE BE[0000]                	MOV	SI,OFFSET COUNTRY_CDPG wrt DOSGROUP
   840 00000301 368B446A                	MOV	AX,[ss:SI + ccDosCodePage]
   841 00000305 5E                      	POP	SI
   842 00000306 C3                      	return
   843                                  EndProc Get_Global_CdPg
   844                                  
   845                                  ;-------------------------------Start of DBCS 2/13/KK
   846                                  BREAK	<ECS_call - Extended Code System support function>
   847                                  
   848                                  ASSUME	DS:NOTHING, ES:NOTHING
   849                                  
   850                                  	procedure   D_ECS_call,NEAR
   850          ******************       warning: proc D_ECS_call... [-w+user]
   851                                  
   852                                  ; Inputs:
   853                                  ;	AL = 0	get lead byte table
   854                                  ;		on return DS:SI has the table location
   855                                  ;
   856                                  ;	AL = 1	set / reset interim console flag
   857                                  ;		DL = flag (00H or 01H)
   858                                  ;		no return
   859                                  ;
   860                                  ;	AL = 2	get interim console flag
   861                                  ;		on return DL = current flag value
   862                                  ;
   863                                  ;	AL = OTHER then error, and returns with:
   864                                  ;		AX = error_invalid_function
   865                                  ;
   866                                  ;  NOTE: THIS CALL DOES GUARANTEE THAT REGISTER OTHER THAN
   867                                  ;	 SS:SP WILL BE PRESERVED!
   868                                  
   869                                   %IF  DBCS									;AN000;
   870                                  										;AN000;
   871                                  	or	al, al			; AL = 0 (get table)?			;AN000;
   872                                  	je	get_lbt 							;AN000;
   873                                  	cmp	al, SetInterimMode	; AL = 1 (set / reset interim flag)?	;AN000;
   874                                  	je	set_interim							;AN000;
   875                                  	cmp	al, GetInterimMode	; AL = 2 (get interim flag)?		;AN000;
   876                                  	je	get_interim							;AN000;
   877                                  	error	error_invalid_function						;AN000;
   878                                  										;AN000;
   879                                  get_lbt:				; get lead byte table			;AN000;
   880                                  	push	ax								;AN000;
   881                                  	push	bx								;AN000;
   882                                  	push	ds								;AN000;
   883                                  	context DS								;AN000;
   884                                  	MOV	BX,offset COUNTRY_CDPG + ccSetDBCS wrt DOSGROUP			;AN000;
   885                                  	MOV	AX,[BX+1]		; set EV address to DS:SI		;AN000;
   886                                  	MOV	BX,[BX+3]							;AN000;
   887                                  	ADD	AX,2			; Skip Lemgth				;AN000;
   888                                  	invoke	get_user_stack							;AN000;
   889                                   assume ds:nothing								;AN000;
   890                                  	MOV	[SI + user_SI], AX						;AN000;
   891                                  	MOV	[SI + user_DS], BX						;AN000;
   892                                  	pop	ds								;AN000;
   893                                  	pop	bx								;AN000;
   894                                  	pop	ax								;AN000;
   895                                  	transfer SYS_RET_OK							;AN000;
   896                                  
   897                                  set_interim:				; Set interim console flag		;AN000;
   898                                  	push	dx								;AN000;
   899                                  	and	dl,01			; isolate bit 1 			;AN000;
   900                                  	mov	[InterCon], dl							;AN000;
   901                                  	push	ds								;AN000;
   902                                  CurrentPDB equ CURRENTPDB	; NASM port label
   903                                  	mov	ds, [CurrentPDB]						;AN000;
   904                                  	mov	byte ptr [PDB_InterCon], dl	; update value in pdb		;AN000;
   905                                  	pop	ds								;AN000;
   906                                  	pop	dx								;AN000;
   907                                  	transfer SYS_RET_OK							;AN000;
   908                                  
   909                                  get_interim:									;AN000;
   910                                  	push	dx								;AN000;
   911                                  	push	ds								;AN000;
   912                                  	mov	dl,[InterCon]							;AN000;
   913                                  	invoke	get_user_stack		; get interim console flag		;AN000;
   914                                   assume ds:nothing								;AN000;
   915                                  	mov	[SI + user_DX],DX 						;AN000;
   916                                  	pop	ds								;AN000;
   917                                  	pop	dx								;AN000;
   918                                  	transfer SYS_RET_OK							;AN000;
   919                                   %ELSE										;AN000;
   920 00000307 08C0                    	or	al, al			; AL = 0 (get table)?  ;AN000;
   921 00000309 750B                    	jnz	okok					       ;AN000;
   922                                  get_lbt:						       ;AN000;
   923 0000030B E8(0000)                	invoke	get_user_stack				       ;AN000;
   924                                   assume ds:nothing					       ;AN000;
   925                                  Dosgroup equ DOSGROUP	; NASM port equate
   926 0000030E C74408[0200]            	MOV	word [SI + user_SI], Offset DBCS_TAB+2 wrt Dosgroup       ;AN000;
   927 00000313 8C540E                  	MOV	[SI + user_DS], ss			       ;AN000;
   928                                  okok:							       ;AN000;
   929 00000316 EBE2                    	transfer SYS_RET_OK		;		       ;AN000;
   930                                  
   931                                   %ENDIF							       ;AN000;
   932                                  
   933                                  D_ECS_call endp						       ;AN000;
   934                                  
   935                                      END
