     1                                  ;	PAGE	,132			;
     2                                  ;	SCCSID = @(#)sysinit1.asm	1.7 85/10/24
     3                                  ;TITLE	BIOS SYSTEM INITIALIZATION
     4                                  %warning out: ...SYSINIT1
     4          ******************       warning: out: ...SYSINIT1 [-w+user]
     5                                  ;==============================================================================
     6                                  ;REVISION HISTORY:
     7                                  ;AN000 - New for DOS Version 4.00 - J.K.
     8                                  ;AC000 - Changed for DOS Version 4.00 - J.K.
     9                                  ;AN00x - PTM number for DOS Version 4.00 - J.K.
    10                                  ;==============================================================================
    11                                  ;AN001; p40 Boot from the system with no floppy diskette drives    6/26/87 J.K.
    12                                  ;AN002; d24  MultiTrack= command added. 			   6/29/87 J.K.
    13                                  ;AN003; d9  Double word mov for 386 machine			   7/15/87 J.K.
    14                                  ;AN004; p447 BUFFERS = 50 /E without EMS installed hangs	   8/25/87 J.K.
    15                                  ;AN005; d184 Set DEVMARK for MEM command			   8/25/87 J.K.
    16                                  ;AN006; p851 Installable files not recognized corretly. 	   9/08/87 J.K.
    17                                  ;AN007; p1299 Set the second entry of DEVMARK for MEM command	   9/25/87 J.K.
    18                                  ;AN008; p1361 New Extended Attribute				   9/28/87 J.K.
    19                                  ;AN009; p1326 Buffers = 50 /e hangs				   9/28/87 J.K.
    20                                  ;AN010; New EMS Interface
    21                                  ;AN011; New Message SKL file					  10/20/87 J.K.
    22                                  ;AN012; P2211 Setting EA=7 for ANSI.SYS hangs the system	  11/02/87 J.K.
    23                                  ;AN013; p2343 Set the name for SYSINIT_BASE for MEM command	  11/11/87 J.K.
    24                                  ;AN014; D358  New device driver INIT function package		  12/03/87 J.K.
    25                                  ;AN015; For Installed module with no parameter			  12/11/87 J.K.
    26                                  ;AN016; D285 Undo the Extended Attribute handling		  12/17/87 J.K.
    27                                  ;AN017; P2806 Show "Error in CONFIG.SYS ..." for INSTALL= command 12/17/87 J.K.
    28                                  ;AN018; P2914 Add Extended Memory Size in SYSVAR		  01/05/88 J.K.
    29                                  ;AN019; P3111 Take out the order dependency of the INSTALL=	  01/25/88 J.K.
    30                                  ;AN020; P3497 Performace fix for new buffer scheme		  02/15/88 J.K.
    31                                  ;AN021; D486 SHARE installation for big media			  02/23/88 J.K.
    32                                  ;AN022; D493 Undo D358 & do not show error message for device driv02/24/88 J.K.
    33                                  ;AN023; D474 Change BUFFERS= /E option to /X for expanded memory  03/16/88 J.K.
    34                                  ;AN024; D506 Take out the order dependency of the IFS=		  03/28/88 J.K.
    35                                  ;AN025; P4086 Memory allocation error when loading SHARE.EXE	  03/31/88 J.K.
    36                                  ;AN026; D517 New Balanced Real memory buffer set up scheme	  04/18/88 J.K.
    37                                  ;AN027; D528 Install XMAEM.SYS first before everything else	  04/29/88 J.K.
    38                                  ;AN028; P4669 SHARE /NC causes an error 			  05/03/88 J.K.
    39                                  ;AN029; P4759 Install EMS INT2fh, INT 67h handler		  05/12/88 J.K.
    40                                  ;AN030; P4934 P4759 INT 2Fh handler number be changed to 1Bh	  05/20/88 J.K.
    41                                  ;==============================================================================
    42                                  
    43                                  extern BUFFHEAD
    44                                  extern sysinit_get_ds_dosbiodata
    45                                  extern sysinit_get_es_dosbiodata
    46                                  
    47                                  TRUE	    EQU 0FFFFh
    48                                  FALSE	    EQU 0
    49                                  CR	    equ 13
    50                                  LF	    equ 10
    51                                  TAB	    equ  9
    52                                  
    53                                  IBMVER	   EQU	   TRUE
    54                                  IBM	   EQU	   IBMVER
    55                                  STACKSW    EQU	   TRUE 		;Include Switchable Hardware Stacks
    56                                  IBMJAPVER  EQU	   FALSE		;If TRUE set KANJI true also
    57                                  %iassign MSVER FALSE
    58                                  ALTVECT    EQU	   FALSE		;Switch to build ALTVECT version
    59                                  KANJI	   EQU	   FALSE
    60                                  MYCDS_SIZE equ	   88			;J.K. Size of Curdir_List. If it is not
    61                                  					;the same, then will generate compile error.
    62                                  
    63                                  ;
    64                                  	%IF	IBMJAPVER
    65                                  NOEXEC	EQU	TRUE
    66                                  	%ELSE
    67                                  NOEXEC	EQU	FALSE
    68                                  	%ENDIF
    69                                  
    70                                  ;DOSSIZE EQU	0A000H
    71                                  ;dossize equ	 0C000H 	;J.K. for the debugging version of IBMDOS.
    72                                  
    73                                  %include "entryseg.nas"
     1                              <1> 
     2                              <1> %ifndef ENTRYSEGNAS
     3                              <1> %define ENTRYSEGNAS 1
     4                              <1> 
     5                              <1> %include "lmacros3.mac"
     1                              <2> [list -]
     1          ******************  <2>  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
    74                                  %include "dcodeseg.nas"
     1                              <1> 
     2                              <1> %ifndef DCODESEGNAS
     3                              <1> %assign DCODESEGNAS 1
     4                              <1> 
     5                              <1> section DOSCODETABLE align=2 PUBLIC class=DOSCODE
     6                              <1> ; (no prior section) ; DOSCODETABLE		ENDS
     7                              <1> section DOSCODECODE align=1 PUBLIC class=DOSCODE
     8                              <1> ; (no prior section) ; DOSCODECODE		ENDS
     9                              <1> section DOSBIOCODE align=2 PUBLIC class=DOSCODE
    10                              <1> section BIOCODE	align=2 PUBLIC class=DOSCODE
    11                              <1> 
    12                              <1> %ifnidni DOSENTRYGROUP, DOSCODEGROUP
    13                              <1>  group DOSCODEGROUP DOSCODETABLE DOSCODECODE DOSBIOCODE BIOCODE
    14                              <1> %endif
    15                              <1> 
    16                              <1> %endif
    75                                  
    76                                  %ifn _RELOCATEDOSCODE
    77                                   [list -]
    78                                  %endif
    79                                  %if _RELOCATEDOSCODE
    80                                  section AFTERDOSCODE class=AFTERDOSCODE align=16
    81                                  	global afterdoscodelabel
    82                                  afterdoscodelabel:
    83                                  %endif
    84                                  %ifn _RELOCATEDOSCODE
    85                                   [list +]
    86                                  %endif
    87                                  
    88                                  	%include "ddataseg.nas"
     1                              <1> 
     2                              <1> %include "lmacros3.mac"
     1                              <2> [list -]
     3                              <1> 
     4                              <1> addsection DOSSTART, align=16 PUBLIC class=DOSSTART
     5                              <1> ; (no prior section) ; DOSSTART		ENDS
     6                              <1> 
     7                              <1> addsection DOSSTARTJUMP, align=1 PUBLIC class=START
     8                              <1> ; (no prior section) ; DOSSTARTJUMP		ENDS
     9                              <1> 
    10                              <1> addsection CONSTANTS, align=2 PUBLIC class=CONST
    11                              <1> ; (no prior section) ; CONSTANTS	ENDS
    12                              <1> 
    13                              <1> addsection DATA, align=2 PUBLIC class=DATA
    14                              <1> ; (no prior section) ; DATA		ENDS
    15                              <1> 
    16                              <1> addsection TABLE, align=2 PUBLIC class=TABLE
    17                              <1> ; (no prior section) ; TABLE		ENDS
    18                              <1> 
    19                              <1> addsection DOSDATATABLE, align=2 PUBLIC class=DOSDATACODE
    20                              <1> ; (no prior section) ; DOSDATATABLE		ENDS
    21                              <1> 
    22                              <1> addsection DOSDATACODE, align=1 PUBLIC class=DOSDATACODE
    23                              <1> ; (no prior section) ; DOSDATACODE		ENDS
    24                              <1> 
    25                              <1> addsection DOSBIODATA, align=2 PUBLIC class=DOSBIODATA
    26                              <1> 
    27                              <1> addsection LAST, align=16 PUBLIC class=LAST
    28                              <1> ; (no prior section) ; LAST		ENDS
    29                              <1> 
    30                              <1> group DOSGROUP DOSSTART DOSSTARTJUMP CONSTANTS DATA TABLE DOSDATATABLE DOSDATACODE DOSBIODATA LAST
    89                                  [list -]
    89          ******************       warning: out: ... for DOS Version 4.00 ... [-w+user]
    89          ******************       warning: out: BPB.INC... [-w+user]
    89          ******************       warning: out: ... CLONE version build switch on ... [-w+user]
    89          ******************       warning: out: DEVSYM.INC... [-w+user]
    89          ******************       warning: out: IOCTL.INC... [-w+user]
    89          ******************       warning: out: BPB.INC... [-w+user]
    89          ******************       warning: out: BIOSTRUC.INC... [-w+user]
    89          ******************       warning: out: ... CLONE version build switch on ... [-w+user]
    89          ******************       warning: out: MSBDS.INC... [-w+user]
   105                                  [list -]
    13                              <1> [list -]
   107                                  	%include "scanptab.mac"
     1                              <1> 
     2                              <1> %if 0
     3                              <1> 
     4                              <1> scanptab - Scan partition table (macros)
     5                              <1>  2019, 2025 by E. C. Masloch
     6                              <1> 
     7                              <1> Usage of the works is permitted provided that this
     8                              <1> instrument is retained with the works, so that any entity
     9                              <1> that uses the works is notified of this instrument.
    10                              <1> 
    11                              <1> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    12                              <1> 
    13                              <1> %endif
    14                              <1> 
    15                              <1> mode_all_ext5			equ 00b
    16                              <1> mode_ignore_ext5		equ 01b
    17                              <1> mode_first_ext5			equ 10b
    18                              <1> mode_first_type_ext5		equ 11b
    19                              <1> 
    20                              <1> mode_all_ext15			equ 00b << 2
    21                              <1> mode_ignore_ext15		equ 01b << 2
    22                              <1> mode_first_ext15		equ 10b << 2
    23                              <1> mode_first_type_ext15		equ 11b << 2
    24                              <1> 
    25                              <1> mode_all_ext85			equ 00b << 4
    26                              <1> mode_ignore_ext85		equ 01b << 4
    27                              <1> mode_first_ext85		equ 10b << 4
    28                              <1> mode_first_type_ext85		equ 11b << 4
    29                              <1> 
    30                              <1> mode_ignore_subsequent_nested	equ            1_00_00_00b
    31                              <1> mode_ignore_subsequent_logical	equ           10_00_00_00b
    32                              <1> mode_ignore_subsequent_primary	equ          100_00_00_00b
    33                              <1> mode_traditional_order_logical	equ         1000_00_00_00b
    34                              <1> mode_active_priority		equ       1_0000_00_00_00b
    35                              <1> mode_subsequent_primary_after	equ      10_0000_00_00_00b
    36                              <1> mode_disable_fat32		equ 00_1000_0000_00_00_00b
    37                              <1> mode_disable_lba		equ 01_0000_0000_00_00_00b
    38                              <1> mode_dlasort_zero		equ 10_0000_0000_00_00_00b
   108                                  	%include "verbose.mac"
     1                              <1> 
     2                              <1> ; Public Domain, 2025 by E. C. Masloch
     3                              <1> 
     4                              <1> verbose_intro	equ 1
     5                              <1> verbose_xms	equ 2
     6                              <1> verbose_cds	equ 4
   109                                  [list +]
   110                                  
   111                                  ;AN000 J.K. If MYCDS_SIZE <> CURDIRLEN, then force a compilatiaon error.
   112                                  	%if	MYCDS_SIZE != curdirLen
   113                                  	   %error  !!! SYSINIT1 COMPILATION FAILED. DIFFERENT CDS SIZE !!!
   114                                  	%endif
   115                                  
   116                                  	%IFN IBMJAPVER
   117                                  	EXTRN	RE_INIT:FAR
   118                                  	%ENDIF
   119                                  
   120                                  ;---------------------------------------
   121                                  ;Equates for Main stack and stack Initialization program
   122                                  	%IF	STACKSW
   123                                  
   124                                  EntrySize		equ	8
   125                                  
   126                                  MinCount		equ	8
   127                                  DefaultCount		equ	9
   128                                  MaxCount		equ	64
   129                                  
   130                                  MinSize 		equ	32
   131                                  DefaultSize		equ	128
   132                                  MaxSize 		equ	512
   133                                  
   134                                  labelsize AllocByte, byte, es:bp+0
   135                                  labelsize IntLevel, byte, es:bp+1
   136                                  labelsize SavedSP, word, es:bp+2
   137                                  labelsize SavedSS, word, es:bp+4
   138                                  labelsize NewSP, word, es:bp+6
   139                                  Free			equ	0
   140                                  allocated		equ	1
   141                                  overflowed		equ	2
   142                                  clobbered		equ	3
   143                                  
   144                                  
   145                                  ;External variables in IBMBIO for INT19h handling rouitne. J.K. 10/23/86
   146                                  	EXTRN	Int19sem:byte
   147                                  
   148                                  %macro extrn_irq_handlers 1-*
   149                                   %rep %0
   150                                  		EXTRN Int19OLD%1:dword
   151                                    %rotate 1
   152                                   %endrep
   153                                  %endmacro
   154                                  
   155                                  extrn_irq_handlers 02,08,09,0A,0B,0C,0D,0E,70,72,73,74,76,77
   149                              <1>  %rep %0
   150                              <1>  EXTRN Int19OLD%1:dword
   151                              <1>  %rotate 1
   152                              <1>  %endrep
   150                              <2>  EXTRN Int19OLD%1:dword
   151                              <2>  %rotate 1
   150                              <2>  EXTRN Int19OLD%1:dword
   151                              <2>  %rotate 1
   150                              <2>  EXTRN Int19OLD%1:dword
   151                              <2>  %rotate 1
   150                              <2>  EXTRN Int19OLD%1:dword
   151                              <2>  %rotate 1
   150                              <2>  EXTRN Int19OLD%1:dword
   151                              <2>  %rotate 1
   150                              <2>  EXTRN Int19OLD%1:dword
   151                              <2>  %rotate 1
   150                              <2>  EXTRN Int19OLD%1:dword
   151                              <2>  %rotate 1
   150                              <2>  EXTRN Int19OLD%1:dword
   151                              <2>  %rotate 1
   150                              <2>  EXTRN Int19OLD%1:dword
   151                              <2>  %rotate 1
   150                              <2>  EXTRN Int19OLD%1:dword
   151                              <2>  %rotate 1
   150                              <2>  EXTRN Int19OLD%1:dword
   151                              <2>  %rotate 1
   150                              <2>  EXTRN Int19OLD%1:dword
   151                              <2>  %rotate 1
   150                              <2>  EXTRN Int19OLD%1:dword
   151                              <2>  %rotate 1
   150                              <2>  EXTRN Int19OLD%1:dword
   151                              <2>  %rotate 1
   156                                  
   157                                  ; (no prior section) ; CODE ends
   158                                  	%ENDIF
   159                                  ;---------------------------------------
   160                                  ;J.K. 6/29/87 External variable defined in IBMBIO module for Multi-track
   161                                  MULTRK_ON	EQU	10000000B	;User spcified Mutitrack=on, or System turns
   162                                  					; it on after handling CONFIG.SYS file as a
   163                                  					; default value, if MulTrk_flag = MULTRK_OFF1.
   164                                  MULTRK_OFF1	EQU	00000000B	;initial value. No "Multitrack=" command entered.
   165                                  MULTRK_OFF2	EQU	00000001B	;User specified Multitrack=off.
   166                                  
   167                                  usesection DOSENTRY
   168                                  	EXTRN	MulTrk_flag:word	;AN002;
   169                                  	extrn CONHEADER:byte
   170                                  ; (no prior section) ; CODE ends
   171                                  ;J.K. 6/29/87 End of Multi-track definition.
   172                                  
   173                                  usesection DOSSTART
   174                                  ; (no prior section) ; DOSSTART		ENDS
   175                                  
   176                                  addsection AFTERDOSDATA, align=16 class=AFTERDOSDATA
   177                                  ; (no prior section) ; AFTERDOSDATA	ENDS
   178                                  	global afterdosdatalabel
   179                                  afterdosdatalabel:
   180                                  
   181                                  addsection SYSINITSEG, PUBLIC class=INIT
   182                                  addsection SYSINITTRAIL, PUBLIC class=INIT align=2
   183                                  addsection SYSINITLAST, PUBLIC class=INIT align=2
   184                                  
   185                                  group SYSINITGROUP SYSINITSEG SYSINITTRAIL SYSINITLAST
   186                                  
   187                                  usesection SYSINITSEG
   188                                  
   189                                  	EXTRN	BADCOM:BYTE
   190                                  	EXTRN	SYSSIZE:BYTE
   191                                  	EXTRN	CONDEV:BYTE,AUXDEV:BYTE,PRNDEV:BYTE,COMMND:BYTE
   192                                  	extrn	DeviceParameters:byte
   193                                  	extrn	DevMark_Addr:word
   194                                  	extrn	SetDevMarkFlag:byte
   195                                  	extrn	PathString:byte 			;AN021;
   196                                  	extrn	LShare:byte				;AN021;
   197                                  	extrn	ShareWarnMsg:byte			;AN021;
   198                                  
   199                                  	EXTRN	MEM_ERR:NEAR
   200                                  	EXTRN	DOCONF:NEAR
   201                                  	extrn	Multi_Pass:NEAR 			;AN024;
   202                                  	extrn	BadLoad:near
   203                                  	extrn	Error_Line:near
   204                                  	extern devicehighflag, shellhighflag
   205                                  
   206                                  	PUBLIC	behind_dosentry_segment
   207                                  	PUBLIC	DEVICE_LIST
   208                                  SYSI_COUNTRY equ SYSI_Country	; NASM port label
   209                                  	PUBLIC	SYSI_COUNTRY
   210                                  	PUBLIC	MEMORY_SIZE
   211                                  	PUBLIC	DEFAULT_DRIVE
   212                                  	PUBLIC	BUFFERS
   213                                  	PUBLIC	FILES
   214                                  	PUBLIC	NUM_CDS
   215                                  	PUBLIC	SYSINIT
   216                                  CNTRYFILEHANDLE equ CntryFilehandle	; NASM port label
   217                                  	PUBLIC	CNTRYFILEHANDLE
   218                                  	PUBLIC	COMMAND_LINE
   219                                  	public	Big_Media_Flag				;AN021;Set by IBMINIT
   220                                  
   221                                  	%IF	STACKSW
   222                                   ;Internal Stack Information
   223                                  	PUBLIC	STACK_COUNT
   224                                  	PUBLIC	STACK_SIZE
   225                                  	PUBLIC	STACK_ADDR
   226                                  	%ENDIF
   227                                  
   228                                  dosinfo equ DOSINFO	; NASM port label
   229                                  entry_point equ ENTRY_POINT	; NASM port label
   230                                  	PUBLIC dosinfo,entry_point
   231                                  fcbs equ FCBS	; NASM port label
   232                                  keep equ Keep	; NASM port label
   233                                  	PUBLIC fcbs,keep
   234                                  	PUBLIC config_block
   235                                  zero equ ZERO	; NASM port label
   236                                  sepchr equ SepChr	; NASM port label
   237                                  	PUBLIC zero,sepchr,STALL
   238                                  count equ COUNT	; NASM port equate
   239                                  chrptr equ CHRPTR	; NASM port label
   240                                  org_count equ Org_Count	; NASM port label
   241                                  	PUBLIC count,chrptr,org_count
   242                                  bufptr equ BUFPTR	; NASM port label
   243                                  prmblk equ PRMBLK	; NASM port label
   244                                  	PUBLIC bufptr,prmblk
   245                                  	PUBLIC PACKET,UNITCOUNT
   246                                  drivenumber equ DriveNumber	; NASM port label
   247                                  	PUBLIC BREAK_ADDR,BPB_ADDR,drivenumber
   248                                  	public Config_Size
   249                                  	public Install_Flag
   250                                  	public COM_Level
   251                                  	public CMMT
   252                                  	public CMMT1
   253                                  	public CMMT2
   254                                  	public Cmd_Indicator
   255                                  	public LineCount
   256                                  	public ShowCount
   257                                  	public Buffer_LineNum
   258                                  	public DoNotShowNum
   259                                  	public IFS_Flag
   260                                  	public IFS_RH
   261                                  	public H_Buffers
   262                                  	public Buffer_Slash_X			;AN023;
   263                                  	public ConfigMsgFlag			;AN014;
   264                                  	public Do_Install_Exec			;AN019;
   265                                  	public Multi_Pass_Id			;AN024;
   266                                  
   267                                  
   268                                  ;
   269                                  SYSINIT$:
   270                                  	%IF	STACKSW
   271                                  ;.SALL
   272                                  ;=== Push trace listing source: msstack.nas
   273                                  	  %include "msstack.nas"		;Main stack program and data definitions ; NASM included file
     1                              <1> ;	MSStack.inc
     2                              <1> ;
     3                              <1> ;	Interrupt level 2, 3, 4, 5, 6, 7,(10, 11, 12, 14, 15 - AT level)
     4                              <1> ;	should follow the standard Interrupt Sharing Scheme which has
     5                              <1> ;	a standard header structure.
     6                              <1> ;	Fyi, the following shows the relations between
     7                              <1> ;	the interrupt vector and interrupt level.
     8                              <1> ; VEC(Hex)    2  8  9  A  B  C	D  E  70  72  73  74  76  77
     9                              <1> ; LVL(Deci)   9  0  1  2  3  4	5  6   8  10  11  12  14  15
    10                              <1> ;	MSSTACK module modifies the following interrupt vectors
    11                              <1> ;	to meet the standard Interrupt Sharing standard;
    12                              <1> ;	  A, B, C, D, E, 72, 73, 74, 76, 77.
    13                              <1> ;	Also, for interrupt level 7 and 15, the FirstFlag in a standard header
    14                              <1> ;	should be initialized to indicat whether this interrupt handler is
    15                              <1> ;	the first (= 80h) or not.  The FirstFlag entry of INT77h's
    16                              <1> ;	program header is initialized in STKINIT.INC module.
    17                              <1> ;	FirstFlag is only meaningful for interrupt level 7 and 15.
    18                              <1> ;
    19                              <1> 
    20                              <1> ;  User specifies the number of stack elements - default = 9
    21                              <1> ;						 minimum = 8
    22                              <1> ;						 maximum = 64
    23                              <1> ;
    24                              <1> ;  Intercepts Asynchronous Hardware Interrupts only
    25                              <1> ;
    26                              <1> ;  Picks a stack from pool of stacks and switches to it
    27                              <1> ;
    28                              <1> ;  Calls the previously saved interrupt vector after pushing flags
    29                              <1> ;
    30                              <1> ;  On return, returns the stack to the stack pool
    31                              <1> ;
    32                              <1> 
    33                              <1> 
    34                              <1> ; This is a modification of STACKS:
    35                              <1> ; 1. To fix a bug which was causing the program to take up too much space.
    36                              <1> ; 2. To dispense stack space from hi-mem first rather than low-mem first.
    37                              <1> ;    . Clobbers the stack that got too big instead of innocent stack
    38                              <1> ;    . Allows system to work if the only stack that got too big was the most
    39                              <1> ;      deeply nested one
    40                              <1> ; 3. Disables NMI interrupts while setting the NMI vector.
    41                              <1> ; 4. Does not intercept any interupts on a PCjr.
    42                              <1> ; 5. Double checks that a nested interrupt didn't get the same stack.
    43                              <1> ; 6. Intercepts Ints 70, 72-77 for PC-ATs and other future products
    44                              <1> 
    45                              <1> ; === alternative section STACKSCODE
    46                              <1> 
    47                              <1>  assume cs:STACKSCODE
    48                              <1> 
    49                              <1> ;The following variables are for MSSTACK.inc
    50                              <1> 		EVEN
    51 00000000 0000                <1> 		dw	0	; SPARE FIELD BUT LEAVE THESE IN ORDER
    52 00000002 0000                <1> StackCount	dw	0
    53 00000004 0000                <1> StackAt 	dw	0
    54 00000006 0000                <1> StackSize	dw	0
    55 00000008 0000                <1> Stacks		dw	0
    56 0000000A 0000                <1> 		dw	0
    57                              <1> 
    58 0000000C [0800]              <1> FirstEntry	dw	Stacks
    59 0000000E [4800]              <1> LastEntry	dw	Stacks+(DefaultCount*EntrySize)-EntrySize
    60 00000010 [4800]              <1> NextEntry	dw	Stacks+(DefaultCount*EntrySize)-EntrySize
    61                              <1> 
    62                              <1> ;End of variables defined for MSSTACK.
    63                              <1> 
    64                              <1> ; === no alternative section
    65                              <1> 
    66                              <1> ;*******************************************************************
    67                              <1> ;Macro Interrupt handler for the ordinary interrupt vectors and
    68                              <1> ;the shared interrupt vectors.
    69                              <1> ;*****************************
    70                              <1> %imacro Stack_Main 1-*
    71                              <1>  %rep %0
    72                              <1> 	ASSUME	DS:NOTHING
    73                              <1> 	ASSUME	ES:NOTHING
    74                              <1> 	ASSUME	SS:NOTHING
    75                              <1> PUBLIC	Int%1
    76                              <1> PUBLIC	Old%1
    77                              <1> ;-----------------------------
    78                              <1> 	%ifn	IntSharingFlag		;if not IntSharingFlag
    79                              <1> ;-----------------------------
    80                              <1> 	Old%1	DD	0
    81                              <1> Int%1	PROC	FAR
    82                              <1> ;-----------------------------
    83                              <1> 	%else				;for shared interrupt. A Header exists.
    84                              <1> 
    85                              <1> PUBLIC	FirstFlag%1
    86                              <1> Int%1	PROC	FAR
    87                              <1> 	jmp	short	  Entry_Int%1_Stk
    88                              <1> 	Old%1	dd	  0		;Forward pointer
    89                              <1> 		dw	  424Bh		;compatible signature for Int. Sharing
    90                              <1> 	FirstFlag%1 db   0		;the firstly hooked.
    91                              <1> 	jmp	short	Intret_%1	;Reset routine. We don't care this.
    92                              <1> 		db	  7 dup (0)	;Reserved for future.
    93                              <1> Entry_Int%1_Stk:
    94                              <1> ;-----------------------------
    95                              <1> 	%endif
    96                              <1> ;-----------------------------
    97                              <1> INT%1 equ Int%1
    98                              <1> OLD%1 equ Old%1
    99                              <1> 
   100                              <1> ;
   101                              <1> ; Keyboard interrupt must have a three byte jump, a NOP and a zero byte
   102                              <1> ; as its first instruction for compatibility reasons
   103                              <1> 	%ifidni	%1, 09
   104                              <1> 	jmp	short Keyboard_lbl
   105                              <1> 	nop
   106                              <1> 	nop
   107                              <1> 	db	0
   108                              <1> Keyboard_lbl	label	near
   109                              <1> 	%endif
   110                              <1> 
   111                              <1> ; This patches INTERRUPT 75h to be "unhooked".  We do this Wierdness,
   112                              <1> ; rather than never hooking INT 75h, to maintain maximum compat. with IBMs
   113                              <1> ; post production patch.
   114                              <1> 	push	ax
   115                              <1> 
   116                              <1> 	%ifidni	%1, 02
   117                              <1> 
   118                              <1> ; *********************************************************************
   119                              <1> ;
   120                              <1> ; This is special support for the PC Convertible / NMI handler
   121                              <1> ;
   122                              <1> ;	On the PC Convertible, there is a situation where an NMI can be 
   123                              <1> ;	caused by using the "OUT" instructions to certain ports.  When this
   124                              <1> ;	occurs, the PC Convertible hardware *GUARANTEES* that **NOTHING** 
   125                              <1> ;	can stop the NMI or interfere with getting to the NMI handler.  This
   126                              <1> ;	includes other type of interrupts (hardware and software), and
   127                              <1> ;	also includes other type of NMI's.  When any NMI has occured,
   128                              <1> ;	no other interrtupt (hardware, software or NMI) can occur until
   129                              <1> ;	the software takes specific steps to allow further interrupting.
   130                              <1> ;
   131                              <1> ;	For PC Convertible, the situation where the NMI is generated by the
   132                              <1> ;	"OUT" to a control port requires "fixing-up" and re-attempting.  In
   133                              <1> ;	otherwords, it is actually a "restartable exception".  In this
   134                              <1> ;	case, the software handler must be able to get to the stack in
   135                              <1> ;	order to figure out what instruction caused the problem, where
   136                              <1> ;	it was "OUT"ing to and what value it was "OUT"ing.  Therefore,
   137                              <1> ;	we will not switch stacks in this situation.  This situation is
   138                              <1> ;	detected by interrogating port 62h, and checking for a bit value
   139                              <1> ;	of 80h.  If set, *****DO NOT SWITCH STACKS*****.
   140                              <1> ;
   141                              <1> ; *********************************************************************
   142                              <1> 
   143                              <1> 	push	es
   144                              <1> 	mov	ax,0f000h
   145                              <1> 	mov	es,ax
   146                              <1>  assume es:nothing
   147                              <1> mdl_convert equ MDL_CONVERT	; NASM port equate
   148                              <1> 	cmp	byte ptr [es:0fffeh],mdl_convert	;check if convertible
   149                              <1> 	pop	es
   150                              <1>  assume es:nothing
   151                              <1> 	jne	Normal%1
   152                              <1> 
   153                              <1> 	in	al,62h
   154                              <1> 	test	al,80h
   155                              <1> 	jz	Normal%1
   156                              <1> 
   157                              <1> Special%1:
   158                              <1> 	pop	ax
   159                              <1> 	jmp	far [cs:Old%1]
   160                              <1> 
   161                              <1> Normal%1:
   162                              <1> 
   163                              <1> ; *********************************************************************
   164                              <1> 
   165                              <1> 	%endif
   166                              <1> 
   167                              <1> 	push	bp
   168                              <1> 	push	es
   169                              <1> STACKS equ Stacks	; NASM port label
   170                              <1> 	mov	es, [cs:STACKS+2]	; Get segment of stacks
   171                              <1>  assume es:STACKSCODE
   172                              <1> 
   173                              <1> 	mov	bp,[cs:NextEntry]		; get most likely candidate
   174                              <1> Allocated equ allocated	; NASM port equate
   175                              <1> 	mov	al,Allocated
   176                              <1> 	xchg	[AllocByte],al		; grab the entry
   177                              <1> 	cmp	al,Free 		; still avail?
   178                              <1> 	jne	NotFree%1
   179                              <1> 
   180                              <1> 	sub	word [cs:NextEntry],EntrySize	; set for next interrupt
   181                              <1> 
   182                              <1> Found%1:
   183                              <1> 	mov	[SavedSP],sp		; save sp value
   184                              <1> 	mov	[SavedSS],ss		; save ss also
   185                              <1> ;	mov	IntLevel,%1h		; save the int level
   186                              <1> 
   187                              <1> 	mov	ax,bp			; temp save of table offset
   188                              <1> 
   189                              <1> 	mov	bp,[NewSP]		; get new SP value
   190                              <1> 	cmp	[es:bp],ax		; check for offset into table
   191                              <1> 	jne	FoundBad%1
   192                              <1> 
   193                              <1> 	mov	ax,es			; point ss,sp to the new stack
   194                              <1> 	mov	ss,ax
   195                              <1> 	mov	sp,bp
   196                              <1>  assume ss:STACKSCODE
   197                              <1> 
   198                              <1> 	pushf				; go execute the real interrupt handler
   199                              <1> 	call	far [cs:Old%1]		;  which will iret back to here
   200                              <1> 
   201                              <1> 	mov	bp,sp			; retrieve the table offset for us
   202                              <1> 	mov	bp,[es:bp]		   ;  but leave it on the stack
   203                              <1> 	mov	ss,[SavedSS]	     ; get old stack back
   204                              <1> 	mov	sp,[SavedSP]
   205                              <1>  assume ss:nothing
   206                              <1> 
   207                              <1> ;	cmp	AllocByte,Allocated	; If an error occured,
   208                              <1> ;	jne	NewError%1		;  do not free us
   209                              <1> 
   210                              <1> 	mov	byte [AllocByte],Free		; free the entry
   211                              <1> 	mov	[cs:NextEntry],bp		; setup to use next time
   212                              <1> 
   213                              <1> NewError%1:
   214                              <1> 	pop	es
   215                              <1>  assume es:nothing
   216                              <1> 	pop	bp			; saved on entry
   217                              <1> 	pop	ax			; saved on entry
   218                              <1> 
   219                              <1> INTRET_%1:								  ;3.30
   220                              <1> 	iret				; done with this interrupt
   221                              <1> Intret_%1 equ INTRET_%1
   222                              <1> 
   223                              <1> NotFree%1:
   224                              <1> 	cmp	al,Allocated		; error flag
   225                              <1> 	je	FindNext%1		;  no, continue
   226                              <1> 	xchg	[AllocByte],al		;  yes, restore error value
   227                              <1> 
   228                              <1> FindNext%1:
   229                              <1> LongPath equ longpath	; NASM port label
   230                              <1> 	call	LongPath
   231                              <1> 	jmp	Found%1
   232                              <1> 
   233                              <1> FoundBad%1:
   234                              <1> 	cmp	bp,[cs:FirstEntry]
   235                              <1> 	jc	FindNext%1
   236                              <1> 	mov	bp,ax			; flag this entry
   237                              <1> Clobbered equ clobbered	; NASM port equate
   238                              <1> 	mov	byte [AllocByte],Clobbered
   239                              <1> ;	add	bp,EntrySize		;  and previous entry
   240                              <1> ;	mov	AllocByte,Overflowed
   241                              <1> ;	sub	bp,EntrySize
   242                              <1> 	jmp	FindNext%1		; keep looking
   243                              <1> 
   244                              <1> int%1	endp
   245                              <1>   %rotate 1
   246                              <1>  %endrep
   247                              <1> 	%endmacro
   248                              <1> 
   249                              <1> ;*****************************						  ;3.30
   250                              <1> ;End of Macro definition						  ;3.30
   251                              <1> ;********************************************************************	  ;3.30
   252                              <1> ; THESE ARE THE INDIVIDUAL INTERRUPT HANDLERS				  ;3.30
   253                              <1> 
   254                              <1> %iassign IntSharingFlag 0
   255                              <1> 	Stack_Main 02,08,09,70
    71                              <2>  %rep %0
    72                              <2>  ASSUME DS:NOTHING
    73                              <2>  ASSUME ES:NOTHING
    74                              <2>  ASSUME SS:NOTHING
    75                              <2> PUBLIC Int%1
    76                              <2> PUBLIC Old%1
    77                              <2> 
    78                              <2>  %ifn IntSharingFlag
    79                              <2> 
    80                              <2>  Old%1 DD 0
    81                              <2> Int%1 PROC FAR
    82                              <2> 
    83                              <2>  %else
    84                              <2> 
    85                              <2> PUBLIC FirstFlag%1
    86                              <2> Int%1 PROC FAR
    87                              <2>  jmp short Entry_Int%1_Stk
    88                              <2>  Old%1 dd 0
    89                              <2>  dw 424Bh
    90                              <2>  FirstFlag%1 db 0
    91                              <2>  jmp short Intret_%1
    92                              <2>  db 7 dup (0)
    93                              <2> Entry_Int%1_Stk:
    94                              <2> 
    95                              <2>  %endif
    96                              <2> 
    97                              <2> INT%1 equ Int%1
    98                              <2> OLD%1 equ Old%1
    99                              <2> 
   100                              <2> 
   101                              <2> 
   102                              <2> 
   103                              <2>  %ifidni %1, 09
   104                              <2>  jmp short Keyboard_lbl
   105                              <2>  nop
   106                              <2>  nop
   107                              <2>  db 0
   108                              <2> Keyboard_lbl label near
   109                              <2>  %endif
   110                              <2> 
   111                              <2> 
   112                              <2> 
   113                              <2> 
   114                              <2>  push ax
   115                              <2> 
   116                              <2>  %ifidni %1, 02
   117                              <2> 
   118                              <2> 
   119                              <2> 
   120                              <2> 
   121                              <2> 
   122                              <2> 
   123                              <2> 
   124                              <2> 
   125                              <2> 
   126                              <2> 
   127                              <2> 
   128                              <2> 
   129                              <2> 
   130                              <2> 
   131                              <2> 
   132                              <2> 
   133                              <2> 
   134                              <2> 
   135                              <2> 
   136                              <2> 
   137                              <2> 
   138                              <2> 
   139                              <2> 
   140                              <2> 
   141                              <2> 
   142                              <2> 
   143                              <2>  push es
   144                              <2>  mov ax,0f000h
   145                              <2>  mov es,ax
   146                              <2>  assume es:nothing
   147                              <2> mdl_convert equ MDL_CONVERT
   148                              <2>  cmp byte ptr [es:0fffeh],mdl_convert
   149                              <2>  pop es
   150                              <2>  assume es:nothing
   151                              <2>  jne Normal%1
   152                              <2> 
   153                              <2>  in al,62h
   154                              <2>  test al,80h
   155                              <2>  jz Normal%1
   156                              <2> 
   157                              <2> Special%1:
   158                              <2>  pop ax
   159                              <2>  jmp far [cs:Old%1]
   160                              <2> 
   161                              <2> Normal%1:
   162                              <2> 
   163                              <2> 
   164                              <2> 
   165                              <2>  %endif
   166                              <2> 
   167                              <2>  push bp
   168                              <2>  push es
   169                              <2> STACKS equ Stacks
   170                              <2>  mov es, [cs:STACKS+2]
   171                              <2>  assume es:STACKSCODE
   172                              <2> 
   173                              <2>  mov bp,[cs:NextEntry]
   174                              <2> Allocated equ allocated
   175                              <2>  mov al,Allocated
   176                              <2>  xchg [AllocByte],al
   177                              <2>  cmp al,Free
   178                              <2>  jne NotFree%1
   179                              <2> 
   180                              <2>  sub word [cs:NextEntry],EntrySize
   181                              <2> 
   182                              <2> Found%1:
   183                              <2>  mov [SavedSP],sp
   184                              <2>  mov [SavedSS],ss
   185                              <2> 
   186                              <2> 
   187                              <2>  mov ax,bp
   188                              <2> 
   189                              <2>  mov bp,[NewSP]
   190                              <2>  cmp [es:bp],ax
   191                              <2>  jne FoundBad%1
   192                              <2> 
   193                              <2>  mov ax,es
   194                              <2>  mov ss,ax
   195                              <2>  mov sp,bp
   196                              <2>  assume ss:STACKSCODE
   197                              <2> 
   198                              <2>  pushf
   199                              <2>  call far [cs:Old%1]
   200                              <2> 
   201                              <2>  mov bp,sp
   202                              <2>  mov bp,[es:bp]
   203                              <2>  mov ss,[SavedSS]
   204                              <2>  mov sp,[SavedSP]
   205                              <2>  assume ss:nothing
   206                              <2> 
   207                              <2> 
   208                              <2> 
   209                              <2> 
   210                              <2>  mov byte [AllocByte],Free
   211                              <2>  mov [cs:NextEntry],bp
   212                              <2> 
   213                              <2> NewError%1:
   214                              <2>  pop es
   215                              <2>  assume es:nothing
   216                              <2>  pop bp
   217                              <2>  pop ax
   218                              <2> 
   219                              <2> INTRET_%1:
   220                              <2>  iret
   221                              <2> Intret_%1 equ INTRET_%1
   222                              <2> 
   223                              <2> NotFree%1:
   224                              <2>  cmp al,Allocated
   225                              <2>  je FindNext%1
   226                              <2>  xchg [AllocByte],al
   227                              <2> 
   228                              <2> FindNext%1:
   229                              <2> LongPath equ longpath
   230                              <2>  call LongPath
   231                              <2>  jmp Found%1
   232                              <2> 
   233                              <2> FoundBad%1:
   234                              <2>  cmp bp,[cs:FirstEntry]
   235                              <2>  jc FindNext%1
   236                              <2>  mov bp,ax
   237                              <2> Clobbered equ clobbered
   238                              <2>  mov byte [AllocByte],Clobbered
   239                              <2> 
   240                              <2> 
   241                              <2> 
   242                              <2>  jmp FindNext%1
   243                              <2> 
   244                              <2> int%1 endp
   245                              <2>  %rotate 1
   246                              <2>  %endrep
    72                              <3>  ASSUME DS:NOTHING
    73                              <3>  ASSUME ES:NOTHING
    74                              <3>  ASSUME SS:NOTHING
    75                              <3> PUBLIC Int%1
    76                              <3> PUBLIC Old%1
    77                              <3> 
    78                              <3>  %ifn IntSharingFlag
    79                              <3> 
    80 00000012 00000000            <3>  Old%1 DD 0
    81                              <3> Int%1 PROC FAR
    82                              <3> 
    83                              <3>  %else
    84                              <3> 
    85                              <3> PUBLIC FirstFlag%1
    86                              <3> Int%1 PROC FAR
    87                              <3>  jmp short Entry_Int%1_Stk
    88                              <3>  Old%1 dd 0
    89                              <3>  dw 424Bh
    90                              <3>  FirstFlag%1 db 0
    91                              <3>  jmp short Intret_%1
    92                              <3>  db 7 dup (0)
    93                              <3> Entry_Int%1_Stk:
    94                              <3> 
    95                              <3>  %endif
    96                              <3> 
    97                              <3> INT%1 equ Int%1
    98                              <3> OLD%1 equ Old%1
    99                              <3> 
   100                              <3> 
   101                              <3> 
   102                              <3> 
   103                              <3>  %ifidni %1, 09
   104                              <3>  jmp short Keyboard_lbl
   105                              <3>  nop
   106                              <3>  nop
   107                              <3>  db 0
   108                              <3> Keyboard_lbl label near
   109                              <3>  %endif
   110                              <3> 
   111                              <3> 
   112                              <3> 
   113                              <3> 
   114 00000016 50                  <3>  push ax
   115                              <3> 
   116                              <3>  %ifidni %1, 02
   117                              <3> 
   118                              <3> 
   119                              <3> 
   120                              <3> 
   121                              <3> 
   122                              <3> 
   123                              <3> 
   124                              <3> 
   125                              <3> 
   126                              <3> 
   127                              <3> 
   128                              <3> 
   129                              <3> 
   130                              <3> 
   131                              <3> 
   132                              <3> 
   133                              <3> 
   134                              <3> 
   135                              <3> 
   136                              <3> 
   137                              <3> 
   138                              <3> 
   139                              <3> 
   140                              <3> 
   141                              <3> 
   142                              <3> 
   143 00000017 06                  <3>  push es
   144 00000018 B800F0              <3>  mov ax,0f000h
   145 0000001B 8EC0                <3>  mov es,ax
   146                              <3>  assume es:nothing
   147                              <3> mdl_convert equ MDL_CONVERT
   148 0000001D 26803EFEFFF9        <3>  cmp byte ptr [es:0fffeh],mdl_convert
   149 00000023 07                  <3>  pop es
   150                              <3>  assume es:nothing
   151 00000024 750C                <3>  jne Normal%1
   152                              <3> 
   153 00000026 E462                <3>  in al,62h
   154 00000028 A880                <3>  test al,80h
   155 0000002A 7406                <3>  jz Normal%1
   156                              <3> 
   157                              <3> Special%1:
   158 0000002C 58                  <3>  pop ax
   159 0000002D 2EFF2E[1200]        <3>  jmp far [cs:Old%1]
   160                              <3> 
   161                              <3> Normal%1:
   162                              <3> 
   163                              <3> 
   164                              <3> 
   165                              <3>  %endif
   166                              <3> 
   167 00000032 55                  <3>  push bp
   168 00000033 06                  <3>  push es
   169                              <3> STACKS equ Stacks
   170 00000034 2E8E06[0A00]        <3>  mov es, [cs:STACKS+2]
   171                              <3>  assume es:STACKSCODE
   172                              <3> 
   173 00000039 2E8B2E[1000]        <3>  mov bp,[cs:NextEntry]
   174                              <3> Allocated equ allocated
   175 0000003E B001                <3>  mov al,Allocated
   176 00000040 26864600            <3>  xchg [AllocByte],al
   177 00000044 3C00                <3>  cmp al,Free
   178 00000046 7542                <3>  jne NotFree%1
   179                              <3> 
   180 00000048 2E832E[1000]08      <3>  sub word [cs:NextEntry],EntrySize
   181                              <3> 
   182                              <3> Found%1:
   183 0000004E 26896602            <3>  mov [SavedSP],sp
   184 00000052 268C5604            <3>  mov [SavedSS],ss
   185                              <3> 
   186                              <3> 
   187 00000056 89E8                <3>  mov ax,bp
   188                              <3> 
   189 00000058 268B6E06            <3>  mov bp,[NewSP]
   190 0000005C 26394600            <3>  cmp [es:bp],ax
   191 00000060 7535                <3>  jne FoundBad%1
   192                              <3> 
   193 00000062 8CC0                <3>  mov ax,es
   194 00000064 8ED0                <3>  mov ss,ax
   195 00000066 89EC                <3>  mov sp,bp
   196                              <3>  assume ss:STACKSCODE
   197                              <3> 
   198 00000068 9C                  <3>  pushf
   199 00000069 2EFF1E[1200]        <3>  call far [cs:Old%1]
   200                              <3> 
   201 0000006E 89E5                <3>  mov bp,sp
   202 00000070 268B6E00            <3>  mov bp,[es:bp]
   203 00000074 268E5604            <3>  mov ss,[SavedSS]
   204 00000078 268B6602            <3>  mov sp,[SavedSP]
   205                              <3>  assume ss:nothing
   206                              <3> 
   207                              <3> 
   208                              <3> 
   209                              <3> 
   210 0000007C 26C6460000          <3>  mov byte [AllocByte],Free
   211 00000081 2E892E[1000]        <3>  mov [cs:NextEntry],bp
   212                              <3> 
   213                              <3> NewError%1:
   214 00000086 07                  <3>  pop es
   215                              <3>  assume es:nothing
   216 00000087 5D                  <3>  pop bp
   217 00000088 58                  <3>  pop ax
   218                              <3> 
   219                              <3> INTRET_%1:
   220 00000089 CF                  <3>  iret
   221                              <3> Intret_%1 equ INTRET_%1
   222                              <3> 
   223                              <3> NotFree%1:
   224 0000008A 3C01                <3>  cmp al,Allocated
   225 0000008C 7404                <3>  je FindNext%1
   226 0000008E 26864600            <3>  xchg [AllocByte],al
   227                              <3> 
   228                              <3> FindNext%1:
   229                              <3> LongPath equ longpath
   230 00000092 E8D506              <3>  call LongPath
   231 00000095 EBB7                <3>  jmp Found%1
   232                              <3> 
   233                              <3> FoundBad%1:
   234 00000097 2E3B2E[0C00]        <3>  cmp bp,[cs:FirstEntry]
   235 0000009C 72F4                <3>  jc FindNext%1
   236 0000009E 89C5                <3>  mov bp,ax
   237                              <3> Clobbered equ clobbered
   238 000000A0 26C6460003          <3>  mov byte [AllocByte],Clobbered
   239                              <3> 
   240                              <3> 
   241                              <3> 
   242 000000A5 EBEB                <3>  jmp FindNext%1
   243                              <3> 
   244                              <3> int%1 endp
   245                              <3>  %rotate 1
    72                              <3>  ASSUME DS:NOTHING
    73                              <3>  ASSUME ES:NOTHING
    74                              <3>  ASSUME SS:NOTHING
    75                              <3> PUBLIC Int%1
    76                              <3> PUBLIC Old%1
    77                              <3> 
    78                              <3>  %ifn IntSharingFlag
    79                              <3> 
    80 000000A7 00000000            <3>  Old%1 DD 0
    81                              <3> Int%1 PROC FAR
    82                              <3> 
    83                              <3>  %else
    84                              <3> 
    85                              <3> PUBLIC FirstFlag%1
    86                              <3> Int%1 PROC FAR
    87                              <3>  jmp short Entry_Int%1_Stk
    88                              <3>  Old%1 dd 0
    89                              <3>  dw 424Bh
    90                              <3>  FirstFlag%1 db 0
    91                              <3>  jmp short Intret_%1
    92                              <3>  db 7 dup (0)
    93                              <3> Entry_Int%1_Stk:
    94                              <3> 
    95                              <3>  %endif
    96                              <3> 
    97                              <3> INT%1 equ Int%1
    98                              <3> OLD%1 equ Old%1
    99                              <3> 
   100                              <3> 
   101                              <3> 
   102                              <3> 
   103                              <3>  %ifidni %1, 09
   104                              <3>  jmp short Keyboard_lbl
   105                              <3>  nop
   106                              <3>  nop
   107                              <3>  db 0
   108                              <3> Keyboard_lbl label near
   109                              <3>  %endif
   110                              <3> 
   111                              <3> 
   112                              <3> 
   113                              <3> 
   114 000000AB 50                  <3>  push ax
   115                              <3> 
   116                              <3>  %ifidni %1, 02
   117                              <3> 
   118                              <3> 
   119                              <3> 
   120                              <3> 
   121                              <3> 
   122                              <3> 
   123                              <3> 
   124                              <3> 
   125                              <3> 
   126                              <3> 
   127                              <3> 
   128                              <3> 
   129                              <3> 
   130                              <3> 
   131                              <3> 
   132                              <3> 
   133                              <3> 
   134                              <3> 
   135                              <3> 
   136                              <3> 
   137                              <3> 
   138                              <3> 
   139                              <3> 
   140                              <3> 
   141                              <3> 
   142                              <3> 
   143                              <3>  push es
   144                              <3>  mov ax,0f000h
   145                              <3>  mov es,ax
   146                              <3>  assume es:nothing
   147                              <3> mdl_convert equ MDL_CONVERT
   148                              <3>  cmp byte ptr [es:0fffeh],mdl_convert
   149                              <3>  pop es
   150                              <3>  assume es:nothing
   151                              <3>  jne Normal%1
   152                              <3> 
   153                              <3>  in al,62h
   154                              <3>  test al,80h
   155                              <3>  jz Normal%1
   156                              <3> 
   157                              <3> Special%1:
   158                              <3>  pop ax
   159                              <3>  jmp far [cs:Old%1]
   160                              <3> 
   161                              <3> Normal%1:
   162                              <3> 
   163                              <3> 
   164                              <3> 
   165                              <3>  %endif
   166                              <3> 
   167 000000AC 55                  <3>  push bp
   168 000000AD 06                  <3>  push es
   169                              <3> STACKS equ Stacks
   170 000000AE 2E8E06[0A00]        <3>  mov es, [cs:STACKS+2]
   171                              <3>  assume es:STACKSCODE
   172                              <3> 
   173 000000B3 2E8B2E[1000]        <3>  mov bp,[cs:NextEntry]
   174                              <3> Allocated equ allocated
   175 000000B8 B001                <3>  mov al,Allocated
   176 000000BA 26864600            <3>  xchg [AllocByte],al
   177 000000BE 3C00                <3>  cmp al,Free
   178 000000C0 7542                <3>  jne NotFree%1
   179                              <3> 
   180 000000C2 2E832E[1000]08      <3>  sub word [cs:NextEntry],EntrySize
   181                              <3> 
   182                              <3> Found%1:
   183 000000C8 26896602            <3>  mov [SavedSP],sp
   184 000000CC 268C5604            <3>  mov [SavedSS],ss
   185                              <3> 
   186                              <3> 
   187 000000D0 89E8                <3>  mov ax,bp
   188                              <3> 
   189 000000D2 268B6E06            <3>  mov bp,[NewSP]
   190 000000D6 26394600            <3>  cmp [es:bp],ax
   191 000000DA 7535                <3>  jne FoundBad%1
   192                              <3> 
   193 000000DC 8CC0                <3>  mov ax,es
   194 000000DE 8ED0                <3>  mov ss,ax
   195 000000E0 89EC                <3>  mov sp,bp
   196                              <3>  assume ss:STACKSCODE
   197                              <3> 
   198 000000E2 9C                  <3>  pushf
   199 000000E3 2EFF1E[A700]        <3>  call far [cs:Old%1]
   200                              <3> 
   201 000000E8 89E5                <3>  mov bp,sp
   202 000000EA 268B6E00            <3>  mov bp,[es:bp]
   203 000000EE 268E5604            <3>  mov ss,[SavedSS]
   204 000000F2 268B6602            <3>  mov sp,[SavedSP]
   205                              <3>  assume ss:nothing
   206                              <3> 
   207                              <3> 
   208                              <3> 
   209                              <3> 
   210 000000F6 26C6460000          <3>  mov byte [AllocByte],Free
   211 000000FB 2E892E[1000]        <3>  mov [cs:NextEntry],bp
   212                              <3> 
   213                              <3> NewError%1:
   214 00000100 07                  <3>  pop es
   215                              <3>  assume es:nothing
   216 00000101 5D                  <3>  pop bp
   217 00000102 58                  <3>  pop ax
   218                              <3> 
   219                              <3> INTRET_%1:
   220 00000103 CF                  <3>  iret
   221                              <3> Intret_%1 equ INTRET_%1
   222                              <3> 
   223                              <3> NotFree%1:
   224 00000104 3C01                <3>  cmp al,Allocated
   225 00000106 7404                <3>  je FindNext%1
   226 00000108 26864600            <3>  xchg [AllocByte],al
   227                              <3> 
   228                              <3> FindNext%1:
   229                              <3> LongPath equ longpath
   230 0000010C E85B06              <3>  call LongPath
   231 0000010F EBB7                <3>  jmp Found%1
   232                              <3> 
   233                              <3> FoundBad%1:
   234 00000111 2E3B2E[0C00]        <3>  cmp bp,[cs:FirstEntry]
   235 00000116 72F4                <3>  jc FindNext%1
   236 00000118 89C5                <3>  mov bp,ax
   237                              <3> Clobbered equ clobbered
   238 0000011A 26C6460003          <3>  mov byte [AllocByte],Clobbered
   239                              <3> 
   240                              <3> 
   241                              <3> 
   242 0000011F EBEB                <3>  jmp FindNext%1
   243                              <3> 
   244                              <3> int%1 endp
   245                              <3>  %rotate 1
    72                              <3>  ASSUME DS:NOTHING
    73                              <3>  ASSUME ES:NOTHING
    74                              <3>  ASSUME SS:NOTHING
    75                              <3> PUBLIC Int%1
    76                              <3> PUBLIC Old%1
    77                              <3> 
    78                              <3>  %ifn IntSharingFlag
    79                              <3> 
    80 00000121 00000000            <3>  Old%1 DD 0
    81                              <3> Int%1 PROC FAR
    82                              <3> 
    83                              <3>  %else
    84                              <3> 
    85                              <3> PUBLIC FirstFlag%1
    86                              <3> Int%1 PROC FAR
    87                              <3>  jmp short Entry_Int%1_Stk
    88                              <3>  Old%1 dd 0
    89                              <3>  dw 424Bh
    90                              <3>  FirstFlag%1 db 0
    91                              <3>  jmp short Intret_%1
    92                              <3>  db 7 dup (0)
    93                              <3> Entry_Int%1_Stk:
    94                              <3> 
    95                              <3>  %endif
    96                              <3> 
    97                              <3> INT%1 equ Int%1
    98                              <3> OLD%1 equ Old%1
    99                              <3> 
   100                              <3> 
   101                              <3> 
   102                              <3> 
   103                              <3>  %ifidni %1, 09
   104 00000125 EB03                <3>  jmp short Keyboard_lbl
   105 00000127 90                  <3>  nop
   106 00000128 90                  <3>  nop
   107 00000129 00                  <3>  db 0
   108                              <3> Keyboard_lbl label near
   109                              <3>  %endif
   110                              <3> 
   111                              <3> 
   112                              <3> 
   113                              <3> 
   114 0000012A 50                  <3>  push ax
   115                              <3> 
   116                              <3>  %ifidni %1, 02
   117                              <3> 
   118                              <3> 
   119                              <3> 
   120                              <3> 
   121                              <3> 
   122                              <3> 
   123                              <3> 
   124                              <3> 
   125                              <3> 
   126                              <3> 
   127                              <3> 
   128                              <3> 
   129                              <3> 
   130                              <3> 
   131                              <3> 
   132                              <3> 
   133                              <3> 
   134                              <3> 
   135                              <3> 
   136                              <3> 
   137                              <3> 
   138                              <3> 
   139                              <3> 
   140                              <3> 
   141                              <3> 
   142                              <3> 
   143                              <3>  push es
   144                              <3>  mov ax,0f000h
   145                              <3>  mov es,ax
   146                              <3>  assume es:nothing
   147                              <3> mdl_convert equ MDL_CONVERT
   148                              <3>  cmp byte ptr [es:0fffeh],mdl_convert
   149                              <3>  pop es
   150                              <3>  assume es:nothing
   151                              <3>  jne Normal%1
   152                              <3> 
   153                              <3>  in al,62h
   154                              <3>  test al,80h
   155                              <3>  jz Normal%1
   156                              <3> 
   157                              <3> Special%1:
   158                              <3>  pop ax
   159                              <3>  jmp far [cs:Old%1]
   160                              <3> 
   161                              <3> Normal%1:
   162                              <3> 
   163                              <3> 
   164                              <3> 
   165                              <3>  %endif
   166                              <3> 
   167 0000012B 55                  <3>  push bp
   168 0000012C 06                  <3>  push es
   169                              <3> STACKS equ Stacks
   170 0000012D 2E8E06[0A00]        <3>  mov es, [cs:STACKS+2]
   171                              <3>  assume es:STACKSCODE
   172                              <3> 
   173 00000132 2E8B2E[1000]        <3>  mov bp,[cs:NextEntry]
   174                              <3> Allocated equ allocated
   175 00000137 B001                <3>  mov al,Allocated
   176 00000139 26864600            <3>  xchg [AllocByte],al
   177 0000013D 3C00                <3>  cmp al,Free
   178 0000013F 7542                <3>  jne NotFree%1
   179                              <3> 
   180 00000141 2E832E[1000]08      <3>  sub word [cs:NextEntry],EntrySize
   181                              <3> 
   182                              <3> Found%1:
   183 00000147 26896602            <3>  mov [SavedSP],sp
   184 0000014B 268C5604            <3>  mov [SavedSS],ss
   185                              <3> 
   186                              <3> 
   187 0000014F 89E8                <3>  mov ax,bp
   188                              <3> 
   189 00000151 268B6E06            <3>  mov bp,[NewSP]
   190 00000155 26394600            <3>  cmp [es:bp],ax
   191 00000159 7535                <3>  jne FoundBad%1
   192                              <3> 
   193 0000015B 8CC0                <3>  mov ax,es
   194 0000015D 8ED0                <3>  mov ss,ax
   195 0000015F 89EC                <3>  mov sp,bp
   196                              <3>  assume ss:STACKSCODE
   197                              <3> 
   198 00000161 9C                  <3>  pushf
   199 00000162 2EFF1E[2101]        <3>  call far [cs:Old%1]
   200                              <3> 
   201 00000167 89E5                <3>  mov bp,sp
   202 00000169 268B6E00            <3>  mov bp,[es:bp]
   203 0000016D 268E5604            <3>  mov ss,[SavedSS]
   204 00000171 268B6602            <3>  mov sp,[SavedSP]
   205                              <3>  assume ss:nothing
   206                              <3> 
   207                              <3> 
   208                              <3> 
   209                              <3> 
   210 00000175 26C6460000          <3>  mov byte [AllocByte],Free
   211 0000017A 2E892E[1000]        <3>  mov [cs:NextEntry],bp
   212                              <3> 
   213                              <3> NewError%1:
   214 0000017F 07                  <3>  pop es
   215                              <3>  assume es:nothing
   216 00000180 5D                  <3>  pop bp
   217 00000181 58                  <3>  pop ax
   218                              <3> 
   219                              <3> INTRET_%1:
   220 00000182 CF                  <3>  iret
   221                              <3> Intret_%1 equ INTRET_%1
   222                              <3> 
   223                              <3> NotFree%1:
   224 00000183 3C01                <3>  cmp al,Allocated
   225 00000185 7404                <3>  je FindNext%1
   226 00000187 26864600            <3>  xchg [AllocByte],al
   227                              <3> 
   228                              <3> FindNext%1:
   229                              <3> LongPath equ longpath
   230 0000018B E8DC05              <3>  call LongPath
   231 0000018E EBB7                <3>  jmp Found%1
   232                              <3> 
   233                              <3> FoundBad%1:
   234 00000190 2E3B2E[0C00]        <3>  cmp bp,[cs:FirstEntry]
   235 00000195 72F4                <3>  jc FindNext%1
   236 00000197 89C5                <3>  mov bp,ax
   237                              <3> Clobbered equ clobbered
   238 00000199 26C6460003          <3>  mov byte [AllocByte],Clobbered
   239                              <3> 
   240                              <3> 
   241                              <3> 
   242 0000019E EBEB                <3>  jmp FindNext%1
   243                              <3> 
   244                              <3> int%1 endp
   245                              <3>  %rotate 1
    72                              <3>  ASSUME DS:NOTHING
    73                              <3>  ASSUME ES:NOTHING
    74                              <3>  ASSUME SS:NOTHING
    75                              <3> PUBLIC Int%1
    76                              <3> PUBLIC Old%1
    77                              <3> 
    78                              <3>  %ifn IntSharingFlag
    79                              <3> 
    80 000001A0 00000000            <3>  Old%1 DD 0
    81                              <3> Int%1 PROC FAR
    82                              <3> 
    83                              <3>  %else
    84                              <3> 
    85                              <3> PUBLIC FirstFlag%1
    86                              <3> Int%1 PROC FAR
    87                              <3>  jmp short Entry_Int%1_Stk
    88                              <3>  Old%1 dd 0
    89                              <3>  dw 424Bh
    90                              <3>  FirstFlag%1 db 0
    91                              <3>  jmp short Intret_%1
    92                              <3>  db 7 dup (0)
    93                              <3> Entry_Int%1_Stk:
    94                              <3> 
    95                              <3>  %endif
    96                              <3> 
    97                              <3> INT%1 equ Int%1
    98                              <3> OLD%1 equ Old%1
    99                              <3> 
   100                              <3> 
   101                              <3> 
   102                              <3> 
   103                              <3>  %ifidni %1, 09
   104                              <3>  jmp short Keyboard_lbl
   105                              <3>  nop
   106                              <3>  nop
   107                              <3>  db 0
   108                              <3> Keyboard_lbl label near
   109                              <3>  %endif
   110                              <3> 
   111                              <3> 
   112                              <3> 
   113                              <3> 
   114 000001A4 50                  <3>  push ax
   115                              <3> 
   116                              <3>  %ifidni %1, 02
   117                              <3> 
   118                              <3> 
   119                              <3> 
   120                              <3> 
   121                              <3> 
   122                              <3> 
   123                              <3> 
   124                              <3> 
   125                              <3> 
   126                              <3> 
   127                              <3> 
   128                              <3> 
   129                              <3> 
   130                              <3> 
   131                              <3> 
   132                              <3> 
   133                              <3> 
   134                              <3> 
   135                              <3> 
   136                              <3> 
   137                              <3> 
   138                              <3> 
   139                              <3> 
   140                              <3> 
   141                              <3> 
   142                              <3> 
   143                              <3>  push es
   144                              <3>  mov ax,0f000h
   145                              <3>  mov es,ax
   146                              <3>  assume es:nothing
   147                              <3> mdl_convert equ MDL_CONVERT
   148                              <3>  cmp byte ptr [es:0fffeh],mdl_convert
   149                              <3>  pop es
   150                              <3>  assume es:nothing
   151                              <3>  jne Normal%1
   152                              <3> 
   153                              <3>  in al,62h
   154                              <3>  test al,80h
   155                              <3>  jz Normal%1
   156                              <3> 
   157                              <3> Special%1:
   158                              <3>  pop ax
   159                              <3>  jmp far [cs:Old%1]
   160                              <3> 
   161                              <3> Normal%1:
   162                              <3> 
   163                              <3> 
   164                              <3> 
   165                              <3>  %endif
   166                              <3> 
   167 000001A5 55                  <3>  push bp
   168 000001A6 06                  <3>  push es
   169                              <3> STACKS equ Stacks
   170 000001A7 2E8E06[0A00]        <3>  mov es, [cs:STACKS+2]
   171                              <3>  assume es:STACKSCODE
   172                              <3> 
   173 000001AC 2E8B2E[1000]        <3>  mov bp,[cs:NextEntry]
   174                              <3> Allocated equ allocated
   175 000001B1 B001                <3>  mov al,Allocated
   176 000001B3 26864600            <3>  xchg [AllocByte],al
   177 000001B7 3C00                <3>  cmp al,Free
   178 000001B9 7542                <3>  jne NotFree%1
   179                              <3> 
   180 000001BB 2E832E[1000]08      <3>  sub word [cs:NextEntry],EntrySize
   181                              <3> 
   182                              <3> Found%1:
   183 000001C1 26896602            <3>  mov [SavedSP],sp
   184 000001C5 268C5604            <3>  mov [SavedSS],ss
   185                              <3> 
   186                              <3> 
   187 000001C9 89E8                <3>  mov ax,bp
   188                              <3> 
   189 000001CB 268B6E06            <3>  mov bp,[NewSP]
   190 000001CF 26394600            <3>  cmp [es:bp],ax
   191 000001D3 7535                <3>  jne FoundBad%1
   192                              <3> 
   193 000001D5 8CC0                <3>  mov ax,es
   194 000001D7 8ED0                <3>  mov ss,ax
   195 000001D9 89EC                <3>  mov sp,bp
   196                              <3>  assume ss:STACKSCODE
   197                              <3> 
   198 000001DB 9C                  <3>  pushf
   199 000001DC 2EFF1E[A001]        <3>  call far [cs:Old%1]
   200                              <3> 
   201 000001E1 89E5                <3>  mov bp,sp
   202 000001E3 268B6E00            <3>  mov bp,[es:bp]
   203 000001E7 268E5604            <3>  mov ss,[SavedSS]
   204 000001EB 268B6602            <3>  mov sp,[SavedSP]
   205                              <3>  assume ss:nothing
   206                              <3> 
   207                              <3> 
   208                              <3> 
   209                              <3> 
   210 000001EF 26C6460000          <3>  mov byte [AllocByte],Free
   211 000001F4 2E892E[1000]        <3>  mov [cs:NextEntry],bp
   212                              <3> 
   213                              <3> NewError%1:
   214 000001F9 07                  <3>  pop es
   215                              <3>  assume es:nothing
   216 000001FA 5D                  <3>  pop bp
   217 000001FB 58                  <3>  pop ax
   218                              <3> 
   219                              <3> INTRET_%1:
   220 000001FC CF                  <3>  iret
   221                              <3> Intret_%1 equ INTRET_%1
   222                              <3> 
   223                              <3> NotFree%1:
   224 000001FD 3C01                <3>  cmp al,Allocated
   225 000001FF 7404                <3>  je FindNext%1
   226 00000201 26864600            <3>  xchg [AllocByte],al
   227                              <3> 
   228                              <3> FindNext%1:
   229                              <3> LongPath equ longpath
   230 00000205 E86205              <3>  call LongPath
   231 00000208 EBB7                <3>  jmp Found%1
   232                              <3> 
   233                              <3> FoundBad%1:
   234 0000020A 2E3B2E[0C00]        <3>  cmp bp,[cs:FirstEntry]
   235 0000020F 72F4                <3>  jc FindNext%1
   236 00000211 89C5                <3>  mov bp,ax
   237                              <3> Clobbered equ clobbered
   238 00000213 26C6460003          <3>  mov byte [AllocByte],Clobbered
   239                              <3> 
   240                              <3> 
   241                              <3> 
   242 00000218 EBEB                <3>  jmp FindNext%1
   243                              <3> 
   244                              <3> int%1 endp
   245                              <3>  %rotate 1
   256                              <1> 
   257                              <1> %iassign IntSharingFlag 1
   258                              <1> 	Stack_Main 0A,0B,0C,0D,0E,72,73,74,76,77
    71                              <2>  %rep %0
    72                              <2>  ASSUME DS:NOTHING
    73                              <2>  ASSUME ES:NOTHING
    74                              <2>  ASSUME SS:NOTHING
    75                              <2> PUBLIC Int%1
    76                              <2> PUBLIC Old%1
    77                              <2> 
    78                              <2>  %ifn IntSharingFlag
    79                              <2> 
    80                              <2>  Old%1 DD 0
    81                              <2> Int%1 PROC FAR
    82                              <2> 
    83                              <2>  %else
    84                              <2> 
    85                              <2> PUBLIC FirstFlag%1
    86                              <2> Int%1 PROC FAR
    87                              <2>  jmp short Entry_Int%1_Stk
    88                              <2>  Old%1 dd 0
    89                              <2>  dw 424Bh
    90                              <2>  FirstFlag%1 db 0
    91                              <2>  jmp short Intret_%1
    92                              <2>  db 7 dup (0)
    93                              <2> Entry_Int%1_Stk:
    94                              <2> 
    95                              <2>  %endif
    96                              <2> 
    97                              <2> INT%1 equ Int%1
    98                              <2> OLD%1 equ Old%1
    99                              <2> 
   100                              <2> 
   101                              <2> 
   102                              <2> 
   103                              <2>  %ifidni %1, 09
   104                              <2>  jmp short Keyboard_lbl
   105                              <2>  nop
   106                              <2>  nop
   107                              <2>  db 0
   108                              <2> Keyboard_lbl label near
   109                              <2>  %endif
   110                              <2> 
   111                              <2> 
   112                              <2> 
   113                              <2> 
   114                              <2>  push ax
   115                              <2> 
   116                              <2>  %ifidni %1, 02
   117                              <2> 
   118                              <2> 
   119                              <2> 
   120                              <2> 
   121                              <2> 
   122                              <2> 
   123                              <2> 
   124                              <2> 
   125                              <2> 
   126                              <2> 
   127                              <2> 
   128                              <2> 
   129                              <2> 
   130                              <2> 
   131                              <2> 
   132                              <2> 
   133                              <2> 
   134                              <2> 
   135                              <2> 
   136                              <2> 
   137                              <2> 
   138                              <2> 
   139                              <2> 
   140                              <2> 
   141                              <2> 
   142                              <2> 
   143                              <2>  push es
   144                              <2>  mov ax,0f000h
   145                              <2>  mov es,ax
   146                              <2>  assume es:nothing
   147                              <2> mdl_convert equ MDL_CONVERT
   148                              <2>  cmp byte ptr [es:0fffeh],mdl_convert
   149                              <2>  pop es
   150                              <2>  assume es:nothing
   151                              <2>  jne Normal%1
   152                              <2> 
   153                              <2>  in al,62h
   154                              <2>  test al,80h
   155                              <2>  jz Normal%1
   156                              <2> 
   157                              <2> Special%1:
   158                              <2>  pop ax
   159                              <2>  jmp far [cs:Old%1]
   160                              <2> 
   161                              <2> Normal%1:
   162                              <2> 
   163                              <2> 
   164                              <2> 
   165                              <2>  %endif
   166                              <2> 
   167                              <2>  push bp
   168                              <2>  push es
   169                              <2> STACKS equ Stacks
   170                              <2>  mov es, [cs:STACKS+2]
   171                              <2>  assume es:STACKSCODE
   172                              <2> 
   173                              <2>  mov bp,[cs:NextEntry]
   174                              <2> Allocated equ allocated
   175                              <2>  mov al,Allocated
   176                              <2>  xchg [AllocByte],al
   177                              <2>  cmp al,Free
   178                              <2>  jne NotFree%1
   179                              <2> 
   180                              <2>  sub word [cs:NextEntry],EntrySize
   181                              <2> 
   182                              <2> Found%1:
   183                              <2>  mov [SavedSP],sp
   184                              <2>  mov [SavedSS],ss
   185                              <2> 
   186                              <2> 
   187                              <2>  mov ax,bp
   188                              <2> 
   189                              <2>  mov bp,[NewSP]
   190                              <2>  cmp [es:bp],ax
   191                              <2>  jne FoundBad%1
   192                              <2> 
   193                              <2>  mov ax,es
   194                              <2>  mov ss,ax
   195                              <2>  mov sp,bp
   196                              <2>  assume ss:STACKSCODE
   197                              <2> 
   198                              <2>  pushf
   199                              <2>  call far [cs:Old%1]
   200                              <2> 
   201                              <2>  mov bp,sp
   202                              <2>  mov bp,[es:bp]
   203                              <2>  mov ss,[SavedSS]
   204                              <2>  mov sp,[SavedSP]
   205                              <2>  assume ss:nothing
   206                              <2> 
   207                              <2> 
   208                              <2> 
   209                              <2> 
   210                              <2>  mov byte [AllocByte],Free
   211                              <2>  mov [cs:NextEntry],bp
   212                              <2> 
   213                              <2> NewError%1:
   214                              <2>  pop es
   215                              <2>  assume es:nothing
   216                              <2>  pop bp
   217                              <2>  pop ax
   218                              <2> 
   219                              <2> INTRET_%1:
   220                              <2>  iret
   221                              <2> Intret_%1 equ INTRET_%1
   222                              <2> 
   223                              <2> NotFree%1:
   224                              <2>  cmp al,Allocated
   225                              <2>  je FindNext%1
   226                              <2>  xchg [AllocByte],al
   227                              <2> 
   228                              <2> FindNext%1:
   229                              <2> LongPath equ longpath
   230                              <2>  call LongPath
   231                              <2>  jmp Found%1
   232                              <2> 
   233                              <2> FoundBad%1:
   234                              <2>  cmp bp,[cs:FirstEntry]
   235                              <2>  jc FindNext%1
   236                              <2>  mov bp,ax
   237                              <2> Clobbered equ clobbered
   238                              <2>  mov byte [AllocByte],Clobbered
   239                              <2> 
   240                              <2> 
   241                              <2> 
   242                              <2>  jmp FindNext%1
   243                              <2> 
   244                              <2> int%1 endp
   245                              <2>  %rotate 1
   246                              <2>  %endrep
    72                              <3>  ASSUME DS:NOTHING
    73                              <3>  ASSUME ES:NOTHING
    74                              <3>  ASSUME SS:NOTHING
    75                              <3> PUBLIC Int%1
    76                              <3> PUBLIC Old%1
    77                              <3> 
    78                              <3>  %ifn IntSharingFlag
    79                              <3> 
    80                              <3>  Old%1 DD 0
    81                              <3> Int%1 PROC FAR
    82                              <3> 
    83                              <3>  %else
    84                              <3> 
    85                              <3> PUBLIC FirstFlag%1
    86                              <3> Int%1 PROC FAR
    87 0000021A EB10                <3>  jmp short Entry_Int%1_Stk
    88 0000021C 00000000            <3>  Old%1 dd 0
    89 00000220 4B42                <3>  dw 424Bh
    90 00000222 00                  <3>  FirstFlag%1 db 0
    91 00000223 EB5F                <3>  jmp short Intret_%1
    92 00000225 00000000000000      <3>  db 7 dup (0)
    93                              <3> Entry_Int%1_Stk:
    94                              <3> 
    95                              <3>  %endif
    96                              <3> 
    97                              <3> INT%1 equ Int%1
    98                              <3> OLD%1 equ Old%1
    99                              <3> 
   100                              <3> 
   101                              <3> 
   102                              <3> 
   103                              <3>  %ifidni %1, 09
   104                              <3>  jmp short Keyboard_lbl
   105                              <3>  nop
   106                              <3>  nop
   107                              <3>  db 0
   108                              <3> Keyboard_lbl label near
   109                              <3>  %endif
   110                              <3> 
   111                              <3> 
   112                              <3> 
   113                              <3> 
   114 0000022C 50                  <3>  push ax
   115                              <3> 
   116                              <3>  %ifidni %1, 02
   117                              <3> 
   118                              <3> 
   119                              <3> 
   120                              <3> 
   121                              <3> 
   122                              <3> 
   123                              <3> 
   124                              <3> 
   125                              <3> 
   126                              <3> 
   127                              <3> 
   128                              <3> 
   129                              <3> 
   130                              <3> 
   131                              <3> 
   132                              <3> 
   133                              <3> 
   134                              <3> 
   135                              <3> 
   136                              <3> 
   137                              <3> 
   138                              <3> 
   139                              <3> 
   140                              <3> 
   141                              <3> 
   142                              <3> 
   143                              <3>  push es
   144                              <3>  mov ax,0f000h
   145                              <3>  mov es,ax
   146                              <3>  assume es:nothing
   147                              <3> mdl_convert equ MDL_CONVERT
   148                              <3>  cmp byte ptr [es:0fffeh],mdl_convert
   149                              <3>  pop es
   150                              <3>  assume es:nothing
   151                              <3>  jne Normal%1
   152                              <3> 
   153                              <3>  in al,62h
   154                              <3>  test al,80h
   155                              <3>  jz Normal%1
   156                              <3> 
   157                              <3> Special%1:
   158                              <3>  pop ax
   159                              <3>  jmp far [cs:Old%1]
   160                              <3> 
   161                              <3> Normal%1:
   162                              <3> 
   163                              <3> 
   164                              <3> 
   165                              <3>  %endif
   166                              <3> 
   167 0000022D 55                  <3>  push bp
   168 0000022E 06                  <3>  push es
   169                              <3> STACKS equ Stacks
   170 0000022F 2E8E06[0A00]        <3>  mov es, [cs:STACKS+2]
   171                              <3>  assume es:STACKSCODE
   172                              <3> 
   173 00000234 2E8B2E[1000]        <3>  mov bp,[cs:NextEntry]
   174                              <3> Allocated equ allocated
   175 00000239 B001                <3>  mov al,Allocated
   176 0000023B 26864600            <3>  xchg [AllocByte],al
   177 0000023F 3C00                <3>  cmp al,Free
   178 00000241 7542                <3>  jne NotFree%1
   179                              <3> 
   180 00000243 2E832E[1000]08      <3>  sub word [cs:NextEntry],EntrySize
   181                              <3> 
   182                              <3> Found%1:
   183 00000249 26896602            <3>  mov [SavedSP],sp
   184 0000024D 268C5604            <3>  mov [SavedSS],ss
   185                              <3> 
   186                              <3> 
   187 00000251 89E8                <3>  mov ax,bp
   188                              <3> 
   189 00000253 268B6E06            <3>  mov bp,[NewSP]
   190 00000257 26394600            <3>  cmp [es:bp],ax
   191 0000025B 7535                <3>  jne FoundBad%1
   192                              <3> 
   193 0000025D 8CC0                <3>  mov ax,es
   194 0000025F 8ED0                <3>  mov ss,ax
   195 00000261 89EC                <3>  mov sp,bp
   196                              <3>  assume ss:STACKSCODE
   197                              <3> 
   198 00000263 9C                  <3>  pushf
   199 00000264 2EFF1E[1C02]        <3>  call far [cs:Old%1]
   200                              <3> 
   201 00000269 89E5                <3>  mov bp,sp
   202 0000026B 268B6E00            <3>  mov bp,[es:bp]
   203 0000026F 268E5604            <3>  mov ss,[SavedSS]
   204 00000273 268B6602            <3>  mov sp,[SavedSP]
   205                              <3>  assume ss:nothing
   206                              <3> 
   207                              <3> 
   208                              <3> 
   209                              <3> 
   210 00000277 26C6460000          <3>  mov byte [AllocByte],Free
   211 0000027C 2E892E[1000]        <3>  mov [cs:NextEntry],bp
   212                              <3> 
   213                              <3> NewError%1:
   214 00000281 07                  <3>  pop es
   215                              <3>  assume es:nothing
   216 00000282 5D                  <3>  pop bp
   217 00000283 58                  <3>  pop ax
   218                              <3> 
   219                              <3> INTRET_%1:
   220 00000284 CF                  <3>  iret
   221                              <3> Intret_%1 equ INTRET_%1
   222                              <3> 
   223                              <3> NotFree%1:
   224 00000285 3C01                <3>  cmp al,Allocated
   225 00000287 7404                <3>  je FindNext%1
   226 00000289 26864600            <3>  xchg [AllocByte],al
   227                              <3> 
   228                              <3> FindNext%1:
   229                              <3> LongPath equ longpath
   230 0000028D E8DA04              <3>  call LongPath
   231 00000290 EBB7                <3>  jmp Found%1
   232                              <3> 
   233                              <3> FoundBad%1:
   234 00000292 2E3B2E[0C00]        <3>  cmp bp,[cs:FirstEntry]
   235 00000297 72F4                <3>  jc FindNext%1
   236 00000299 89C5                <3>  mov bp,ax
   237                              <3> Clobbered equ clobbered
   238 0000029B 26C6460003          <3>  mov byte [AllocByte],Clobbered
   239                              <3> 
   240                              <3> 
   241                              <3> 
   242 000002A0 EBEB                <3>  jmp FindNext%1
   243                              <3> 
   244                              <3> int%1 endp
   245                              <3>  %rotate 1
    72                              <3>  ASSUME DS:NOTHING
    73                              <3>  ASSUME ES:NOTHING
    74                              <3>  ASSUME SS:NOTHING
    75                              <3> PUBLIC Int%1
    76                              <3> PUBLIC Old%1
    77                              <3> 
    78                              <3>  %ifn IntSharingFlag
    79                              <3> 
    80                              <3>  Old%1 DD 0
    81                              <3> Int%1 PROC FAR
    82                              <3> 
    83                              <3>  %else
    84                              <3> 
    85                              <3> PUBLIC FirstFlag%1
    86                              <3> Int%1 PROC FAR
    87 000002A2 EB10                <3>  jmp short Entry_Int%1_Stk
    88 000002A4 00000000            <3>  Old%1 dd 0
    89 000002A8 4B42                <3>  dw 424Bh
    90 000002AA 00                  <3>  FirstFlag%1 db 0
    91 000002AB EB5F                <3>  jmp short Intret_%1
    92 000002AD 00000000000000      <3>  db 7 dup (0)
    93                              <3> Entry_Int%1_Stk:
    94                              <3> 
    95                              <3>  %endif
    96                              <3> 
    97                              <3> INT%1 equ Int%1
    98                              <3> OLD%1 equ Old%1
    99                              <3> 
   100                              <3> 
   101                              <3> 
   102                              <3> 
   103                              <3>  %ifidni %1, 09
   104                              <3>  jmp short Keyboard_lbl
   105                              <3>  nop
   106                              <3>  nop
   107                              <3>  db 0
   108                              <3> Keyboard_lbl label near
   109                              <3>  %endif
   110                              <3> 
   111                              <3> 
   112                              <3> 
   113                              <3> 
   114 000002B4 50                  <3>  push ax
   115                              <3> 
   116                              <3>  %ifidni %1, 02
   117                              <3> 
   118                              <3> 
   119                              <3> 
   120                              <3> 
   121                              <3> 
   122                              <3> 
   123                              <3> 
   124                              <3> 
   125                              <3> 
   126                              <3> 
   127                              <3> 
   128                              <3> 
   129                              <3> 
   130                              <3> 
   131                              <3> 
   132                              <3> 
   133                              <3> 
   134                              <3> 
   135                              <3> 
   136                              <3> 
   137                              <3> 
   138                              <3> 
   139                              <3> 
   140                              <3> 
   141                              <3> 
   142                              <3> 
   143                              <3>  push es
   144                              <3>  mov ax,0f000h
   145                              <3>  mov es,ax
   146                              <3>  assume es:nothing
   147                              <3> mdl_convert equ MDL_CONVERT
   148                              <3>  cmp byte ptr [es:0fffeh],mdl_convert
   149                              <3>  pop es
   150                              <3>  assume es:nothing
   151                              <3>  jne Normal%1
   152                              <3> 
   153                              <3>  in al,62h
   154                              <3>  test al,80h
   155                              <3>  jz Normal%1
   156                              <3> 
   157                              <3> Special%1:
   158                              <3>  pop ax
   159                              <3>  jmp far [cs:Old%1]
   160                              <3> 
   161                              <3> Normal%1:
   162                              <3> 
   163                              <3> 
   164                              <3> 
   165                              <3>  %endif
   166                              <3> 
   167 000002B5 55                  <3>  push bp
   168 000002B6 06                  <3>  push es
   169                              <3> STACKS equ Stacks
   170 000002B7 2E8E06[0A00]        <3>  mov es, [cs:STACKS+2]
   171                              <3>  assume es:STACKSCODE
   172                              <3> 
   173 000002BC 2E8B2E[1000]        <3>  mov bp,[cs:NextEntry]
   174                              <3> Allocated equ allocated
   175 000002C1 B001                <3>  mov al,Allocated
   176 000002C3 26864600            <3>  xchg [AllocByte],al
   177 000002C7 3C00                <3>  cmp al,Free
   178 000002C9 7542                <3>  jne NotFree%1
   179                              <3> 
   180 000002CB 2E832E[1000]08      <3>  sub word [cs:NextEntry],EntrySize
   181                              <3> 
   182                              <3> Found%1:
   183 000002D1 26896602            <3>  mov [SavedSP],sp
   184 000002D5 268C5604            <3>  mov [SavedSS],ss
   185                              <3> 
   186                              <3> 
   187 000002D9 89E8                <3>  mov ax,bp
   188                              <3> 
   189 000002DB 268B6E06            <3>  mov bp,[NewSP]
   190 000002DF 26394600            <3>  cmp [es:bp],ax
   191 000002E3 7535                <3>  jne FoundBad%1
   192                              <3> 
   193 000002E5 8CC0                <3>  mov ax,es
   194 000002E7 8ED0                <3>  mov ss,ax
   195 000002E9 89EC                <3>  mov sp,bp
   196                              <3>  assume ss:STACKSCODE
   197                              <3> 
   198 000002EB 9C                  <3>  pushf
   199 000002EC 2EFF1E[A402]        <3>  call far [cs:Old%1]
   200                              <3> 
   201 000002F1 89E5                <3>  mov bp,sp
   202 000002F3 268B6E00            <3>  mov bp,[es:bp]
   203 000002F7 268E5604            <3>  mov ss,[SavedSS]
   204 000002FB 268B6602            <3>  mov sp,[SavedSP]
   205                              <3>  assume ss:nothing
   206                              <3> 
   207                              <3> 
   208                              <3> 
   209                              <3> 
   210 000002FF 26C6460000          <3>  mov byte [AllocByte],Free
   211 00000304 2E892E[1000]        <3>  mov [cs:NextEntry],bp
   212                              <3> 
   213                              <3> NewError%1:
   214 00000309 07                  <3>  pop es
   215                              <3>  assume es:nothing
   216 0000030A 5D                  <3>  pop bp
   217 0000030B 58                  <3>  pop ax
   218                              <3> 
   219                              <3> INTRET_%1:
   220 0000030C CF                  <3>  iret
   221                              <3> Intret_%1 equ INTRET_%1
   222                              <3> 
   223                              <3> NotFree%1:
   224 0000030D 3C01                <3>  cmp al,Allocated
   225 0000030F 7404                <3>  je FindNext%1
   226 00000311 26864600            <3>  xchg [AllocByte],al
   227                              <3> 
   228                              <3> FindNext%1:
   229                              <3> LongPath equ longpath
   230 00000315 E85204              <3>  call LongPath
   231 00000318 EBB7                <3>  jmp Found%1
   232                              <3> 
   233                              <3> FoundBad%1:
   234 0000031A 2E3B2E[0C00]        <3>  cmp bp,[cs:FirstEntry]
   235 0000031F 72F4                <3>  jc FindNext%1
   236 00000321 89C5                <3>  mov bp,ax
   237                              <3> Clobbered equ clobbered
   238 00000323 26C6460003          <3>  mov byte [AllocByte],Clobbered
   239                              <3> 
   240                              <3> 
   241                              <3> 
   242 00000328 EBEB                <3>  jmp FindNext%1
   243                              <3> 
   244                              <3> int%1 endp
   245                              <3>  %rotate 1
    72                              <3>  ASSUME DS:NOTHING
    73                              <3>  ASSUME ES:NOTHING
    74                              <3>  ASSUME SS:NOTHING
    75                              <3> PUBLIC Int%1
    76                              <3> PUBLIC Old%1
    77                              <3> 
    78                              <3>  %ifn IntSharingFlag
    79                              <3> 
    80                              <3>  Old%1 DD 0
    81                              <3> Int%1 PROC FAR
    82                              <3> 
    83                              <3>  %else
    84                              <3> 
    85                              <3> PUBLIC FirstFlag%1
    86                              <3> Int%1 PROC FAR
    87 0000032A EB10                <3>  jmp short Entry_Int%1_Stk
    88 0000032C 00000000            <3>  Old%1 dd 0
    89 00000330 4B42                <3>  dw 424Bh
    90 00000332 00                  <3>  FirstFlag%1 db 0
    91 00000333 EB5F                <3>  jmp short Intret_%1
    92 00000335 00000000000000      <3>  db 7 dup (0)
    93                              <3> Entry_Int%1_Stk:
    94                              <3> 
    95                              <3>  %endif
    96                              <3> 
    97                              <3> INT%1 equ Int%1
    98                              <3> OLD%1 equ Old%1
    99                              <3> 
   100                              <3> 
   101                              <3> 
   102                              <3> 
   103                              <3>  %ifidni %1, 09
   104                              <3>  jmp short Keyboard_lbl
   105                              <3>  nop
   106                              <3>  nop
   107                              <3>  db 0
   108                              <3> Keyboard_lbl label near
   109                              <3>  %endif
   110                              <3> 
   111                              <3> 
   112                              <3> 
   113                              <3> 
   114 0000033C 50                  <3>  push ax
   115                              <3> 
   116                              <3>  %ifidni %1, 02
   117                              <3> 
   118                              <3> 
   119                              <3> 
   120                              <3> 
   121                              <3> 
   122                              <3> 
   123                              <3> 
   124                              <3> 
   125                              <3> 
   126                              <3> 
   127                              <3> 
   128                              <3> 
   129                              <3> 
   130                              <3> 
   131                              <3> 
   132                              <3> 
   133                              <3> 
   134                              <3> 
   135                              <3> 
   136                              <3> 
   137                              <3> 
   138                              <3> 
   139                              <3> 
   140                              <3> 
   141                              <3> 
   142                              <3> 
   143                              <3>  push es
   144                              <3>  mov ax,0f000h
   145                              <3>  mov es,ax
   146                              <3>  assume es:nothing
   147                              <3> mdl_convert equ MDL_CONVERT
   148                              <3>  cmp byte ptr [es:0fffeh],mdl_convert
   149                              <3>  pop es
   150                              <3>  assume es:nothing
   151                              <3>  jne Normal%1
   152                              <3> 
   153                              <3>  in al,62h
   154                              <3>  test al,80h
   155                              <3>  jz Normal%1
   156                              <3> 
   157                              <3> Special%1:
   158                              <3>  pop ax
   159                              <3>  jmp far [cs:Old%1]
   160                              <3> 
   161                              <3> Normal%1:
   162                              <3> 
   163                              <3> 
   164                              <3> 
   165                              <3>  %endif
   166                              <3> 
   167 0000033D 55                  <3>  push bp
   168 0000033E 06                  <3>  push es
   169                              <3> STACKS equ Stacks
   170 0000033F 2E8E06[0A00]        <3>  mov es, [cs:STACKS+2]
   171                              <3>  assume es:STACKSCODE
   172                              <3> 
   173 00000344 2E8B2E[1000]        <3>  mov bp,[cs:NextEntry]
   174                              <3> Allocated equ allocated
   175 00000349 B001                <3>  mov al,Allocated
   176 0000034B 26864600            <3>  xchg [AllocByte],al
   177 0000034F 3C00                <3>  cmp al,Free
   178 00000351 7542                <3>  jne NotFree%1
   179                              <3> 
   180 00000353 2E832E[1000]08      <3>  sub word [cs:NextEntry],EntrySize
   181                              <3> 
   182                              <3> Found%1:
   183 00000359 26896602            <3>  mov [SavedSP],sp
   184 0000035D 268C5604            <3>  mov [SavedSS],ss
   185                              <3> 
   186                              <3> 
   187 00000361 89E8                <3>  mov ax,bp
   188                              <3> 
   189 00000363 268B6E06            <3>  mov bp,[NewSP]
   190 00000367 26394600            <3>  cmp [es:bp],ax
   191 0000036B 7535                <3>  jne FoundBad%1
   192                              <3> 
   193 0000036D 8CC0                <3>  mov ax,es
   194 0000036F 8ED0                <3>  mov ss,ax
   195 00000371 89EC                <3>  mov sp,bp
   196                              <3>  assume ss:STACKSCODE
   197                              <3> 
   198 00000373 9C                  <3>  pushf
   199 00000374 2EFF1E[2C03]        <3>  call far [cs:Old%1]
   200                              <3> 
   201 00000379 89E5                <3>  mov bp,sp
   202 0000037B 268B6E00            <3>  mov bp,[es:bp]
   203 0000037F 268E5604            <3>  mov ss,[SavedSS]
   204 00000383 268B6602            <3>  mov sp,[SavedSP]
   205                              <3>  assume ss:nothing
   206                              <3> 
   207                              <3> 
   208                              <3> 
   209                              <3> 
   210 00000387 26C6460000          <3>  mov byte [AllocByte],Free
   211 0000038C 2E892E[1000]        <3>  mov [cs:NextEntry],bp
   212                              <3> 
   213                              <3> NewError%1:
   214 00000391 07                  <3>  pop es
   215                              <3>  assume es:nothing
   216 00000392 5D                  <3>  pop bp
   217 00000393 58                  <3>  pop ax
   218                              <3> 
   219                              <3> INTRET_%1:
   220 00000394 CF                  <3>  iret
   221                              <3> Intret_%1 equ INTRET_%1
   222                              <3> 
   223                              <3> NotFree%1:
   224 00000395 3C01                <3>  cmp al,Allocated
   225 00000397 7404                <3>  je FindNext%1
   226 00000399 26864600            <3>  xchg [AllocByte],al
   227                              <3> 
   228                              <3> FindNext%1:
   229                              <3> LongPath equ longpath
   230 0000039D E8CA03              <3>  call LongPath
   231 000003A0 EBB7                <3>  jmp Found%1
   232                              <3> 
   233                              <3> FoundBad%1:
   234 000003A2 2E3B2E[0C00]        <3>  cmp bp,[cs:FirstEntry]
   235 000003A7 72F4                <3>  jc FindNext%1
   236 000003A9 89C5                <3>  mov bp,ax
   237                              <3> Clobbered equ clobbered
   238 000003AB 26C6460003          <3>  mov byte [AllocByte],Clobbered
   239                              <3> 
   240                              <3> 
   241                              <3> 
   242 000003B0 EBEB                <3>  jmp FindNext%1
   243                              <3> 
   244                              <3> int%1 endp
   245                              <3>  %rotate 1
    72                              <3>  ASSUME DS:NOTHING
    73                              <3>  ASSUME ES:NOTHING
    74                              <3>  ASSUME SS:NOTHING
    75                              <3> PUBLIC Int%1
    76                              <3> PUBLIC Old%1
    77                              <3> 
    78                              <3>  %ifn IntSharingFlag
    79                              <3> 
    80                              <3>  Old%1 DD 0
    81                              <3> Int%1 PROC FAR
    82                              <3> 
    83                              <3>  %else
    84                              <3> 
    85                              <3> PUBLIC FirstFlag%1
    86                              <3> Int%1 PROC FAR
    87 000003B2 EB10                <3>  jmp short Entry_Int%1_Stk
    88 000003B4 00000000            <3>  Old%1 dd 0
    89 000003B8 4B42                <3>  dw 424Bh
    90 000003BA 00                  <3>  FirstFlag%1 db 0
    91 000003BB EB5F                <3>  jmp short Intret_%1
    92 000003BD 00000000000000      <3>  db 7 dup (0)
    93                              <3> Entry_Int%1_Stk:
    94                              <3> 
    95                              <3>  %endif
    96                              <3> 
    97                              <3> INT%1 equ Int%1
    98                              <3> OLD%1 equ Old%1
    99                              <3> 
   100                              <3> 
   101                              <3> 
   102                              <3> 
   103                              <3>  %ifidni %1, 09
   104                              <3>  jmp short Keyboard_lbl
   105                              <3>  nop
   106                              <3>  nop
   107                              <3>  db 0
   108                              <3> Keyboard_lbl label near
   109                              <3>  %endif
   110                              <3> 
   111                              <3> 
   112                              <3> 
   113                              <3> 
   114 000003C4 50                  <3>  push ax
   115                              <3> 
   116                              <3>  %ifidni %1, 02
   117                              <3> 
   118                              <3> 
   119                              <3> 
   120                              <3> 
   121                              <3> 
   122                              <3> 
   123                              <3> 
   124                              <3> 
   125                              <3> 
   126                              <3> 
   127                              <3> 
   128                              <3> 
   129                              <3> 
   130                              <3> 
   131                              <3> 
   132                              <3> 
   133                              <3> 
   134                              <3> 
   135                              <3> 
   136                              <3> 
   137                              <3> 
   138                              <3> 
   139                              <3> 
   140                              <3> 
   141                              <3> 
   142                              <3> 
   143                              <3>  push es
   144                              <3>  mov ax,0f000h
   145                              <3>  mov es,ax
   146                              <3>  assume es:nothing
   147                              <3> mdl_convert equ MDL_CONVERT
   148                              <3>  cmp byte ptr [es:0fffeh],mdl_convert
   149                              <3>  pop es
   150                              <3>  assume es:nothing
   151                              <3>  jne Normal%1
   152                              <3> 
   153                              <3>  in al,62h
   154                              <3>  test al,80h
   155                              <3>  jz Normal%1
   156                              <3> 
   157                              <3> Special%1:
   158                              <3>  pop ax
   159                              <3>  jmp far [cs:Old%1]
   160                              <3> 
   161                              <3> Normal%1:
   162                              <3> 
   163                              <3> 
   164                              <3> 
   165                              <3>  %endif
   166                              <3> 
   167 000003C5 55                  <3>  push bp
   168 000003C6 06                  <3>  push es
   169                              <3> STACKS equ Stacks
   170 000003C7 2E8E06[0A00]        <3>  mov es, [cs:STACKS+2]
   171                              <3>  assume es:STACKSCODE
   172                              <3> 
   173 000003CC 2E8B2E[1000]        <3>  mov bp,[cs:NextEntry]
   174                              <3> Allocated equ allocated
   175 000003D1 B001                <3>  mov al,Allocated
   176 000003D3 26864600            <3>  xchg [AllocByte],al
   177 000003D7 3C00                <3>  cmp al,Free
   178 000003D9 7542                <3>  jne NotFree%1
   179                              <3> 
   180 000003DB 2E832E[1000]08      <3>  sub word [cs:NextEntry],EntrySize
   181                              <3> 
   182                              <3> Found%1:
   183 000003E1 26896602            <3>  mov [SavedSP],sp
   184 000003E5 268C5604            <3>  mov [SavedSS],ss
   185                              <3> 
   186                              <3> 
   187 000003E9 89E8                <3>  mov ax,bp
   188                              <3> 
   189 000003EB 268B6E06            <3>  mov bp,[NewSP]
   190 000003EF 26394600            <3>  cmp [es:bp],ax
   191 000003F3 7535                <3>  jne FoundBad%1
   192                              <3> 
   193 000003F5 8CC0                <3>  mov ax,es
   194 000003F7 8ED0                <3>  mov ss,ax
   195 000003F9 89EC                <3>  mov sp,bp
   196                              <3>  assume ss:STACKSCODE
   197                              <3> 
   198 000003FB 9C                  <3>  pushf
   199 000003FC 2EFF1E[B403]        <3>  call far [cs:Old%1]
   200                              <3> 
   201 00000401 89E5                <3>  mov bp,sp
   202 00000403 268B6E00            <3>  mov bp,[es:bp]
   203 00000407 268E5604            <3>  mov ss,[SavedSS]
   204 0000040B 268B6602            <3>  mov sp,[SavedSP]
   205                              <3>  assume ss:nothing
   206                              <3> 
   207                              <3> 
   208                              <3> 
   209                              <3> 
   210 0000040F 26C6460000          <3>  mov byte [AllocByte],Free
   211 00000414 2E892E[1000]        <3>  mov [cs:NextEntry],bp
   212                              <3> 
   213                              <3> NewError%1:
   214 00000419 07                  <3>  pop es
   215                              <3>  assume es:nothing
   216 0000041A 5D                  <3>  pop bp
   217 0000041B 58                  <3>  pop ax
   218                              <3> 
   219                              <3> INTRET_%1:
   220 0000041C CF                  <3>  iret
   221                              <3> Intret_%1 equ INTRET_%1
   222                              <3> 
   223                              <3> NotFree%1:
   224 0000041D 3C01                <3>  cmp al,Allocated
   225 0000041F 7404                <3>  je FindNext%1
   226 00000421 26864600            <3>  xchg [AllocByte],al
   227                              <3> 
   228                              <3> FindNext%1:
   229                              <3> LongPath equ longpath
   230 00000425 E84203              <3>  call LongPath
   231 00000428 EBB7                <3>  jmp Found%1
   232                              <3> 
   233                              <3> FoundBad%1:
   234 0000042A 2E3B2E[0C00]        <3>  cmp bp,[cs:FirstEntry]
   235 0000042F 72F4                <3>  jc FindNext%1
   236 00000431 89C5                <3>  mov bp,ax
   237                              <3> Clobbered equ clobbered
   238 00000433 26C6460003          <3>  mov byte [AllocByte],Clobbered
   239                              <3> 
   240                              <3> 
   241                              <3> 
   242 00000438 EBEB                <3>  jmp FindNext%1
   243                              <3> 
   244                              <3> int%1 endp
   245                              <3>  %rotate 1
    72                              <3>  ASSUME DS:NOTHING
    73                              <3>  ASSUME ES:NOTHING
    74                              <3>  ASSUME SS:NOTHING
    75                              <3> PUBLIC Int%1
    76                              <3> PUBLIC Old%1
    77                              <3> 
    78                              <3>  %ifn IntSharingFlag
    79                              <3> 
    80                              <3>  Old%1 DD 0
    81                              <3> Int%1 PROC FAR
    82                              <3> 
    83                              <3>  %else
    84                              <3> 
    85                              <3> PUBLIC FirstFlag%1
    86                              <3> Int%1 PROC FAR
    87 0000043A EB10                <3>  jmp short Entry_Int%1_Stk
    88 0000043C 00000000            <3>  Old%1 dd 0
    89 00000440 4B42                <3>  dw 424Bh
    90 00000442 00                  <3>  FirstFlag%1 db 0
    91 00000443 EB5F                <3>  jmp short Intret_%1
    92 00000445 00000000000000      <3>  db 7 dup (0)
    93                              <3> Entry_Int%1_Stk:
    94                              <3> 
    95                              <3>  %endif
    96                              <3> 
    97                              <3> INT%1 equ Int%1
    98                              <3> OLD%1 equ Old%1
    99                              <3> 
   100                              <3> 
   101                              <3> 
   102                              <3> 
   103                              <3>  %ifidni %1, 09
   104                              <3>  jmp short Keyboard_lbl
   105                              <3>  nop
   106                              <3>  nop
   107                              <3>  db 0
   108                              <3> Keyboard_lbl label near
   109                              <3>  %endif
   110                              <3> 
   111                              <3> 
   112                              <3> 
   113                              <3> 
   114 0000044C 50                  <3>  push ax
   115                              <3> 
   116                              <3>  %ifidni %1, 02
   117                              <3> 
   118                              <3> 
   119                              <3> 
   120                              <3> 
   121                              <3> 
   122                              <3> 
   123                              <3> 
   124                              <3> 
   125                              <3> 
   126                              <3> 
   127                              <3> 
   128                              <3> 
   129                              <3> 
   130                              <3> 
   131                              <3> 
   132                              <3> 
   133                              <3> 
   134                              <3> 
   135                              <3> 
   136                              <3> 
   137                              <3> 
   138                              <3> 
   139                              <3> 
   140                              <3> 
   141                              <3> 
   142                              <3> 
   143                              <3>  push es
   144                              <3>  mov ax,0f000h
   145                              <3>  mov es,ax
   146                              <3>  assume es:nothing
   147                              <3> mdl_convert equ MDL_CONVERT
   148                              <3>  cmp byte ptr [es:0fffeh],mdl_convert
   149                              <3>  pop es
   150                              <3>  assume es:nothing
   151                              <3>  jne Normal%1
   152                              <3> 
   153                              <3>  in al,62h
   154                              <3>  test al,80h
   155                              <3>  jz Normal%1
   156                              <3> 
   157                              <3> Special%1:
   158                              <3>  pop ax
   159                              <3>  jmp far [cs:Old%1]
   160                              <3> 
   161                              <3> Normal%1:
   162                              <3> 
   163                              <3> 
   164                              <3> 
   165                              <3>  %endif
   166                              <3> 
   167 0000044D 55                  <3>  push bp
   168 0000044E 06                  <3>  push es
   169                              <3> STACKS equ Stacks
   170 0000044F 2E8E06[0A00]        <3>  mov es, [cs:STACKS+2]
   171                              <3>  assume es:STACKSCODE
   172                              <3> 
   173 00000454 2E8B2E[1000]        <3>  mov bp,[cs:NextEntry]
   174                              <3> Allocated equ allocated
   175 00000459 B001                <3>  mov al,Allocated
   176 0000045B 26864600            <3>  xchg [AllocByte],al
   177 0000045F 3C00                <3>  cmp al,Free
   178 00000461 7542                <3>  jne NotFree%1
   179                              <3> 
   180 00000463 2E832E[1000]08      <3>  sub word [cs:NextEntry],EntrySize
   181                              <3> 
   182                              <3> Found%1:
   183 00000469 26896602            <3>  mov [SavedSP],sp
   184 0000046D 268C5604            <3>  mov [SavedSS],ss
   185                              <3> 
   186                              <3> 
   187 00000471 89E8                <3>  mov ax,bp
   188                              <3> 
   189 00000473 268B6E06            <3>  mov bp,[NewSP]
   190 00000477 26394600            <3>  cmp [es:bp],ax
   191 0000047B 7535                <3>  jne FoundBad%1
   192                              <3> 
   193 0000047D 8CC0                <3>  mov ax,es
   194 0000047F 8ED0                <3>  mov ss,ax
   195 00000481 89EC                <3>  mov sp,bp
   196                              <3>  assume ss:STACKSCODE
   197                              <3> 
   198 00000483 9C                  <3>  pushf
   199 00000484 2EFF1E[3C04]        <3>  call far [cs:Old%1]
   200                              <3> 
   201 00000489 89E5                <3>  mov bp,sp
   202 0000048B 268B6E00            <3>  mov bp,[es:bp]
   203 0000048F 268E5604            <3>  mov ss,[SavedSS]
   204 00000493 268B6602            <3>  mov sp,[SavedSP]
   205                              <3>  assume ss:nothing
   206                              <3> 
   207                              <3> 
   208                              <3> 
   209                              <3> 
   210 00000497 26C6460000          <3>  mov byte [AllocByte],Free
   211 0000049C 2E892E[1000]        <3>  mov [cs:NextEntry],bp
   212                              <3> 
   213                              <3> NewError%1:
   214 000004A1 07                  <3>  pop es
   215                              <3>  assume es:nothing
   216 000004A2 5D                  <3>  pop bp
   217 000004A3 58                  <3>  pop ax
   218                              <3> 
   219                              <3> INTRET_%1:
   220 000004A4 CF                  <3>  iret
   221                              <3> Intret_%1 equ INTRET_%1
   222                              <3> 
   223                              <3> NotFree%1:
   224 000004A5 3C01                <3>  cmp al,Allocated
   225 000004A7 7404                <3>  je FindNext%1
   226 000004A9 26864600            <3>  xchg [AllocByte],al
   227                              <3> 
   228                              <3> FindNext%1:
   229                              <3> LongPath equ longpath
   230 000004AD E8BA02              <3>  call LongPath
   231 000004B0 EBB7                <3>  jmp Found%1
   232                              <3> 
   233                              <3> FoundBad%1:
   234 000004B2 2E3B2E[0C00]        <3>  cmp bp,[cs:FirstEntry]
   235 000004B7 72F4                <3>  jc FindNext%1
   236 000004B9 89C5                <3>  mov bp,ax
   237                              <3> Clobbered equ clobbered
   238 000004BB 26C6460003          <3>  mov byte [AllocByte],Clobbered
   239                              <3> 
   240                              <3> 
   241                              <3> 
   242 000004C0 EBEB                <3>  jmp FindNext%1
   243                              <3> 
   244                              <3> int%1 endp
   245                              <3>  %rotate 1
    72                              <3>  ASSUME DS:NOTHING
    73                              <3>  ASSUME ES:NOTHING
    74                              <3>  ASSUME SS:NOTHING
    75                              <3> PUBLIC Int%1
    76                              <3> PUBLIC Old%1
    77                              <3> 
    78                              <3>  %ifn IntSharingFlag
    79                              <3> 
    80                              <3>  Old%1 DD 0
    81                              <3> Int%1 PROC FAR
    82                              <3> 
    83                              <3>  %else
    84                              <3> 
    85                              <3> PUBLIC FirstFlag%1
    86                              <3> Int%1 PROC FAR
    87 000004C2 EB10                <3>  jmp short Entry_Int%1_Stk
    88 000004C4 00000000            <3>  Old%1 dd 0
    89 000004C8 4B42                <3>  dw 424Bh
    90 000004CA 00                  <3>  FirstFlag%1 db 0
    91 000004CB EB5F                <3>  jmp short Intret_%1
    92 000004CD 00000000000000      <3>  db 7 dup (0)
    93                              <3> Entry_Int%1_Stk:
    94                              <3> 
    95                              <3>  %endif
    96                              <3> 
    97                              <3> INT%1 equ Int%1
    98                              <3> OLD%1 equ Old%1
    99                              <3> 
   100                              <3> 
   101                              <3> 
   102                              <3> 
   103                              <3>  %ifidni %1, 09
   104                              <3>  jmp short Keyboard_lbl
   105                              <3>  nop
   106                              <3>  nop
   107                              <3>  db 0
   108                              <3> Keyboard_lbl label near
   109                              <3>  %endif
   110                              <3> 
   111                              <3> 
   112                              <3> 
   113                              <3> 
   114 000004D4 50                  <3>  push ax
   115                              <3> 
   116                              <3>  %ifidni %1, 02
   117                              <3> 
   118                              <3> 
   119                              <3> 
   120                              <3> 
   121                              <3> 
   122                              <3> 
   123                              <3> 
   124                              <3> 
   125                              <3> 
   126                              <3> 
   127                              <3> 
   128                              <3> 
   129                              <3> 
   130                              <3> 
   131                              <3> 
   132                              <3> 
   133                              <3> 
   134                              <3> 
   135                              <3> 
   136                              <3> 
   137                              <3> 
   138                              <3> 
   139                              <3> 
   140                              <3> 
   141                              <3> 
   142                              <3> 
   143                              <3>  push es
   144                              <3>  mov ax,0f000h
   145                              <3>  mov es,ax
   146                              <3>  assume es:nothing
   147                              <3> mdl_convert equ MDL_CONVERT
   148                              <3>  cmp byte ptr [es:0fffeh],mdl_convert
   149                              <3>  pop es
   150                              <3>  assume es:nothing
   151                              <3>  jne Normal%1
   152                              <3> 
   153                              <3>  in al,62h
   154                              <3>  test al,80h
   155                              <3>  jz Normal%1
   156                              <3> 
   157                              <3> Special%1:
   158                              <3>  pop ax
   159                              <3>  jmp far [cs:Old%1]
   160                              <3> 
   161                              <3> Normal%1:
   162                              <3> 
   163                              <3> 
   164                              <3> 
   165                              <3>  %endif
   166                              <3> 
   167 000004D5 55                  <3>  push bp
   168 000004D6 06                  <3>  push es
   169                              <3> STACKS equ Stacks
   170 000004D7 2E8E06[0A00]        <3>  mov es, [cs:STACKS+2]
   171                              <3>  assume es:STACKSCODE
   172                              <3> 
   173 000004DC 2E8B2E[1000]        <3>  mov bp,[cs:NextEntry]
   174                              <3> Allocated equ allocated
   175 000004E1 B001                <3>  mov al,Allocated
   176 000004E3 26864600            <3>  xchg [AllocByte],al
   177 000004E7 3C00                <3>  cmp al,Free
   178 000004E9 7542                <3>  jne NotFree%1
   179                              <3> 
   180 000004EB 2E832E[1000]08      <3>  sub word [cs:NextEntry],EntrySize
   181                              <3> 
   182                              <3> Found%1:
   183 000004F1 26896602            <3>  mov [SavedSP],sp
   184 000004F5 268C5604            <3>  mov [SavedSS],ss
   185                              <3> 
   186                              <3> 
   187 000004F9 89E8                <3>  mov ax,bp
   188                              <3> 
   189 000004FB 268B6E06            <3>  mov bp,[NewSP]
   190 000004FF 26394600            <3>  cmp [es:bp],ax
   191 00000503 7535                <3>  jne FoundBad%1
   192                              <3> 
   193 00000505 8CC0                <3>  mov ax,es
   194 00000507 8ED0                <3>  mov ss,ax
   195 00000509 89EC                <3>  mov sp,bp
   196                              <3>  assume ss:STACKSCODE
   197                              <3> 
   198 0000050B 9C                  <3>  pushf
   199 0000050C 2EFF1E[C404]        <3>  call far [cs:Old%1]
   200                              <3> 
   201 00000511 89E5                <3>  mov bp,sp
   202 00000513 268B6E00            <3>  mov bp,[es:bp]
   203 00000517 268E5604            <3>  mov ss,[SavedSS]
   204 0000051B 268B6602            <3>  mov sp,[SavedSP]
   205                              <3>  assume ss:nothing
   206                              <3> 
   207                              <3> 
   208                              <3> 
   209                              <3> 
   210 0000051F 26C6460000          <3>  mov byte [AllocByte],Free
   211 00000524 2E892E[1000]        <3>  mov [cs:NextEntry],bp
   212                              <3> 
   213                              <3> NewError%1:
   214 00000529 07                  <3>  pop es
   215                              <3>  assume es:nothing
   216 0000052A 5D                  <3>  pop bp
   217 0000052B 58                  <3>  pop ax
   218                              <3> 
   219                              <3> INTRET_%1:
   220 0000052C CF                  <3>  iret
   221                              <3> Intret_%1 equ INTRET_%1
   222                              <3> 
   223                              <3> NotFree%1:
   224 0000052D 3C01                <3>  cmp al,Allocated
   225 0000052F 7404                <3>  je FindNext%1
   226 00000531 26864600            <3>  xchg [AllocByte],al
   227                              <3> 
   228                              <3> FindNext%1:
   229                              <3> LongPath equ longpath
   230 00000535 E83202              <3>  call LongPath
   231 00000538 EBB7                <3>  jmp Found%1
   232                              <3> 
   233                              <3> FoundBad%1:
   234 0000053A 2E3B2E[0C00]        <3>  cmp bp,[cs:FirstEntry]
   235 0000053F 72F4                <3>  jc FindNext%1
   236 00000541 89C5                <3>  mov bp,ax
   237                              <3> Clobbered equ clobbered
   238 00000543 26C6460003          <3>  mov byte [AllocByte],Clobbered
   239                              <3> 
   240                              <3> 
   241                              <3> 
   242 00000548 EBEB                <3>  jmp FindNext%1
   243                              <3> 
   244                              <3> int%1 endp
   245                              <3>  %rotate 1
    72                              <3>  ASSUME DS:NOTHING
    73                              <3>  ASSUME ES:NOTHING
    74                              <3>  ASSUME SS:NOTHING
    75                              <3> PUBLIC Int%1
    76                              <3> PUBLIC Old%1
    77                              <3> 
    78                              <3>  %ifn IntSharingFlag
    79                              <3> 
    80                              <3>  Old%1 DD 0
    81                              <3> Int%1 PROC FAR
    82                              <3> 
    83                              <3>  %else
    84                              <3> 
    85                              <3> PUBLIC FirstFlag%1
    86                              <3> Int%1 PROC FAR
    87 0000054A EB10                <3>  jmp short Entry_Int%1_Stk
    88 0000054C 00000000            <3>  Old%1 dd 0
    89 00000550 4B42                <3>  dw 424Bh
    90 00000552 00                  <3>  FirstFlag%1 db 0
    91 00000553 EB5F                <3>  jmp short Intret_%1
    92 00000555 00000000000000      <3>  db 7 dup (0)
    93                              <3> Entry_Int%1_Stk:
    94                              <3> 
    95                              <3>  %endif
    96                              <3> 
    97                              <3> INT%1 equ Int%1
    98                              <3> OLD%1 equ Old%1
    99                              <3> 
   100                              <3> 
   101                              <3> 
   102                              <3> 
   103                              <3>  %ifidni %1, 09
   104                              <3>  jmp short Keyboard_lbl
   105                              <3>  nop
   106                              <3>  nop
   107                              <3>  db 0
   108                              <3> Keyboard_lbl label near
   109                              <3>  %endif
   110                              <3> 
   111                              <3> 
   112                              <3> 
   113                              <3> 
   114 0000055C 50                  <3>  push ax
   115                              <3> 
   116                              <3>  %ifidni %1, 02
   117                              <3> 
   118                              <3> 
   119                              <3> 
   120                              <3> 
   121                              <3> 
   122                              <3> 
   123                              <3> 
   124                              <3> 
   125                              <3> 
   126                              <3> 
   127                              <3> 
   128                              <3> 
   129                              <3> 
   130                              <3> 
   131                              <3> 
   132                              <3> 
   133                              <3> 
   134                              <3> 
   135                              <3> 
   136                              <3> 
   137                              <3> 
   138                              <3> 
   139                              <3> 
   140                              <3> 
   141                              <3> 
   142                              <3> 
   143                              <3>  push es
   144                              <3>  mov ax,0f000h
   145                              <3>  mov es,ax
   146                              <3>  assume es:nothing
   147                              <3> mdl_convert equ MDL_CONVERT
   148                              <3>  cmp byte ptr [es:0fffeh],mdl_convert
   149                              <3>  pop es
   150                              <3>  assume es:nothing
   151                              <3>  jne Normal%1
   152                              <3> 
   153                              <3>  in al,62h
   154                              <3>  test al,80h
   155                              <3>  jz Normal%1
   156                              <3> 
   157                              <3> Special%1:
   158                              <3>  pop ax
   159                              <3>  jmp far [cs:Old%1]
   160                              <3> 
   161                              <3> Normal%1:
   162                              <3> 
   163                              <3> 
   164                              <3> 
   165                              <3>  %endif
   166                              <3> 
   167 0000055D 55                  <3>  push bp
   168 0000055E 06                  <3>  push es
   169                              <3> STACKS equ Stacks
   170 0000055F 2E8E06[0A00]        <3>  mov es, [cs:STACKS+2]
   171                              <3>  assume es:STACKSCODE
   172                              <3> 
   173 00000564 2E8B2E[1000]        <3>  mov bp,[cs:NextEntry]
   174                              <3> Allocated equ allocated
   175 00000569 B001                <3>  mov al,Allocated
   176 0000056B 26864600            <3>  xchg [AllocByte],al
   177 0000056F 3C00                <3>  cmp al,Free
   178 00000571 7542                <3>  jne NotFree%1
   179                              <3> 
   180 00000573 2E832E[1000]08      <3>  sub word [cs:NextEntry],EntrySize
   181                              <3> 
   182                              <3> Found%1:
   183 00000579 26896602            <3>  mov [SavedSP],sp
   184 0000057D 268C5604            <3>  mov [SavedSS],ss
   185                              <3> 
   186                              <3> 
   187 00000581 89E8                <3>  mov ax,bp
   188                              <3> 
   189 00000583 268B6E06            <3>  mov bp,[NewSP]
   190 00000587 26394600            <3>  cmp [es:bp],ax
   191 0000058B 7535                <3>  jne FoundBad%1
   192                              <3> 
   193 0000058D 8CC0                <3>  mov ax,es
   194 0000058F 8ED0                <3>  mov ss,ax
   195 00000591 89EC                <3>  mov sp,bp
   196                              <3>  assume ss:STACKSCODE
   197                              <3> 
   198 00000593 9C                  <3>  pushf
   199 00000594 2EFF1E[4C05]        <3>  call far [cs:Old%1]
   200                              <3> 
   201 00000599 89E5                <3>  mov bp,sp
   202 0000059B 268B6E00            <3>  mov bp,[es:bp]
   203 0000059F 268E5604            <3>  mov ss,[SavedSS]
   204 000005A3 268B6602            <3>  mov sp,[SavedSP]
   205                              <3>  assume ss:nothing
   206                              <3> 
   207                              <3> 
   208                              <3> 
   209                              <3> 
   210 000005A7 26C6460000          <3>  mov byte [AllocByte],Free
   211 000005AC 2E892E[1000]        <3>  mov [cs:NextEntry],bp
   212                              <3> 
   213                              <3> NewError%1:
   214 000005B1 07                  <3>  pop es
   215                              <3>  assume es:nothing
   216 000005B2 5D                  <3>  pop bp
   217 000005B3 58                  <3>  pop ax
   218                              <3> 
   219                              <3> INTRET_%1:
   220 000005B4 CF                  <3>  iret
   221                              <3> Intret_%1 equ INTRET_%1
   222                              <3> 
   223                              <3> NotFree%1:
   224 000005B5 3C01                <3>  cmp al,Allocated
   225 000005B7 7404                <3>  je FindNext%1
   226 000005B9 26864600            <3>  xchg [AllocByte],al
   227                              <3> 
   228                              <3> FindNext%1:
   229                              <3> LongPath equ longpath
   230 000005BD E8AA01              <3>  call LongPath
   231 000005C0 EBB7                <3>  jmp Found%1
   232                              <3> 
   233                              <3> FoundBad%1:
   234 000005C2 2E3B2E[0C00]        <3>  cmp bp,[cs:FirstEntry]
   235 000005C7 72F4                <3>  jc FindNext%1
   236 000005C9 89C5                <3>  mov bp,ax
   237                              <3> Clobbered equ clobbered
   238 000005CB 26C6460003          <3>  mov byte [AllocByte],Clobbered
   239                              <3> 
   240                              <3> 
   241                              <3> 
   242 000005D0 EBEB                <3>  jmp FindNext%1
   243                              <3> 
   244                              <3> int%1 endp
   245                              <3>  %rotate 1
    72                              <3>  ASSUME DS:NOTHING
    73                              <3>  ASSUME ES:NOTHING
    74                              <3>  ASSUME SS:NOTHING
    75                              <3> PUBLIC Int%1
    76                              <3> PUBLIC Old%1
    77                              <3> 
    78                              <3>  %ifn IntSharingFlag
    79                              <3> 
    80                              <3>  Old%1 DD 0
    81                              <3> Int%1 PROC FAR
    82                              <3> 
    83                              <3>  %else
    84                              <3> 
    85                              <3> PUBLIC FirstFlag%1
    86                              <3> Int%1 PROC FAR
    87 000005D2 EB10                <3>  jmp short Entry_Int%1_Stk
    88 000005D4 00000000            <3>  Old%1 dd 0
    89 000005D8 4B42                <3>  dw 424Bh
    90 000005DA 00                  <3>  FirstFlag%1 db 0
    91 000005DB EB5F                <3>  jmp short Intret_%1
    92 000005DD 00000000000000      <3>  db 7 dup (0)
    93                              <3> Entry_Int%1_Stk:
    94                              <3> 
    95                              <3>  %endif
    96                              <3> 
    97                              <3> INT%1 equ Int%1
    98                              <3> OLD%1 equ Old%1
    99                              <3> 
   100                              <3> 
   101                              <3> 
   102                              <3> 
   103                              <3>  %ifidni %1, 09
   104                              <3>  jmp short Keyboard_lbl
   105                              <3>  nop
   106                              <3>  nop
   107                              <3>  db 0
   108                              <3> Keyboard_lbl label near
   109                              <3>  %endif
   110                              <3> 
   111                              <3> 
   112                              <3> 
   113                              <3> 
   114 000005E4 50                  <3>  push ax
   115                              <3> 
   116                              <3>  %ifidni %1, 02
   117                              <3> 
   118                              <3> 
   119                              <3> 
   120                              <3> 
   121                              <3> 
   122                              <3> 
   123                              <3> 
   124                              <3> 
   125                              <3> 
   126                              <3> 
   127                              <3> 
   128                              <3> 
   129                              <3> 
   130                              <3> 
   131                              <3> 
   132                              <3> 
   133                              <3> 
   134                              <3> 
   135                              <3> 
   136                              <3> 
   137                              <3> 
   138                              <3> 
   139                              <3> 
   140                              <3> 
   141                              <3> 
   142                              <3> 
   143                              <3>  push es
   144                              <3>  mov ax,0f000h
   145                              <3>  mov es,ax
   146                              <3>  assume es:nothing
   147                              <3> mdl_convert equ MDL_CONVERT
   148                              <3>  cmp byte ptr [es:0fffeh],mdl_convert
   149                              <3>  pop es
   150                              <3>  assume es:nothing
   151                              <3>  jne Normal%1
   152                              <3> 
   153                              <3>  in al,62h
   154                              <3>  test al,80h
   155                              <3>  jz Normal%1
   156                              <3> 
   157                              <3> Special%1:
   158                              <3>  pop ax
   159                              <3>  jmp far [cs:Old%1]
   160                              <3> 
   161                              <3> Normal%1:
   162                              <3> 
   163                              <3> 
   164                              <3> 
   165                              <3>  %endif
   166                              <3> 
   167 000005E5 55                  <3>  push bp
   168 000005E6 06                  <3>  push es
   169                              <3> STACKS equ Stacks
   170 000005E7 2E8E06[0A00]        <3>  mov es, [cs:STACKS+2]
   171                              <3>  assume es:STACKSCODE
   172                              <3> 
   173 000005EC 2E8B2E[1000]        <3>  mov bp,[cs:NextEntry]
   174                              <3> Allocated equ allocated
   175 000005F1 B001                <3>  mov al,Allocated
   176 000005F3 26864600            <3>  xchg [AllocByte],al
   177 000005F7 3C00                <3>  cmp al,Free
   178 000005F9 7542                <3>  jne NotFree%1
   179                              <3> 
   180 000005FB 2E832E[1000]08      <3>  sub word [cs:NextEntry],EntrySize
   181                              <3> 
   182                              <3> Found%1:
   183 00000601 26896602            <3>  mov [SavedSP],sp
   184 00000605 268C5604            <3>  mov [SavedSS],ss
   185                              <3> 
   186                              <3> 
   187 00000609 89E8                <3>  mov ax,bp
   188                              <3> 
   189 0000060B 268B6E06            <3>  mov bp,[NewSP]
   190 0000060F 26394600            <3>  cmp [es:bp],ax
   191 00000613 7535                <3>  jne FoundBad%1
   192                              <3> 
   193 00000615 8CC0                <3>  mov ax,es
   194 00000617 8ED0                <3>  mov ss,ax
   195 00000619 89EC                <3>  mov sp,bp
   196                              <3>  assume ss:STACKSCODE
   197                              <3> 
   198 0000061B 9C                  <3>  pushf
   199 0000061C 2EFF1E[D405]        <3>  call far [cs:Old%1]
   200                              <3> 
   201 00000621 89E5                <3>  mov bp,sp
   202 00000623 268B6E00            <3>  mov bp,[es:bp]
   203 00000627 268E5604            <3>  mov ss,[SavedSS]
   204 0000062B 268B6602            <3>  mov sp,[SavedSP]
   205                              <3>  assume ss:nothing
   206                              <3> 
   207                              <3> 
   208                              <3> 
   209                              <3> 
   210 0000062F 26C6460000          <3>  mov byte [AllocByte],Free
   211 00000634 2E892E[1000]        <3>  mov [cs:NextEntry],bp
   212                              <3> 
   213                              <3> NewError%1:
   214 00000639 07                  <3>  pop es
   215                              <3>  assume es:nothing
   216 0000063A 5D                  <3>  pop bp
   217 0000063B 58                  <3>  pop ax
   218                              <3> 
   219                              <3> INTRET_%1:
   220 0000063C CF                  <3>  iret
   221                              <3> Intret_%1 equ INTRET_%1
   222                              <3> 
   223                              <3> NotFree%1:
   224 0000063D 3C01                <3>  cmp al,Allocated
   225 0000063F 7404                <3>  je FindNext%1
   226 00000641 26864600            <3>  xchg [AllocByte],al
   227                              <3> 
   228                              <3> FindNext%1:
   229                              <3> LongPath equ longpath
   230 00000645 E82201              <3>  call LongPath
   231 00000648 EBB7                <3>  jmp Found%1
   232                              <3> 
   233                              <3> FoundBad%1:
   234 0000064A 2E3B2E[0C00]        <3>  cmp bp,[cs:FirstEntry]
   235 0000064F 72F4                <3>  jc FindNext%1
   236 00000651 89C5                <3>  mov bp,ax
   237                              <3> Clobbered equ clobbered
   238 00000653 26C6460003          <3>  mov byte [AllocByte],Clobbered
   239                              <3> 
   240                              <3> 
   241                              <3> 
   242 00000658 EBEB                <3>  jmp FindNext%1
   243                              <3> 
   244                              <3> int%1 endp
   245                              <3>  %rotate 1
    72                              <3>  ASSUME DS:NOTHING
    73                              <3>  ASSUME ES:NOTHING
    74                              <3>  ASSUME SS:NOTHING
    75                              <3> PUBLIC Int%1
    76                              <3> PUBLIC Old%1
    77                              <3> 
    78                              <3>  %ifn IntSharingFlag
    79                              <3> 
    80                              <3>  Old%1 DD 0
    81                              <3> Int%1 PROC FAR
    82                              <3> 
    83                              <3>  %else
    84                              <3> 
    85                              <3> PUBLIC FirstFlag%1
    86                              <3> Int%1 PROC FAR
    87 0000065A EB10                <3>  jmp short Entry_Int%1_Stk
    88 0000065C 00000000            <3>  Old%1 dd 0
    89 00000660 4B42                <3>  dw 424Bh
    90 00000662 00                  <3>  FirstFlag%1 db 0
    91 00000663 EB5F                <3>  jmp short Intret_%1
    92 00000665 00000000000000      <3>  db 7 dup (0)
    93                              <3> Entry_Int%1_Stk:
    94                              <3> 
    95                              <3>  %endif
    96                              <3> 
    97                              <3> INT%1 equ Int%1
    98                              <3> OLD%1 equ Old%1
    99                              <3> 
   100                              <3> 
   101                              <3> 
   102                              <3> 
   103                              <3>  %ifidni %1, 09
   104                              <3>  jmp short Keyboard_lbl
   105                              <3>  nop
   106                              <3>  nop
   107                              <3>  db 0
   108                              <3> Keyboard_lbl label near
   109                              <3>  %endif
   110                              <3> 
   111                              <3> 
   112                              <3> 
   113                              <3> 
   114 0000066C 50                  <3>  push ax
   115                              <3> 
   116                              <3>  %ifidni %1, 02
   117                              <3> 
   118                              <3> 
   119                              <3> 
   120                              <3> 
   121                              <3> 
   122                              <3> 
   123                              <3> 
   124                              <3> 
   125                              <3> 
   126                              <3> 
   127                              <3> 
   128                              <3> 
   129                              <3> 
   130                              <3> 
   131                              <3> 
   132                              <3> 
   133                              <3> 
   134                              <3> 
   135                              <3> 
   136                              <3> 
   137                              <3> 
   138                              <3> 
   139                              <3> 
   140                              <3> 
   141                              <3> 
   142                              <3> 
   143                              <3>  push es
   144                              <3>  mov ax,0f000h
   145                              <3>  mov es,ax
   146                              <3>  assume es:nothing
   147                              <3> mdl_convert equ MDL_CONVERT
   148                              <3>  cmp byte ptr [es:0fffeh],mdl_convert
   149                              <3>  pop es
   150                              <3>  assume es:nothing
   151                              <3>  jne Normal%1
   152                              <3> 
   153                              <3>  in al,62h
   154                              <3>  test al,80h
   155                              <3>  jz Normal%1
   156                              <3> 
   157                              <3> Special%1:
   158                              <3>  pop ax
   159                              <3>  jmp far [cs:Old%1]
   160                              <3> 
   161                              <3> Normal%1:
   162                              <3> 
   163                              <3> 
   164                              <3> 
   165                              <3>  %endif
   166                              <3> 
   167 0000066D 55                  <3>  push bp
   168 0000066E 06                  <3>  push es
   169                              <3> STACKS equ Stacks
   170 0000066F 2E8E06[0A00]        <3>  mov es, [cs:STACKS+2]
   171                              <3>  assume es:STACKSCODE
   172                              <3> 
   173 00000674 2E8B2E[1000]        <3>  mov bp,[cs:NextEntry]
   174                              <3> Allocated equ allocated
   175 00000679 B001                <3>  mov al,Allocated
   176 0000067B 26864600            <3>  xchg [AllocByte],al
   177 0000067F 3C00                <3>  cmp al,Free
   178 00000681 7542                <3>  jne NotFree%1
   179                              <3> 
   180 00000683 2E832E[1000]08      <3>  sub word [cs:NextEntry],EntrySize
   181                              <3> 
   182                              <3> Found%1:
   183 00000689 26896602            <3>  mov [SavedSP],sp
   184 0000068D 268C5604            <3>  mov [SavedSS],ss
   185                              <3> 
   186                              <3> 
   187 00000691 89E8                <3>  mov ax,bp
   188                              <3> 
   189 00000693 268B6E06            <3>  mov bp,[NewSP]
   190 00000697 26394600            <3>  cmp [es:bp],ax
   191 0000069B 7535                <3>  jne FoundBad%1
   192                              <3> 
   193 0000069D 8CC0                <3>  mov ax,es
   194 0000069F 8ED0                <3>  mov ss,ax
   195 000006A1 89EC                <3>  mov sp,bp
   196                              <3>  assume ss:STACKSCODE
   197                              <3> 
   198 000006A3 9C                  <3>  pushf
   199 000006A4 2EFF1E[5C06]        <3>  call far [cs:Old%1]
   200                              <3> 
   201 000006A9 89E5                <3>  mov bp,sp
   202 000006AB 268B6E00            <3>  mov bp,[es:bp]
   203 000006AF 268E5604            <3>  mov ss,[SavedSS]
   204 000006B3 268B6602            <3>  mov sp,[SavedSP]
   205                              <3>  assume ss:nothing
   206                              <3> 
   207                              <3> 
   208                              <3> 
   209                              <3> 
   210 000006B7 26C6460000          <3>  mov byte [AllocByte],Free
   211 000006BC 2E892E[1000]        <3>  mov [cs:NextEntry],bp
   212                              <3> 
   213                              <3> NewError%1:
   214 000006C1 07                  <3>  pop es
   215                              <3>  assume es:nothing
   216 000006C2 5D                  <3>  pop bp
   217 000006C3 58                  <3>  pop ax
   218                              <3> 
   219                              <3> INTRET_%1:
   220 000006C4 CF                  <3>  iret
   221                              <3> Intret_%1 equ INTRET_%1
   222                              <3> 
   223                              <3> NotFree%1:
   224 000006C5 3C01                <3>  cmp al,Allocated
   225 000006C7 7404                <3>  je FindNext%1
   226 000006C9 26864600            <3>  xchg [AllocByte],al
   227                              <3> 
   228                              <3> FindNext%1:
   229                              <3> LongPath equ longpath
   230 000006CD E89A00              <3>  call LongPath
   231 000006D0 EBB7                <3>  jmp Found%1
   232                              <3> 
   233                              <3> FoundBad%1:
   234 000006D2 2E3B2E[0C00]        <3>  cmp bp,[cs:FirstEntry]
   235 000006D7 72F4                <3>  jc FindNext%1
   236 000006D9 89C5                <3>  mov bp,ax
   237                              <3> Clobbered equ clobbered
   238 000006DB 26C6460003          <3>  mov byte [AllocByte],Clobbered
   239                              <3> 
   240                              <3> 
   241                              <3> 
   242 000006E0 EBEB                <3>  jmp FindNext%1
   243                              <3> 
   244                              <3> int%1 endp
   245                              <3>  %rotate 1
    72                              <3>  ASSUME DS:NOTHING
    73                              <3>  ASSUME ES:NOTHING
    74                              <3>  ASSUME SS:NOTHING
    75                              <3> PUBLIC Int%1
    76                              <3> PUBLIC Old%1
    77                              <3> 
    78                              <3>  %ifn IntSharingFlag
    79                              <3> 
    80                              <3>  Old%1 DD 0
    81                              <3> Int%1 PROC FAR
    82                              <3> 
    83                              <3>  %else
    84                              <3> 
    85                              <3> PUBLIC FirstFlag%1
    86                              <3> Int%1 PROC FAR
    87 000006E2 EB10                <3>  jmp short Entry_Int%1_Stk
    88 000006E4 00000000            <3>  Old%1 dd 0
    89 000006E8 4B42                <3>  dw 424Bh
    90 000006EA 00                  <3>  FirstFlag%1 db 0
    91 000006EB EB5F                <3>  jmp short Intret_%1
    92 000006ED 00000000000000      <3>  db 7 dup (0)
    93                              <3> Entry_Int%1_Stk:
    94                              <3> 
    95                              <3>  %endif
    96                              <3> 
    97                              <3> INT%1 equ Int%1
    98                              <3> OLD%1 equ Old%1
    99                              <3> 
   100                              <3> 
   101                              <3> 
   102                              <3> 
   103                              <3>  %ifidni %1, 09
   104                              <3>  jmp short Keyboard_lbl
   105                              <3>  nop
   106                              <3>  nop
   107                              <3>  db 0
   108                              <3> Keyboard_lbl label near
   109                              <3>  %endif
   110                              <3> 
   111                              <3> 
   112                              <3> 
   113                              <3> 
   114 000006F4 50                  <3>  push ax
   115                              <3> 
   116                              <3>  %ifidni %1, 02
   117                              <3> 
   118                              <3> 
   119                              <3> 
   120                              <3> 
   121                              <3> 
   122                              <3> 
   123                              <3> 
   124                              <3> 
   125                              <3> 
   126                              <3> 
   127                              <3> 
   128                              <3> 
   129                              <3> 
   130                              <3> 
   131                              <3> 
   132                              <3> 
   133                              <3> 
   134                              <3> 
   135                              <3> 
   136                              <3> 
   137                              <3> 
   138                              <3> 
   139                              <3> 
   140                              <3> 
   141                              <3> 
   142                              <3> 
   143                              <3>  push es
   144                              <3>  mov ax,0f000h
   145                              <3>  mov es,ax
   146                              <3>  assume es:nothing
   147                              <3> mdl_convert equ MDL_CONVERT
   148                              <3>  cmp byte ptr [es:0fffeh],mdl_convert
   149                              <3>  pop es
   150                              <3>  assume es:nothing
   151                              <3>  jne Normal%1
   152                              <3> 
   153                              <3>  in al,62h
   154                              <3>  test al,80h
   155                              <3>  jz Normal%1
   156                              <3> 
   157                              <3> Special%1:
   158                              <3>  pop ax
   159                              <3>  jmp far [cs:Old%1]
   160                              <3> 
   161                              <3> Normal%1:
   162                              <3> 
   163                              <3> 
   164                              <3> 
   165                              <3>  %endif
   166                              <3> 
   167 000006F5 55                  <3>  push bp
   168 000006F6 06                  <3>  push es
   169                              <3> STACKS equ Stacks
   170 000006F7 2E8E06[0A00]        <3>  mov es, [cs:STACKS+2]
   171                              <3>  assume es:STACKSCODE
   172                              <3> 
   173 000006FC 2E8B2E[1000]        <3>  mov bp,[cs:NextEntry]
   174                              <3> Allocated equ allocated
   175 00000701 B001                <3>  mov al,Allocated
   176 00000703 26864600            <3>  xchg [AllocByte],al
   177 00000707 3C00                <3>  cmp al,Free
   178 00000709 7542                <3>  jne NotFree%1
   179                              <3> 
   180 0000070B 2E832E[1000]08      <3>  sub word [cs:NextEntry],EntrySize
   181                              <3> 
   182                              <3> Found%1:
   183 00000711 26896602            <3>  mov [SavedSP],sp
   184 00000715 268C5604            <3>  mov [SavedSS],ss
   185                              <3> 
   186                              <3> 
   187 00000719 89E8                <3>  mov ax,bp
   188                              <3> 
   189 0000071B 268B6E06            <3>  mov bp,[NewSP]
   190 0000071F 26394600            <3>  cmp [es:bp],ax
   191 00000723 7535                <3>  jne FoundBad%1
   192                              <3> 
   193 00000725 8CC0                <3>  mov ax,es
   194 00000727 8ED0                <3>  mov ss,ax
   195 00000729 89EC                <3>  mov sp,bp
   196                              <3>  assume ss:STACKSCODE
   197                              <3> 
   198 0000072B 9C                  <3>  pushf
   199 0000072C 2EFF1E[E406]        <3>  call far [cs:Old%1]
   200                              <3> 
   201 00000731 89E5                <3>  mov bp,sp
   202 00000733 268B6E00            <3>  mov bp,[es:bp]
   203 00000737 268E5604            <3>  mov ss,[SavedSS]
   204 0000073B 268B6602            <3>  mov sp,[SavedSP]
   205                              <3>  assume ss:nothing
   206                              <3> 
   207                              <3> 
   208                              <3> 
   209                              <3> 
   210 0000073F 26C6460000          <3>  mov byte [AllocByte],Free
   211 00000744 2E892E[1000]        <3>  mov [cs:NextEntry],bp
   212                              <3> 
   213                              <3> NewError%1:
   214 00000749 07                  <3>  pop es
   215                              <3>  assume es:nothing
   216 0000074A 5D                  <3>  pop bp
   217 0000074B 58                  <3>  pop ax
   218                              <3> 
   219                              <3> INTRET_%1:
   220 0000074C CF                  <3>  iret
   221                              <3> Intret_%1 equ INTRET_%1
   222                              <3> 
   223                              <3> NotFree%1:
   224 0000074D 3C01                <3>  cmp al,Allocated
   225 0000074F 7404                <3>  je FindNext%1
   226 00000751 26864600            <3>  xchg [AllocByte],al
   227                              <3> 
   228                              <3> FindNext%1:
   229                              <3> LongPath equ longpath
   230 00000755 E81200              <3>  call LongPath
   231 00000758 EBB7                <3>  jmp Found%1
   232                              <3> 
   233                              <3> FoundBad%1:
   234 0000075A 2E3B2E[0C00]        <3>  cmp bp,[cs:FirstEntry]
   235 0000075F 72F4                <3>  jc FindNext%1
   236 00000761 89C5                <3>  mov bp,ax
   237                              <3> Clobbered equ clobbered
   238 00000763 26C6460003          <3>  mov byte [AllocByte],Clobbered
   239                              <3> 
   240                              <3> 
   241                              <3> 
   242 00000768 EBEB                <3>  jmp FindNext%1
   243                              <3> 
   244                              <3> int%1 endp
   245                              <3>  %rotate 1
   259                              <1> 
   260                              <1> ;********************************************************************	  ;3.30
   261                              <1> ;Common routines							  ;3.30
   262                              <1> 
   263                              <1> longpath:
   264 0000076A 2E8B2E[0E00]        <1> 	mov	bp,[cs:LastEntry]		; start with last entry in table
   265                              <1> 
   266                              <1> LPLOOPP:								  ;3.30
   267 0000076F 26807E0000          <1> 	cmp	byte [AllocByte],Free		; is entry free?
   268 00000774 7512                <1> 	jne	.inuse			;  no, try next one
   269                              <1> 
   270 00000776 B001                <1> 	mov	al,Allocated
   271 00000778 26864600            <1> 	xchg	[AllocByte],al		; allocate entry
   272 0000077C 3C00                <1> 	cmp	al,Free 		; is it still free?
   273 0000077E 7414                <1> 	je	.found			;  yes, go use it
   274                              <1> 
   275 00000780 3C01                <1> 	cmp	al,Allocated		; is it other than Allocated or Free?
   276 00000782 7404                <1> 	je	.inuse			;  no, check the next one
   277                              <1> 
   278 00000784 26884600            <1> 	mov	[AllocByte],al		;  yes, put back the error state
   279                              <1> 
   280                              <1> .inuse:
   281 00000788 2E3B2E[0C00]        <1> 	cmp	bp,[cs:FirstEntry]
   282                              <1> stack_Fatal equ stack_fatal	; NASM port label
   283 0000078D 7406                <1> 	je	stack_Fatal
   284 0000078F 83ED08              <1> 	sub	bp,EntrySize
   285 00000792 EBDB                <1> 	JMP	LPLOOPP 						  ;3.30
   286                              <1> 
   287                              <1> .found:
   288 00000794 C3                  <1> 	ret
   289                              <1> 
   290                              <1> ;	page
   291                              <1> 
   292                              <1> stack_fatal	proc	near
   293 00000795 1E                  <1> 	push	ds							  ;3.30
   294 00000796 B800F0              <1> 	mov	ax, 0f000h		;loook at the model byte	  ;3.30
   295 00000799 8ED8                <1> 	mov	ds, ax
   296                              <1>  assume ds:nothing
   297 0000079B 803EFEFFF9          <1> 	cmp	byte ptr [0fffeh], mdl_convert	;convertible?	  ;3.30
   298 000007A0 1F                  <1> 	pop	ds							  ;3.30
   299                              <1>  assume ds:nothing
   300 000007A1 7504                <1> 	jne	Skip_NMIS						  ;3.30
   301                              <1> 									  ;3.30
   302 000007A3 B007                <1> 	mov	al,07h				; disable PC Convertible NMIs
   303 000007A5 E672                <1> 	out	72h,al
   304                              <1> 
   305                              <1> Skip_NMIS:								  ;3.30
   306 000007A7 FA                  <1> 	cli					; disable and mask
   307 000007A8 B0FF                <1> 	mov	al,0ffh 			;   all other ints
   308 000007AA E621                <1> 	out	021h,al
   309 000007AC E6A1                <1> 	out	0a1h,al
   310                              <1> 
   311 000007AE 8CCE                <1> 	mov	si,cs
   312 000007B0 8EDE                <1> 	mov	ds,si
   313                              <1>  assume ds:STACKSCODE
   314                              <1> fatal_msg equ FATAL_MSG	; NASM port label
   315 000007B2 BE[C407]            <1> 	mov	si,offset fatal_msg
   316                              <1> 
   317                              <1> fatal_loop:
   318 000007B5 AC                  <1> 	lodsb
   319 000007B6 3C24                <1> 	cmp	al,'$'
   320 000007B8 7408                <1> 	je	fatal_done
   321                              <1> 
   322 000007BA B307                <1> 	mov	bl,7						      ;3.30*
   323 000007BC B40E                <1> 	mov	ah,14						      ;3.30*
   324 000007BE CD10                <1> 	int	010h			; whoops, this enables ints   ;3.30*
   325 000007C0 EBF3                <1> 	jmp	fatal_loop
   326                              <1> 
   327                              <1> fatal_done:
   328 000007C2 EBFE                <1> 	jmp	fatal_done
   329                              <1> stack_fatal	endp
   330                              <1> 
   331                              <1>  assume cs:SYSINITGROUP
   274                                  ;=== Pop trace listing source
   275                                  ;	  include STKMES.INC		;Fatal stack error message
   276                                  ;=== Push trace listing source: msbio.cl5
   277                                  	  %include "msbio.cl5"		;Fatal stack error message ; NASM included file
     1                              <1> ; msbio.cl5 
     2                              <1> 
     3                              <1> 
     4                              <1> ;_______________________
     5                              <1> 
     6 000007C4 0D0A070D0A496E7465- <1> FATAL_MSG DB    0DH,0AH,7,0DH,0AH, "Internal stack overflow",0DH,0AH
     6 000007CD 726E616C2073746163- <1>
     6 000007D6 6B206F766572666C6F- <1>
     6 000007DF 770D0A              <1>
     7 000007E2 53797374656D206861- <1> 	DB   	"System halted",0DH,0AH,"$"
     7 000007EB 6C7465640D0A24      <1>
   278                                  ;=== Pop trace listing source
   279                                  ;.XALL
   280                                  	align 2, nop
   281                                  	    public Endstackcode
   282                                  Endstackcode	label byte
   283                                  	%ENDIF
   284                                  
   285                                  
   286                                  	even
   287                                  DOSINFO 		LABEL	DWORD
   288 000007F2 00000000                			DW	0,0
   289                                  
   290                                  ENTRY_POINT		LABEL	DWORD
   291 000007F6 00000000                			dw 0, 0
   292                                  
   293 000007FA 0000                    behind_dosentry_segment	DW	0000
   294                                   global verbose_mode
   295 000007FC 0000                    verbose_mode:		dw 0			; high byte is clobbered
   296                                  DEVICE_LIST:
   297 000007FE [00FF][ssss]             dw CONHEADER - DOSENTRYDEVICEBASE * 16, seg CONHEADER + DOSENTRYDEVICEBASE
   298                                  
   299                                  SYSI_Country		LABEL	DWORD		;J.K. 5/29/86 Pointer to
   300 00000802 0000                    			DW	0000		;country table in DOS
   301 00000804 0000                    			DW	0000
   302                                  
   303 00000806 00                      Fake_Floppy_Drv 	db	0		;AN001;Set to 1 if this machine
   304                                  						;does not have any floppies!!!
   305 00000807 00                      Big_Media_Flag		db	0		;AN021;Set by IBMINIT if > 32 MB fixed media exist.
   306 00000808 00                      verbose_hide_cds:	db 0
   307                                  
   308 00000809 00                      	even
   309                                   global sysinit_bootdrive_hidden, sysinit_bootdrive_unit
   310                                   global sysinit_have_bootdrive_preliminary
   311                                   global sysinit_have_bootdrive_exact
   312 0000080A 00000000                sysinit_bootdrive_hidden:	dd 0
   313 0000080E 00                      sysinit_bootdrive_unit:		db 0
   314 0000080F 00                      sysinit_have_bootdrive_preliminary:	db 0
   315 00000810 00                      sysinit_have_bootdrive_exact:		db 0
   316                                  
   317                                   global dosdata_relocate_first, dosdata_relocate_early
   318                                  dosdata_relocated_to_final_position:
   319 00000811 00                      			db 0
   320 00000812 00                      dosdata_relocate_first:	db 0
   321 00000813 00                      dosdata_relocate_early:	db 0
   322                                  doscode_relocated_to_final_position:
   323 00000814 00                      			db 0
   324                                  
   325 00000815 00                      	even
   326                                  ;
   327                                  ;Variables for Stack Initialization Program.
   328                                  	%IF	STACKSW
   329 00000816 0900                    STACK_COUNT		DW	DefaultCount
   330 00000818 8000                    STACK_SIZE		DW	DefaultSize
   331 0000081A 00000000                STACK_ADDR		DD	00000000
   332                                  	%ENDIF
   333                                  ; various default values
   334                                  
   335 0000081E 0100                    MEMORY_SIZE		DW	0001
   336 00000820 00                      DEFAULT_DRIVE		DB	00	;initialized by IBMINIT.
   337 00000821 FFFF                    BUFFERS 		DW	-1	; initialized during buffer allocation
   338 00000823 0000                    H_Buffers		dw	0	;AN000; # of the Heuristic buffers. Initially 0.
   339                                  %ifndef BUF2
   340                                  Buffer_Pages		dw	0	;AN000; # of extended memory pages for the buffer.
   341                                  BufferBuckets		dw	0	;AN000;
   342                                  Buffer_odds		dw	0	;AN000;
   343                                  %endif
   344 00000825 ????                    SingleBufferSize	dw	?	;AN000; Maximum sector size + buffer header
   345                                  %ifndef BUF2
   346                                  MaxNumBuf1		db     15	;AN026;Num of buffers in a bucket group 1.
   347                                  MaxNumBuf2		db     15	;AN026;Num of buffers in a possible bucket group 2.
   348                                  NthBuck 		db	0	;AN026; 1st bucket group = 1st bucket through Nth Bucket. The rest = second group
   349                                  
   350                                  %IF	BUFFERFLAG
   351                                  
   352                                  FIRST_PAGE		DW	0, 0
   353                                  LAST_PAGE		DW	0, 0
   354                                  NPA640			DW	0
   355                                  EMS_SAVE_BUF		DB	0,0,0,0,0,0,0,0,0,0,0,0
   356                                  
   357                                  %ENDIF
   358                                  %endif
   359                                  
   360 00000827 08                      FILES			DB	8	; enough files for pipe
   361 00000828 04                      FCBS			DB	4	; performance for recycling
   362 00000829 00                      Keep			DB	0	; keep original set
   363 0000082A 05                      NUM_CDS 		DB	5	; 5 net drives
   364 0000082B ????                    config_block		DW	?
   365 0000082D 0000                    buffer_block:		dw	0
   366 0000082F 0000                    altah_block:		dw	0
   367 00000831 413A                    FOOSTRNG		DB	"A:"
   368 00000833 020050                  COMMAND_LINE		DB	2,0,"P" ;Default Command.com Args
   369 00000836 000000000000000000-     			DB	29 DUP (0)
   369 0000083F 000000000000000000-
   369 00000848 000000000000000000-
   369 00000851 0000               
   370 00000853 00                      ZERO			DB	0
   371 00000854 00                      SepChr			DB	0
   372 00000855 0000                    LineCount		dw	0	;AN000;  Line count in config.sys
   373 00000857 20202020200D0A24        ShowCount		db	'     ',CR,LF,'$' ;AN000;  Used to convert Linecount to ASCII.
   374 0000085F 0000                    Buffer_LineNum		dw	0	;AN000; Line count for "BUFFERS=" command if entered.
   375                                  
   376 00000861 FF                      Sys_Model_Byte		db	0FFh	;model byte used in SYSINIT
   377 00000862 00                      Sys_Scnd_Model_Byte	db	0	;secondary model byte used in SYSINIT
   378                                  ;
   379 00000863 00                      Buffer_Slash_X		db	0	;AN000;AN023; BUFFERS= ... /X option entered.
   380                                  %ifndef BUF2
   381                                  Real_IBM_Page_Id	dw	0	;AN029;
   382                                  IBM_Frame_Seg		dw	0	;AN000; segment value for physical IBM page frame.
   383                                  Frame_Info_Buffer	dw	(MAX_NUM_PAGEFRAME * 4) dup (0) ;AN010; For EMS. as per spec. 2 words per entry
   384                                  EMSHandleName		db	'BUFFERS ' ;AN010; 8 char. EMS handle name
   385                                  EMS_Ctrl_Tab		dd	0	;AN010;
   386                                  EMS_State_Buf		dd	0	;AN010;
   387                                  BUF_PREV_OFF		dw	0	;AN020;
   388                                  EMS_Buf_First		dw	0	;AN020;
   389                                  %endif
   390                                  
   391                                  	%IFN NOEXEC
   392                                  	align 2, db 0
   393                                  COMEXE: ; NASM structure instance
   394                                  Exec0_size equ Exec0_struc_size	; NASM port equate
   395                                  istruc Exec0
   396                                  at Exec0_environ
   397 00000864 0000                    	dw 0
   398                                  at Exec0_com_line
   399 00000866 [3308]0000              	dw COMMAND_LINE, 0
   400                                  at Exec0_5C_FCB
   401 0000086A [7A08]0000              	dw Ldexec_FCB1, 0
   402                                  at Exec0_6C_FCB
   403 0000086E [8A08]0000              	dw Ldexec_FCB2, 0
   404                                  iend
   405                                  	%ENDIF
   406                                  
   407                                  ;------------------------------------------------------------------
   408                                  ;J.K.  2/23/87 ;variables for INSTALL= command.
   409                                  
   410 00000872 FF                      Multi_Pass_Id		db	-1	;AN024;AN027;
   411                                  
   412 00000873 00                      	align 2, db 0
   413 00000874 0000                    Install_Flag		dw	0	;AN000;
   414                                     HAVE_INSTALL_CMD	 equ	 00000001b ;AN019; CONFIG.SYS has INSTALL= commands
   415                                     HAS_INSTALLED	 equ	 00000010b ;AN019; SYSINIT_BASE installed.
   416                                     SHARE_INSTALL	 equ	 00000100b ;AN021; Used to install SHARE.EXE
   417                                  
   418 00000876 0000                    Config_Size		dw	0	;AN000; size of config.sys file. Set by SYSCONF.ASM
   419 00000878 0000                    CheckSum		dw	0	;AN000; Used by Sum_up
   420                                  
   421 0000087A 00<rep 10h>             Ldexec_FCB1		times 16 db 0
   422 0000088A 00<rep 10h>             Ldexec_FCB2		times 16 db 0
   423 0000089A 00                      Ldexec_Line		db	0		;AN000;# of parm characters
   424 0000089B 20                      Ldexec_start		db	' '		;AN000;
   425 0000089C 000000000000000000-     Ldexec_parm		db	80 dup (0)	;AN000;
   425 000008A5 000000000000000000-
   425 000008AE 000000000000000000-
   425 000008B7 000000000000000000-
   425 000008C0 000000000000000000-
   425 000008C9 000000000000000000-
   425 000008D2 000000000000000000-
   425 000008DB 000000000000000000-
   425 000008E4 0000000000000000   
   426                                  
   427                                  	align 2, db 0
   428                                  INSTEXE: ; NASM structure instance
   429                                  istruc Exec0
   430                                  at Exec0_environ
   431 000008EC 0000                    	dw 0
   432                                  at Exec0_com_line
   433 000008EE [9A08]0000              	dw Ldexec_Line, 0
   434                                  at Exec0_5C_FCB
   435 000008F2 [7A08]0000              	dw Ldexec_FCB1, 0
   436                                  at Exec0_6C_FCB
   437 000008F6 [8A08]0000              	dw Ldexec_FCB2, 0
   438                                  iend
   439                                  
   440                                  ;AN016; Undo the extended attribute handling
   441                                  ;EA_QueryList		 label	 byte
   442                                  ;			 dw	 1	 ;AN008; I need just one EA info.
   443                                  ;			 db	 02h	 ;AN008; Type is BINARY
   444                                  ;			 dw	 8000h	 ;AN008; Flag is SYSTEM DEFINED.
   445                                  ;			 db	 8	 ;AN008; Length of name is 8 bytes
   446                                  ;			 db	 'FILETYPE' ;AN008; Name is FILETYPE
   447                                  ;Ext_Attr_List		 dw	 1	 ;AN008; Just 1 Extended attribute List
   448                                  ;			 db	 2	 ;AN008;EA_TYPE
   449                                  ;			 dw	 8000h	 ;AN008;FLAG
   450                                  ;			 db	 0	 ;AN008;Failure reason
   451                                  ;			 db	 8	 ;AN008;Length of NAME
   452                                  ;			 dw	 1	 ;AN008;Length of VALUE
   453                                  ;			 db	 'FILETYPE' ;AN008;Name
   454                                  ;Ext_Attr_Value 	 db	 0	 ;AN008;Value
   455                                  ;SIZE_EXT_ATTR_LIST	 equ	 $-Ext_Attr_List	 ;AN008;
   456                                  ;
   457                                  ;;Extended attribute value
   458                                  ;EA_INSTALLABLE 	 equ	 4	 ;AN008;Value for Installable file
   459                                  
   460                                  ;------------------------------------------------------------------
   461                                  ;J.K. 5/15/87  ;Request header, variables for IFS= command.
   462                                  
   463 000008FA 0000                    IFS_Flag	dw	0			;AN000; Set to 1 if it is an IFS.
   464                                     IS_IFS	  equ	00000001b		;IFS command?
   465                                     NOT_IFS	  equ	11111110b
   466                                  
   467                                  IFS_RH: ; NASM structure instance
   468                                  IFSRH_size equ IFSRH_struc_size	; NASM port equate
   469                                  istruc IFSRH
   470                                  at IFSR_LENGTH
   471 000008FC 1C00                    	dw LENGTH_INIT
   472                                  at IFSR_FUNCTION
   473 000008FE 01                      	db IFSINIT
   474 000008FF 00<rep 39h>             iend
   475                                  
   476                                  ;------------------------------------------------------------------
   477                                  ;Variables for Comment=
   478 00000938 00                      COM_Level	db	0		;AN000;level of " " in command line
   479 00000939 00                      CMMT		db	0		;AN000;length of COMMENT string token
   480 0000093A 00                      CMMT1		db	0		;AN000;token
   481 0000093B 00                      CMMT2		db	0		;AN000;token
   482 0000093C ??                      Cmd_Indicator	db	?		;AN000;
   483 0000093D 00                      DoNotShowNum	db	0		;AN000;
   484                                  
   485                                  ;------------------------------------------------------------------
   486 0000093E 0000                    COUNT		DW	0000
   487 00000940 0000                    Org_Count	dw	0000		;AN019;
   488 00000942 0000                    CHRPTR		DW	0000
   489 00000944 0000                    CntryFilehandle DW 0000
   490                                  ;------------------------------------------------------------------
   491                                  BucketPTR LABEL  dword			;AN000;
   492                                  BUFPTR	LABEL	DWORD			;LEAVE THIS STUFF IN ORDER!
   493 00000946 0000                    	DW	0
   494 00000948 0000                    	DW	0
   495                                  PRMBLK	LABEL	WORD
   496 0000094A 0000                    	dw 0
   497 0000094C 0000                    	dw 0
   498                                  
   499 0000094E 18                      PACKET			DB	24	;AN014; Was 22
   500 0000094F 00                      			DB	0
   501 00000950 00                      			DB	0	;INITIALIZE CODE
   502 00000951 0000                    			DW	0
   503 00000953 ????????????????        			DB	8 DUP (?)
   504 0000095B 00                      UNITCOUNT		DB	0
   505 0000095C 00000000                BREAK_ADDR		DD	0
   506 00000960 00000000                BPB_ADDR		DD	0
   507 00000964 00                      DriveNumber		DB	0
   508 00000965 0000                    ConfigMsgFlag		dw	0	;AN014;AN022; Used to control "Error in CONFIG.SYS line #" message
   509                                  
   510 00000967 00<rep 9h>              	align 16, db 0
   511                                  initpspmcb:
   512                                  istruc arena
   513 00000970 4D                      at arena_signature,	db 'M'
   514                                  at arena_owner
   515 00000971 00<rep 2h>0600          at arena_size,		dw 6
   516                                  at arena_reserved
   517 00000975 00<rep 3h>494E4954-     at arena_name,		db "INIT",0
   517 0000097C 00                 
   518 0000097D 00<rep 3h>              at arena_struc_size
   519                                  ; iend		; cannot use arena_size as it clashes with the field named the same
   520                                  %pop
   521                                  
   522 00000980 0000                    tempcds_block:		dw 0
   523                                  
   524                                   global kernelcommandline
   525                                   global kernelcommandline.end
   526                                  	align 2, db 0
   527 00000982 00FF00<rep FEh>         kernelcommandline:	fill 256, 0, {db 0, -1}
   528 00000A82 0000                    .end:		dw 0
   529                                  
   530                                  
   531                                   extern OLDCONFIG_name
   532                                   global CONFIG_pointers
   533                                   extern cmdline_noop, cmdline_checkdebugger, cmdline_verbose, cmdline_scanmode
   534                                   extern cmdline_haltflag
   535                                  
   536                                   global commandnames
   537                                  ; format:
   538                                  ;  word		function pointer - 1 in DOSENTRY, 0FFFFh if end
   539                                  ;  word		content pointer, written to -> last command content, 0 if empty
   540                                  ;  word		name pointer, -> ASCIZ name in SYSINIT
   541                                  commandnames:
   542                                  	; these are just to validate the names.
   543                                  	;  their contents aren't used here.
   544 00000A84 [FFFF]0000[F20A]        		dw cmdline_noop - 1, 0, namedot
   545 00000A8A [FFFF]0000[E30A]        		dw cmdline_noop - 1, 0, nameprepend
   546 00000A90 [FFFF]0000[EB0A]        		dw cmdline_noop - 1, 0, nameappend
   547                                  
   548                                  	; These use the function pointer to run things.
   549                                  	;  The content pointers aren't used later on.
   550 00000A96 [FFFF]0000[3900]        		dw cmdline_checkdebugger - 1, 0, namecheckdebugger
   551 00000A9C [FFFF]0000[4700]        		dw cmdline_verbose - 1, 0, nameverbose
   552 00000AA2 [FFFF]0000[4F00]        		dw cmdline_scanmode - 1, 0, namescanmode
   553 00000AA8 [FFFF]0000[5800]        		dw cmdline_haltflag - 1, 0, namehaltflag
   554 00000AAE [FFFF]0000[6100]        		dw cmdline_haltflag - 1, 0, namehaltflags
   555                                  
   556                                  CONFIG_pointers:
   557                                  	; The content pointers in these are used to set the
   558                                  	;  filenames used for the configuration file.
   559 00000AB4 [FFFF]0000[C80A]        .config:	dw cmdline_noop - 1, 0, .nameconfig
   560 00000ABA [FFFF][F40A][CF0A]      .altconfig:	dw cmdline_noop - 1, ALTCONFIG_name, .namealtconfig
   561 00000AC0 [FFFF][0000][D90A]      .oldconfig:	dw cmdline_noop - 1, OLDCONFIG_name, .nameoldconfig
   562 00000AC6 FFFF                    		dw -1
   563                                  
   564 00000AC8 434F4E46494700          .nameconfig:	asciz "CONFIG"
   565 00000ACF 414C54434F4E464947-     .namealtconfig:	asciz "ALTCONFIG"
   565 00000AD8 00                 
   566 00000AD9 4F4C44434F4E464947-     .nameoldconfig:	asciz "OLDCONFIG"
   566 00000AE2 00                 
   567                                  
   568                                  global nameprepend, nameappend
   569 00000AE3 50524550454E4400        nameprepend:	asciz "PREPEND"
   570 00000AEB 415050454E4400          nameappend:	asciz "APPEND"
   571 00000AF2 2E00                    namedot:	asciz "."
   572                                  
   573 00000AF4 6C646F732E696E6900      ALTCONFIG_name:	asciz "ldos.ini"
   574                                  
   575                                  msg_startingsmall:
   576 00000AFD 5374617274696E6720-     .:		db "Starting small "
   576 00000B06 736D616C6C20       
   577                                  .length equ $ - .
   578                                  msg_linebreak:
   579 00000B0C 0D0A                    .:		db 13,10
   580                                  .length equ $ - .
   581                                  
   582                                  msg:
   583 00000B0E 0D0A456E7465722063-     .prompt:		db 13,10,"Enter command to load as a shell: "
   583 00000B17 6F6D6D616E6420746F-
   583 00000B20 206C6F616420617320-
   583 00000B29 61207368656C6C3A20 
   584                                  .prompt.length equ $ - .prompt
   585 00000B32 696E69743A20434453-     .cds.1:			asciz "init: CDS has "
   585 00000B3B 206861732000       
   586 00000B41 20656E7472792C206C-     .cds.2.singular:	asciz " entry, last is drive "
   586 00000B4A 617374206973206472-
   586 00000B53 6976652000         
   587 00000B58 20656E74726965732C-     .cds.2.plural:		asciz " entries, last is drive "
   587 00000B61 206C61737420697320-
   587 00000B6A 64726976652000     
   588 00000B71 3A2C20757365642000      .cds.3:			asciz ":, used "
   589 00000B7A 206C61737420757365-     .cds.4:			asciz " last used drive "
   589 00000B83 642064726976652000 
   590 00000B8C 3A0D0A00                .cds.5:			asciz ":",13,10
   591 00000B90 696E69743A20496E74-     .cds.error:		asciz "init: Internal CDS allocation error!",13,10
   591 00000B99 65726E616C20434453-
   591 00000BA2 20616C6C6F63617469-
   591 00000BAB 6F6E206572726F7221-
   591 00000BB4 0D0A00             
   592                                  
   593                                  	usesection SYSINITLAST
   594                                  stack_low: equ $
   595 00000000 4C444F533230323400      .ldos2024:		asciz "LDOS2024"
   596 00000009 4C444F534E455700        .ldosnew:		asciz "LDOSNEW"
   597 00000011 46524545444F5300        .freedos:		asciz "FREEDOS"
   598 00000019 46524545444F53444C-     .freedosdla:		asciz "FREEDOSDLA"
   598 00000022 4100               
   599 00000024 454452444F5300          .edrdos:		asciz "EDRDOS"
   600 0000002B 4D53444F533500          .msdos5:		asciz "MSDOS5"
   601 00000032 4D53444F533700          .msdos7:		asciz "MSDOS7"
   602 00000039 434845434B44454255-     namecheckdebugger:	asciz "CHECKDEBUGGER"
   602 00000042 4747455200         
   603 00000047 564552424F534500        nameverbose:		asciz "VERBOSE"
   604 0000004F 5343414E4D4F444500      namescanmode:		asciz "SCANMODE"
   605 00000058 48414C54464C414700      namehaltflag:		asciz "HALTFLAG"
   606 00000061 48414C54464C414753-     namehaltflags:		asciz "HALTFLAGS"
   606 0000006A 00                 
   607                                  
   608 0000006B 00                      	align 2, db 0
   609                                  modetable:
   610 0000006C [0000]                  	dw msg.ldos2024
   611 0000006E DAA3                    	dw mode_first_ext5 | mode_first_ext15 | mode_ignore_ext85 		| mode_ignore_subsequent_nested 		| mode_ignore_subsequent_logical 		| mode_ignore_subsequent_primary 		| mode_traditional_order_logical 		| mode_disable_fat32 		| mode_dlasort_zero
   618 00000070 [0900]                  	dw msg.ldosnew
   619 00000072 0020                    	dw mode_all_ext5 | mode_all_ext15 | mode_all_ext85 		| mode_disable_fat32
   621 00000074 [1100]                  	dw msg.freedos
   622 00000076 5A8E                    	dw mode_first_ext5 | mode_first_ext15 | mode_ignore_ext85 		| mode_ignore_subsequent_nested 		| mode_traditional_order_logical 		| mode_active_priority 		| mode_subsequent_primary_after 		| mode_dlasort_zero
   628 00000078 [1900]                  	dw msg.freedosdla
   629 0000007A 5A0E                    	dw mode_first_ext5 | mode_first_ext15 | mode_ignore_ext85 		| mode_ignore_subsequent_nested 		| mode_traditional_order_logical 		| mode_active_priority 		| mode_subsequent_primary_after
   634 0000007C [2400]                  	dw msg.edrdos
   635 0000007E 5A82                    	dw mode_first_ext5 | mode_first_ext15 | mode_ignore_ext85 		| mode_ignore_subsequent_nested 		| mode_traditional_order_logical 		| mode_dlasort_zero
   639 00000080 [2B00]                  	dw msg.msdos5
   640 00000082 D6EE                    	dw mode_first_ext5 | mode_ignore_ext15 | mode_ignore_ext85 		| mode_ignore_subsequent_nested 		| mode_ignore_subsequent_logical 		| mode_traditional_order_logical 		| mode_active_priority 		| mode_subsequent_primary_after 		| mode_disable_fat32 		| mode_disable_lba 		| mode_dlasort_zero
   649 00000084 [3200]                  	dw msg.msdos7
   650 00000086 DA8E                    	dw mode_first_ext5 | mode_first_ext15 | mode_ignore_ext85 		| mode_ignore_subsequent_nested 		| mode_ignore_subsequent_logical 		| mode_traditional_order_logical 		| mode_active_priority 		| mode_subsequent_primary_after 		| mode_dlasort_zero
   657                                  .end:
   658                                  
   659                                  
   660                                   global GOINIT
   661                                  GOINIT:
   662                                   assume ds:nothing, es:nothing, ss:nothing
   663 00000088 51                      	push cx
   664                                  ;J.K. before doing anything else, let's set the model byte
   665                                  ;SB33043*****************************************************************
   666 00000089 B4C0                    	mov	ah,0c0h 		;get system configuration     ;SB ;3.30*
   667 0000008B CD15                    	int	15h			; *			      ;SB ;3.30*
   668                                  ;SB33043*****************************************************************
   669 0000008D 7217                    	jc	No_ROM_Config
   670 0000008F 80FC00                  	cmp	ah, 0			; double check
   671 00000092 7512                    	jne	No_ROM_Config
   672 00000094 268A4702                	mov	al, [ES:BX + bios_SD_modelbyte]
   673 00000098 2EA2[6108]              	mov	[cs:Sys_Model_Byte], al
   674 0000009C 268A4703                	mov	al, [ES:BX + bios_SD_scnd_modelbyte]
   675 000000A0 2EA2[6208]              	mov	[cs:Sys_Scnd_Model_Byte], al
   676 000000A4 EB0C                    	jmp	@F
   677                                  No_ROM_Config:				; Old ROM
   678 000000A6 B800F0                  	mov	ax, 0f000h
   679 000000A9 8ED8                    	mov	ds, ax
   680                                   assume ds:nothing
   681 000000AB A0FEFF                  	mov	al, byte ptr [0fffeh]
   682 000000AE 2EA2[6108]              	mov	[cs:Sys_Model_Byte], al ;set the model byte.
   683                                  @@:
   684                                  
   685                                  ;J.K.6/24/87 Set Fake_Floppy_Drv if there is no diskette drives in this machine.
   686                                  ;SB34SYSINIT1001********************************************************
   687                                  ;SB	execute the equipment determination interrupt and then
   688                                  ;SB	check the returned value to see if we have any floppy drives
   689                                  ;SB	if we have no floppy drive we set cs:Fake_Floppy_Drv to 1
   690                                  ;SB	See the AT Tech Ref BIOS listings for help on the equipment
   691                                  ;SB	flag interrupt (11h)
   692                                  
   693 000000B2 CD11                    	int	11h
   694 000000B4 A801                    	test	al, 1			; has floppy ?
   695 000000B6 7506                    	jnz	Move_Myself
   696 000000B8 2EC606[0608]01          	mov	byte [cs:Fake_Floppy_Drv],1	; no floppy, fake.
   697                                  
   698                                  ;SB34SYSINIT1001********************************************************
   699                                  Move_Myself:
   700 000000BE FC                      	CLD				; Set up move
   701 000000BF 31F6                    	XOR	SI,SI
   702 000000C1 89F7                    	MOV	DI,SI
   703                                  
   704                                  %if 0
   705                                  	%IF	MSVER
   706                                  	MOV	CX,[cs:MEMORY_SIZE]
   707                                  	CMP	CX,1			; 1 means do scan
   708                                  	JNZ	NOSCAN
   709                                  	MOV	CX,2048 		;START SCANNING AT 32K BOUNDARY
   710                                  	XOR	BX,BX
   711                                  
   712                                  MEMSCAN:INC	CX
   713                                  	JZ	SETEND
   714                                  	MOV	DS,CX
   715                                  	MOV	AL,[BX]
   716                                  	NOT	AL
   717                                  	MOV	[BX],AL
   718                                  	CMP	AL,[BX]
   719                                  	NOT	AL
   720                                  	MOV	[BX],AL
   721                                  	JZ	MEMSCAN
   722                                  SETEND:
   723                                  	MOV	[cs:MEMORY_SIZE],CX
   724                                  	%ENDIF
   725                                  
   726                                  	%IF	IBMVER | IBMJAPVER
   727                                  	MOV	CX,[cs:MEMORY_SIZE]
   728                                  	%ENDIF
   729                                  NOSCAN:					; CX is mem size in para
   730                                  %endif
   731                                  
   732                                  SYSIN:
   733                                  
   734                                  %if 0
   735                                  	xor ax, ax
   736                                  	mov ds, ax
   737                                  	ASSUME	DS:NOTHING,ES:SYSINITSEG,SS:NOTHING
   738                                  	MOV	ax, [cs:FINAL_DOS_LOCATION]	; Where it is going (set by BIOS)
   739                                  	mov word [31h * 4 + 2], ax
   740                                  	mov es, ax
   741                                  	ASSUME	ES:NOTHING
   742                                  	xor di, di
   743                                  	mov bx, DOSSTART
   744                                  	mov cx, afterdosdatalabel wrt DOSSTART	; = early DOS data length
   745                                  	mov ds, bx			; => early DOS data location
   746                                  	xor si, si
   747                                  	cmp bx, ax
   748                                  	; cmp ds, es
   749                                  	jae load_dos_to_lower
   750                                  load_dos_to_higher:
   751                                  	mov si, cx			; -> behind source
   752                                  	mov di, si			; -> behind dest
   753                                  	std				; set DOWN
   754                                  	cmpsw				; -> at last words
   755                                  load_dos_to_lower:
   756                                  	shr cx, 1
   757                                  	rep movsw
   758                                  	cld
   759                                  %endif
   760                                  
   761 000000C3 5B                      	pop bx				; => first trail S MCB
   762 000000C4 83EB07                  	sub bx, 7			; => place for MCB
   763 000000C7 8EC3                    	mov es, bx
   764                                   assume es:nothing
   765 000000C9 53                      	push bx				; => MCB
   766 000000CA 43                      	inc bx				; => place for PSP
   767 000000CB 31FF                    	xor di, di			; es:di -> MCB
   768 000000CD 0E                      	push cs
   769 000000CE 1F                      	pop ds
   770                                   assume ds:SYSINITGROUP
   771 000000CF BE[7009]                	mov si, initpspmcb		; ds:si -> template
   772 000000D2 895C01                  	mov word [si + arena_owner], bx
   773 000000D5 B90800                  	mov cx, 8
   774 000000D8 F3A5                    	rep movsw
   775 000000DA C644F05A                	mov byte [si - MCB_size + mcbSignature], 'Z'
   776                                  
   777 000000DE 8B16[1E08]              	MOV	DX,[MEMORY_SIZE]	; Set for call to DOSINIT
   778 000000E2 C536[FE07]              	LDS	SI,[DEVICE_LIST]	; Set for call to DOSINIT
   779                                   assume ds:nothing
   780 000000E6 59                      	pop cx				; => first trail S MCB
   781 000000E7 2E8B3E[FA07]            	mov di, word [cs:behind_dosentry_segment]
   782                                  					; free MCB
   783 000000EC FA                      	CLI
   784 000000ED E9(0000)                	jmp SYSINIT_CALL_DOS
   785                                  
   786                                  	align 16, db 26h
   787                                  stack_high equ $ + fromparas(paras(SYSINITSTACK))
   788                                  
   789                                  	usesection SYSINITTRAIL
   790                                  SYSINIT_CALL_DOS:
   791                                  
   792 00000000 8CC8                    	MOV	AX,CS
   793 00000002 8ED0                    	MOV	SS,AX
   794 00000004 BC[7002]                	MOV	SP, stack_high		; Set stack
   795                                   assume ss:SYSINITGROUP
   796                                  
   797                                  %if (stack_high - stack_low) < 512
   798                                   %assign NUMBER (stack_high - stack_low)
   799                                   %error Too small stack, want 512, have NUMBER
   800                                  %endif
   801                                  
   802                                  	%IFN ALTVECT
   803 00000007 FB                      	STI				; Leave INTs disabled for ALTVECT
   804                                  	%ENDIF
   805                                  
   806 00000008 31C0                    	xor ax, ax
   807 0000000A 8EC0                    	mov es, ax
   808                                   assume es:IVT
   809 0000000C 268E06C600              	mov es, word [es:31h * 4 + 2]	; => DOSDATA
   810                                   assume es:DOSGROUP
   811                                  		; INP:	dx => behind LMA
   812                                  		;	dx - 1 => where to place first UMCB
   813                                  		;	ds:si -> first non-NUL device header
   814                                  		;	es => DOSDATA to initialise
   815                                  		;	es - 1 => DOSDATA MCB, shrink as desired
   816                                  		;	cx => first trail MCB
   817                                  		;	bx => space for init PSP
   818                                  		;	di => space for free MCB (should link to cx => MCB)
   819 00000011 CC                      	int3
   820                                  
   821                                   extern NEARDOSINIT
   822 00000012 E8(0000)                	call NEARDOSINIT
   823                                   assume es:DOSGROUP			;ES:DI -> SysInitVars_Ext
   824 00000015 268B05                  	mov	ax, word ptr [es:di + SYSI_InitVars] ;J.K. 5/29/86
   825 00000018 36A3[F207]              	mov	word ptr [ss:dosinfo], ax
   826 0000001C 268B4502                	mov	ax, word ptr [es:di + SYSI_InitVars+2]
   827 00000020 36A3[F407]              	mov	word ptr [ss:dosinfo+2],ax ;set the sysvar pointer
   828                                  
   829 00000024 268B4504                	mov	ax, word ptr [es:di + SYSI_Country_Tab]
   830 00000028 36A3[0208]              	mov	word ptr [ss:SYSI_Country],ax
   831 0000002C 268B4506                	mov	ax, word ptr [es:di + SYSI_Country_Tab+2]
   832 00000030 36A3[0408]              	mov	word ptr [ss:SYSI_Country+2],ax	;set the SYSI_Country pointer J.K.
   833                                  
   834 00000034 B440                    	mov ah, 40h
   835 00000036 BB0100                  	mov bx, 1
   836 00000039 0E                      	 push cs
   837 0000003A 1F                      	 pop ds
   838                                   assume ds:SYSINITGROUP
   839 0000003B F606[FC07]01            	testopt [verbose_mode], verbose_intro
   840 00000040 7431                    	jz .nointro
   841 00000042 BA[FD0A]                	mov dx, msg_startingsmall
   842 00000045 B90F00                  	mov cx, msg_startingsmall.length
   843 00000048 CD21                    	int 21h
   844 0000004A B8FF33                  	mov ax, 33FFh
   845 0000004D CD21                    	int 21h
   846 0000004F 92                      	xchg dx, ax		; dx -> message, ax => segment
   847 00000050 89D7                    	mov di, dx
   848 00000052 8EC0                    	mov es, ax
   849                                   assume es:DOSCODEGROUP
   850 00000054 8ED8                    	mov ds, ax
   851                                   assume ds:DOSCODEGROUP
   852 00000056 B000                    	mov al, 0
   853 00000058 B9FFFF                  	mov cx, -1
   854 0000005B F2AE                    	repne scasb
   855 0000005D F7D1                    	not cx
   856 0000005F 49                      	dec cx
   857 00000060 B440                    	mov ah, 40h
   858 00000062 CD21                    	int 21h
   859 00000064 B440                    	mov ah, 40h
   860 00000066 BB0100                  	mov bx, 1
   861 00000069 0E                      	 push cs
   862 0000006A 1F                      	 pop ds
   863                                   assume ds:SYSINITGROUP
   864 0000006B BA[0C0B]                	mov dx, msg_linebreak
   865 0000006E B90200                  	mov cx, msg_linebreak.length
   866 00000071 CD21                    	int 21h
   867                                  
   868                                  .nointro:
   869                                  	extern INITUPB
   870 00000073 E8(0000)                	call INITUPB
   871                                   assume ds:nothing, es:nothing, ss:SYSINITGROUP
   872                                  
   873                                  	extern INITDPB
   874 00000076 E8(0000)                	call INITDPB
   875                                   assume ds:nothing, es:nothing, ss:SYSINITGROUP
   876                                  
   877                                  relocate_upb_early:
   878                                   extern sysinit_get_ds_dosentry, dskdrvs_indirect, START_BDS, DRVMAX
   879                                  
   880 00000079 E8(0000)                	call sysinit_get_ds_dosentry	; DRVMAX in DOSENTRY
   881                                   assume ds:DOSENTRYGROUP
   882 0000007C 31F6                    	xor si, si
   883 0000007E 8A2E[0000]              	mov ch, [DRVMAX]		; ch = how many UPBs
   884                                  %ifnidni %[DOSBIODATA], %[DOSENTRY]
   885 00000082 E8(0000)                	call sysinit_get_ds_dosbiodata
   886                                   assume ds:DOSGROUP
   887                                  %endif
   888 00000085 C43E[0000]              	les di, [START_BDS]		; es:di -> first UPB
   889                                   assume es:UPB
   890 00000089 C516[0000]              	lds dx, [dskdrvs_indirect]	; ds:dx -> dskdrvs array (used by INITDPB)
   891                                   assume ds:UPB
   892 0000008D 83FFFF                  	cmp di, -1			; none ?
   893 00000090 7503E90701              	je .warn			; then skip -->
   894 00000095 84ED                    	test ch, ch
   895 00000097 7503E90001              	jz .warn
   896                                  		; Harden: Expect UPBs at start of memory block.
   897 0000009C 85FF                    	test di, di
   898 0000009E 7403E9F900              	jnz .warn
   899 000000A3 8CC0                    	mov ax, es
   900 000000A5 8CDB                    	mov bx, ds
   901 000000A7 39D8                    	cmp ax, bx			; UPB segment == dskdrvs segment ?
   902 000000A9 7403E9EE00              	jne .warn
   903 000000AE 48                      	dec ax
   904 000000AF 8ED8                    	mov ds, ax
   905                                   assume ds:MCB
   906 000000B1 837C0108                	cmp word [si + mcbOwner], 8	; an S MCB ?
   907 000000B5 7403E9E200              	jne .warn
   908 000000BA 837C0853                	cmp word [si + mcbName], "S"	; S MCB ?
   909 000000BE 7403E9D900              	jne .warn
   910 000000C3 807C0A09                	cmp byte [si + smcbType], S_UPB	; correct type ?
   911 000000C7 7403E9D000              	jne .warn
   912 000000CC 8B4403                  	mov ax, [si + mcbSize]
   913 000000CF B104                    	mov cl, 4
   914 000000D1 D3E0                    	shl ax, cl			; = size in bytes
   915 000000D3 89C3                    	mov bx, ax
   916 000000D5 D3E8                    	shr ax, cl			; compute paragraphs again
   917 000000D7 394403                  	cmp word [si + mcbSize], ax	; match ?
   918 000000DA 7403E9BD00              	jne .warn
   919 000000DF 39D3                    	cmp bx, dx			; dskdrvs array fits in block ?
   920 000000E1 7703E9B600              	jbe .warn			; certainly no -->
   921 000000E6 31C0                    	xor ax, ax
   922 000000E8 88E8                    	mov al, ch			; ax = how many UPBs
   923 000000EA 01C0                    	add ax, ax			; how large dskdrvs array should be
   924 000000EC 01D0                    	add ax, dx			; -> behind array
   925 000000EE 83C00F                  	add ax, 15			; round up
   926 000000F1 24F0                    	and al, ~ 15			; get to paragraph boundary
   927 000000F3 39C3                    	cmp bx, ax			; match ?
   928 000000F5 7403E9A200              	jne .warn
   929 000000FA B064                    	mov al, BDS_TYPE_struc_size
   930 000000FC F6E5                    	mul ch				; ax = how many bytes needed for UPBs
   931 000000FE 39C2                    	cmp dx, ax			; last UPB fits below dskdrvs ?
   932 00000100 7303E99700              	jb .warn			; no -->
   933 00000105 89C3                    	mov bx, ax
   934 00000107 40                      	inc ax
   935 00000108 24FE                    	and al, ~ 1
   936 0000010A 39C2                    	cmp dx, ax
   937 0000010C 7403E98B00              	jne .warn
   938                                  
   939 00000111 88E9                    	mov cl, ch
   940 00000113 84C9                    	test cl, cl
   941 00000115 7503E98200              	jz .warn
   942 0000011A 06                      	push es
   943 0000011B 57                      	push di
   944                                  .loop:
   945 0000011C 80F901                  	cmp cl, 1
   946 0000011F 7416                    	je .last
   947 00000121 8CC3                    	mov bx, es
   948 00000123 26395D02                	cmp word [es:di + LINK + 2], bx
   949 00000127 7571                    	jne .warn_pop_pop
   950 00000129 8D5D64                  	lea bx, [di + BDS_TYPE_struc_size]
   951 0000012C 26391D                  	cmp word [es:di + LINK], bx
   952 0000012F 7569                    	jne .warn_pop_pop
   953 00000131 49                      	dec cx				; count down
   954 00000132 26C43D                  	les di, [es:di + LINK]
   955                                   assume es:UPB
   956 00000135 EBE5                    	jmp .loop
   957                                  
   958                                  .last:
   959 00000137 26833DFF                	cmp word [es:di + LINK], -1
   960 0000013B 755D                    	jne .warn_pop_pop
   961                                  
   962 0000013D BE[3623]                	mov si, alloc_upb_temporary
   963 00000140 51                      	push cx
   964 00000141 50                      	push ax
   965 00000142 E84D23                  	call allocate_temporary_block
   966                                   assume es:nothing
   967 00000145 59                      	pop cx				; = size of initialised UPBs
   968 00000146 5B                      	pop bx				; bh = number of UPBs
   969 00000147 5E                      	pop si
   970 00000148 1F                      	pop ds				; -> first UPB source
   971                                   assume ds:UPB
   972 00000149 89FA                    	mov dx, di			; es:dx -> destination
   973 0000014B F3A4                    	rep movsb			; copy them over
   974 0000014D 89D7                    	mov di, dx			; es:di -> copied UPBs
   975 0000014F 88F9                    	mov cl, bh
   976 00000151 B500                    	mov ch, 0			; cx = amount UPBs
   977 00000153 8CDB                    	mov bx, ds
   978                                  
   979                                  .newloop:
   980 00000155 49                      	dec cx
   981 00000156 7417                    	jz .newlast
   982 00000158 26395D02                	cmp word [es:di + LINK + 2], bx
   983 0000015C 7537                    	jne .warn_free
   984 0000015E 8D4564                  	lea ax, [di + BDS_TYPE_struc_size]
   985 00000161 263905                  	cmp word [es:di + LINK], ax
   986 00000164 752F                    	jne .warn_free
   987 00000166 268C4502                	mov word [es:di + LINK + 2], es	; relocate next link
   988 0000016A 26C43D                  	les di, [es:di + LINK]
   989                                   assume es:nothing
   990 0000016D EBE6                    	jmp .newloop
   991                                  
   992                                  .newlast:
   993 0000016F 26833DFF                	cmp word [es:di + LINK], -1
   994 00000173 7520                    	jne .warn_free
   995                                  
   996 00000175 E8(0000)                	call sysinit_get_ds_dosbiodata
   997                                   assume ds:DOSGROUP
   998 00000178 FA                      	cli
   999 00000179 B8FFFF                  	mov ax, -1
  1000 0000017C A3[0000]                	mov word [dskdrvs_indirect], ax
  1001 0000017F A3[0200]                	mov word [dskdrvs_indirect + 2], ax
  1002                                  					; invalidate the dskdrvs pointer
  1003 00000182 8CC0                    	mov ax, es
  1004 00000184 8916[0000]              	mov word [START_BDS], dx
  1005 00000188 8706[0200]              	xchg word [START_BDS + 2], ax	; relocate the UPBs
  1006 0000018C FB                      	sti
  1007 0000018D 8EC0                    	mov es, ax
  1008                                   assume es:nothing
  1009 0000018F B449                    	mov ah, 49h
  1010 00000191 CD21                    	int 21h				; free the original allocation
  1011 00000193 EB16                    	jmp .done
  1012                                  
  1013                                  .warn_free:
  1014 00000195 B449                    	mov ah, 49h
  1015 00000197 CD21                    	int 21h				; free new allocation
  1016 00000199 A9                      	db __TEST_IMM16			; skip twice pop
  1017                                  .warn_pop_pop:
  1018 0000019A 58                      	pop ax
  1019 0000019B 58                      	pop ax
  1020                                  .warn:
  1021 0000019C 0E                      	push cs
  1022 0000019D 1F                      	pop ds
  1023                                   assume ds:SYSINITGROUP
  1024 0000019E BA[3F25]                	mov dx, sysinit_msg.warn_upb
  1025 000001A1 B92800                  	mov cx, sysinit_msg.warn_upb.size
  1026 000001A4 BB0100                  	mov bx, 1
  1027 000001A7 B440                    	mov ah, 40h
  1028 000001A9 CD21                    	int 21h
  1029                                  .done:
  1030                                   assume ds:nothing, es:nothing, ss:SYSINITGROUP
  1031                                  
  1032                                  
  1033                                  		; ! Note that at this point no SFTs, CDSes, buffers
  1034                                  		;  hold references to our early DOS-internal DPBs.
  1035                                  relocate_dpb_early:
  1036                                   extern NUMIO, DPBHEAD, sysinit_getdosdata
  1037                                  
  1038 000001AB E8(0000)                	call sysinit_getdosdata
  1039 000001AE 8ED8                    	mov ds, ax
  1040                                   assume ds:DOSGROUP
  1041 000001B0 31F6                    	xor si, si
  1042 000001B2 8A2E[0000]              	mov ch, [NUMIO]			; ch = how many DPBs (at this point)
  1043 000001B6 C43E[0000]              	les di, [DPBHEAD]		; es:di -> first DPB
  1044                                   assume es:DPB
  1045 000001BA 83FFFF                  	cmp di, -1			; none ?
  1046 000001BD 7503E9E500              	je .warn			; then skip -->
  1047 000001C2 84ED                    	test ch, ch
  1048 000001C4 7503E9DE00              	jz .warn
  1049                                  		; Harden: Expect DPBs at start of memory block.
  1050 000001C9 85FF                    	test di, di
  1051 000001CB 7403E9D700              	jnz .warn
  1052 000001D0 8CC0                    	mov ax, es
  1053 000001D2 48                      	dec ax
  1054 000001D3 8ED8                    	mov ds, ax
  1055                                   assume ds:MCB
  1056 000001D5 837C0108                	cmp word [si + mcbOwner], 8	; an S MCB ?
  1057 000001D9 7403E9C900              	jne .warn
  1058 000001DE 837C0853                	cmp word [si + mcbName], "S"	; S MCB ?
  1059 000001E2 7403E9C000              	jne .warn
  1060 000001E7 807C0A08                	cmp byte [si + smcbType], S_DPB	; correct type ?
  1061 000001EB 7403E9B700              	jne .warn
  1062 000001F0 8B4403                  	mov ax, [si + mcbSize]
  1063 000001F3 B104                    	mov cl, 4
  1064 000001F5 D3E0                    	shl ax, cl			; = size in bytes
  1065 000001F7 89C3                    	mov bx, ax
  1066 000001F9 D3E8                    	shr ax, cl			; compute paragraphs again
  1067 000001FB 394403                  	cmp word [si + mcbSize], ax	; match ?
  1068 000001FE 7403E9A400              	jne .warn
  1069 00000203 B021                    	mov al, dpb_struc_size
  1070 00000205 F6E5                    	mul ch				; ax = how many bytes needed for DPBs
  1071 00000207 39C3                    	cmp bx, ax			; last DPB fits in block ?
  1072 00000209 7303E99900              	jb .warn			; no -->
  1073 0000020E 89C2                    	mov dx, ax
  1074 00000210 83C20F                  	add dx, 15
  1075 00000213 80E2F0                  	and dl, ~ 15
  1076 00000216 39D3                    	cmp bx, dx
  1077 00000218 7403E98A00              	jne .warn
  1078                                  
  1079 0000021D 88E9                    	mov cl, ch
  1080 0000021F 84C9                    	test cl, cl
  1081 00000221 7503E98100              	jz .warn
  1082 00000226 06                      	push es
  1083 00000227 57                      	push di
  1084                                  .loop:
  1085 00000228 80F901                  	cmp cl, 1
  1086 0000022B 7418                    	je .last
  1087 0000022D 8CC3                    	mov bx, es
  1088 0000022F 26395D1B                	cmp word [es:di + dpb_next_dpb + 2], bx
  1089 00000233 7570                    	jne .warn_pop_pop
  1090 00000235 8D5D21                  	lea bx, [di + dpb_struc_size]
  1091 00000238 26395D19                	cmp word [es:di + dpb_next_dpb], bx
  1092 0000023C 7567                    	jne .warn_pop_pop
  1093 0000023E 49                      	dec cx				; count down
  1094 0000023F 26C47D19                	les di, [es:di + dpb_next_dpb]
  1095                                   assume es:DPB
  1096 00000243 EBE3                    	jmp .loop
  1097                                  
  1098                                  .last:
  1099 00000245 26837D19FF              	cmp word [es:di + dpb_next_dpb], -1
  1100 0000024A 7559                    	jne .warn_pop_pop
  1101                                  
  1102 0000024C BE[4A23]                	mov si, alloc_dpb_temporary
  1103 0000024F 51                      	push cx
  1104 00000250 50                      	push ax
  1105 00000251 E83E22                  	call allocate_temporary_block
  1106                                   assume es:nothing
  1107 00000254 59                      	pop cx				; = size of initialised DPBs
  1108 00000255 5B                      	pop bx				; bh = number of DPBs
  1109 00000256 5E                      	pop si
  1110 00000257 1F                      	pop ds				; -> first DPB source
  1111                                   assume ds:DPB
  1112 00000258 89FA                    	mov dx, di			; es:dx -> destination
  1113 0000025A F3A4                    	rep movsb			; copy them over
  1114 0000025C 89D7                    	mov di, dx			; es:di -> copied DPBs
  1115 0000025E 88F9                    	mov cl, bh
  1116 00000260 B500                    	mov ch, 0			; cx = amount DPBs
  1117 00000262 8CDB                    	mov bx, ds
  1118                                  
  1119                                  .newloop:
  1120 00000264 49                      	dec cx
  1121 00000265 7419                    	jz .newlast
  1122 00000267 26395D1B                	cmp word [es:di + dpb_next_dpb + 2], bx
  1123 0000026B 7533                    	jne .warn_free
  1124 0000026D 8D4521                  	lea ax, [di + dpb_struc_size]
  1125 00000270 26394519                	cmp word [es:di + dpb_next_dpb], ax
  1126 00000274 752A                    	jne .warn_free
  1127 00000276 268C451B                	mov word [es:di + dpb_next_dpb + 2], es	; relocate next link
  1128 0000027A 26C47D19                	les di, [es:di + dpb_next_dpb]
  1129                                   assume es:nothing
  1130 0000027E EBE4                    	jmp .newloop
  1131                                  
  1132                                  .newlast:
  1133 00000280 26837D19FF              	cmp word [es:di + dpb_next_dpb], -1
  1134 00000285 7519                    	jne .warn_free
  1135                                  
  1136 00000287 E8(0000)                	call sysinit_getdosdata
  1137 0000028A 8ED8                    	mov ds, ax
  1138                                   assume ds:DOSGROUP
  1139 0000028C FA                      	cli
  1140 0000028D 8CC0                    	mov ax, es
  1141 0000028F 8916[0000]              	mov word [DPBHEAD], dx
  1142 00000293 8706[0200]              	xchg word [DPBHEAD + 2], ax	; relocate the DPBs
  1143 00000297 FB                      	sti
  1144 00000298 8EC0                    	mov es, ax
  1145                                   assume es:nothing
  1146 0000029A B449                    	mov ah, 49h
  1147 0000029C CD21                    	int 21h				; free the original allocation
  1148 0000029E EB16                    	jmp .done
  1149                                  
  1150                                  .warn_free:
  1151 000002A0 B449                    	mov ah, 49h
  1152 000002A2 CD21                    	int 21h				; free new allocation
  1153 000002A4 A9                      	db __TEST_IMM16			; skip twice pop
  1154                                  .warn_pop_pop:
  1155 000002A5 58                      	pop ax
  1156 000002A6 58                      	pop ax
  1157                                  .warn:
  1158 000002A7 0E                      	push cs
  1159 000002A8 1F                      	pop ds
  1160                                   assume ds:SYSINITGROUP
  1161 000002A9 BA[6725]                	mov dx, sysinit_msg.warn_dpb
  1162 000002AC B92800                  	mov cx, sysinit_msg.warn_dpb.size
  1163 000002AF BB0100                  	mov bx, 1
  1164 000002B2 B440                    	mov ah, 40h
  1165 000002B4 CD21                    	int 21h
  1166                                  .done:
  1167                                   assume ds:nothing, es:nothing, ss:SYSINITGROUP
  1168                                  
  1169 000002B6 36C43E[F207]            	les	di, [ss:dosinfo]		;es:di -> dosinfo
  1170                                   assume es:DOSGROUP
  1171                                  
  1172 000002BB F8                      	clc					;AN018;Get the extended memory size
  1173                                  ;SB34SYSINIT1002**************************************************************
  1174                                  ;SB	execute the get extended memory size subfunction in the BIOS INT 15h
  1175                                  ;SB	if the function reports an error do nothing else store the extended
  1176                                  ;SB	memory size reported at the appropriate location in the dosinfo buffer
  1177                                  ;SB	currently pointed to by es:di.	Use the offsets specified in the
  1178                                  ;SB	definition of the sysinitvars struct in inc\sysvar.inc
  1179                                  ;SB		5 LOCS
  1180                                  
  1181 000002BC B488                    	mov	ah,88h
  1182 000002BE CD15                    	int	15h				;check extended memory size
  1183 000002C0 7204                    	jc	No_Ext_Memory
  1184 000002C2 26894545                	mov	[es:di + SYSI_EXT_MEM],ax 	;save extended memory size
  1185                                  No_Ext_Memory:
  1186                                  
  1187                                  ;SB34SYSINIT1002**************************************************************
  1188 000002C6 26C7453BFFFF            	mov	word ptr [es:di + SYSI_IFS], -1	;AN000; Initialize SYSI_IFS chain.
  1189 000002CC 26C7453DFFFF            	mov	word ptr [es:di + SYSI_IFS+2], -1 ;AN000;
  1190                                  
  1191 000002D2 268B4510                	mov	ax, [es:di + SYSI_MAXSEC] 	;AN020; Get the sector size
  1192 000002D6 83C010                  	add	ax, BUFINSIZ			;AN020; size of buffer header
  1193 000002D9 36A3[2508]              	mov	[ss:SingleBufferSize], ax	;AN020; total size for a buffer
  1194                                  
  1195                                  Default_Drive equ DEFAULT_DRIVE	; NASM port label
  1196 000002DD 36A0[2008]              	mov	al, [ss:Default_Drive]		;AN000;Get the 1 based boot drive number set by IBMINIT
  1197 000002E1 26884543                	mov	[es:di + SYSI_BOOT_DRIVE], al	;AN000; set SYSI_BOOT_DRIVE
  1198                                  
  1199                                  ; Determine if 386 system...
  1200                                  	Get_CPU_Type			; macro to determine cpu type
    10 000002E5 9C                  <1>  pushf
    11 000002E6 53                  <1>  push bx
    12 000002E7 31DB                <1>  xor bx, bx
    13                              <1> 
    14 000002E9 31C0                <1>  xor ax,ax
    15 000002EB 50                  <1>  push ax
    16 000002EC 9D                  <1>  popf
    17 000002ED 9C                  <1>  pushf
    18 000002EE 58                  <1>  pop ax
    19 000002EF 2500F0              <1>  and ax,0F000h
    20 000002F2 3D00F0              <1>  cmp ax,0F000h
    21 000002F5 740E                <1>  je %%cpu_8086
    22                              <1> 
    23 000002F7 B800F0              <1>  mov ax,0F000h
    24 000002FA 50                  <1>  push ax
    25 000002FB 9D                  <1>  popf
    26 000002FC 9C                  <1>  pushf
    27 000002FD 58                  <1>  pop ax
    28 000002FE 2500F0              <1>  and ax,0F000h
    29 00000301 7401                <1>  jz %%cpu_286
    30                              <1> 
    31                              <1> %%cpu_386:
    32 00000303 43                  <1>  inc bx
    33                              <1> %%cpu_286:
    34 00000304 43                  <1>  inc bx
    35                              <1> %%cpu_8086:
    36 00000305 89D8                <1>  mov ax, bx
    37 00000307 5B                  <1>  pop bx
    38 00000308 9D                  <1>  popf
  1201 00000309 83F802                  	cmp	ax, 2			; is it a 386?
  1202 0000030C 7505                    	jne	Not_386_System		; no: don't mess with flag
  1203 0000030E 26C6454401              	mov	byte [es:di + SYSI_DWMOVE], 1		  ;AN003;
  1204                                  Not_386_System:					;AN003;
  1205 00000313 268A4520                	MOV	AL,[ES:DI + SYSI_NUMIO]
  1206 00000317 36A2[6409]              	MOV	[ss:DriveNumber],AL		; Save start of installable block drvs
  1207                                  
  1208 0000031B 06                      	push	es			;AN020;
  1209 0000031C 57                      	push	di			;AN020;
  1210                                  
  1211 0000031D 06                      	push es
  1212 0000031E 36A1[2508]              	mov ax, [ss:SingleBufferSize]	;AN020;Temporary Single buffer area
  1213 00000322 BE[0E23]                	mov si, alloc_init
  1214 00000325 E86A21                  	call allocate_temporary_block
  1215                                   assume es:nothing
  1216 00000328 8CC0                    	mov ax, es			; ax => buffer
  1217 0000032A 07                      	pop es				; es => DOSDATA
  1218                                   assume es:DOSGROUP
  1219                                  
  1220 0000032B 36A3[2D08]              	mov word [ss:buffer_block], ax
  1221                                  %ifdef BUF2
  1222 0000032F 26A3[0200]              	mov word [es:BUFFHEAD + 2], ax
  1223 00000333 268326[0000]00          	and word [es:BUFFHEAD], 0
  1224 00000339 8EC0                    	mov es, ax
  1225                                   assume es:nothing
  1226 0000033B 31FF                    	xor di, di
  1227 0000033D 26834D02FF              	or word [es:di + NEXTBUF + 2], -1
  1228 00000342 26830DFF                	or word [es:di + NEXTBUF], -1
  1229 00000346 26C74504FF00            	mov word [es:di + BUFDRV], 00FFh
  1230                                  %else
  1231                                  	les	di, [es:di + SYSI_BUF]	;AN020;get the buffer hash entry pointer
  1232                                  HASH_PTR equ Hash_ptr	; NASM port equate
  1233                                  	les	di, [es:di + HASH_PTR]	;AN020;
  1234                                  	mov	word ptr [es:di + BUFFER_BUCKET],0	;AN020;
  1235                                  	mov	word ptr [es:di + BUFFER_BUCKET+2], ax	;AN020;
  1236                                  	mov	es, ax			;AN020;
  1237                                  	xor	ax, ax			;AN020;
  1238                                  	mov	di, ax			;AN020;es:di -> Single buffer
  1239                                  BUF_NEXT equ buf_next	; NASM port equate
  1240                                  	mov	[es:di + BUF_NEXT], ax	;AN020;points to itself
  1241                                  BUF_PREV equ buf_prev	; NASM port equate
  1242                                  	mov	[es:di + BUF_PREV], ax	;AN020;points to itself
  1243                                  BUF_ID equ buf_ID	; NASM port equate
  1244                                  	mov	word ptr [es:di + BUF_ID],00FFh	       ;AN020;free buffer, clear flag
  1245                                  BUF_SECTOR equ buf_sector	; NASM port equate
  1246                                  	mov	word ptr [es:di + BUF_SECTOR], ax	       ;AN020;
  1247                                  	mov	word ptr [es:di + BUF_SECTOR+2], ax       ;AN020;
  1248                                  %endif
  1249 0000034C 5F                      	pop	di			;AN020;
  1250 0000034D 07                      	pop	es			;AN020;
  1251                                   assume es:DOSGROUP
  1252                                  
  1253 0000034E 1E                      	PUSH	DS			; Save as input to RE_INIT
  1254 0000034F 0E                      	PUSH	CS
  1255 00000350 1F                      	POP	DS
  1256                                   ASSUME DS:SYSINITGROUP
  1257 00000351 E86D08                  	CALL	TEMPCDS			; Set up CDSs so RE_INIT and SYSINIT
  1258                                  					;   can make DISK system calls
  1259                                  
  1260                                  init_early_fcbsft:
  1261 00000354 31C0                    	xor ax, ax
  1262 00000356 B004                    	MOV	AL, 4		; ! hardcoded
  1263 00000358 50                      	push ax
  1264 00000359 B33B                    	MOV	BL,SF_ENTRY_struc_size
  1265 0000035B F6E3                    	MUL	BL			;AX = NUMBER OF BYTES TO CLEAR
  1266 0000035D 83C006                  	add ax, 6
  1267 00000360 BE[E622]                	mov si, alloc_initfcb
  1268 00000363 E82C21                  	call allocate_temporary_block
  1269                                   assume es:nothing
  1270                                  
  1271 00000366 36C536[F207]            	LDS si, [ss:DOSINFO]
  1272                                   assume ds:DOSGROUP
  1273                                  
  1274 0000036B 897C1A                  	MOV	WORD PTR [si + SYSI_FCB], di
  1275 0000036E 8C441C                  	MOV	WORD PTR [si + SYSI_FCB+2], es	; SET POINTER TO NEW Table
  1276 00000371 31DB                    	xor bx, bx
  1277 00000373 B302                    	MOV	BL, 2		; ! hardcoded
  1278                                  SYSI_keep equ SYSI_Keep	; NASM port equate
  1279 00000375 895C1E                  	MOV	[si + SYSI_keep],BX
  1280 00000378 0E                      	PUSH	CS
  1281 00000379 1F                      	POP	DS
  1282                                   ASSUME DS:SYSINITGROUP
  1283 0000037A 26830DFF                	or	WORD PTR [ES:DI + SFLINK], -1
  1284 0000037E 59                      	pop cx
  1285 0000037F 26894D04                	mov word [ES:DI + SFCOUNT], cx
  1286                                  
  1287                                  sf_struc_size equ SF_struc_size		; NASM port equate
  1288 00000383 83C706                  	add di, sf_struc_size-2		; es:di -> SFT entries
  1289                                  
  1290 00000386 B041                    	MOV	AL,"A"
  1291                                  .FillLoop:
  1292 00000388 51                      	PUSH	CX			; save count
  1293 00000389 B93B00                  	MOV	CX,sf_entry_struc_size	; number of bytes to fill
  1294 0000038C FC                      	cld
  1295 0000038D F3AA                    	REP	STOSB			; filled
  1296 0000038F 26894DC5                	MOV	WORD PTR [ES:DI-(sf_entry_struc_size)+sf_ref_count], cx
  1297 00000393 26894DDA                	MOV	WORD PTR [ES:DI-(sf_entry_struc_size)+sf_position], cx
  1298 00000397 26894DDC                	MOV	WORD PTR [ES:DI-(sf_entry_struc_size)+sf_position+2], cx
  1299 0000039B 59                      	POP	CX
  1300 0000039C E2EA                    	LOOP	.FillLoop
  1301                                  
  1302 0000039E 1F                      	POP	DS			; Recover DS input to RE_INIT
  1303                                   ASSUME DS:NOTHING
  1304                                  
  1305                                  	%IFN IBMJAPVER
  1306 0000039F E8(0000)                	CALL	RE_INIT			; Re-call the BIOS
  1307                                  	%ENDIF
  1308                                  
  1309 000003A2 FB                      	STI				; INTs OK
  1310 000003A3 FC                      	CLD				; MAKE SURE
  1311                                  
  1312                                  %if 0
  1313                                  ; DOSINIT has set up a default "process" (PHP) at DS:0. We will move it out
  1314                                  ; of the way by putting it just below SYSINIT at end of memory.
  1315                                  	MOV	BX,CS
  1316                                  	SUB	BX,10H
  1317                                  	MOV	ES,BX
  1318                                  	XOR	SI,SI
  1319                                  	MOV	DI,SI
  1320                                  	MOV	CX,80H
  1321                                  	REP	MOVSW
  1322                                  	MOV	WORD PTR [ES:PDB_JFN_Pointer + 2],ES	; Relocate
  1323                                  SET_CURRENT_PDB equ Set_Current_PDB	; NASM port equate
  1324                                  	MOV	AH,SET_CURRENT_PDB
  1325                                  	INT	21H			; Tell DOS we moved it
  1326                                  %endif
  1327                                  
  1328 000003A4 0E                      	PUSH	CS
  1329 000003A5 1F                      	POP	DS
  1330                                   ASSUME DS:SYSINITGROUP
  1331                                  
  1332                                  %if 0
  1333                                  	MOV	BX,0FFFFH
  1334                                  ALLOC equ Alloc	; NASM port equate
  1335                                  	MOV	AH,ALLOC
  1336                                  	INT	21H			;FIRST TIME FAILS
  1337                                  	MOV	AH,ALLOC
  1338                                  	INT	21H			;SECOND TIME GETS IT
  1339                                  	MOV	[AREA],AX
  1340                                  	MOV	[MEMHI],AX		; MEMHI:MEMLO now points to
  1341                                  					; start of free memory
  1342                                  %endif
  1343                                  	%IF	ALTVECT
  1344                                  	MOV	DX,OFFSET BOOTMES
  1345                                  	invoke	PRINT			;Print message DOSINIT couldn't
  1346                                  	%ENDIF
  1347                                  
  1348                                   ASSUME DS:NOTHING
  1349                                  
  1350 000003A6 368A16[2008]            	MOV	DL,[ss:DEFAULT_DRIVE]
  1351 000003AB 08D2                    	OR	DL,DL
  1352 000003AD 7406                    	JZ	NODRVSET		; BIOS didn't say
  1353 000003AF FECA                    	DEC	DL			;A = 0
  1354                                  SET_DEFAULT_DRIVE equ Set_Default_Drive	; NASM port equate
  1355 000003B1 B40E                    	MOV	AH,SET_DEFAULT_DRIVE
  1356 000003B3 CD21                    	INT	21H			;SELECT THE DISK
  1357                                  ;J.K.  2/23/87	Modified to handle INSTALL= command.
  1358                                  NODRVSET:
  1359 000003B5 E8(0000)                	CALL	DOCONF			;DO THE CONFIG STUFF
  1360                                  
  1361                                  do_altah:
  1362                                   assume ds:nothing, es:nothing, ss:SYSINITGROUP
  1363                                   extern altah_option, configmsg.altah_message, configmsg.altah_message.error
  1364                                   extern incompatible_ALTAH, altah_indirect
  1365                                   extern sysinit_get_ds_dosbiodata, sysinit_get_es_dosentry
  1366                                  
  1367 000003B8 2ED006[0000]            	rol byte [cs:altah_option], 1
  1368 000003BD 736F                    	jnc .none
  1369                                  
  1370 000003BF B448                    	mov ah, 48h
  1371 000003C1 31DB                    	xor bx, bx
  1372 000003C3 CD21                    	int 21h
  1373 000003C5 7261                    	jc .error
  1374 000003C7 8EC0                    	mov es, ax
  1375                                   assume es:nothing
  1376                                  
  1377                                  altah_want equ 61Bh + 700h
  1378 000003C9 3DD100                  	cmp ax, paras(altah_want & ~15)
  1379 000003CC 7756                    	ja .error_free
  1380 000003CE BBD200                  	mov bx, paras(altah_want + 1)
  1381 000003D1 29C3                    	sub bx, ax
  1382 000003D3 B44A                    	mov ah, 4Ah
  1383 000003D5 CD21                    	int 21h
  1384 000003D7 724B                    	jc .error_free
  1385                                  
  1386 000003D9 8CC0                    	mov ax, es
  1387 000003DB 2EA3[2F08]              	mov word [cs:altah_block], ax
  1388 000003DF 48                      	dec ax
  1389 000003E0 8ED8                    	mov ds, ax
  1390                                   assume ds:MCB
  1391 000003E2 C70601000800            	mov word [mcbOwner], 8
  1392 000003E8 C70608005300            	mov word [mcbName], "S"
  1393 000003EE C6060A0034              	mov byte [smcbType], S_EXCLDALTAH
  1394                                  
  1395 000003F3 31FF                    	xor di, di
  1396 000003F5 B103                    	mov cl, 3
  1397 000003F7 D3E3                    	shl bx, cl
  1398 000003F9 89D9                    	mov cx, bx
  1399 000003FB B8CCCC                  	mov ax, 0CCCCh
  1400 000003FE F3AB                    	rep stosw
  1401                                  
  1402 00000400 B8[ssss]                	mov ax, DOSENTRY
  1403 00000403 B104                    	mov cl, 4
  1404 00000405 D3E0                    	shl ax, cl
  1405 00000407 BF1B0D                  	mov di, altah_want
  1406 0000040A 29C7                    	sub di, ax
  1407 0000040C E8(0000)                	call sysinit_get_ds_dosbiodata
  1408                                   assume ds:DOSGROUP
  1409 0000040F E8(0000)                	call sysinit_get_es_dosentry
  1410                                   assume es:DOSENTRYGROUP	
  1411 00000412 BB[0000]                	mov bx, incompatible_ALTAH
  1412 00000415 FA                      	cli
  1413 00000416 268A07                  	mov al, [es:bx]
  1414 00000419 893E[0000]              	mov word [altah_indirect], di
  1415 0000041D AA                      	stosb
  1416 0000041E FB                      	sti
  1417                                  
  1418 0000041F BA[0000]                	mov dx, configmsg.altah_message
  1419 00000422 EB07                    	jmp .done
  1420                                  
  1421                                  .error_free:
  1422 00000424 B449                    	mov ah, 49h
  1423 00000426 CD21                    	int 21h
  1424                                  .error:
  1425 00000428 BA[0000]                	mov dx, configmsg.altah_message.error
  1426                                  .done:
  1427 0000042B E8501D                  	call init2_disp_msg_asciz_cs_dx
  1428                                  
  1429                                  .none:
  1430                                   assume ds:nothing, es:nothing, ss:SYSINITGROUP
  1431                                  
  1432                                   extern hidedosentry_option, hidedosdatafirst_option, Arena_Head
  1433                                   extern configmsg.hidedosentry_message
  1434                                   extern configmsg.hidedosentry_error
  1435                                   extern configmsg.hidedosdata_message
  1436                                   extern configmsg.hidedosdata_error
  1437                                  hide_dosentry:
  1438 0000042E 2ED006[0000]            	rol byte [cs:hidedosentry_option], 1
  1439 00000433 733C                    	jnc .no
  1440 00000435 E8(0000)                	call sysinit_get_ds_dosbiodata
  1441                                   assume ds:DOSGROUP
  1442 00000438 A1[0000]                	mov ax, word [Arena_Head]
  1443 0000043B 8EC0                    	mov es, ax
  1444                                   assume es:MCB
  1445 0000043D 26803E00004D            	cmp byte [es:mcbSignature], 'M'
  1446 00000443 7526                    	jne .error
  1447 00000445 26833E010008            	cmp word [es:mcbOwner], 8
  1448 0000044B 751E                    	jne .error
  1449 0000044D 26833E080053            	cmp word [es:mcbName], "S"
  1450 00000453 7516                    	jne .error
  1451 00000455 26803E0A0001            	cmp byte [es:smcbType], S_DOSENTRY
  1452 0000045B 750E                    	jne .error
  1453 0000045D 2603060300              	add ax, [es:mcbSize]
  1454 00000462 40                      	inc ax
  1455 00000463 A3[0000]                	mov word [Arena_Head], ax
  1456 00000466 BA[0000]                	mov dx, configmsg.hidedosentry_message
  1457 00000469 EB03                    	jmp .done
  1458                                  
  1459                                  .error:
  1460 0000046B BA[0000]                	mov dx, configmsg.hidedosentry_error
  1461                                  .done:
  1462 0000046E E80D1D                  	call init2_disp_msg_asciz_cs_dx
  1463                                  
  1464                                  .no:
  1465                                   assume ds:nothing, es:nothing, ss:SYSINITGROUP
  1466                                  
  1467                                  relocate_dosdata_first:
  1468 00000471 2ED006[1208]            	rol byte [cs:dosdata_relocate_first], 1
  1469 00000476 736F                    	jnc @F
  1470 00000478 31D2                    	xor dx, dx			; 0 = relocate in any case, LMA if needed
  1471 0000047A E84F1D                  	call relocate_dosdata
  1472                                  
  1473                                  hide_dosdata_first:
  1474 0000047D 2ED006[0000]            	rol byte [cs:hidedosdatafirst_option], 1
  1475 00000482 7363                    	jnc .no
  1476 00000484 E8(0000)                	call sysinit_get_ds_dosbiodata
  1477                                   assume ds:DOSGROUP
  1478 00000487 A1[0000]                	mov ax, word [Arena_Head]
  1479 0000048A 8CDB                    	mov bx, ds
  1480 0000048C 4B                      	dec bx
  1481                                  .loop:
  1482 0000048D 8EC0                    	mov es, ax
  1483                                   assume es:MCB
  1484 0000048F 39D8                    	cmp ax, bx
  1485 00000491 7420                    	je .found
  1486 00000493 26803E00004D            	cmp byte [es:mcbSignature], 'M'
  1487 00000499 7546                    	jne .error
  1488 0000049B 26833E010008            	cmp word [es:mcbOwner], 8
  1489 000004A1 753E                    	jne .error
  1490 000004A3 26833E080053            	cmp word [es:mcbName], "S"
  1491 000004A9 7536                    	jne .error
  1492 000004AB 2603060300              	add ax, word [es:mcbSize]
  1493 000004B0 40                      	inc ax
  1494 000004B1 EBDA                    	jmp .loop
  1495                                  
  1496                                  .found:
  1497 000004B3 26803E00004D            	cmp byte [es:mcbSignature], 'M'
  1498 000004B9 7526                    	jne .error
  1499 000004BB 26833E010008            	cmp word [es:mcbOwner], 8
  1500 000004C1 751E                    	jne .error
  1501 000004C3 26833E080053            	cmp word [es:mcbName], "S"
  1502 000004C9 7516                    	jne .error
  1503 000004CB 26803E0A0003            	cmp byte [es:smcbType], S_DOSDATA
  1504 000004D1 750E                    	jne .error
  1505 000004D3 2603060300              	add ax, [es:mcbSize]
  1506 000004D8 40                      	inc ax
  1507 000004D9 A3[0000]                	mov word [Arena_Head], ax
  1508 000004DC BA[0000]                	mov dx, configmsg.hidedosdata_message
  1509 000004DF EB03                    	jmp .done
  1510                                  
  1511                                  .error:
  1512 000004E1 BA[0000]                	mov dx, configmsg.hidedosdata_error
  1513                                  .done:
  1514 000004E4 E8971C                  	call init2_disp_msg_asciz_cs_dx
  1515                                  
  1516                                  .no:
  1517                                   assume ds:nothing, es:nothing, ss:SYSINITGROUP
  1518                                  
  1519                                  @@:
  1520                                  
  1521                                  do_multi:
  1522                                   assume ds:nothing, es:nothing, ss:SYSINITGROUP
  1523 000004E7 2EFE06[7208]            	inc	byte [cs:Multi_Pass_Id]	;AN027; = 0
  1524 000004EC E8(0000)                	call	Multi_Pass		;AN027;
  1525 000004EF 2EFE06[7208]            	inc	byte [cs:Multi_Pass_Id]	;AN027; = 1
  1526 000004F4 E8(0000)                	call	Multi_Pass		;AN027;
  1527 000004F7 2EFE06[7208]            	inc	byte [cs:Multi_Pass_Id]	;AN024; = 2
  1528 000004FC E8(0000)                	call	Multi_Pass		;AN024;
  1529                                  EndFile equ ENDFILE	; NASM port label
  1530 000004FF E83F08                  	call	EndFile
  1531 00000502 36F706[7408]0100        	test	word [ss:Install_Flag], HAVE_INSTALL_CMD		;AN019;
  1532 00000509 740B                    	jz	DoLast					;AN019;
  1533 0000050B E86705                  	call relocate_config
  1534 0000050E 2EFE06[7208]            	inc	byte [cs:Multi_Pass_Id]			;AN024; = 3
  1535 00000513 E8(0000)                	call	Multi_Pass				;AN019;AN024; Execute INSTALL= commands
  1536                                  
  1537                                  ;J.K. [AREA] has the segment address for the allocated memory of SYSINIT,CONFBOT.
  1538                                  ;Free the CONFBOT area used for CONFIG.SYS and SYSINIT itself.
  1539                                  DoLast:
  1540                                  
  1541 00000516 B8FFFF                  	mov ax, -1
  1542 00000519 E8FF14                  	call init2_relocate_device
  1543 0000051C B8FFFF                  	mov ax, -1
  1544 0000051F E8021D                  	call init2_relocate_end
  1545                                  
  1546                                  	extern dosdata_to_doscode
  1547                                   assume ds:nothing, es:nothing, ss:SYSINITGROUP
  1548                                  
  1549                                  
  1550                                  relocate_upb_late:
  1551 00000522 E8(0000)                	call sysinit_get_ds_dosentry	; DRVMAX in DOSENTRY
  1552                                   assume ds:DOSENTRYGROUP
  1553 00000525 31F6                    	xor si, si
  1554 00000527 8A2E[0000]              	mov ch, [DRVMAX]		; ch = how many UPBs
  1555                                  %ifnidni %[DOSBIODATA], %[DOSENTRY]
  1556 0000052B E8(0000)                	call sysinit_get_ds_dosbiodata
  1557                                   assume ds:DOSGROUP
  1558                                  %endif
  1559 0000052E C43E[0000]              	les di, [START_BDS]		; es:di -> first UPB
  1560                                   assume es:UPB
  1561 00000532 83FFFF                  	cmp di, -1			; none ?
  1562 00000535 7503E90C01              	je .warn			; then skip -->
  1563 0000053A 84ED                    	test ch, ch
  1564 0000053C 7503E90501              	jz .warn
  1565                                  		; Harden: Expect UPBs at start of memory block.
  1566 00000541 85FF                    	test di, di
  1567 00000543 7403E9FE00              	jnz .warn
  1568 00000548 8CC0                    	mov ax, es
  1569 0000054A 48                      	dec ax
  1570 0000054B 8ED8                    	mov ds, ax
  1571                                   assume ds:MCB
  1572 0000054D 837C0108                	cmp word [si + mcbOwner], 8	; an S MCB ?
  1573 00000551 7403E9F000              	jne .warn
  1574 00000556 837C0853                	cmp word [si + mcbName], "S"	; S MCB ?
  1575 0000055A 7403E9E700              	jne .warn
  1576 0000055F 807C0A09                	cmp byte [si + smcbType], S_UPB	; correct type ?
  1577 00000563 7403E9DE00              	jne .warn
  1578 00000568 8B4403                  	mov ax, [si + mcbSize]
  1579 0000056B B104                    	mov cl, 4
  1580 0000056D D3E0                    	shl ax, cl			; = size in bytes
  1581 0000056F 89C3                    	mov bx, ax
  1582 00000571 D3E8                    	shr ax, cl			; compute paragraphs again
  1583 00000573 394403                  	cmp word [si + mcbSize], ax	; match ?
  1584 00000576 7403E9CB00              	jne .warn
  1585 0000057B B064                    	mov al, BDS_TYPE_struc_size
  1586 0000057D F6E5                    	mul ch				; ax = how many bytes needed for UPBs
  1587 0000057F 39C3                    	cmp bx, ax			; last UPB fits below size ?
  1588 00000581 7303E9C000              	jb .warn			; no -->
  1589 00000586 89C2                    	mov dx, ax
  1590 00000588 83C20F                  	add dx, 15
  1591 0000058B 80E2F0                  	and dl, ~ 15
  1592 0000058E 39D3                    	cmp bx, dx
  1593 00000590 7403E9B100              	jne .warn
  1594                                  
  1595 00000595 88E9                    	mov cl, ch
  1596 00000597 84C9                    	test cl, cl
  1597 00000599 7503E9A800              	jz .warn
  1598 0000059E 06                      	push es
  1599 0000059F 57                      	push di
  1600                                  .loop:
  1601 000005A0 80F901                  	cmp cl, 1
  1602 000005A3 741C                    	je .last
  1603 000005A5 8CC3                    	mov bx, es
  1604 000005A7 26395D02                	cmp word [es:di + LINK + 2], bx
  1605 000005AB 7403E99400              	jne .warn_pop_pop
  1606 000005B0 8D5D64                  	lea bx, [di + BDS_TYPE_struc_size]
  1607 000005B3 26391D                  	cmp word [es:di + LINK], bx
  1608 000005B6 7403E98900              	jne .warn_pop_pop
  1609 000005BB 49                      	dec cx				; count down
  1610 000005BC 26C43D                  	les di, [es:di + LINK]
  1611                                   assume es:UPB
  1612 000005BF EBDF                    	jmp .loop
  1613                                  
  1614                                  .last:
  1615 000005C1 26833DFF                	cmp word [es:di + LINK], -1
  1616 000005C5 7408                    	je @F
  1617 000005C7 8CC3                    	mov bx, es
  1618 000005C9 26395D02                	cmp word [es:di + LINK + 2], bx
  1619 000005CD 7477                    	je .warn
  1620                                  @@:
  1621                                  
  1622 000005CF BE[4023]                	mov si, alloc_upb
  1623 000005D2 51                      	push cx
  1624 000005D3 50                      	push ax
  1625 000005D4 E8A71D                  	call allocate_relocate_block
  1626                                   assume es:nothing
  1627 000005D7 59                      	pop cx				; = size of initialised UPBs
  1628 000005D8 5B                      	pop bx				; bh = number of UPBs
  1629 000005D9 5E                      	pop si
  1630 000005DA 1F                      	pop ds				; -> first UPB source
  1631                                   assume ds:UPB
  1632 000005DB 56                      	 push si
  1633 000005DC 89FA                    	mov dx, di			; es:dx -> destination
  1634 000005DE F3A4                    	rep movsb			; copy them over
  1635 000005E0 89D7                    	mov di, dx			; es:di -> copied UPBs
  1636 000005E2 89D6                    	mov si, dx			; es:si -> first UPB in new allocation
  1637 000005E4 31C9                    	xor cx, cx
  1638 000005E6 08F9                    	or cl, bh			; cx = amount UPBs
  1639 000005E8 5B                      	 pop bx				; ds:bx -> source
  1640 000005E9 8CDA                    	mov dx, ds
  1641 000005EB 7438                    	jz .warn_free
  1642                                  .newloop:
  1643 000005ED 49                      	dec cx
  1644 000005EE 741E                    	jz .newlast
  1645 000005F0 26395502                	cmp word [es:di + LINK + 2], dx
  1646 000005F4 752F                    	jne .warn_free
  1647 000005F6 8D4764                  	lea ax, [bx + BDS_TYPE_struc_size]
  1648                                  					; ds:ax -> next expected source UPB
  1649 000005F9 263905                  	cmp word [es:di + LINK], ax
  1650 000005FC 7527                    	jne .warn_free
  1651 000005FE 93                      	xchg bx, ax			; ds:bx -> next source UPB
  1652                                  		; ! in HMA allocstion the offset is changed
  1653 000005FF 8D4564                  	lea ax, [di + BDS_TYPE_struc_size]
  1654                                  					; es:di -> next destination
  1655 00000602 268C4502                	mov word [es:di + LINK + 2], es	; relocate next link segment
  1656 00000606 268905                  	mov word [es:di + LINK], ax	; relocate next link offset
  1657 00000609 26C43D                  	les di, [es:di + LINK]
  1658                                   assume es:nothing
  1659 0000060C EBDF                    	jmp .newloop
  1660                                  
  1661                                  .newlast:
  1662                                  		; ! last relocated UPB's next link pointer is left alone
  1663                                  
  1664 0000060E E8(0000)                	call sysinit_get_ds_dosbiodata
  1665                                   assume ds:DOSGROUP
  1666 00000611 FA                      	cli
  1667 00000612 8CC0                    	mov ax, es
  1668 00000614 8936[0000]              	mov word [START_BDS], si
  1669 00000618 8706[0200]              	xchg word [START_BDS + 2], ax	; relocate the UPBs
  1670 0000061C FB                      	sti
  1671 0000061D 8EC0                    	mov es, ax
  1672                                   assume es:nothing
  1673 0000061F B449                    	mov ah, 49h
  1674 00000621 CD21                    	int 21h				; free the original allocation
  1675 00000623 EB30                    	jmp .done
  1676                                  
  1677                                  .warn_free:
  1678 00000625 8CC3                    	mov bx, es
  1679 00000627 83FBFE                  	cmp bx, -2			; HMA ?
  1680 0000062A 7213                    	jb @F				; no -->
  1681 0000062C 7706                    	ja .warn_free_hma_essi		; it is es == 0FFFFh -->
  1682                                  					; it is es == 0FFFEh
  1683 0000062E 43                      	inc bx				; = 0FFFFh
  1684 0000062F 8EC3                    	mov es, bx			; es = 0FFFFh
  1685                                   assume es:nothing
  1686 00000631 83EE10                  	sub si, 16			; es:si -> HMA allocation
  1687                                  .warn_free_hma_essi:
  1688 00000634 89F7                    	mov di, si
  1689 00000636 B8034A                  	mov ax, 4A03h
  1690 00000639 B202                    	mov dl, 2
  1691 0000063B CD2F                    	int 2Fh				; free new HMA allocation
  1692 0000063D EB07                    	jmp .warn
  1693                                  
  1694                                  @@:
  1695 0000063F B449                    	mov ah, 49h
  1696 00000641 CD21                    	int 21h				; free new LMA/UMA allocation
  1697 00000643 A9                      	db __TEST_IMM16			; skip twice pop
  1698                                  .warn_pop_pop:
  1699 00000644 58                      	pop ax
  1700 00000645 58                      	pop ax
  1701                                  .warn:
  1702 00000646 0E                      	push cs
  1703 00000647 1F                      	pop ds
  1704                                   assume ds:SYSINITGROUP
  1705 00000648 BA[3F25]                	mov dx, sysinit_msg.warn_upb
  1706 0000064B B92800                  	mov cx, sysinit_msg.warn_upb.size
  1707 0000064E BB0100                  	mov bx, 1
  1708 00000651 B440                    	mov ah, 40h
  1709 00000653 CD21                    	int 21h
  1710                                  .done:
  1711                                   assume ds:nothing, es:nothing, ss:SYSINITGROUP
  1712                                  
  1713                                  
  1714                                  relocate_dpb_late:
  1715 00000655 E8(0000)                	call sysinit_getdosdata
  1716 00000658 8ED8                    	mov ds, ax
  1717                                   assume ds:DOSGROUP
  1718 0000065A 31F6                    	xor si, si
  1719 0000065C 8A2E[0000]              	mov ch, [NUMIO]			; ch = how many DPBs at most
  1720 00000660 C43E[0000]              	les di, [DPBHEAD]		; es:di -> first DPB
  1721                                   assume es:DPB
  1722 00000664 83FFFF                  	cmp di, -1			; none ?
  1723 00000667 7503E98401              	je .warn			; then skip -->
  1724 0000066C 84ED                    	test ch, ch
  1725 0000066E 7503E97D01              	jz .warn
  1726                                  		; Harden: Expect DPBs at start of memory block.
  1727 00000673 85FF                    	test di, di
  1728 00000675 7403E97601              	jnz .warn
  1729 0000067A 8CC0                    	mov ax, es
  1730 0000067C 48                      	dec ax
  1731 0000067D 8ED8                    	mov ds, ax
  1732                                   assume ds:MCB
  1733                                  		; We expect at least two DOS-internal DPBs.
  1734                                  		;  Although we do somewhat work if none are
  1735                                  		;  used, we can warn here anyway.
  1736 0000067F 837C0108                	cmp word [si + mcbOwner], 8	; an S MCB ?
  1737 00000683 7403E96801              	jne .warn
  1738 00000688 837C0853                	cmp word [si + mcbName], "S"	; S MCB ?
  1739 0000068C 7403E95F01              	jne .warn
  1740 00000691 807C0A08                	cmp byte [si + smcbType], S_DPB	; correct type ?
  1741 00000695 7403E95601              	jne .warn
  1742 0000069A 8B4403                  	mov ax, [si + mcbSize]
  1743 0000069D 89C2                    	mov dx, ax
  1744 0000069F B104                    	mov cl, 4
  1745 000006A1 D3E0                    	shl ax, cl			; = size in bytes
  1746 000006A3 D3E8                    	shr ax, cl			; compute paragraphs again
  1747 000006A5 394403                  	cmp word [si + mcbSize], ax	; match ?
  1748 000006A8 7403E94301              	jne .warn
  1749                                  
  1750 000006AD 88E9                    	mov cl, ch
  1751 000006AF 84C9                    	test cl, cl
  1752 000006B1 7503E93A01              	jz .warn
  1753 000006B6 B500                    	mov ch, 0
  1754 000006B8 06                      	push es
  1755 000006B9 57                      	push di
  1756                                  .loop:
  1757 000006BA FEC5                    	inc ch
  1758 000006BC 80F901                  	cmp cl, 1
  1759 000006BF 7418                    	je .last
  1760 000006C1 8CC3                    	mov bx, es
  1761 000006C3 26395D1B                	cmp word [es:di + dpb_next_dpb + 2], bx
  1762 000006C7 7522                    	jne .havelast_pop_pop
  1763 000006C9 8D5D21                  	lea bx, [di + dpb_struc_size]
  1764 000006CC 26395D19                	cmp word [es:di + dpb_next_dpb], bx
  1765 000006D0 7519                    	jne .havelast_pop_pop
  1766 000006D2 49                      	dec cx				; count down
  1767 000006D3 26C47D19                	les di, [es:di + dpb_next_dpb]
  1768                                   assume es:DPB
  1769 000006D7 EBE1                    	jmp .loop
  1770                                  
  1771                                  .last:
  1772 000006D9 26837D19FF              	cmp word [es:di + dpb_next_dpb], -1
  1773 000006DE 740B                    	je @F
  1774 000006E0 8CC3                    	mov bx, es
  1775 000006E2 26395D1B                	cmp word [es:di + dpb_next_dpb + 2], bx
  1776 000006E6 7503E90301              	je .warn_pop_pop
  1777                                  @@:
  1778                                  .havelast_pop_pop:
  1779 000006EB 8D4521                  	lea ax, [di + dpb_struc_size]
  1780 000006EE 50                      	push ax
  1781 000006EF E8230A                  	call ParaRound
  1782 000006F2 39D0                    	cmp ax, dx			; MCB size matches ?
  1783 000006F4 58                      	pop ax
  1784 000006F5 7403E9F400              	jne .warn_pop_pop
  1785                                  
  1786 000006FA BE[5423]                	mov si, alloc_dpb
  1787 000006FD 51                      	push cx
  1788 000006FE 50                      	push ax
  1789 000006FF E87C1C                  	call allocate_relocate_block
  1790                                   assume es:nothing
  1791 00000702 59                      	pop cx				; = size of relocateable DPBs
  1792 00000703 5B                      	pop bx				; bh = number of relocateable DPBs
  1793 00000704 5E                      	pop si
  1794 00000705 1F                      	pop ds				; -> first DPB source
  1795                                   assume ds:UPB
  1796 00000706 56                      	 push si
  1797 00000707 89FA                    	mov dx, di			; es:dx -> destination
  1798 00000709 F3A4                    	rep movsb			; copy them over
  1799 0000070B 89D7                    	mov di, dx			; es:di -> copied DPBs
  1800 0000070D 89D6                    	mov si, dx			; es:si -> first DPB in new allocation
  1801 0000070F 31C9                    	xor cx, cx
  1802 00000711 08F9                    	or cl, bh			; cl = amount relocated DPBs
  1803 00000713 5B                      	 pop bx				; ds:bx -> source
  1804 00000714 89DD                    	mov bp, bx			; dx:bp -> first source DPB
  1805 00000716 88CD                    	mov ch, cl			; ch = amount relocated DPBs
  1806 00000718 8CDA                    	mov dx, ds
  1807 0000071A 7503E9B000              	jz .warn_free
  1808                                  .newloop:
  1809 0000071F FEC9                    	dec cl
  1810 00000721 7427                    	jz .newlast
  1811 00000723 2639551B                	cmp word [es:di + dpb_next_dpb + 2], dx
  1812 00000727 7403E9A300              	jne .warn_free
  1813 0000072C 8D4721                  	lea ax, [bx + dpb_struc_size]
  1814                                  					; ds:ax -> next expected source UPB
  1815 0000072F 26394519                	cmp word [es:di + dpb_next_dpb], ax
  1816 00000733 7403E99700              	jne .warn_free
  1817 00000738 93                      	xchg bx, ax			; ds:bx -> next source UPB
  1818                                  		; ! in HMA allocstion the offset is changed
  1819 00000739 8D4521                  	lea ax, [di + dpb_struc_size]
  1820                                  					; es:di -> next destination
  1821 0000073C 268C451B                	mov word [es:di + dpb_next_dpb + 2], es	; relocate next link segment
  1822 00000740 26894519                	mov word [es:di + dpb_next_dpb], ax	; relocate next link offset
  1823 00000744 26C47D19                	les di, [es:di + dpb_next_dpb]
  1824                                   assume es:nothing
  1825 00000748 EBD5                    	jmp .newloop
  1826                                  
  1827                                  .newlast:
  1828                                  		; ! last relocated DPB's next link pointer is left alone
  1829                                  
  1830                                  		; now we have to relocate all references to the DPBs.
  1831                                  		;  there's buffers, CDSes, SFTs, and FCB SFTs.
  1832                                  		; INP:	dx:bp -> first relocated DPB source
  1833                                  		;	ch = amount
  1834                                  		;	es:si -> first destination DPB
  1835 0000074A 06                      	push es
  1836 0000074B 56                      	push si
  1837 0000074C 88E9                    	mov cl, ch
  1838 0000074E B500                    	mov ch, 0
  1839                                  
  1840                                   extern BUFFHEAD, CDSADDR, CDSCOUNT, sft_addr, sftFCB
  1841                                  
  1842                                  .relocloop:
  1843 00000750 51                      	push cx
  1844                                  
  1845                                   %ifndef BUF2
  1846                                    %fatal DPB reloc not done for non-BUF2
  1847                                   %endif
  1848                                  
  1849 00000751 E8(0000)                	call sysinit_getdosdata
  1850 00000754 8ED8                    	mov ds, ax
  1851                                   assume ds:DOSGROUP
  1852 00000756 C53E[0000]              	lds di, [BUFFHEAD]
  1853                                   assume ds:nothing
  1854                                  @@:
  1855 0000075A 83FFFF                  	cmp di, -1
  1856 0000075D 7410                    	je @FF
  1857 0000075F 807D04FF                	cmp byte [di + BUFDRV], -1
  1858 00000763 7406                    	je @F
  1859 00000765 BB0C00                  	mov bx, BUFDRVDP
  1860 00000768 E85603                  	call relocate_dibx_dpb_from_dxbp_to_essi
  1861                                  @@:
  1862 0000076B C53D                    	lds di, [di + NEXTBUF]
  1863                                   assume ds:nothing
  1864 0000076D EBEB                    	jmp @BB
  1865                                  
  1866                                  @@:
  1867                                  
  1868 0000076F E8(0000)                	call sysinit_getdosdata
  1869 00000772 8ED8                    	mov ds, ax
  1870                                   assume ds:DOSGROUP
  1871 00000774 8A0E[0000]              	mov cl, byte [CDSCOUNT]		; ch already 0
  1872 00000778 C53E[0000]              	lds di, [CDSADDR]
  1873                                   assume ds:nothing
  1874                                  @@:
  1875 0000077C F6454480                	testopt [di + curdir_flags], curdir_isnet
  1876                                  					; net or IFS ?
  1877 00000780 7506                    	jnz @F				; yes, don't check -->
  1878 00000782 BB4500                  	mov bx, curdir_devptr
  1879 00000785 E83903                  	call relocate_dibx_dpb_from_dxbp_to_essi
  1880                                  @@:
  1881 00000788 83C758                  	add di, curdir_list_struc_size
  1882 0000078B E2EF                    	loop @BB
  1883                                  
  1884 0000078D E8(0000)                	call sysinit_getdosdata
  1885 00000790 8ED8                    	mov ds, ax
  1886                                   assume ds:DOSGROUP
  1887 00000792 C53E[0000]              	lds di, [sft_addr]
  1888                                   assume ds:nothing
  1889 00000796 E83903                  	call reloc_dpb_in_sftc
  1890                                  
  1891 00000799 E8(0000)                	call sysinit_getdosdata
  1892 0000079C 8ED8                    	mov ds, ax
  1893                                   assume ds:DOSGROUP
  1894 0000079E C53E[0000]              	lds di, [sftFCB]
  1895                                   assume ds:nothing
  1896 000007A2 E82D03                  	call reloc_dpb_in_sftc
  1897                                  
  1898                                  .relocnext:
  1899 000007A5 59                      	pop cx
  1900 000007A6 26C47419                	les si, [es:si + dpb_next_dpb]
  1901                                   assume es:nothing
  1902 000007AA 8EDA                    	mov ds, dx
  1903                                   assume ds:nothing
  1904 000007AC 3EC56E19                	lds bp, [ds:bp + dpb_next_dpb]
  1905                                   assume ds:nothing
  1906 000007B0 8CDA                    	mov dx, ds
  1907 000007B2 E29C                    	loop .relocloop
  1908                                  
  1909 000007B4 5E                      	pop si
  1910 000007B5 07                      	pop es
  1911                                   assume es:nothing
  1912                                  
  1913 000007B6 E8(0000)                	call sysinit_getdosdata
  1914 000007B9 8ED8                    	mov ds, ax
  1915                                   assume ds:DOSGROUP
  1916 000007BB FA                      	cli
  1917 000007BC 8CC0                    	mov ax, es
  1918 000007BE 8936[0000]              	mov word [DPBHEAD], si
  1919 000007C2 8706[0200]              	xchg word [DPBHEAD + 2], ax	; relocate the DPBs
  1920 000007C6 FB                      	sti
  1921 000007C7 8EC0                    	mov es, ax
  1922                                   assume es:nothing
  1923 000007C9 B449                    	mov ah, 49h
  1924 000007CB CD21                    	int 21h				; free the original allocation
  1925 000007CD EB30                    	jmp .done
  1926                                  
  1927                                  .warn_free:
  1928 000007CF 8CC3                    	mov bx, es
  1929 000007D1 83FBFE                  	cmp bx, -2			; HMA ?
  1930 000007D4 7213                    	jb @F				; no -->
  1931 000007D6 7706                    	ja .warn_free_hma_essi		; it is es == 0FFFFh -->
  1932                                  					; it is es == 0FFFEh
  1933 000007D8 43                      	inc bx				; = 0FFFFh
  1934 000007D9 8EC3                    	mov es, bx			; es = 0FFFFh
  1935                                   assume es:nothing
  1936 000007DB 83EE10                  	sub si, 16			; es:si -> HMA allocation
  1937                                  .warn_free_hma_essi:
  1938 000007DE 89F7                    	mov di, si
  1939 000007E0 B8034A                  	mov ax, 4A03h
  1940 000007E3 B202                    	mov dl, 2
  1941 000007E5 CD2F                    	int 2Fh				; free new HMA allocation
  1942 000007E7 EB07                    	jmp .warn
  1943                                  
  1944                                  @@:
  1945 000007E9 B449                    	mov ah, 49h
  1946 000007EB CD21                    	int 21h				; free new LMA/UMA allocation
  1947 000007ED A9                      	db __TEST_IMM16			; skip twice pop
  1948                                  .warn_pop_pop:
  1949 000007EE 58                      	pop ax
  1950 000007EF 58                      	pop ax
  1951                                  .warn:
  1952 000007F0 0E                      	push cs
  1953 000007F1 1F                      	pop ds
  1954                                   assume ds:SYSINITGROUP
  1955 000007F2 BA[6725]                	mov dx, sysinit_msg.warn_dpb
  1956 000007F5 B92800                  	mov cx, sysinit_msg.warn_dpb.size
  1957 000007F8 BB0100                  	mov bx, 1
  1958 000007FB B440                    	mov ah, 40h
  1959 000007FD CD21                    	int 21h
  1960                                  .done:
  1961                                   assume ds:nothing, es:nothing, ss:SYSINITGROUP
  1962                                  
  1963                                  
  1964                                  %imacro neartransfer 1.nolist
  1965                                  	extern %1
  1966                                  	call transfer_sysinitseg_to_doscode
  1967                                  	jmp strict short %%skip
  1968                                  	dw %1
  1969                                  %%skip:
  1970                                  %endmacro
  1971                                  
  1972                                   extern transfer_sysinitseg_to_doscode
  1973                                  
  1974                                  shrink_altah_block:
  1975 000007FF 2EA1[2F08]              	mov ax, word [cs:altah_block]
  1976 00000803 85C0                    	test ax, ax
  1977 00000805 7434                    	jz .none
  1978 00000807 48                      	dec ax
  1979 00000808 8ED8                    	mov ds, ax
  1980                                   assume ds:MCB
  1981 0000080A 8B1E0300                	mov bx, word [mcbSize]
  1982 0000080E 31FF                    	xor di, di
  1983 00000810 83FB01                  	cmp bx, 1
  1984 00000813 7626                    	jbe .done
  1985 00000815 BA0800                  	mov dx, 8
  1986 00000818 8D4FFE                  	lea cx, [bx - 2]
  1987 0000081B E8(0000)EB02[0000]      	neartransfer SplitMCB
  1988 00000822 E8(0000)EB02[0000]      	neartransfer ClearMCB
  1989 00000829 8EDA                    	mov ds, dx
  1990                                   assume ds:MCB
  1991 0000082B C606080053              	mov byte [mcbName], 'S'
  1992 00000830 C6060A0034              	mov byte [smcbType], S_EXCLDALTAH
  1993 00000835 42                      	inc dx
  1994 00000836 2E8916[2F08]            	mov word [cs:altah_block], dx
  1995                                  .done:
  1996                                  .none:
  1997                                   assume ds:nothing, es:nothing, ss:SYSINITGROUP
  1998                                  
  1999                                  
  2000                                  relocate_psp_late:
  2001 0000083B B86000                  	mov ax, 60h
  2002 0000083E BE[2C23]                	mov si, alloc_initpsp
  2003 00000841 E83A1B                  	call allocate_relocate_block
  2004                                   assume es:nothing
  2005 00000844 B462                    	mov ah, 62h
  2006 00000846 CD21                    	int 21h			; get old PSP
  2007 00000848 8EDB                    	mov ds, bx
  2008                                   assume ds:nothing
  2009 0000084A 89DA                    	mov dx, bx
  2010 0000084C 31F6                    	xor si, si		; ds:si -> old PSP
  2011 0000084E B93000                  	mov cx, words(60h)
  2012 00000851 F3A5                    	rep movsw
  2013 00000853 8CC0                    	mov ax, es
  2014                                  
  2015                                  		; Because of the abort.nas "Scan" handling we
  2016                                  		;  have to relocate the owner process of open
  2017                                  		;  SFT entries that we want to keep across the
  2018                                  		;  process termination. This code may become
  2019                                  		;  useless once we improve "Scan" but it won't
  2020                                  		;  do any harm to keep doing this.
  2021 00000855 1E                      	push ds
  2022 00000856 E8(0000)                	call sysinit_get_ds_dosbiodata
  2023                                   assume ds:DOSGROUP
  2024 00000859 C536[0000]              	lds si, [sft_addr]
  2025                                   assume ds:nothing
  2026                                  .loop_sftc:
  2027 0000085D 46                      	inc si
  2028 0000085E 7421                    	jz .done_sftc
  2029 00000860 56                      	push si
  2030 00000861 8B4C03                  	mov cx, word [si - 1 + SFCount]
  2031 00000864 E315                    	jcxz .next_sftc
  2032 00000866 83C605                  	add si, SFTable - 1
  2033                                  .loop_sft:
  2034 00000869 833C00                  	cmp word [si + sf_ref_count], 0
  2035 0000086C 7408                    	je .next_sft
  2036 0000086E 395431                  	cmp word [si + sf_PID], dx
  2037 00000871 7503                    	jne .next_sft
  2038 00000873 894431                  	mov word [si + sf_PID], ax
  2039                                  .next_sft:
  2040 00000876 83C63B                  	add si, sf_entry_struc_size
  2041 00000879 E2EE                    	loop .loop_sft
  2042                                  .next_sftc:
  2043 0000087B 5E                      	pop si
  2044 0000087C C574FF                  	lds si, [si - 1 + SFLink]
  2045                                   assume ds:nothing
  2046 0000087F EBDC                    	jmp .loop_sftc
  2047                                  .done_sftc:
  2048 00000881 1F                      	pop ds
  2049                                   assume ds:nothing
  2050                                  
  2051                                  	; mov es, ax		; es = new PSP
  2052 00000882 BF1800                  	mov di, 18h
  2053 00000885 B91400                  	mov cx, 20
  2054 00000888 26A33600                	mov word [ es:34h+2 ], ax
  2055 0000088C 26893E3400              	mov word [ es:34h ], di	; fix the new PSP's PHT pointer
  2056 00000891 26890E3200              	mov word [ es:32h ], cx	;  and the count of PHT entries field
  2057 00000896 50                      	 push ax
  2058 00000897 B0FF                    	mov al, -1
  2059 00000899 57                      	 push di
  2060 0000089A 89CB                    	mov bx, cx		; = 20
  2061 0000089C F3AA                    	rep stosb		; initialise new PHT with empty entries
  2062 0000089E 5F                      	 pop di
  2063 0000089F 8B0E3200                	mov cx, word [ 32h ]	; cx = count of PHT entries
  2064 000008A3 39D9                    	cmp cx, bx		; >= 20 ?
  2065 000008A5 7202                    	jb .shortertable	; no -->
  2066 000008A7 89D9                    	mov cx, bx		; limit to 20
  2067                                  .shortertable:
  2068 000008A9 C5363400                	lds si, [ 34h ]		; ds:si-> old PHT
  2069 000008AD 56                      	push si
  2070 000008AE 51                      	push cx
  2071 000008AF F3A4                    	rep movsb		; get all entries
  2072 000008B1 59                      	pop cx
  2073 000008B2 5F                      	pop di
  2074 000008B3 1E                      	 push ds
  2075 000008B4 07                      	 pop es			; es:di-> old PHT
  2076                                   assume es:nothing
  2077 000008B5 F3AA                    	rep stosb		; fill moved entries with -1 (closed)
  2078 000008B7 8EDA                    	mov ds, dx		; ds = old PSP
  2079                                   assume ds:nothing
  2080 000008B9 C7060A00[0C09]          	mov word [ 0Ah ], .terminated
  2081 000008BF 8C0E0C00                	mov word [ 0Ah+2 ], cs
  2082 000008C3 B82335                  	mov ax, 3523h
  2083 000008C6 CD21                    	int 21h
  2084 000008C8 891E0E00                	mov word [ 0Eh ], bx
  2085 000008CC 8C061000                	mov word [ 0Eh+2 ], es
  2086 000008D0 B82435                  	mov ax, 3524h
  2087 000008D3 CD21                    	int 21h
  2088 000008D5 891E1200                	mov word [ 12h ], bx
  2089 000008D9 8C061400                	mov word [ 12h+2 ], es	; set interrupt vectors to ours
  2090 000008DD 58                      	 pop ax
  2091 000008DE A31600                  	mov word [ 16h ], ax	; set parent PSP to the relocated one
  2092 000008E1 8EC0                    	mov es, ax
  2093                                   assume es:nothing
  2094 000008E3 268C163000              	mov word [ es:2Eh+2 ], ss
  2095                                  				; set SS used by process termination
  2096                                  
  2097 000008E8 93                      	xchg ax, bx		; bx = new location, dx = old location
  2098 000008E9 B85D33                  	mov ax, 335Dh
  2099 000008EC CD21                    	int 21h			; PSP relocated call-out
  2100 000008EE 89D7                    	mov di, dx
  2101                                  
  2102                                  		; In order to set the correct stack address here,
  2103                                  		; the last Int21 call to a usual function (such as
  2104                                  		; Int21.48) must've been made with the same stack
  2105                                  		; pointer as the Int21.4C call below gets.
  2106                                  		;
  2107                                  		; Update: dosemu2 does weird things to the stack.
  2108                                  		;  In particular, it inserts an additional iret
  2109                                  		;  frame depending on some conditions.
  2110                                  		; Only the interrupt 21h subfunctions 00h, 26h,
  2111                                  		;  31h, 4Bh, and 4Ch are handled differently.
  2112                                  		;  As a workaround we can call service 4Bh as the
  2113                                  		;  last interrupt 21h function before terminating.
  2114                                  		; Refer to https://github.com/dosemu2/dosemu2/blob/d7402eec84478c051d25e7b26dd8515514c186e2/src/base/core/int.c#L1633-L1639
  2115                                  
  2116                                  	; rol byte [j_flags.invalidexec], 1
  2117                                  	; jnc @F
  2118                                  
  2119 000008F0 0E                      	push cs
  2120 000008F1 1F                      	pop ds
  2121                                   assume ds:SYSINITGROUP
  2122 000008F2 BA[8F25]                	mov dx, sysinit_msg.nullbyte
  2123                                  				; just in case, ds:dx -> zero value byte
  2124 000008F5 B87F4B                  	mov ax, 4B7Fh		; 21.4B with invalid subfunction in al
  2125                                  				;  (note that FreeDOS masks off 80h)
  2126 000008F8 CD21                    	int 21h
  2127                                  @@:
  2128                                  
  2129 000008FA 8EDF                    	mov ds, di
  2130                                   assume ds:nothing
  2131 000008FC 8EC3                    	mov es, bx
  2132                                   assume es:nothing
  2133 000008FE FF362E00                	push word [ 2Eh ]
  2134 00000902 268F062E00              	pop word [ es:2Eh ]	; set SP used by process termination
  2135                                  .nullbyte: equ $ - 1
  2136                                  
  2137 00000907 B8004C                  	mov ax, 4C00h
  2138 0000090A CD21                    	int 21h			; terminate, and make the new PSP active
  2139                                  				; also handles freeing all memory allocated to the old PSP
  2140                                  				; also closes any handles >20 if PHT larger
  2141                                  				; also relocates Int23, Int24
  2142                                  				; also notifies resident software old PSP is no longer valid
  2143                                  .terminated:			; (ax, bx, es, ds, bp might be changed)
  2144                                   assume ds:nothing, es:nothing, ss:SYSINITGROUP
  2145                                  
  2146 0000090C 36F706[7408]0100        	test	word [ss:Install_Flag], HAVE_INSTALL_CMD		;AN019;
  2147 00000913 740B                    	jz	@F					;AN019;
  2148 00000915 E85D01                  	call relocate_config
  2149 00000918 2EFE06[7208]            	inc	byte [cs:Multi_Pass_Id]		; = 4
  2150 0000091D E8(0000)                	call	Multi_Pass			; Execute INSTALLLAST=
  2151                                  @@:
  2152                                   assume ds:nothing, es:nothing, ss:SYSINITGROUP
  2153                                  
  2154 00000920 31C9                    	xor cx, cx
  2155 00000922 2E870E[2B08]            	xchg cx, word [cs:config_block]
  2156 00000927 E306                    	jcxz @F
  2157 00000929 8EC1                    	mov es, cx
  2158                                   assume es:nothing
  2159 0000092B B449                    	mov ah, 49h
  2160 0000092D CD21                    	int 21h
  2161                                  @@:
  2162                                   assume ds:nothing, es:nothing, ss:SYSINITGROUP
  2163                                  
  2164 0000092F 0E                      	 push cs
  2165 00000930 1F                      	 pop ds
  2166                                   assume ds:SYSINITGROUP
  2167 00000931 0E                      	 push cs
  2168 00000932 07                      	 pop es
  2169                                   assume ds:SYSINITGROUP, es:SYSINITGROUP, ss:SYSINITGROUP
  2170                                  
  2171 00000933 E8620C                  	call	LoadShare		;AN021; Try to load share.exe, if needed.
  2172 00000936 2EC606[3D09]01          	mov	byte [cs:DoNotShowNum], 1	;AN000; Done with CONFIG.SYS. Do not show line number message.
  2173                                  %if 0
  2174                                  	mov	cx, [ss:area]		;AN000;
  2175                                  	mov	es, cx			;AN000;
  2176                                  	mov	ah, 49h 		;AN000; Free allocated memory for command.com
  2177                                  	int	21h			;AN000;
  2178                                  
  2179                                  Install_flag equ Install_Flag	; NASM port label
  2180                                  	test	word [cs:Install_flag], HAS_INSTALLED ;AN013; SYSINIT_BASE installed?
  2181                                  	jz	Skip_Free_SYSINITBASE		 ;AN013; No.
  2182                                  ;Set Block from the Old_Area with Impossible_Owner_size.
  2183                                  ;This will free the unnecessary SYSINIT_BASE that had been put in memory to
  2184                                  ;handle INSTALL= command.
  2185                                  	push	es			       ;AN013;
  2186                                  	push	bx			       ;AN013;
  2187                                  	mov	ax, [cs:Old_Area]	       ;AN013;
  2188                                  	mov	es, ax			       ;AN013;
  2189                                  	mov	bx, [cs:Impossible_Owner_Size] ;AN013;
  2190                                  SETBLOCK equ Setblock	; NASM port equate
  2191                                  	mov	ah, SETBLOCK		       ;AN013;
  2192                                  	int	21h			       ;AN013;
  2193                                  	MOV	AX,ES			       ;AN013;
  2194                                  	DEC	AX			       ;AN013;
  2195                                  	MOV	ES,AX			       ;Point to arena
  2196                                  	MOV	word [ES:arena_owner],8	       ;Set impossible owner
  2197                                  	mov word ptr [es:arena_name], "SD"	; set SD name	; NASM port swapped text literals
  2198                                  	and word ptr [es:arena_name + 2], 0	; NUL
  2199                                  	pop	bx			       ;AN013;
  2200                                  	pop	es			       ;AN013;
  2201                                  Skip_Free_SYSINITBASE:			       ;AN013;
  2202                                  %endif
  2203                                  	%IF	NOEXEC
  2204                                  	MOV	BP,DS			       ;SAVE COMMAND.COM SEGMENT
  2205                                  	PUSH	DS
  2206                                  	POP	ES
  2207                                  	MOV	BX,CS
  2208                                  	SUB	BX,10H			       ; Point to current PHP
  2209                                  	MOV	DS,BX
  2210                                  	XOR	SI,SI
  2211                                  	MOV	DI,SI
  2212                                  	MOV	CX,80H
  2213                                  	REP	MOVSW			       ; Copy it to new location for shell
  2214                                  	MOV	WORD PTR [ES:PDB_JFN_Pointer + 2],ES	; Relocate
  2215                                  	MOV	BX,ES
  2216                                  	MOV	AH,SET_CURRENT_PDB
  2217                                  	INT	21H			       ; Tell DOS we moved it
  2218                                  PDB_PARENT_PID equ PDB_Parent_PID	; NASM port equate
  2219                                  	MOV	[ES:PDB_PARENT_PID],ES	       ;WE ARE THE ROOT
  2220                                  	%ENDIF
  2221                                  
  2222 0000093C 0E                      	PUSH	CS
  2223 0000093D 1F                      	POP	DS
  2224                                   ASSUME DS:SYSINITGROUP
  2225                                  ;
  2226                                  ; SET UP THE PARAMETERS FOR COMMAND
  2227                                  ;
  2228                                  
  2229 0000093E BE[3408]                	MOV	SI,OFFSET COMMAND_LINE+1
  2230                                  
  2231                                  	%IF	NOEXEC
  2232                                  	MOV	DI,81H
  2233                                  	%ELSE
  2234 00000941 1E                      	PUSH	DS
  2235 00000942 07                      	POP	ES
  2236                                   assume es:SYSINITGROUP
  2237 00000943 89F7                    	MOV	DI,SI
  2238                                  	%ENDIF
  2239                                  
  2240 00000945 B1FF                    	MOV	CL,-1
  2241                                  COMTRANLP:				;FIND LENGTH OF COMMAND LINE
  2242 00000947 FEC1                    	INC	CL
  2243 00000949 AC                      	LODSB
  2244 0000094A AA                      	STOSB				;COPY COMMAND LINE IN
  2245 0000094B 08C0                    	OR	AL,AL
  2246 0000094D 75F8                    	JNZ	COMTRANLP
  2247 0000094F 4F                      	DEC	DI
  2248 00000950 B00D                    	MOV	AL,CR		       ; CR terminate
  2249 00000952 AA                      	STOSB
  2250                                  
  2251                                  	%IF	NOEXEC
  2252                                  	MOV	[ES:80H],CL		; Set up header
  2253                                  	MOV	AL,[DEFAULT_DRIVE]
  2254                                  	MOV	[ES:5CH],AL
  2255                                  	%ELSE
  2256 00000953 880E[3308]              	MOV	[COMMAND_LINE],CL	;Count
  2257                                  	%ENDIF
  2258                                  
  2259 00000957 BA[0000]                	MOV	DX,OFFSET COMMND	;NOW POINTING TO FILE DESCRIPTION
  2260                                  
  2261                                  	%IF	NOEXEC
  2262                                  	MOV	ES,BP			;SET LOAD ADDRESS
  2263                                  	MOV	BX,100H
  2264                                  	CALL	LDFIL			;READ IN COMMAND
  2265                                  	JC	COMERR
  2266                                  	MOV	DS,BP
  2267                                  	MOV	DX,80H
  2268                                  SET_DMA equ Set_DMA	; NASM port equate
  2269                                  	MOV	AH,SET_DMA		;SET DISK TRANFER ADDRESS
  2270                                  	INT	21H
  2271                                  	CLI
  2272                                  	MOV	SS,BP
  2273                                  	MOV	SP,DX
  2274                                  	STI
  2275                                  	XOR	AX,AX			;PUSH A WORD OF ZEROS
  2276                                  	PUSH	AX
  2277                                  	PUSH	BP			;SET HIGH PART OF JUMP ADDRESS
  2278                                  	MOV	AX,100H
  2279                                  	PUSH	AX			;SET LOW PART OF JUMP ADDRESS
  2280                                  CCC	PROC	FAR
  2281                                  	RET				;CRANK UP COMMAND!
  2282                                  CCC	ENDP
  2283                                  
  2284                                  	%ELSE
  2285                                  ; We are going to open the command interpreter and size it as is done in
  2286                                  ; LDFIL.  The reason we must do this is that SYSINIT is in free memory.  If
  2287                                  ; there is not enough room for the command interpreter, EXEC will probably
  2288                                  ; overlay our stack and code so when it returns with an error SYSINIT won't be
  2289                                  ; here to catch it.  This code is not perfect (for instance .EXE command
  2290                                  ; interpreters are possible) because it does its sizing based on the
  2291                                  ; assumption that the file being loaded is a .COM file.  It is close enough to
  2292                                  ; correctness to be usable.
  2293                                  
  2294 0000095A 52                      	PUSH	DX			; Save pointer to name
  2295                                  
  2296                                  %if 0
  2297                                  ; First, find out where the command interpreter is going to go.
  2298                                  	MOV	BX,0FFFFH
  2299                                  	MOV	AH,ALLOC
  2300                                  	INT	21H			;Get biggest piece
  2301                                  	MOV	AH,ALLOC
  2302                                  	INT	21H			;SECOND TIME GETS IT
  2303                                  	JC	MEMERRJX		; Oooops
  2304                                  	MOV	ES,AX
  2305                                  DEALLOC equ Dealloc	; NASM port equate
  2306                                  	MOV	AH,DEALLOC
  2307                                  	INT	21H			; Give it right back
  2308                                  	MOV	BP,BX
  2309                                  ; ES:0 points to Block, and BP is the size of the block
  2310                                  ;   in para.
  2311                                  
  2312                                  ; We will now adjust the size in BP DOWN by the size of SYSINIT. We
  2313                                  ;   need to do this because EXEC might get upset if some of the EXEC
  2314                                  ;   data in SYSINIT is overlayed during the EXEC.
  2315                                  	MOV	BX,[MEMORY_SIZE]
  2316                                  	MOV	AX,CS
  2317                                  	SUB	BX,AX			; BX is size of SYSINIT in Para
  2318                                  	inc bx				; for SYSINIT S MCB
  2319                                  	SUB	BP,BX			; BAIS down
  2320                                  	JC	MEMERRJX		; No Way.
  2321                                  
  2322                                  	MOV	AX,(OPEN << 8) 	;OPEN THE FILE being EXECED
  2323                                  	STC				;IN CASE OF INT 24
  2324                                  	INT	21H
  2325                                  	JC	COMERR			; Ooops
  2326                                  	MOV	BX,AX			;Handle in BX
  2327                                  	XOR	CX,CX
  2328                                  	XOR	DX,DX
  2329                                  	MOV	AX,(LSEEK << 8) | 2
  2330                                  	STC				;IN CASE OF INT 24
  2331                                  	INT	21H			; Get file size in DX:AX
  2332                                  	JC	COMERR
  2333                                      ; Convert size in DX:AX to para in AX
  2334                                  	ADD	AX,15			; Round up size for conversion to para
  2335                                  	ADC	DX,0
  2336                                  	MOV	CL,4
  2337                                  	SHR	AX,CL
  2338                                  	MOV	CL,12
  2339                                  	SHL	DX,CL			; Low nibble of DX to high nibble
  2340                                  	OR	AX,DX			; AX is now # of para for file
  2341                                  	ADD	AX,10H			; 100H byte PHP
  2342                                  	CMP	AX,BP			; Will it fit?
  2343                                  	JB	OKLD			; Jump if yes.
  2344                                  %else
  2345 0000095B EB03                    	jmp OKLD
  2346                                  %endif
  2347                                  
  2348                                  MEMERRJX:
  2349 0000095D E9(0000)                	JMP	MEM_ERR
  2350                                  
  2351                                  OKLD:
  2352                                  %if 0
  2353                                  	MOV	AH,CLOSE
  2354                                  	INT	21H			; Close file
  2355                                  %endif
  2356                                  OPEN equ Open	; NASM port equate
  2357                                  LSEEK equ LSeek	; NASM port equate
  2358                                  CLOSE equ Close	; NASM port equate
  2359                                  
  2360                                  
  2361                                  INITSTACKSIZE equ fromparas(paras(160))
  2362 00000960 B8A000                  	mov ax, INITSTACKSIZE
  2363 00000963 BE[5E23]                	mov si, alloc_initstack
  2364 00000966 E8151A                  	call allocate_relocate_block
  2365 00000969 81C7A000                	add di, INITSTACKSIZE
  2366 0000096D 5A                      	POP	DX			; Recover pointer to name
  2367                                  
  2368 0000096E 8CC0                    	mov ax, es			; use this as a stack if exec returns
  2369 00000970 FA                      	cli
  2370 00000971 8ED0                    	mov ss, ax
  2371 00000973 89FC                    	mov sp, di			; -> stack
  2372                                   assume ss:nothing
  2373 00000975 FB                      	sti
  2374                                  
  2375                                  loop_shell:
  2376                                   extern backdoor_free_mcb_exec, backdoor_indicator
  2377                                   extern shell_return_has_been_freed, shell_return_address
  2378 00000976 BB[7009]                	mov bx, initpspmcb
  2379 00000979 2EC6075A                	mov byte [cs:bx + mcbSignature], 'Z'
  2380                                  					; pretend we are a valid process MCB
  2381 0000097D B104                    	mov cl, 4
  2382 0000097F D3EB                    	shr bx, cl			; segment displacement
  2383 00000981 43                      	inc bx				; pretend PSP
  2384 00000982 E8(0000)                	call sysinit_getdosdata
  2385 00000985 8EC0                    	mov es, ax
  2386                                   assume es:DOSGROUP
  2387 00000987 8CC8                    	mov ax, cs
  2388 00000989 01D8                    	add ax, bx			; => our pseudo INIT PSP
  2389 0000098B 26A3[0000]              	mov word [es:backdoor_free_mcb_exec], ax
  2390                                  					; enter owner for the backdoor free
  2391 0000098F 268C0E[0200]            	mov word [es:shell_return_address + 2], cs
  2392 00000994 26C706[0000][EF09]      	mov word [es:shell_return_address], sysinit_shellreturned
  2393                                  					; ! must be set before next variable
  2394 0000099B BB[0000]                	mov bx, shell_return_has_been_freed
  2395 0000099E 26C60700                	mov byte [es:bx], 0		; indicate sysinit still allocated
  2396 000009A2 268C06[0200]            	mov word [es:backdoor_indicator + 2], es
  2397 000009A7 26891E[0000]            	mov word [es:backdoor_indicator], bx
  2398 000009AC 8CCB                    	mov bx, cs
  2399 000009AE 4B                      	dec bx
  2400 000009AF 8EC3                    	mov es, bx
  2401                                   assume es:MCB
  2402 000009B1 26A30100                	mov word [es:mcbOwner], ax	; owned by backdoor owner
  2403                                  
  2404 000009B5 0E                      	 push cs
  2405 000009B6 1F                      	 pop ds
  2406                                   assume ds:SYSINITGROUP
  2407 000009B7 BE[3408]                	mov si, COMMAND_LINE + 1
  2408 000009BA 0E                      	 push cs
  2409 000009BB 07                      	 pop es
  2410                                   assume es:SYSINITGROUP
  2411 000009BC BF[7A08]                	mov di, Ldexec_FCB1
  2412 000009BF E88A07                  	call parse_dssi_cmdline_to_esdi_fcbs
  2413                                  		;AN000;  Make a null environment segment
  2414                                  		;AN000;   by overlap JMP instruction of SYSINITSEG.
  2415 000009C2 8326000000              	and	word [0], 0
  2416 000009C7 BB[6408]                	mov	bx, offset COMEXE		;AN000;  ES:BX -> parm block.
  2417                                  EXEC0_COM_LINE equ Exec0_com_line	; NASM port equate
  2418                                  EXEC0_5C_FCB equ Exec0_5C_FCB	; NASM port equate
  2419                                  EXEC0_6C_FCB equ Exec0_6C_FCB	; NASM port equate
  2420 000009CA 8C1F                    	mov	[bx + EXEC0_ENVIRON], ds	;AN000; Set the environment seg.
  2421 000009CC 8C5F04                  	mov	word [bx + EXEC0_COM_LINE+2], ds;AN000; Set the seg.
  2422 000009CF 8C5F08                  	mov	word [bx + EXEC0_5C_FCB+2], ds	;AN000;
  2423 000009D2 8C5F0C                  	mov	word [bx + EXEC0_6C_FCB+2], ds	;AN000;
  2424                                  EXEC equ Exec	; NASM port equate
  2425 000009D5 B8004B                  	mov ax, EXEC << 8		; Load and go
  2426 000009D8 D006[0000]              	rol byte [shellhighflag], 1
  2427 000009DC D0D8                    	rcr al, 1			; al = 80h if shellhigh=
  2428 000009DE F9                      	STC				;IN CASE OF INT 24
  2429 000009DF EA[A003][ssss]          	jmp DOSENTRY - DOSENTRYADJUSTSEGMENT 	 : run_int21_shell + DOSENTRYADJUSTOFFSET
  2431                                   extern run_int21_shell			;GO START UP COMMAND
  2432                                  	%ENDIF
  2433                                  ; NOTE FALL THROUGH IF EXEC RETURNS (an error)
  2434                                  
  2435                                  COMERR:
  2436 000009E4 BA[0000]                	MOV	DX,OFFSET BADCOM	;WANT TO PRINT COMMAND ERROR
  2437 000009E7 E8(0000)                	INVOKE	BADFIL
  2438                                  STALL:
  2439 000009EA CC                      	int3
  2440 000009EB FB                      	sti
  2441 000009EC F4                      	hlt
  2442 000009ED EBFB                    	JMP	STALL
  2443                                  
  2444                                  
  2445                                  sysinit_shellreturned:
  2446                                  
  2447 000009EF 0E                      	push cs
  2448 000009F0 1F                      	pop ds
  2449                                   assume ds:SYSINITGROUP
  2450 000009F1 0E                      	push cs
  2451 000009F2 07                      	pop es
  2452                                   assume es:SYSINITGROUP
  2453                                  
  2454 000009F3 BA[0E0B]                	mov dx, msg.prompt
  2455 000009F6 B92400                  	mov cx, msg.prompt.length
  2456 000009F9 BB0100                  	mov bx, 1
  2457 000009FC B440                    	mov ah, 40h
  2458 000009FE CD21                    	int 21h
  2459                                  
  2460                                   extern linein
  2461 00000A00 BE[0000]                	mov si, COMMND
  2462 00000A03 BF[0200]                	mov di, linein + 2
  2463 00000A06 A8                      	db __TEST_IMM8			; (skip stosb)
  2464                                  @@:
  2465 00000A07 AA                      	stosb
  2466 00000A08 AC                      	lodsb
  2467 00000A09 84C0                    	test al, al
  2468 00000A0B 75FA                    	jnz @B
  2469                                  
  2470 00000A0D 31C0                    	xor ax, ax
  2471 00000A0F 8B36[6608]              	mov si, word [COMEXE + EXEC0_COM_LINE]
  2472 00000A13 AC                      	lodsb				; = length of tail
  2473 00000A14 91                      	xchg cx, ax
  2474 00000A15 803C0D                  	cmp byte [si], 13
  2475 00000A18 740D                    	je @F
  2476 00000A1A 803C09                  	cmp byte [si], 9
  2477 00000A1D 7408                    	je @F
  2478 00000A1F 803C20                  	cmp byte [si], 32
  2479 00000A22 7403                    	je @F
  2480 00000A24 B020                    	mov al, 32
  2481 00000A26 AA                      	stosb
  2482                                  @@:
  2483 00000A27 41                      	inc cx				; include the terminator CR
  2484 00000A28 F3A4                    	rep movsb
  2485                                  
  2486 00000A2A 97                      	xchg ax, di
  2487 00000A2B 2D[0300]                	sub ax, linein + 3
  2488 00000A2E A2[0100]                	mov byte [linein + 1], al
  2489                                  
  2490                                  .prompt:
  2491 00000A31 BA[0000]                	mov dx, linein
  2492 00000A34 CC                      	int3
  2493 00000A35 B40A                    	mov ah, 0Ah
  2494 00000A37 CD21                    	int 21h				; read input line
  2495 00000A39 B402                    	mov ah, 02h
  2496 00000A3B B20D                    	mov dl, 13
  2497 00000A3D CD21                    	int 21h
  2498 00000A3F B402                    	mov ah, 02h
  2499 00000A41 B20A                    	mov dl, 10
  2500 00000A43 CD21                    	int 21h
  2501                                  
  2502 00000A45 BE[0200]                	mov si, linein + 2
  2503                                  @@:
  2504 00000A48 AC                      	lodsb
  2505 00000A49 3C20                    	cmp al, 32
  2506 00000A4B 74FB                    	je @B
  2507 00000A4D 3C09                    	cmp al, 9
  2508 00000A4F 74F7                    	je @B
  2509                                  
  2510 00000A51 BF[0000]                	MOV	DI,OFFSET COMMND
  2511 00000A54 A9                      	db __TEST_IMM16			; skip stosb, lodsb
  2512                                  STORESHELL:
  2513 00000A55 AA                      	stosb
  2514 00000A56 AC                      	lodsb
  2515                                  @@:
  2516 00000A57 3C20                    	cmp al, 32
  2517 00000A59 77FA                    	ja STORESHELL
  2518                                  
  2519                                  GETSHPARMS:
  2520 00000A5B C60500                  	MOV	BYTE PTR [DI],0
  2521 00000A5E BF[3408]                	MOV	DI,OFFSET COMMAND_LINE+1
  2522 00000A61 A8                      	db __TEST_IMM8			; skip lodsb
  2523                                  PARMLOOP:
  2524 00000A62 AC                      	lodsb
  2525 00000A63 AA                      	stosb
  2526 00000A64 3C0D                    	cmp al, 13
  2527 00000A66 75FA                    	jne PARMLOOP
  2528                                  
  2529 00000A68 97                      	xchg ax, di
  2530 00000A69 2D[3508]                	sub ax, COMMAND_LINE + 2
  2531 00000A6C A2[3308]                	mov byte [COMMAND_LINE], al
  2532                                  
  2533 00000A6F BA[0000]                	mov dx, COMMND
  2534 00000A72 E901FF                  	jmp loop_shell
  2535                                  
  2536                                  
  2537                                   extern get_config_size
  2538                                  relocate_config:
  2539                                   assume ds:nothing, es:nothing, ss:SYSINITGROUP
  2540 00000A75 B80058                  	mov ax, 5800h
  2541 00000A78 CD21                    	int 21h
  2542 00000A7A 50                      	push ax
  2543 00000A7B B80158                  	mov ax, 5801h
  2544 00000A7E BB2003                  	mov bx, 0320h			; ignore UMB link, one area,
  2545 00000A81 CD21                    	int 21h				;  LMA then UMA, first fit
  2546 00000A83 E8(0000)                	call get_config_size
  2547 00000A86 B448                    	mov ah, 48h
  2548 00000A88 CD21                    	int 21h
  2549 00000A8A 722E                    	jc .fail
  2550 00000A8C 8EC0                    	mov es, ax
  2551                                   assume es:nothing
  2552 00000A8E 31FF                    	xor di, di
  2553 00000A90 2E8E1E[2B08]            	mov ds, word [cs:config_block]
  2554                                   assume ds:nothing
  2555 00000A95 31F6                    	xor si, si
  2556 00000A97 06                      	 push es
  2557 00000A98 51                      	push cx
  2558 00000A99 F3A4                    	rep movsb
  2559 00000A9B 1E                      	 push ds
  2560 00000A9C 07                      	 pop es
  2561                                   assume es:nothing
  2562 00000A9D B449                    	mov ah, 49h
  2563 00000A9F CD21                    	int 21h
  2564 00000AA1 58                      	pop ax
  2565 00000AA2 50                      	push ax
  2566 00000AA3 BE[2223]                	mov si, alloc_initconfig
  2567 00000AA6 E8E919                  	call allocate_temporary_block
  2568                                   assume es:nothing
  2569 00000AA9 59                      	pop cx
  2570 00000AAA 1F                      	 pop ds
  2571                                   assume ds:nothing
  2572 00000AAB 31F6                    	xor si, si
  2573 00000AAD F3A4                    	rep movsb
  2574 00000AAF 2E8C06[2B08]            	mov word [cs:config_block], es
  2575 00000AB4 1E                      	push ds
  2576 00000AB5 07                      	pop es
  2577                                   assume es:nothing
  2578 00000AB6 B449                    	mov ah, 49h
  2579 00000AB8 CD21                    	int 21h
  2580                                  .fail:
  2581 00000ABA 5B                      	pop bx
  2582 00000ABB B80158                  	mov ax, 5801h
  2583 00000ABE CD21                    	int 21h
  2584 00000AC0 C3                      	retn
  2585                                  
  2586                                  
  2587                                  relocate_dibx_dpb_from_dxbp_to_essi:
  2588                                   assume ds:nothing, es:nothing, ss:SYSINITGROUP
  2589 00000AC1 3929                    	cmp word [di + bx], bp
  2590 00000AC3 750C                    	jne .ret
  2591 00000AC5 395102                  	cmp word [di + bx + 2], dx
  2592 00000AC8 7507                    	jne .ret			; match ?
  2593 00000ACA FA                      	cli
  2594 00000ACB 8931                    	mov word [di + bx], si
  2595 00000ACD 8C4102                  	mov word [di + bx + 2], es
  2596 00000AD0 FB                      	sti				; yes, relocate
  2597                                  .ret:
  2598 00000AD1 C3                      	retn
  2599                                  
  2600                                  
  2601                                  reloc_dpb_in_sftc:
  2602                                   assume ds:nothing, es:nothing, ss:SYSINITGROUP
  2603                                  .loop_sftc:
  2604 00000AD2 83FFFF                  	cmp di, -1
  2605 00000AD5 7425                    	je .done
  2606 00000AD7 57                      	push di
  2607 00000AD8 8B4D04                  	mov cx, [di + SFCount]
  2608 00000ADB E31A                    	jcxz .next_sftc
  2609 00000ADD 83C706                  	add di, SFTable
  2610                                  .loop_entry:
  2611 00000AE0 833D00                  	cmp word [di + sf_ref_count], 0
  2612 00000AE3 740D                    	je @F
  2613 00000AE5 F745058080              	testopt [di + sf_flags], sf_isnet | devid_device
  2613          ******************       warning: Macro generated word access [-w+user]
  2614                                  					; net or device ?
  2615 00000AEA 7506                    	jnz @F				; yes, don't check -->
  2616 00000AEC BB0700                  	mov bx, sf_devptr
  2617 00000AEF E8CFFF                  	call relocate_dibx_dpb_from_dxbp_to_essi
  2618                                  @@:
  2619 00000AF2 83C73B                  	add di, sf_entry_struc_size
  2620 00000AF5 E2E9                    	loop .loop_entry
  2621                                  .next_sftc:
  2622 00000AF7 5F                      	pop di
  2623 00000AF8 C53D                    	lds di, [di + SFLink]
  2624 00000AFA EBD6                    	jmp .loop_sftc
  2625                                  
  2626                                  .done:
  2627 00000AFC C3                      	retn
  2628                                  
  2629                                  
  2630                                  		; ! called far from DOSENTRY init code.
  2631                                  		; Runs in unrelocated SYSINIT.
  2632                                  		; Must return far.
  2633                                  		;
  2634                                  		; INP:	ds:si -> text
  2635                                  		; OUT:	NC if found,
  2636                                  		;	 ds:si -> at terminator
  2637                                  		;	 dx = bit mask selected
  2638                                  		;	CY if not found,
  2639                                  		;	 ds:si -> past commas and blanks and equal signs
  2640                                  		; STT:	called far
  2641                                  		;	cs = ds = es => SYSINIT
  2642                                  		; CHG:	dx, bx, ax
  2643                                   global sysinit_cmdline_scanmode_keyword
  2644                                   extern isstring?, skipcomma, skipcomm0, skipwhite, skipwh0
  2645                                  sysinit_cmdline_scanmode_keyword:
  2646                                  @@:
  2647 00000AFD E8(0000)                	call skipcomma
  2648 00000B00 3C3D                    	cmp al, '='
  2649 00000B02 74F9                    	je @B
  2650 00000B04 4E                      	dec si
  2651 00000B05 BB[6C00]                	mov bx, modetable
  2652                                  .mode_loop:
  2653 00000B08 8B17                    	mov dx, [bx]
  2654 00000B0A E8(0000)                	call isstring?
  2655 00000B0D 7505                    	jne @F
  2656 00000B0F 8B5702                  	mov dx, [bx + 2]
  2657 00000B12 F8                      	clc
  2658 00000B13 CB                      	retf
  2659                                  
  2660                                  @@:
  2661 00000B14 83C304                  	add bx, 4
  2662 00000B17 81FB[8800]              	cmp bx, strict word modetable.end
  2663 00000B1B 72EB                    	jb .mode_loop
  2664 00000B1D F9                      	stc
  2665 00000B1E CB                      	retf
  2666                                  
  2667                                  
  2668                                  free_temp_cds:
  2669                                   assume ds:nothing, es:nothing, ss:SYSINITGROUP
  2670 00000B1F 31C0                    	xor ax, ax
  2671 00000B21 2E8706[8009]            	xchg ax, word [cs:tempcds_block]
  2672 00000B26 85C0                    	test ax, ax
  2673 00000B28 7408                    	jz @F
  2674 00000B2A 06                      	 push es
  2675 00000B2B 8EC0                    	mov es, ax
  2676                                   assume es:nothing
  2677 00000B2D B449                    	mov ah, 49h
  2678 00000B2F CD21                    	int 21h
  2679 00000B31 07                      	 pop es
  2680                                   assume es:nothing
  2681                                  @@:
  2682 00000B32 C3                      	retn
  2683                                  
  2684                                  
  2685                                  	PUBLIC	TEMPCDS_after_block_device
  2686                                    global cds_last_used, cds_first_unused
  2687                                    global alloc_initcds, free_temp_cds, tempcds_block
  2688                                    global FOOSTRNG, FOOSET
  2689                                  	extern devicefirstnewdpb, devicefirstnewdrive, deviceamountnew
  2690                                  	extern reinitcds_option
  2691                                  	extern cds_amount_wanted
  2692                                  TEMPCDS_after_block_device:
  2693                                   assume ds:SYSINITGROUP, es:nothing, ss:SYSINITGROUP
  2694 00000B33 D006[0000]              	rol byte [reinitcds_option], 1
  2695 00000B37 7303E98500              	jc TEMPCDS
  2696                                  
  2697 00000B3C C43E[F207]              	LES	DI,[DOSINFO]
  2698                                   assume es:DOSGROUP
  2699 00000B40 268A5D21                	mov bl, [es:di + SYSI_NCDS]
  2700 00000B44 B058                    	mov al, curdir_list_struc_size
  2701 00000B46 F6E3                    	mul bl
  2702 00000B48 53                      	push bx				; stack = how many entries in old CDS
  2703 00000B49 50                      	push ax				; stack = how much to preserve in bytes
  2704                                  
  2705 00000B4A 31C9                    	xor cx, cx
  2706 00000B4C 2E8A0E[0000]            	mov cl, byte [cs:cds_amount_wanted]	; cx = how many drives needed
  2707 00000B51 26384D21                	cmp byte [es:di + SYSI_NCDS], cl	; have more CDS entries ?
  2708 00000B55 7204                    	jb @F					; no -->
  2709 00000B57 268A4D21                	mov cl, byte [es:di + SYSI_NCDS]	; yes, keep as many
  2710                                  @@:
  2711 00000B5B 26884D21                	mov byte [es:di + SYSI_NCDS], cl	; update amount CDS entries
  2712 00000B5F B058                    	mov al, curdir_list_struc_size
  2713 00000B61 F6E1                    	mul cl				; ax = how much to allocate in bytes
  2714                                  
  2715 00000B63 51                      	push cx
  2716 00000B64 06                      	push es
  2717 00000B65 57                      	push di
  2718 00000B66 BE[1823]                	mov si, alloc_initcds
  2719 00000B69 E82619                  	call allocate_temporary_block
  2720                                   assume es:nothing
  2721 00000B6C 5E                      	pop si
  2722 00000B6D 1F                      	pop ds				; -> DOSINFO
  2723                                   assume ds:DOSGROUP
  2724 00000B6E 5B                      	pop bx				; bl = how many entries in new CDS
  2725 00000B6F 59                      	pop cx				; = how much to preserve in bytes
  2726                                  
  2727 00000B70 1E                      	push ds
  2728 00000B71 56                      	push si
  2729 00000B72 C57416                  	lds si, [si + SYSI_CDS]		; -> old CDS
  2730                                   assume ds:CDS
  2731 00000B75 89FA                    	mov dx, di			; es:dx -> new CDS
  2732 00000B77 F3A4                    	rep movsb			; preserve old
  2733 00000B79 5E                      	pop si
  2734 00000B7A 1F                      	pop ds
  2735                                   assume ds:DOSGROUP
  2736 00000B7B E8A1FF                  	call free_temp_cds		; free old
  2737 00000B7E 2E8C06[8009]            	mov word [cs:tempcds_block], es	; => temp CDS
  2738 00000B83 58                      	pop ax				; al = how many entries in old CDS
  2739 00000B84 28C3                    	sub bl, al			; = additional amount
  2740 00000B86 0441                    	add al, "A"			; prior amount + "A"
  2741 00000B88 36A2[3108]              	mov byte [ss:FOOSTRNG], al	; first letter of additional table
  2742                                  
  2743 00000B8C 8C4418                  	MOV	WORD PTR [si + SYSI_CDS + 2], es
  2744 00000B8F 895416                  	mov	WORD PTR [si + SYSI_CDS], dx
  2745                                  					; -> new temp CDS
  2746 00000B92 31C9                    	xor cx, cx
  2747 00000B94 88D9                    	mov cl, bl			; cx = additional amount of CDS entries
  2748 00000B96 BEFFFF                  	mov si, -1			; no DPBs for additional table
  2749 00000B99 36F616[0808]            	not byte [ss:verbose_hide_cds]
  2750 00000B9E E84E00                  	call FOOSET			; init additional table
  2751                                  
  2752 00000BA1 2EC536[0000]            	lds si, [cs:devicefirstnewdpb]	; ds:si -> first new DPB
  2753                                   ASSUME DS:DPB
  2754 00000BA6 2E8A1E[0000]            	mov bl, [cs:devicefirstnewdrive]
  2755 00000BAB B058                    	mov al, curdir_list_struc_size
  2756 00000BAD F6E3                    	mul bl
  2757 00000BAF 97                      	xchg di, ax			; es:di -> CDS entry for first new drive
  2758 00000BB0 31C9                    	xor cx, cx
  2759 00000BB2 2E8A0E[0000]            	mov cl, byte [cs:deviceamountnew]
  2760                                  					; cx = how many drives
  2761 00000BB7 80C341                  	add bl, "A"			; letter of first new drive
  2762 00000BBA 36881E[3108]            	mov byte [ss:FOOSTRNG], bl	; first letter of additional table
  2763 00000BBF EB2E                    	jmp FOOSET
  2764                                  
  2765                                  
  2766                                  	PUBLIC	TEMPCDS
  2767                                  TEMPCDS:
  2768                                   assume ds:SYSINITGROUP, es:nothing, ss:SYSINITGROUP
  2769 00000BC1 E85BFF                  	call free_temp_cds
  2770                                  
  2771 00000BC4 C43E[F207]              	LES	DI,[DOSINFO]
  2772                                   assume es:DOSGROUP
  2773                                  
  2774 00000BC8 268A4D20                	MOV	CL,BYTE PTR [ES:DI + SYSI_NUMIO]
  2775 00000BCC 30ED                    	XOR	CH,CH
  2776 00000BCE 26884D21                	MOV	[ES:DI + SYSI_NCDS],CL
  2777 00000BD2 B058                    	mov al, curdir_list_struc_size
  2778 00000BD4 F6E1                    	mul cl
  2779                                  
  2780 00000BD6 51                      	push cx
  2781 00000BD7 06                      	push es
  2782 00000BD8 57                      	push di
  2783 00000BD9 BE[1823]                	mov si, alloc_initcds
  2784 00000BDC E8B318                  	call allocate_temporary_block
  2785                                   assume es:nothing
  2786 00000BDF 2E8C06[8009]            	mov word [cs:tempcds_block], es	; => temp CDS
  2787 00000BE4 5E                      	pop si
  2788 00000BE5 1F                      	pop ds				; -> DOSINFO
  2789                                   assume ds:DOSGROUP
  2790 00000BE6 59                      	pop cx
  2791                                  
  2792 00000BE7 8C4418                  	MOV	WORD PTR [si + SYSI_CDS + 2], es
  2793 00000BEA 897C16                  	mov	WORD PTR [si + SYSI_CDS], di
  2794                                  					; -> temp CDS
  2795 00000BED C534                    	LDS	SI,[si + SYSI_DPB]	; -> first DPB
  2796                                   ASSUME DS:DPB
  2797                                  
  2798                                  FOOSET:					; Init CDSs
  2799 00000BEF 1E                      	push ds
  2800 00000BF0 56                      	push si
  2801 00000BF1 36C536[F207]            	lds si, [ss:DOSINFO]
  2802                                   assume ds:DOSGROUP
  2803 00000BF6 B058                    	mov al, curdirLen
  2804 00000BF8 F66421                  	mul byte [si + SYSI_NCDS]
  2805 00000BFB 8B5416                  	mov dx, [si + SYSI_CDS]
  2806 00000BFE 01C2                    	add dx, ax
  2807 00000C00 E37A                    	jcxz fooret_pops		; (additional table may be empty)
  2808                                  
  2809                                  fooset_loop:
  2810 00000C02 39D7                    	cmp di, dx
  2811 00000C04 7203E9D900              	jae foo_error
  2812                                  
  2813 00000C09 5E                      	pop si
  2814 00000C0A 1F                      	pop ds
  2815                                   assume ds:nothing
  2816 00000C0B 1E                      	push ds
  2817 00000C0C 56                      	push si
  2818                                  
  2819 00000C0D 36A1[3108]              	MOV	AX,WORD PTR [ss:FOOSTRNG]
  2820 00000C11 36FE06[3108]            	INC	BYTE PTR [ss:FOOSTRNG]
  2821 00000C16 26F64544C0              	testopt [es:di + curdir_flags], curdir_isnet | curdir_inuse
  2822 00000C1B 7559                    	jnz fooset_next
  2823 00000C1D AB                      	STOSW
  2824 00000C1E 2C41                    	sub al, 'A'
  2825 00000C20 93                      	xchg bx, ax			; bl = drive to match
  2826 00000C21 B85C00                  	MOV	AX, "\"			; constant
  2827 00000C24 AB                      	STOSW
  2828 00000C25 31C0                    	XOR	AX,AX
  2829 00000C27 51                      	PUSH	CX
  2830 00000C28 B93F00                  	MOV	CX,curdir_flags - 4
  2831 00000C2B F3AA                    	REP	STOSB
  2832 00000C2D 83FEFF                  	CMP	SI,-1
  2833                                  ;	 JNZ	 NORMCDS
  2834                                  ;J.K. 6/24/87 Should handle the system that does not have any floppies.
  2835                                  ;J.K. In this case, we are going to pretended there are two dummy floppies
  2836                                  ;J.K. in the system. Still they have DPB and CDS, but we are going to
  2837                                  ;J.K. 0 out Curdir_Flags, Curdir_devptr of CDS so IBMDOS can issue
  2838                                  ;J.K. "Invalid drive specification" message when the user try to
  2839                                  ;J.K. access them.
  2840 00000C30 740D                    	je	Fooset_Zero		;AN001;Don't have any physical drive.
  2841                                  ;SB34SYSINIT1003*************************************************************
  2842                                  ;SB	Check to see if we are faking floppy drives.  If not go to NORMCDS.
  2843                                  ;SB	If we are faking floppy drives then see if this CDS being initialised
  2844                                  ;SB	is for drive a: or b: by checking the appropriate field in the DPB
  2845                                  ;SB	pointed to by ds:si.  If not for a: or b: then go to NORMCDS.  If
  2846                                  ;Sb	for a: or b: then execute the code given below starting at Fooset_Zero.
  2847                                  ;SB	For dpb offsets look at inc\dpb.inc.
  2848                                  ;SB	 5 LOCS
  2849                                  
  2850 00000C32 2E803E[0608]01          	cmp	byte [cs:Fake_Floppy_Drv],1	;fake drive ?
  2851 00000C38 750C                    	jnz	NORMCDS
  2852 00000C3A 80FB02                  	cmp bl, 2
  2853 00000C3D 7307                    	jae	NORMCDS
  2854                                  
  2855                                  ;SB34SYSINIT1003*************************************************************
  2856                                  Fooset_Zero:				;AN001;
  2857                                  		; ax still zero
  2858 00000C3F B103                    	MOV	CL,3
  2859 00000C41 F3AB                    	REP	STOSW
  2860 00000C43 59                      	POP	CX
  2861 00000C44 EB1E                    	JMP	SHORT FINCDS
  2862                                  NORMCDS:
  2863                                  .loop:
  2864 00000C46 381C                    	cmp byte [si + dpb_drive], bl
  2865 00000C48 740A                    	je .got
  2866 00000C4A C57419                  	LDS	SI,[SI + dpb_next_dpb]
  2867                                   assume ds:nothing
  2868 00000C4D 83FEFF                  	cmp si, -1
  2869 00000C50 75F4                    	jne .loop
  2870 00000C52 EBEB                    	jmp Fooset_Zero
  2871                                  
  2872                                  .got:
  2873 00000C54 59                      	POP	CX
  2874                                  ;J.K. If a non-fat based media is detected (by DPB.NumberOfFat == 0), then
  2875                                  ; set curdir_flags to 0.  This is for signaling IBMDOS and IFSfunc that
  2876                                  ; this media is a non-fat based one.
  2877 00000C55 807C0800                	cmp	byte [SI + dpb_FAT_count], 0	;AN000; Non fat system?
  2878 00000C59 7402                    	je	SetNormCDS		;AN000; Yes. Set curdir_Flags to 0. AX = 0 now.
  2879                                  CURDIR_INUSE equ curdir_inuse	; NASM port equate
  2880 00000C5B B440                    	MOV	ah, CURDIR_INUSE >> 8	;AN000;  else, FAT system. set the flag to CURDIR_INUSE.
  2881                                  SetNormCDS:				;AN000;
  2882 00000C5D AB                      	STOSW				; curdir_flags
  2883 00000C5E 89F0                    	MOV	AX,SI
  2884 00000C60 AB                      	STOSW				; curdir_devptr
  2885 00000C61 8CD8                    	MOV	AX,DS
  2886 00000C63 AB                      	STOSW
  2887                                  FINCDS:
  2888 00000C64 B8FFFF                  	MOV	AX,-1
  2889 00000C67 AB                      	STOSW				; curdir_ID
  2890 00000C68 AB                      	STOSW				; curdir_ID
  2891 00000C69 AB                      	STOSW				; curdir_user_word
  2892 00000C6A B80200                  	mov	ax,2
  2893 00000C6D AB                      	stosw				; curdir_end
  2894 00000C6E 31C0                    	xor ax, ax			;AN000;Clear out 7 bytes (curdir_type,
  2895 00000C70 AB                      	stosw				;AN000;  curdir_ifs_hdr, curdir_fsda)
  2896 00000C71 AB                      	stosw				;AN000;
  2897 00000C72 AB                      	stosw				;AN000;
  2898 00000C73 AA                      	stosb				;AN000;
  2899 00000C74 EB04                    	jmp @F
  2900                                  fooset_next:
  2901 00000C76 41                      	inc cx
  2902 00000C77 83C758                  	add di, curdirLen
  2903                                  @@:
  2904 00000C7A E286                    	LOOP fooset_loop
  2905                                  fooret_pops:
  2906 00000C7C 58                      	pop ax
  2907 00000C7D 58                      	pop ax
  2908                                  fooret:
  2909 00000C7E 36C606[3108]41          	MOV	BYTE PTR [ss:FOOSTRNG],"A"
  2910                                  
  2911 00000C84 36D006[0808]            	rol byte [ss:verbose_hide_cds], 1
  2912 00000C89 7306                    	jnc @F
  2913 00000C8B 36F616[0808]            	not byte [ss:verbose_hide_cds]
  2914                                  .ret:
  2915 00000C90 C3                      	retn
  2916                                  @@:
  2917                                  
  2918 00000C91 36F606[FC07]04          	testopt [ss:verbose_mode], verbose_cds
  2919 00000C97 74F7                    	jz .ret
  2920 00000C99 06                      	push es
  2921 00000C9A 36C43E[F207]            	LES	DI,[ss:DOSINFO]
  2922                                   assume es:DOSGROUP
  2923 00000C9F 31C0                    	xor ax, ax
  2924 00000CA1 268A4521                	mov al, [es:di + SYSI_NCDS]
  2925 00000CA5 BA[320B]                	mov dx, msg.cds.1
  2926 00000CA8 E8D314                  	call init2_disp_msg_asciz_cs_dx
  2927 00000CAB E8820C                  	call init2_disp_ax_dec
  2928 00000CAE BA[410B]                	mov dx, msg.cds.2.singular
  2929 00000CB1 3C01                    	cmp al, 1
  2930 00000CB3 7403                    	je @F
  2931 00000CB5 BA[580B]                	mov dx, msg.cds.2.plural
  2932                                  @@:
  2933 00000CB8 E8C314                  	call init2_disp_msg_asciz_cs_dx
  2934 00000CBB 0440                    	add al, 'A' - 1
  2935 00000CBD E8D714                  	call init2_disp_al
  2936 00000CC0 BA[710B]                	mov dx, msg.cds.3
  2937 00000CC3 E8B814                  	call init2_disp_msg_asciz_cs_dx
  2938 00000CC6 E82100                  	call cds_last_used
  2939                                   assume es:DOSGROUP, ds:CDS
  2940 00000CC9 86FB                    	xchg bh, bl			; bl = last used
  2941 00000CCB E8620C                  	call init2_disp_ax_dec
  2942 00000CCE BA[7A0B]                	mov dx, msg.cds.4
  2943 00000CD1 E8AA14                  	call init2_disp_msg_asciz_cs_dx
  2944 00000CD4 8D4741                  	lea ax, [bx + 'A']
  2945 00000CD7 E8BD14                  	call init2_disp_al
  2946 00000CDA BA[8C0B]                	mov dx, msg.cds.5
  2947 00000CDD E89E14                  	call init2_disp_msg_asciz_cs_dx
  2948 00000CE0 07                      	pop es
  2949                                   assume es:CDS
  2950 00000CE1 C3                      	return
  2951                                  
  2952                                  
  2953                                  foo_error:
  2954 00000CE2 BA[900B]                	mov dx, msg.cds.error
  2955 00000CE5 E89614                  	call init2_disp_msg_asciz_cs_dx
  2956 00000CE8 EB92                    	jmp fooret_pops
  2957                                  
  2958                                  
  2959                                  		; INP:	-
  2960                                  		; OUT:	bh = 0-based index of last used CDS, or 0
  2961                                  		;	ax = number of used CDS entries
  2962                                  		;	es:di -> DOSINFO
  2963                                  		; CHG:	es, di, ds, si, bl, cx
  2964                                  		; STT:	ss => SYSINITGROUP
  2965                                  cds_last_used:
  2966                                   assume ds:nothing, es:nothing, ss:SYSINITGROUP
  2967 00000CEA 36C43E[F207]            	LES	DI,[ss:DOSINFO]
  2968                                   assume es:DOSGROUP
  2969 00000CEF 31C9                    	xor cx, cx
  2970 00000CF1 268A4D21                	mov cl, [es:di + SYSI_NCDS]
  2971 00000CF5 26C57516                	lds si, [es:di + SYSI_CDS]
  2972                                   assume ds:CDS
  2973 00000CF9 31DB                    	xor bx, bx
  2974 00000CFB 31C0                    	xor ax, ax
  2975 00000CFD E30F                    	jcxz .done
  2976                                  .loop:
  2977 00000CFF F64444C0                	testopt [si + curdir_flags], curdir_isnet + curdir_inuse
  2978 00000D03 7403                    	jz .skip
  2979 00000D05 40                      	inc ax
  2980 00000D06 88DF                    	mov bh, bl
  2981                                  .skip:
  2982 00000D08 43                      	inc bx
  2983 00000D09 83C658                  	add si, curdirLen
  2984 00000D0C E2F1                    	loop .loop
  2985                                  .done:
  2986 00000D0E C3                      	retn
  2987                                  
  2988                                  
  2989                                  		; INP:	al = 0-based index to start check
  2990                                  		; OUT:	NC if valid,
  2991                                  		;	 bh = 0-based index of first unused >= INP:al
  2992                                  		;	 ds:si -> found unused entry
  2993                                  		;	CY if not valid,
  2994                                  		;	 bh = max(INP:al, 0-based index after last CDS entry)
  2995                                  		; CHG:	ds, si, bl
  2996                                  		; STT:	ss => SYSINITGROUP
  2997                                  cds_first_unused:
  2998                                   assume ds:nothing, es:nothing, ss:SYSINITGROUP
  2999 00000D0F 06                      	push es
  3000 00000D10 57                      	push di
  3001 00000D11 50                      	push ax
  3002 00000D12 51                      	push cx
  3003 00000D13 36C43E[F207]            	LES	DI,[ss:DOSINFO]
  3004                                   assume es:DOSGROUP
  3005 00000D18 31C9                    	xor cx, cx
  3006 00000D1A 268A4D21                	mov cl, [es:di + SYSI_NCDS]
  3007                                  				; cx = how many total
  3008 00000D1E 26C57516                	lds si, [es:di + SYSI_CDS]
  3009                                   assume ds:CDS
  3010 00000D22 88C7                    	mov bh, al		; bh = requested
  3011 00000D24 28C1                    	sub cl, al		; cl = how many to check
  3012 00000D26 7613                    	jbe .done_CY
  3013 00000D28 B458                    	mov ah, curdirLen
  3014 00000D2A F6E4                    	mul ah			; ax = offset of first to check
  3015 00000D2C 01C6                    	add si, ax		; ds:si -> first to check
  3016                                  .loop:
  3017 00000D2E F64444C0                	testopt [si + curdir_flags], curdir_isnet + curdir_inuse
  3018 00000D32 7408                    	jz .found		; (NC)
  3019 00000D34 FEC7                    	inc bh
  3020 00000D36 83C658                  	add si, curdirLen
  3021 00000D39 E2F3                    	loop .loop
  3022                                  .done_CY:
  3023 00000D3B F9                      	stc
  3024                                  .found:
  3025 00000D3C 59                      	pop cx
  3026 00000D3D 58                      	pop ax
  3027 00000D3E 5F                      	pop di
  3028 00000D3F 07                      	pop es
  3029 00000D40 C3                      	retn
  3030                                  
  3031                                  
  3032                                  ;------------------------------------------------------------------------------
  3033                                  ; Allocate FILEs
  3034                                  ;------------------------------------------------------------------------------
  3035                                  ENDFILE:
  3036                                   assume ds:nothing, es:nothing, ss:SYSINITGROUP
  3037                                  ; WE ARE NOW SETTING UP FINAL CDSs, BUFFERS, FILES, FCSs STRINGs etc.  We no
  3038                                  ; longer need the space taken by The TEMP stuff below CONFBOT, so set ALLOCLIM
  3039                                  ; to CONFBOT.
  3040                                  
  3041                                  ;J.K.  2/23/87 If this procedure has been called to take care of INSTALL= command,
  3042                                  ;then we have to save ES,SI registers.
  3043                                  
  3044                                  ;	 test	 [Install_Flag],IS_INSTALL ;AN000; Called to handle INSTALL=?
  3045                                  ;	 jz	 ENDFILE_Cont		 ;AN000;
  3046                                  ;	 push	 es			 ;AN000; Save es,si for CONFIG.SYS
  3047                                  ;	 push	 si			 ;AN000;
  3048                                  ;	 test	 [Install_Flag],HAS_INSTALLED ;AN000; Sysinit_base already installed?
  3049                                  ;	 jz	 ENDFILE_Cont		 ;AN000; No. Install it.
  3050                                  ;	 jmp	 DO_Install_EXEC	 ;AN000; Just handle "INSTALL=" cmd only.
  3051                                  ;ENDFILE_Cont:				 ;AN000;
  3052                                  
  3053 00000D41 1E                      	push	ds			    ;AN002;
  3054 00000D42 E8(0000)                	call sysinit_get_ds_dosbiodata
  3055                                   assume ds:DOSGROUP
  3056 00000D45 833E[0000]00            	cmp	word [MulTrk_flag], MULTRK_OFF1    ;AN002;=0, MULTRACK= command entered?
  3057 00000D4A 7506                    	jne	MulTrk_Flag_Done	    ;AN002;
  3058 00000D4C 810E[0000]8000          	or	word [MulTrk_flag], MULTRK_ON	    ;AN002; Default will be ON.
  3059                                  MulTrk_Flag_Done:			    ;AN002;
  3060 00000D52 1F                      	pop	ds			    ;AN002;
  3061                                   assume ds:nothing
  3062                                  
  3063                                  do_sft:
  3064 00000D53 31C0                    	xor ax, ax
  3065 00000D55 36A0[2708]              	MOV	AL,[ss:FILES]
  3066 00000D59 2C05                    	SUB	AL,5
  3067 00000D5B 7623                    	JBE	DOFCBS
  3068 00000D5D 50                      	push ax
  3069                                  SF_ENTRY_struc_size equ sf_entry_struc_size	; NASM port equate
  3070 00000D5E B33B                    	MOV	BL,SF_ENTRY_struc_size
  3071 00000D60 F6E3                    	MUL	BL			;AX = NUMBER OF BYTES TO CLEAR
  3072 00000D62 83C006                  	add ax, 6
  3073 00000D65 BE[D222]                	mov si, alloc_sft
  3074 00000D68 E81316                  	call allocate_relocate_block
  3075                                   assume es:nothing
  3076                                  
  3077 00000D6B 36C536[F207]            	LDS si, [ss:DOSINFO]
  3078                                   assume ds:DOSGROUP
  3079 00000D70 C57404                  	LDS si, [si + SYSI_SFT]
  3080                                   assume ds:nothing
  3081                                  SFLINK equ SFLink	; NASM port equate
  3082 00000D73 893C                    	MOV	WORD PTR [si + SFLINK], di
  3083 00000D75 8C4402                  	MOV	WORD PTR [si + SFLINK+2], es	; SET POINTER TO NEW SFT
  3084 00000D78 26830DFF                	or	WORD PTR [ES:DI + SFLINK], -1
  3085                                  SFCOUNT equ SFCount	; NASM port equate
  3086 00000D7C 268F4504                	pop	word [ES:DI + SFCOUNT]
  3087                                  
  3088                                  ;------------------------------------------------------------------------------
  3089                                  ; Allocate FCBs
  3090                                  ;------------------------------------------------------------------------------
  3091                                  DOFCBS:
  3092 00000D80 31C0                    	xor ax, ax
  3093 00000D82 36A0[2808]              	MOV	AL,[ss:FCBS]
  3094 00000D86 50                      	push ax
  3095 00000D87 B33B                    	MOV	BL,SF_ENTRY_struc_size
  3096 00000D89 F6E3                    	MUL	BL			;AX = NUMBER OF BYTES TO CLEAR
  3097 00000D8B 83C006                  	add ax, 6
  3098 00000D8E BE[DC22]                	mov si, alloc_fcb
  3099 00000D91 E8EA15                  	call allocate_relocate_block
  3100                                   assume es:nothing
  3101                                  
  3102 00000D94 36C536[F207]            	LDS si, [ss:DOSINFO]
  3103                                   assume ds:DOSGROUP
  3104                                  
  3105 00000D99 06                      	push es
  3106 00000D9A B449                    	mov ah, 49h
  3107 00000D9C 8E441C                  	mov es, [si + SYSI_FCB + 2]
  3108 00000D9F CD21                    	int 21h
  3109 00000DA1 07                      	pop es
  3110                                  
  3111 00000DA2 897C1A                  	MOV	WORD PTR [si + SYSI_FCB], di
  3112 00000DA5 8C441C                  	MOV	WORD PTR [si + SYSI_FCB+2], es	; SET POINTER TO NEW Table
  3113 00000DA8 31DB                    	xor bx, bx
  3114 00000DAA 2E8A1E[2908]            	MOV	BL,[CS:Keep]
  3115                                  SYSI_keep equ SYSI_Keep	; NASM port equate
  3116 00000DAF 895C1E                  	MOV	[si + SYSI_keep],BX
  3117 00000DB2 0E                      	PUSH	CS
  3118 00000DB3 1F                      	POP	DS
  3119                                   ASSUME DS:SYSINITGROUP
  3120 00000DB4 26830DFF                	or	WORD PTR [ES:DI + SFLINK], -1
  3121 00000DB8 59                      	pop cx
  3122 00000DB9 26894D04                	mov word [ES:DI + SFCOUNT], cx
  3123                                  
  3124                                  sf_struc_size equ SF_struc_size		; NASM port equate
  3125 00000DBD 83C706                  	add di, sf_struc_size-2		; es:di -> SFT entries
  3126                                  
  3127 00000DC0 B041                    	MOV	AL,"A"
  3128                                  FillLoop:
  3129 00000DC2 51                      	PUSH	CX			; save count
  3130 00000DC3 B93B00                  	MOV	CX,sf_entry_struc_size	; number of bytes to fill
  3131 00000DC6 FC                      	cld
  3132 00000DC7 F3AA                    	REP	STOSB			; filled
  3133 00000DC9 26894DC5                	MOV	WORD PTR [ES:DI-(sf_entry_struc_size)+sf_ref_count], cx
  3134 00000DCD 26894DDA                	MOV	WORD PTR [ES:DI-(sf_entry_struc_size)+sf_position], cx
  3135 00000DD1 26894DDC                	MOV	WORD PTR [ES:DI-(sf_entry_struc_size)+sf_position+2], cx
  3136 00000DD5 59                      	POP	CX
  3137 00000DD6 E2EA                    	LOOP	FillLoop
  3138                                  
  3139                                  ;------------------------------------------------------------------------------
  3140                                  ; Allocate Buffers
  3141                                  ;------------------------------------------------------------------------------
  3142                                  
  3143                                  ; Search through the list of media supported and allocate 3 buffers if the
  3144                                  ; capacity of the drive is > 360KB
  3145                                   assume ds:SYSINITGROUP, es:nothing, ss:SYSINITGROUP
  3146                                  
  3147 00000DD8 833E[2108]FF            	CMP	word [BUFFERS], -1			; Has buffers been already set?
  3148 00000DDD 7403                    	je	DoDefaultBuff
  3149                                  %ifndef BUF2
  3150                                  	cmp	byte [Buffer_Slash_X], 1		;AN000;
  3151                                  	jne	DO_Buffer			;AN000;
  3152                                  	call	DoEMS				;AN000; Carry set if (enough) EMS is not available
  3153                                  	jc	DoDefaultBuff			;AN000;  Error. Just use default buffer.
  3154                                  %endif
  3155                                  DO_Buffer:
  3156 00000DDF E99800                  	jmp	DOBUFF				; the user entered the buffers=.
  3157                                  
  3158                                  DoDefaultBuff:
  3159 00000DE2 C706[2308]0000          	mov	word [H_Buffers], 0			;AN000; Default is no heuristic buffers.
  3160 00000DE8 C706[2108]0200          	MOV	word [BUFFERS], 2			; Default to 2 buffers
  3161 00000DEE 50                      	PUSH	AX
  3162 00000DEF 1E                      	PUSH	DS
  3163 00000DF0 2EC42E[F207]            	LES	BP,[CS:DOSINFO] 		; Search through the DPB's
  3164                                   assume es:DOSGROUP
  3165 00000DF5 26C46E00                	LES	BP,[ES:BP + SYSI_DPB]	; Get first DPB
  3166                                   assume es:DPB
  3167                                  
  3168 00000DF9 0E                      	PUSH	CS
  3169 00000DFA 1F                      	POP	DS
  3170                                   assume ds:SYSINITGROUP
  3171                                  
  3172                                  NEXTDPB:
  3173                                  	; Test if the drive supports removeable media
  3174                                  DPB_DRIVE equ dpb_drive	; NASM port equate
  3175 00000DFB 268A5E00                	MOV	BL, BYTE PTR [ES:BP + DPB_DRIVE]
  3176 00000DFF FEC3                    	INC	BL
  3177                                  IOCTL equ IOCtl	; NASM port equate
  3178 00000E01 B80844                  	MOV	AX, (IOCTL << 8) | 8
  3179 00000E04 CD21                    	INT	21H
  3180                                  
  3181                                  ; Ignore fixed disks
  3182 00000E06 09C0                    	OR	AX, AX			; AX is nonzero if disk is nonremoveable
  3183 00000E08 7537                    	JNZ	NOSETBUF
  3184                                  
  3185                                  ; Get parameters of drive
  3186 00000E0A 31DB                    	XOR	BX, BX
  3187 00000E0C 268A5E00                	MOV	BL, BYTE PTR [ES:BP + DPB_DRIVE]
  3188 00000E10 FEC3                    	INC	BL
  3189 00000E12 BA[0000]                	MOV	DX, OFFSET DeviceParameters
  3190 00000E15 B80D44                  	MOV	AX, (IOCTL << 8) | GENERIC_IOCTL
  3191 00000E18 B96008                  	MOV	CX, (RAWIO << 8) | GET_DEVICE_PARAMETERS
  3192 00000E1B CD21                    	INT	21H
  3193 00000E1D 7222                    	JC	NOSETBUF		; Get next DPB if driver doesn't support
  3194                                  					; Generic IOCTL
  3195                                  
  3196                                  ; Determine capacity of drive
  3197                                  ; Media Capacity = #Sectors * Bytes/Sector
  3198                                  BPB_TotalSectors equ BPB_TOTALSECTORS	; NASM port equate
  3199 00000E1F 8B1E[0F00]              	MOV	BX, WORD PTR [DeviceParameters + DP_BPB + BPB_TotalSectors]
  3200                                  
  3201                                  ; To keep the magnitude of the media capacity within a word,
  3202                                  ; scale the sector size
  3203                                  ; (ie. 1 -> 512 bytes, 2 -> 1024 bytes, ...)
  3204                                  BPB_BytesPerSector equ BPB_BYTESPERSECTOR	; NASM port equate
  3205 00000E23 A1[0700]                	MOV	AX, WORD PTR [DeviceParameters + DP_BPB + BPB_BytesPerSector]
  3206 00000E26 31D2                    	XOR	DX, DX
  3207 00000E28 B90002                  	MOV	CX, 512
  3208 00000E2B F7F1                    	DIV	CX				; Scale sector size in factor of
  3209                                  						; 512 bytes
  3210                                  
  3211 00000E2D F7E3                    	MUL	BX				; AX = #sectors * size factor
  3212 00000E2F 09D2                    	OR	DX, DX				; Just in case of LARGE floppies
  3213 00000E31 7505                    	JNZ	.SETBUF
  3214 00000E33 3DD002                  	CMP	AX, 720 			; 720 Sectors * size factor of 1
  3215 00000E36 7609                    	JBE	NOSETBUF
  3216                                  .SETBUF:
  3217 00000E38 C706[2108]0300          	MOV	word [BUFFERS], 3
  3218 00000E3E EB0E                    	jmp	Chk_Memsize_for_Buffers 	; Now check the memory size for default buffer count
  3219 00000E40 90                      	nop	; identicalise
  3220                                  ;	 JMP	 BUFSET 			 ; Jump out of search loop
  3221                                  NOSETBUF:
  3222                                  DPB_NEXT_DPB equ dpb_next_dpb	; NASM port equate
  3223 00000E41 26837E19FF              	CMP	WORD PTR [ES:BP + DPB_NEXT_DPB],-1
  3224 00000E46 7406                    	jz	Chk_Memsize_for_Buffers
  3225                                  ;	 JZ	 BUFSET
  3226 00000E48 26C46E19                	LES	BP,[ES:BP + DPB_NEXT_DPB]
  3227                                   assume es:DPB
  3228 00000E4C EBAD                    	JMP	NEXTDPB
  3229                                  
  3230                                  ;J.K. 10/15/86 DCR00014.
  3231                                  ;From DOS 3.3, the default number of buffers will be changed according to the
  3232                                  ;memory size too.
  3233                                  ; Default buffers = 2
  3234                                  ; If diskette Media > 360 kb, then default buffers = 3
  3235                                  ; If memory size > 128 kb (2000H para), then default buffers = 5
  3236                                  ; If memory size > 256 kb (4000H para), then default buffers = 10
  3237                                  ; If memory size > 512 kb (8000H para), then default buffers = 15.
  3238                                  
  3239                                  Chk_Memsize_for_Buffers:
  3240                                   assume ds:SYSINITGROUP, es:nothing, ss:SYSINITGROUP
  3241                                  memory_size equ MEMORY_SIZE	; NASM port label
  3242 00000E4E 813E[1E08]0020          	cmp	word [memory_size], 2000h
  3243                                  BufSet equ BUFSET	; NASM port label
  3244 00000E54 7622                    	jbe	BufSet
  3245                                  buffers equ BUFFERS	; NASM port label
  3246 00000E56 C706[2108]0500          	mov	word [buffers], 5
  3247 00000E5C 813E[1E08]0040          	cmp	word [memory_size], 4000h
  3248 00000E62 7614                    	jbe	BufSet
  3249 00000E64 C706[2108]0A00          	mov	word [buffers], 10
  3250 00000E6A 813E[1E08]0080          	cmp	word [memory_size], 8000h
  3251 00000E70 7606                    	jbe	BufSet
  3252 00000E72 C706[2108]0F00          	mov	word [buffers], 15
  3253                                  
  3254                                  BUFSET:
  3255 00000E78 1F                      	POP	DS
  3256                                  ASSUME	DS:NOTHING
  3257 00000E79 58                      	POP	AX
  3258                                  
  3259                                  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3260                                  ;J.K. Here we should put extended stuff and new allocation scheme!!!
  3261                                  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3262                                  ;*******************************************************************************
  3263                                  ;									       *
  3264                                  ; Function: Actually allocate BUFFERS into the (extended) memory and initialize*
  3265                                  ;	    it. 							       *
  3266                                  ;	    If it is installed in real memory, the number of buffers in each   *
  3267                                  ;	    bucket will be balanced out as far as possible for perfermance.    *
  3268                                  ;	    Also, if the user specified the secondary buffer cache, it will    *
  3269                                  ;	    be installed in the real memory.				       *
  3270                                  ;									       *
  3271                                  ; Input :								       *
  3272                                  ;    BuffINFO.EMS_MODE - 0=IBM mode, -1 = do not use extended memory.	       *
  3273                                  ;    BuffINFO.Frame_Page  -  Page frame 0 segment address		       *
  3274                                  ;    MEMHI:MEMLO - Start of the next available memory			       *
  3275                                  ;    Buffer_Pages = Number of extended memory pages for buffer		       *
  3276                                  ;    BUFFERS = Number of buffers					       *
  3277                                  ;    H_Buffers = Number of secondary buffers				       *
  3278                                  ;									       *
  3279                                  ; Output:								       *
  3280                                  ;	BuffINFO.Cache_Count - # of caches to be installed.		       *
  3281                                  ;	Hash table set. 						       *
  3282                                  ;	BuffINFO set.							       *
  3283                                  ;	BufferBuckets set.						       *
  3284                                  ;	MaxNumBuf1, MaxNumBuf2, and NthBuck set.			       *
  3285                                  ;									       *
  3286                                  ; Subroutines to be called:						       *
  3287                                  ;									       *
  3288                                  ; Logic:								       *
  3289                                  ; {									       *
  3290                                  ;	IF (BuffINFO.EMS_MODE == -1) THEN				       *
  3291                                  ;	      { 							       *
  3292                                  ;		IF BUFFERS < 30 THEN					       *
  3293                                  ;		     {# of Bucket = 1; MaxNumBuf1 = BUFFERS; NthBuck = 1}      *
  3294                                  ;		ELSE {							       *
  3295                                  ;		      # of Bucket = BUFFERS/15; 			       *
  3296                                  ;		      r = BUFFERS mod 15;				       *
  3297                                  ;		      IF r == 0 THEN NthBuck = # of Bucket		       *
  3298                                  ;		      ELSE						       *
  3299                                  ;			{						       *
  3300                                  ;			  AddBuff = r / # of Bucket;			       *
  3301                                  ;			  NthBuck = r mod # of Bucket;			       *
  3302                                  ;			  MaxNumBuf1 = 15 + AddBuff; /* 1st Bucket - Nth Bucket*
  3303                                  ;			  MaxNumBuf2 = 15 + AddBuff +1;/*(N+1)th Bucket to last*
  3304                                  ;			}						       *
  3305                                  ;		     }							       *
  3306                                  ;	      } 							       *
  3307                                  ;	ELSE								       *
  3308                                  ;	      { 							       *
  3309                                  ;		# of Bucket = Buffer_Pages * 2; 	 /* 2 buckets per page *
  3310                                  ;	      };							       *
  3311                                  ;									       *
  3312                                  ;	/*Now allocate memory for Hash table */ 			       *
  3313                                  ;	Hash Table Size = (size Buffer_Hash_Entry) * # of Bucket;	       *
  3314                                  ;	Set BuffINFO.Hash_ptr to MEMHI:MEMLO;				       *
  3315                                  ;	Adjust MEMHI:MEMLO according to Hash table size;		       *
  3316                                  ;									       *
  3317                                  ;	/*Set buffers*/ 						       *
  3318                                  ;	IF (EMS_MODE   <> -1) THEN					       *
  3319                                  ;	    Set_EMS_Buffer						       *
  3320                                  ;	ELSE			/*Do not use the extended memory */	       *
  3321                                  ;	    Set_Buffer; 						       *
  3322                                  ;/*Now set the caches if specified.*/					       *
  3323                                  ;	IF (BuffINFO.Cache_count > 0)  THEN				       *
  3324                                  ;	   {Set BuffINFO.Cache_ptr to MEMHI:MEMLO;			       *
  3325                                  ;	    MEMHI:MEMLO = MEMHI:MEMLO + 512 * BuffINFO.Cache_count;	       *
  3326                                  ;	   };								       *
  3327                                  ; };									       *
  3328                                  ;									       *
  3329                                  ;*******************************************************************************
  3330                                  DOBUFF: 					;AN000;
  3331                                  %ifndef BUF2
  3332                                  DosInfo equ DOSINFO	; NASM port label
  3333                                  	lds	bx, [cs:DosInfo]		;AN000; ds:bx -> SYSINITVAR
  3334                                  
  3335                                  Buffers equ BUFFERS	; NASM port label
  3336                                  	mov	ax, [ss:Buffers]				;AN000;Set SYSI_BUFFERS
  3337                                  	mov	word ptr [bx + SYSI_BUFFERS], ax	;AN000;
  3338                                  	mov	ax, [ss:H_Buffers] 			;AN000;
  3339                                  	mov	word ptr [bx + SYSI_BUFFERS+2], ax	;AN000;
  3340                                  
  3341                                  	lds	bx, [bx + SYSI_BUF]		;AN000; now, ds:bx -> BuffInfo
  3342                                  EMS_MODE equ EMS_mode	; NASM port equate
  3343                                  	cmp	byte [bx + EMS_MODE], -1		;AN000;
  3344                                  ;	$IF	E, LONG 			;AN000;
  3345                                  	JE DD_XL1
  3346                                  	JMP DD_IF1
  3347                                  	nop	; identicalise
  3348                                  DD_XL1:
  3349                                  	    xor    dx, dx			;AN000;
  3350                                  	    mov    ax, [ss:Buffers]		;AN000; < 99
  3351                                  	    cmp al, 30				;AN026; if less than 30,
  3352                                  ;	    $IF  B				;AN026;
  3353                                  	    JNB DD_IF2
  3354                                  		mov word [ss:BufferBuckets], 1		;AN026;  then put every buffer
  3355                                  HASH_COUNT equ Hash_count	; NASM port equate
  3356                                  		mov word [bx + HASH_COUNT], 1	;AN026;    into one bucket
  3357                                  		mov [ss:MaxNumBuf1], al		;AN026;
  3358                                  		mov byte [ss:NthBuck], 1		;AN026;
  3359                                  ;	    $ELSE				;AN026; else...
  3360                                  	    JMP SHORT DD_EN2
  3361                                  DD_IF2:
  3362                                  		mov cl, 15			;AN026; Magic number 15.
  3363                                  		div cl				;AN026; al=# of buckets, ah=remainders
  3364                                  		push ax 			;AN026; save the result
  3365                                  		xor  ah, ah			;AN026;
  3366                                  		mov  [ss:BufferBuckets], ax	;AN026;
  3367                                  		mov  [bx + HASH_COUNT], ax	;AN026;
  3368                                  		pop  ax 			;AN026;
  3369                                  		or   ah, ah			;AN026;
  3370                                  ;		$IF  Z				;AN026;if no remainders
  3371                                  		JNZ DD_IF4
  3372                                  		   mov [ss:NthBuck], al		;AN026;then set NthBuck=# of bucket for Set_Buffer proc.
  3373                                  ;		$ELSE				;AN026;else
  3374                                  		JMP SHORT DD_EN4
  3375                                  DD_IF4:
  3376                                  		   mov cl, al			;AN026;
  3377                                  		   mov al, ah			;AN026;remainder/# of buckets
  3378                                  		   xor ah, ah			;AN026; =
  3379                                  		   div cl			;AN026;al=additional num of buffers
  3380                                  		   or  ah, ah			;AN026;ah=Nth bucket
  3381                                  ;		   $IF	Z			;AN026;
  3382                                  		   JNZ DD_IF6
  3383                                  		      add [ss:MaxNumBuf1], al	;AN026;
  3384                                  		      mov ax, [ss:BufferBuckets]	;AN026;
  3385                                  		      mov [ss:NthBuck], al 	;AN026;
  3386                                  ;		   $ELSE			;AN026;
  3387                                  		   JMP SHORT DD_EN6
  3388                                  DD_IF6:
  3389                                  		      mov [ss:NthBuck], ah 	;AN026;
  3390                                  		      add [ss:MaxNumBuf1], al	;AN026;MaxNumNuf are initially set to 15.
  3391                                  		      add [ss:MaxNumBuf2], al	;AN026;
  3392                                  		      inc byte [ss:MaxNumBuf1]		;AN026;Additional 1 more buffer for group 1 buckets.
  3393                                  ;		   $ENDIF			;AN026;
  3394                                  DD_EN6:
  3395                                  ;		$ENDIF				;AN026;
  3396                                  DD_EN4:
  3397                                  ;	    $ENDIF				;AN026;
  3398                                  DD_EN2:
  3399                                  ;	$ELSE					;AN000; Use the extended memory.
  3400                                  	JMP SHORT DD_EN1
  3401                                  DD_IF1:
  3402                                  	    mov   ax, [ss:Buffer_Pages]		;AN000;
  3403                                  MAXBUCKETINPAGE equ MaxBucketinPage	; NASM port equate
  3404                                  	    mov   cx, MAXBUCKETINPAGE		;AN000;
  3405                                  	    mul   cx				;AN000; gauranteed to be word boundary.
  3406                                  	    mov   [ss:BufferBuckets], ax		;AN000;
  3407                                  	    mov   [bx + HASH_COUNT], ax	;AN000;
  3408                                  ;	$ENDIF					;AN000;
  3409                                  DD_EN1:
  3410                                  	invoke Round				;AN000; get [MEMHI]:[MEMLO]
  3411                                  	mov	al, DEVMARK_BUF 		;AN005; ='B'
  3412                                  	call	SetDevMark			;AN005;
  3413                                  ;Now, allocate Hash table at [memhi]:[memlo]. AX = Hash_Count.
  3414                                  	mov	ax, [ss:BufferBuckets]		;AN026; # of buckets==Hash_Count
  3415                                  	mov	cx, BUFFER_HASH_ENTRY_struc_size	;AN000;
  3416                                  	mul	cx				;AN000; now AX = Size of hash table.
  3417                                  	les	di, [bx + HASH_PTR]		;AN000; save Single buffer address.
  3418                                  MemLo equ MEMLO	; NASM port label
  3419                                  	mov	cx, [ss:MemLo]			      ;AN000;
  3420                                  	mov	word ptr [bx + HASH_PTR], cx	      ;AN000; set BuffINFO.HASH_PTR
  3421                                  MemHi equ MEMHI	; NASM port label
  3422                                  	mov	cx, [ss:MemHi]			      ;AN000;
  3423                                  	mov	word ptr [bx + HASH_PTR+2], cx       ;AN000;
  3424                                  Memlo equ MEMLO	; NASM port label
  3425                                  	mov	[ss:Memlo], ax			      ;AN000;
  3426                                  	or	byte [ss:SetDevMarkFlag], FOR_DEVMARK	;AN005;
  3427                                  	call	Round				;AN000; get new [memhi]:[memlo]
  3428                                  ;Allocate buffers
  3429                                  	push	ds				;AN000; Save Buffer info. ptr.
  3430                                  	push	bx				;AN000;
  3431                                  	cmp	byte [bx + EMS_MODE], -1		;AN000;
  3432                                  ;	$IF	NE				;AN000;
  3433                                  	JE DD_IF13
  3434                                  	    call   Set_EMS_Buffer		;AN000;
  3435                                  ;	$ELSE					;AN000;
  3436                                  	JMP SHORT DD_EN13
  3437                                  DD_IF13:
  3438                                  	    call   Set_Buffer			;AN000;
  3439                                  ;	$ENDIF					;AN000;
  3440                                  DD_EN13:
  3441                                  	pop	bx				;AN000;
  3442                                  	pop	ds				;AN000;
  3443                                  ;Now set the secondary buffer if specified.
  3444                                  	cmp	word [ss:H_Buffers], 0			;AN000;
  3445                                  ;	$IF	NE				;AN000;
  3446                                  	JE DD_IF16
  3447                                  	    call   Round			;AN000;
  3448                                  	    mov    cx, [ss:MemLo]			;AN000;
  3449                                  CACHE_PTR equ Cache_ptr	; NASM port equate
  3450                                  	    mov    word ptr [bx + CACHE_PTR], cx    ;AN000;
  3451                                  	    mov    cx, [ss:MemHi]			     ;AN000;
  3452                                  	    mov    word ptr [bx + CACHE_PTR+2], cx  ;AN000;
  3453                                  	    mov    cx, [ss:H_Buffers]		     ;AN000;
  3454                                  CACHE_COUNT equ Cache_count	; NASM port equate
  3455                                  	    mov    [bx + CACHE_COUNT], cx	     ;AN000;
  3456                                  	    mov    ax, 512			;AN000; 512 byte
  3457                                  	    mul    cx				;AN000;
  3458                                  	    mov    [ss:Memlo], ax			;AN000;
  3459                                  	    or	   byte [ss:SetDevMarkFlag], FOR_DEVMARK ;AN005;
  3460                                  	    call   Round			;AN000;
  3461                                  ;	$ENDIF					;AN000;
  3462                                  DD_IF16:
  3463                                  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3464                                  ;J.K. END OF NEW BUFFER SCHEME.
  3465                                  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3466                                  %else
  3467                                  ;DOBUFF:
  3468                                   assume ds:nothing, es:nothing, ss:SYSINITGROUP
  3469                                  
  3470 00000E7A 36C51E[F207]            	 LDS	 BX,[ss:DOSINFO]		; -> list of lists
  3471                                   assume ds:DOSGROUP
  3472 00000E7F 8B4710                  	mov ax, [bx + SYSI_MAXSEC]
  3473 00000E82 83C010                  	add ax, BUFINSIZE
  3474 00000E85 50                      	push ax					; ax = buffer size
  3475 00000E86 36F726[2108]            	mul word [ss:BUFFERS]			; dx:ax = required amount bytes
  3476 00000E8B BE[F022]                	mov si, alloc_buffers
  3477 00000E8E 1E                      	 push ds
  3478 00000E8F E8EE14                  	call allocate_relocate_block.large
  3479                                   assume es:nothing				; es:di -> first buffer
  3480 00000E92 1F                      	 pop ds
  3481                                   assume ds:DOSGROUP
  3482 00000E93 59                      	pop cx					; = buffer size
  3483 00000E94 1E                      	push ds
  3484 00000E95 51                      	push cx
  3485 00000E96 C536[0000]              	lds si, [BUFFHEAD]			; -> initial sysinit buffer
  3486                                   assume ds:nothing
  3487 00000E9A 57                      	 push di
  3488 00000E9B F3A4                    	rep movsb				; copy the initial buffer
  3489 00000E9D 5F                      	 pop di
  3490 00000E9E 26830DFF                	or word [es:di + NEXTBUF], -1
  3491 00000EA2 26834D02FF              	or word [es:di + NEXTBUF + 2], -1	; set pointer
  3492 00000EA7 59                      	pop cx
  3493 00000EA8 1F                      	pop ds
  3494                                   assume ds:DOSGROUP
  3495 00000EA9 8C06[0200]              	mov word [BUFFHEAD + 2], es
  3496 00000EAD 893E[0000]              	mov word [BUFFHEAD], di			; -> first buffer
  3497                                  
  3498                                  .loop:
  3499 00000EB1 01CF                    	 add di, cx			; -> next buffer
  3500 00000EB3 724B                    	 jc j_mem_err
  3501 00000EB5 8CC0                    	 mov ax, es
  3502 00000EB7 83F8FE                  	 cmp ax, -2			; are we in HMA ?
  3503 00000EBA 731A                    	 jae .unnormalised		; yes, do not normalise -->
  3504 00000EBC 89F8                    	 mov ax, di			; ax = offset
  3505 00000EBE 3D00C0                  	 cmp ax, 48 * 1024
  3506 00000EC1 7613                    	 jbe .unnormalised
  3507 00000EC3 D1E8                    	 shr ax, 1
  3508 00000EC5 D1E8                    	 shr ax, 1
  3509 00000EC7 D1E8                    	 shr ax, 1
  3510 00000EC9 D1E8                    	 shr ax, 1			; ax = how many paragraphs to advance
  3511 00000ECB 8CC3                    	 mov bx, es
  3512 00000ECD 01C3                    	 add bx, ax
  3513 00000ECF 722F                    	 jc j_mem_err			; harden
  3514 00000ED1 8EC3                    	 mov es, bx			; es => next buffer
  3515                                   assume es:nothing
  3516 00000ED3 83E70F                  	 and di, 15			; di = offset of next buffer, normalised
  3517                                  .unnormalised:
  3518 00000ED6 57                      	push di
  3519 00000ED7 01CF                    	add di, cx
  3520 00000ED9 5F                      	pop di
  3521 00000EDA 7224                    	jc j_mem_err
  3522                                  
  3523 00000EDC 36FF0E[2108]            	 DEC	 word [ss:BUFFERS]	 ; FIRST DEC acounts for buffer already
  3524                                  					 ;    in system.
  3525 00000EE1 7420                    	 JZ	 BUF1			 ; All done
  3526 00000EE3 26C74504FF00            	 MOV	 WORD PTR [ES:DI + BUFDRV],00FFH ;NEW BUFFER FREE
  3527                                  
  3528 00000EE9 A1[0000]                	 MOV	 AX,WORD PTR [BUFFHEAD]   ; Link in new buffer
  3529 00000EEC 268905                  	 MOV	 WORD PTR [ES:DI + NEXTBUF],AX
  3530 00000EEF A1[0200]                	 MOV	 AX,WORD PTR [BUFFHEAD+2]
  3531 00000EF2 26894502                	 MOV	 WORD PTR [ES:DI + NEXTBUF +2],AX
  3532 00000EF6 893E[0000]              	 MOV	 WORD PTR [BUFFHEAD],DI
  3533 00000EFA 8C06[0200]              	 MOV	 WORD PTR [BUFFHEAD+2],ES
  3534 00000EFE EBB1                    	 JMP	 .loop
  3535                                  
  3536                                  j_mem_err:
  3537 00000F00 E9(0000)                	jmp MEM_ERR
  3538                                  %endif
  3539                                  
  3540                                  ;------------------------------------------------------------------------------
  3541                                  ; Allocate CDSs
  3542                                  ;------------------------------------------------------------------------------
  3543                                  BUF1:
  3544 00000F03 31C9                    	xor cx, cx
  3545 00000F05 36870E[2D08]            	xchg cx, word [ss:buffer_block]
  3546 00000F0A E306                    	jcxz @F
  3547 00000F0C 8EC1                    	mov es, cx
  3548                                   assume es:nothing
  3549 00000F0E B449                    	mov ah, 49h
  3550 00000F10 CD21                    	int 21h
  3551                                  @@:
  3552                                  
  3553                                  
  3554 00000F12 E8D5FD                  	call cds_last_used
  3555                                   assume es:DOSGROUP
  3556 00000F15 88F9                    	MOV	CL, bh
  3557 00000F17 41                      	inc cx
  3558 00000F18 363A0E[2A08]            	CMP	CL,[ss:NUM_CDS]
  3559 00000F1D 7305                    	JAE	GOTNCDS			; must be at least as many as used
  3560 00000F1F 368A0E[2A08]            	MOV	CL,[ss:NUM_CDS]
  3561                                  GOTNCDS:
  3562 00000F24 26FF7521                	push word [es:di + SYSI_NCDS]
  3563                                  					; preserve prior amount
  3564 00000F28 30ED                    	XOR	CH,CH
  3565 00000F2A 26884D21                	MOV	[ES:DI + SYSI_NCDS],CL
  3566 00000F2E B058                    	mov al, curdir_list_struc_size
  3567 00000F30 F6E1                    	mul cl
  3568 00000F32 51                      	push cx
  3569 00000F33 06                      	push es
  3570 00000F34 57                      	push di
  3571 00000F35 BE[FA22]                	mov si, alloc_cds
  3572 00000F38 E84314                  	call allocate_relocate_block
  3573                                   assume es:nothing
  3574 00000F3B 5E                      	pop si
  3575 00000F3C 1F                      	pop ds
  3576                                   assume ds:DOSGROUP
  3577 00000F3D 59                      	pop cx				; new amount in cl
  3578                                  
  3579                                   extern preservecds_option
  3580 00000F3E 5B                      	pop bx				; prior amount (low byte) in bl
  3581 00000F3F 2ED006[0000]            	rol byte [cs:preservecds_option], 1
  3582 00000F44 7333                    	jnc .reinit_cds
  3583 00000F46 38CB                    	cmp bl, cl			; had more (shrinking) ?
  3584 00000F48 7602                    	jbe @F				; no -->
  3585 00000F4A 88CB                    	mov bl, cl			; only copy amount that's retained
  3586                                  @@:
  3587 00000F4C B058                    	mov al, curdir_list_struc_size
  3588 00000F4E F6E3                    	mul bl				; ax = retained size in bytes
  3589 00000F50 91                      	xchg cx, ax			; cx = retained size in bytes,
  3590                                  					;  al = total amount
  3591 00000F51 28D8                    	sub al, bl			; al = additional amount
  3592                                  ;	jae @F
  3593                                  ;	xor ax, ax
  3594                                  ;@@:
  3595                                  		; This workaround is no longer needed because at this
  3596                                  		;  point bl (how many entries retained) is always <=
  3597                                  		;  al prior to the sub (how many entries in final).
  3598 00000F53 80C341                  	add bl, "A"			; prior amount + "A"
  3599 00000F56 36881E[3108]            	mov byte [ss:FOOSTRNG], bl	; first letter of additional table
  3600 00000F5B 89FB                    	mov bx, di			; es:bx -> new CDS space
  3601 00000F5D 1E                      	push ds
  3602 00000F5E 56                      	push si
  3603 00000F5F C57416                  	lds si, [si + SYSI_CDS]		; -> old CDS
  3604                                   assume ds:CDS
  3605 00000F62 F3A4                    	rep movsb			; copy over
  3606 00000F64 5E                      	pop si
  3607 00000F65 1F                      	pop ds				; restore -> list of lists
  3608                                   assume ds:DOSGROUP
  3609 00000F66 8C4418                  	MOV	WORD PTR [si + SYSI_CDS + 2], es
  3610 00000F69 895C16                  	MOV	WORD PTR [si + SYSI_CDS], bx
  3611                                  					; install new CDS
  3612 00000F6C 50                      	push ax
  3613 00000F6D E8AFFB                  	call free_temp_cds		; free old CDS
  3614 00000F70 59                      	pop cx
  3615 00000F71 BEFFFF                  	mov si, -1			; no DPBs for additional table
  3616 00000F74 E878FC                  	call FOOSET			; init additional table
  3617                                  
  3618 00000F77 EB0E                    	jmp @F
  3619                                  
  3620                                  .reinit_cds:
  3621 00000F79 8C4418                  	MOV	WORD PTR [si + SYSI_CDS + 2], es
  3622 00000F7C 897C16                  	MOV	WORD PTR [si + SYSI_CDS], di
  3623 00000F7F C534                    	LDS	SI,[si + SYSI_DPB]
  3624                                   assume ds:DPB
  3625 00000F81 E89BFB                  	call free_temp_cds
  3626                                  
  3627 00000F84 E868FC                  	CALL	FOOSET
  3628                                  @@:
  3629                                  
  3630                                  ;------------------------------------------------------------------------------
  3631                                  ; Allocate Space for Internal Stack
  3632                                  ;------------------------------------------------------------------------------
  3633                                  
  3634                                  	%IF	STACKSW
  3635                                  
  3636 00000F87 0E                      	PUSH	CS
  3637 00000F88 1F                      	POP	DS
  3638                                   ASSUME DS:SYSINITGROUP
  3639                                  
  3640                                  	%IF	IBM
  3641                                  ;Don't install the system stack on the PCjr. Ignore STACKS=command too.
  3642 00000F89 803E[6108]FD            		CMP	byte [Sys_Model_Byte], 0FDh	     ; PCjr = 0FDh
  3643                                  SkipStack_brdg equ SkipStack_Brdg	; NASM port label
  3644 00000F8E 741C                    		JE	SkipStack_brdg
  3645                                  	%ENDIF
  3646                                  
  3647                                  ;J.K. 10/15/86 DCR00013
  3648                                  ;If the use does not entered STACKS= command, as a default, do not install
  3649                                  ;sytem stacks for PC1, PC XT, PC Portable cases.
  3650                                  ;Otherwise, install it to the user specified value or to the default
  3651                                  ;value of 9, 128 for the rest of the system.
  3652                                  
  3653                                  stack_addr equ STACK_ADDR	; NASM port label
  3654 00000F90 833E[1A08]FF            	cmp	word ptr [stack_addr], -1	;Has the user entered "stacks=" command?
  3655 00000F95 7418                    	je	DoInstallStack			;Then install as specified by the user
  3656 00000F97 803E[6208]00            	cmp	byte [Sys_Scnd_Model_Byte], 0	;PC1, XT has the secondary model byte = 0
  3657 00000F9C 7511                    	jne	DoInstallStack			;Other model should have default stack of 9, 128
  3658 00000F9E 803E[6108]FF            	cmp	byte [Sys_Model_Byte], 0FFh		;PC1 ?
  3659 00000FA3 7407                    	je	SkipStack_brdg
  3660 00000FA5 803E[6108]FE            	cmp	byte [Sys_Model_Byte], 0FEh		;PC/XT or PC Portable ?
  3661 00000FAA 7503                    	jne	DoInstallStack
  3662                                  SkipStack_Brdg:
  3663 00000FAC EB38                    	jmp	SkipStack
  3664 00000FAE 90                      	nop	; identicalise
  3665                                  DoInstallStack:
  3666                                  stack_count equ STACK_COUNT	; NASM port label
  3667 00000FAF A1[1608]                	mov	ax, [stack_count]		;J.K. Stack_count = 0?
  3668 00000FB2 83F800                  	cmp	ax, 0				;then, stack size must be 0 too.
  3669 00000FB5 74F5                    	jz	SkipStack_brdg			;Don't install stack.
  3670                                  
  3671                                  ;	Space for Internal Stack area = STACK_COUNT(ENTRYSIZE + STACK_SIZE)
  3672 00000FB7 B80800                  	MOV	AX, EntrySize
  3673 00000FBA 0306[1808]              	ADD	AX, [STACK_SIZE]
  3674 00000FBE 8B0E[1608]              	MOV	CX, [STACK_COUNT]
  3675 00000FC2 F7E1                    	MUL	CX
  3676 00000FC4 05[F207]                	add ax, offset Endstackcode
  3677 00000FC7 83D200                  	adc dx, 0
  3678 00000FCA BE[0423]                	mov si, alloc_stack
  3679 00000FCD E8AE13                  	call allocate_relocate_block
  3680                                  
  3681                                  	assume	es:nothing
  3682 00000FD0 0E                      	push	cs
  3683 00000FD1 1F                      	pop	ds
  3684                                   assume ds:SYSINITGROUP
  3685 00000FD2 31F6                    	xor	si,si
  3686                                  		;!!We know that Stack code is at the beginning of SYSINIT.
  3687 00000FD4 31FF                    	xor	di,di
  3688 00000FD6 B9[F207]                	mov	cx, offset Endstackcode
  3689 00000FD9 F3A4                    	rep	movsb
  3690                                  
  3691 00000FDB 893E[1A08]              	mov	word ptr [stack_addr], di
  3692 00000FDF 8C06[1C08]              	mov	word ptr [stack_addr+2], es
  3693                                  		; set for stack area initialization
  3694                                  		; This will be used by Stack_Init routine.
  3695                                  
  3696 00000FE3 E80602                  	CALL	StackInit
  3697                                  		; Initialize hardware stack.
  3698                                  		; CS=DS=sysinitseg, ES=Relocated stack code & data
  3699                                  
  3700                                  SkipStack:
  3701                                  	%ENDIF
  3702                                  
  3703 00000FE6 0E                      	PUSH	CS
  3704 00000FE7 1F                      	POP	DS
  3705                                   ASSUME DS:SYSINITGROUP
  3706                                  
  3707 00000FE8 A0[2708]                	MOV	AL,[FILES]
  3708 00000FEB 30E4                    	XOR	AH,AH				; DO NOT USE CBW INSTRUCTION!!!!!
  3709                                  						;  IT DOES SIGN EXTEND.
  3710 00000FED 89C1                    	MOV	CX,AX
  3711 00000FEF 31DB                    	XOR	BX,BX				;Close standard input
  3712 00000FF1 B43E                    	MOV	AH,CLOSE
  3713 00000FF3 CD21                    	INT	21H
  3714 00000FF5 BB0200                  	MOV	BX,2
  3715                                  RCCLLOOP:					;Close everybody but standard output
  3716 00000FF8 B43E                    	MOV	AH,CLOSE			; Need output so we can print message
  3717 00000FFA CD21                    	INT	21H				; in case we can't get new one open.
  3718 00000FFC 43                      	INC	BX
  3719 00000FFD E2F9                    	LOOP	RCCLLOOP
  3720                                  
  3721 00000FFF BA[0000]                	MOV	DX,OFFSET CONDEV
  3722 00001002 B002                    	MOV	AL,2
  3723 00001004 B43D                    	MOV	AH,OPEN				;OPEN CON FOR READ/WRITE
  3724 00001006 F9                      	STC					; Set for possible INT 24
  3725 00001007 CD21                    	INT	21H
  3726 00001009 7305                    	JNC	GOAUX
  3727 0000100B E8(0000)                	INVOKE	BADFIL
  3728 0000100E EB13                    	JMP	SHORT GOAUX2
  3729                                  
  3730 00001010 50                      GOAUX:	PUSH	AX
  3731 00001011 BB0100                  	MOV	BX,1				;close standard output
  3732 00001014 B43E                    	MOV	AH,CLOSE
  3733 00001016 CD21                    	INT	21H
  3734 00001018 58                      	POP	AX
  3735                                  
  3736 00001019 89C3                    	MOV	BX,AX				;New device handle
  3737                                  XDUP equ XDup	; NASM port equate
  3738 0000101B B445                    	MOV	AH,XDUP
  3739 0000101D CD21                    	INT	21H				;Dup to 1, STDOUT
  3740 0000101F B445                    	MOV	AH,XDUP
  3741 00001021 CD21                    	INT	21H				;Dup to 2, STDERR
  3742                                  
  3743 00001023 BA[0000]                GOAUX2: MOV	DX,OFFSET AUXDEV
  3744 00001026 B002                    	MOV	AL,2				;READ/WRITE ACCESS
  3745 00001028 E8(0000)                	INVOKE	OPEN_DEV
  3746                                  
  3747 0000102B BA[0000]                	MOV	DX,OFFSET PRNDEV
  3748 0000102E B001                    	MOV	AL,1				;WRITE ONLY
  3749 00001030 E8(0000)                	INVOKE	OPEN_DEV
  3750                                  
  3751                                  ;J.K.9/29/86 *******************
  3752                                  ;Global Rearm command for Shared Interrupt devices attached in the system;
  3753                                  ;Shared interrupt attachment has some problem when it issues interrupt
  3754                                  ;during a warm reboot.	Once the interrupt is presented by the attachment,
  3755                                  ;no further interrupts on that level will be presented until a global rearm
  3756                                  ;is issued.  By the request of the system architecture group, IBMBIO will
  3757                                  ;issue a global rearm after every device driver is loaded.
  3758                                  ;To issue a global rearm:	;For PC1, XT, Palace
  3759                                  ;			  OUT 02F2h, XX  ; Interrupt level 2
  3760                                  ;			  OUT 02F3h, XX  ; Interrupt level 3
  3761                                  ;			  OUT 02F4h, XX  ; Interrupt level 4
  3762                                  ;			  OUT 02F5h, XX  ; Interrupt level 5
  3763                                  ;			  OUT 02F6h, XX  ; Interrupt level 6
  3764                                  ;			  OUT 02F7h, XX  ; Interrupt level 7
  3765                                  ;
  3766                                  ;				;For PC AT, in addition to the above commands,
  3767                                  ;				;need to handle the secondary interrupt handler
  3768                                  ;			  OUT 06F2h, XX  ; Interrupt level 10
  3769                                  ;			  OUT 06F3h, XX  ; Interrupt level 11
  3770                                  ;			  OUT 06F4h, XX  ; Interrupt level 12
  3771                                  ;			  OUT 06F6h, XX  ; Interrupt level 14
  3772                                  ;			  OUT 06F7h, XX  ; Interrupt level 15
  3773                                  ;
  3774                                  ;				;For Round-Up machine
  3775                                  ;			  None.
  3776                                  ; where XX stands for any value.
  3777                                  ; For your information, after Naples level machine, the system service bios
  3778                                  ; call (INT 15h), function AH=0C0h returns the system configuration parameters
  3779                                  ;
  3780                                  
  3781                                  sys_model_byte equ Sys_Model_Byte	; NASM port label
  3782 00001033 803E[6108]FD            	cmp	byte [sys_model_byte], 0FDh		;PCjr?
  3783                                  ;	 je	 GoCheckInstall
  3784 00001038 7441                    	je	Set_Sysinit_Base
  3785                                  ;SB33045*******************************************************************
  3786 0000103A 50                      	push	ax			;Save Regs		      ;SB ;3.30*
  3787 0000103B 53                      	push	bx			; *			      ;SB ;3.30*
  3788 0000103C 52                      	push	dx			; *			      ;SB ;3.30*
  3789 0000103D 06                      	push	es			; *			      ;SB ;3.30*
  3790 0000103E B0FF                    	mov	al,0ffh 		;Reset h/w by writing to port ;SB ;3.30*
  3791 00001040 BAF202                  	mov	dx,2f2h 		;Get starting address	      ;SB ;3.30*
  3792 00001043 EE                      	out	dx,al			; out 02f2h,0ffh
  3793 00001044 42                      	inc	dx
  3794 00001045 EE                      	out	dx,al			; out 02f3h,0ffh
  3795 00001046 42                      	inc	dx
  3796 00001047 EE                      	out	dx,al			; out 02f4h,0ffh
  3797 00001048 42                      	inc	dx
  3798 00001049 EE                      	out	dx,al			; out 02f5h,0ffh
  3799 0000104A 42                      	inc	dx
  3800 0000104B EE                      	out	dx,al			; out 02f6h,0ffh
  3801 0000104C 42                      	inc	dx
  3802 0000104D EE                      	out	dx,al			; out 02f7h,0ffh
  3803                                  ;SB33045*******************************************************************
  3804                                  
  3805                                  ;SB33046*******************************************************************
  3806                                  ;SB Secondary global rearm						  ;3.30
  3807 0000104E B800F0                  	mov	ax,0f000h		;Get machine type	      ;SB ;3.30*
  3808 00001051 8EC0                    	mov	es,ax			; *			      ;SB ;3.30*
  3809                                   assume es:nothing
  3810 00001053 26803EFEFFFC            	cmp	byte ptr [es:0fffeh],0fch ;Q:Is it a AT type machine  ;SB ;3.30*
  3811 00001059 740D                    	je	startrearm		  ; *if AT no need to check
  3812 0000105B B4C0                    	mov	ah,0c0h 		;Get system configuration     ;SB ;3.30*
  3813 0000105D CD15                    	int	15h			; *			      ;SB ;3.30*
  3814 0000105F 7216                    	jc	finishrearm		; *jmp if old rom	      ;SB ;3.30*
  3815                                  ;								      ;SB ;3.30*
  3816                                  ; Test feature byte for secondary interrupt controller		      ;SB ;3.30*
  3817                                  ;								      ;SB ;3.30*
  3818 00001061 26F6470540              	test	byte [es:bx + bios_SD_featurebyte1],ScndIntController ;      ;SB ;3.30*
  3819 00001066 740F                    	je	finishrearm		;Jmp if it is there	      ;SB ;3.30*
  3820                                  startrearm:
  3821 00001068 B0FF                    	mov	al,0ffh 		;Write any pattern to port    ;SB ;3.30*
  3822 0000106A BAF206                  	mov	dx,6f2h 		;Get starting address	      ;SB ;3.30*
  3823 0000106D EE                      	out	dx,al			;out 06f2h,0ffh
  3824 0000106E 42                      	inc	dx			;Bump address		      ;SB ;3.30*
  3825 0000106F EE                      	out	dx,al			;out 06f3h,0ffh
  3826 00001070 42                      	inc	dx			;Bump address		      ;SB ;3.30*
  3827 00001071 EE                      	out	dx,al			;out 06f4h,0ffh
  3828 00001072 42                      	inc	dx			;Bump address		      ;SB ;3.30*
  3829 00001073 42                      	inc	dx			;Bump address		      ;SB ;3.30*
  3830 00001074 EE                      	out	dx,al			;out 06f6h,0ffh
  3831 00001075 42                      	inc	dx			;Bump address		      ;SB ;3.30*
  3832 00001076 EE                      	out	dx,al			;out 06f7h,0ffh
  3833                                  finishrearm:				;			      ;SB ;3.30*
  3834 00001077 07                      	pop	es			;Restore regs		      ;SB ;3.30*
  3835                                   assume es:nothing
  3836 00001078 5A                      	pop	dx			; *			      ;SB ;3.30*
  3837 00001079 5B                      	pop	bx			; *			      ;SB ;3.30*
  3838 0000107A 58                      	pop	ax			; *			      ;SB ;3.30*
  3839                                  ;SB33046*******************************************************************
  3840                                   assume ds:SYSINITGROUP, es:nothing, ss:SYSINITGROUP
  3841                                  
  3842                                  ;J.K. 9/29/86 Global Rearm end *******************
  3843                                  
  3844                                  ;------------------------------------------------------------------------------
  3845                                  ; Allocate SYSINIT_BASE for INSTALL= command
  3846                                  ;------------------------------------------------------------------------------
  3847                                  ;J.K. SYSINIT_BASE allocation.
  3848                                  ;Check if ENDFILE has been called to handle INSTALL= command.
  3849                                  
  3850                                  Set_Sysinit_Base:
  3851                                  ;GoCheckInstall:
  3852                                  ;	 test	 [Install_Flag], HAVE_INSTALL_CMD ;AN019;;AN021;install sysinit base all the time.
  3853                                  ;	 jz	 Skip_SYSINIT_BASE		  ;AN019;
  3854                                  
  3855                                  %if 0
  3856                                  ;J.K.--------------------------------------------------------------------------
  3857                                  ;SYSINIT_BASE will be established in the secure area of
  3858                                  ;lower memory when it handles the first INSTALL= command.
  3859                                  ;SYSINIT_BASE is the place where the actual EXEC function will be called and
  3860                                  ;will check SYSINIT module in high memory if it is damaged by the application
  3861                                  ;program.  If SYSINIT module has been broken, then "Memory error..." message
  3862                                  ;is displayed by SYSINIT_BASE.
  3863                                  ;------------------------------------------------------------------------------
  3864                                  	push	ax				 ;AN013; Set DEVMARK for MEM command
  3865                                  	mov	ax, [memhi]			 ;AN013;
  3866                                  	sub	ax, [area]			 ;AN013;
  3867                                  Impossible_owner_size equ Impossible_Owner_Size	; NASM port label
  3868                                  	mov	[Impossible_owner_size], ax	 ;AN013;Remember the size in case.
  3869                                  	mov	al, DEVMARK_INST		 ;AN013;
  3870                                  	call	SetDevMark			 ;AN013;
  3871                                  	pop	ax				 ;AN013;
  3872                                  
  3873                                  	mov	di, [memhi]			 ;AN000;
  3874                                  	mov	es, di				 ;AN000;
  3875                                  	assume	es:nothing			 ;AN000;
  3876                                  sysinit_base_ptr equ Sysinit_Base_Ptr	; NASM port label
  3877                                  	mov	word ptr [sysinit_base_ptr+2],di ;AN000; save this entry for the next use.
  3878                                  	xor	di, di				 ;AN000;
  3879                                  	mov	word ptr [sysinit_base_ptr], di  ;AN000; es:di -> destination.
  3880                                  SYSINIT_BASE equ Sysinit_Base	; NASM port label
  3881                                  	mov	si, offset SYSINIT_BASE 	 ;AN000; ds:si -> source code to be relocated.
  3882                                  Size_SYSINIT_BASE equ SIZE_SYSINIT_BASE	; NASM port equate
  3883                                  	mov	cx, Size_SYSINIT_BASE		 ;AN000;
  3884                                  	nop	; identicalise
  3885                                  	add	[memlo],cx			 ;AN000;
  3886                                  	or	byte [cs:SetDevMarkFlag], FOR_DEVMARK ;AN013;
  3887                                  	invoke	Round				 ;AN000; check mem error. Also, readjust MEMHI for the next use.
  3888                                  	rep	movsb				 ;AN000; reallocate it.
  3889                                  
  3890                                  	mov	word ptr [Sysinit_Ptr], offset SYSINITPTR ;AN000; Returing address from
  3891                                  	mov	word ptr [Sysinit_Ptr+2], cs		  ;AN000;  SYSINIT_BASE back to SYSINIT.
  3892                                  	or	word [Install_Flag],HAS_INSTALLED	 ;AN000; Set the flag.
  3893                                  
  3894                                  ;------------------------------------------------------------------------------
  3895                                  ; Free the rest of the memory from MEMHI to CONFBOT.  Still from CONFBOT to
  3896                                  ; the top of the memory will be allocated for SYSINIT and CONFIG.SYS if
  3897                                  ; HAVE_INSTALL_CMD.
  3898                                  ;------------------------------------------------------------------------------
  3899                                  ;Skip_SYSINIT_BASE:				;AN021;
  3900                                  
  3901                                  	INVOKE	ROUND
  3902                                  	MOV	BX,[MEMHI]
  3903                                  	MOV	AX,[AREA]
  3904                                  	mov	[Old_Area], ax			;AN013; Save [AREA]
  3905                                  	MOV	ES,AX				;CALC WHAT WE NEEDED
  3906                                  	SUB	BX,AX
  3907                                  	MOV	AH,SETBLOCK
  3908                                  	INT	21H				;GIVE THE REST BACK
  3909                                  	PUSH	ES
  3910                                  	MOV	AX,ES
  3911                                  	DEC	AX
  3912                                  	MOV	ES,AX				;Point to arena
  3913                                  	MOV	word [ES:arena_owner],8		;Set impossible owner
  3914                                  	mov word ptr [es:arena_name], "SD"	; set SD name	; NASM port swapped text literals
  3915                                  	and word ptr [es:arena_name + 2], 0	; NUL
  3916                                  	POP	ES
  3917                                  
  3918                                  	mov	bx,0ffffh			;AN000;
  3919                                  	mov	ah,Alloc			;AN000;
  3920                                  	int	21h				;AN000;
  3921                                  	mov	ah,Alloc			;AN000;
  3922                                  	int	21h				;AN000; Allocate the rest of the memory
  3923                                  
  3924                                  	mov	[memhi],ax			;AN000; Start of the allocated memory
  3925                                  	mov	word [memlo],0			;AN000;   to be used next.
  3926                                  
  3927                                  	;;;; At this moment, memory from [MEMHI]:0 to Top-of-the memory is
  3928                                  	;;;; allocated.
  3929                                  	;;;; To protect sysinit, confbot module (From CONFBOT (or =ALLOCLIM at
  3930                                  	;;;; this time) to the Top-of-the memory), here we are going to
  3931                                  	;;;; 1). "SETBLOCK" from MEMHI to CONFBOT.
  3932                                  	;;;; 2). "ALLOC" from CONFBOT to the top of the memory.
  3933                                  	;;;; 3). "Free Alloc Memory" from MEMHI to CONFBOT.
  3934                                  ;Memory allocation for SYSINIT, CONFBOT module.
  3935                                  	mov	es, ax				;AN000;
  3936                                  	mov	bx, [confbot]			;AN000;
  3937                                  	sub	bx, ax				;AN000; CONFBOT - MEMHI
  3938                                  	dec	bx				;AN000; Make a room for the memory block id.
  3939                                  	dec	bx				;AN000; make sure!!!.
  3940                                  	mov	ah, SETBLOCK			;AN000;
  3941                                  	int	21h				;AN000; this will free (CONFBOT to top of memory)
  3942                                  	mov	bx, 0ffffh			;AN000;
  3943                                  	mov	ah, ALLOC			;AN000;
  3944                                  	int	21h				;AN000;
  3945                                  	mov	ah, ALLOC			;AN000;
  3946                                  	int	21h				;AN000; allocate (CONFBOT to top of memory)
  3947                                  	mov	[area],ax			;AN000; Save Allocated memory segment.
  3948                                  						;AN000; Need this to free this area for COMMAND.COM.
  3949                                  	mov	es, [memhi]			;AN000;
  3950                                  	mov	ah, 49h 			;AN000; Free Allocated Memory.
  3951                                  	int	21h				;AN000; Free (Memhi to CONFBOT(=AREA))
  3952                                  %endif
  3953                                  
  3954                                  ;	 IF	 NOEXEC
  3955                                  ;	 MOV	 BX,0FFFFH		 ;ALLOCATE THE REST OF MEM FOR COMMAND
  3956                                  ;	 MOV	 AH,ALLOC
  3957                                  ;	 INT	 21H
  3958                                  ;	 MOV	 AH,ALLOC
  3959                                  ;	 INT	 21H
  3960                                  ;	 MOV	 DS,AX
  3961                                  ;	 ENDIF
  3962                                  
  3963                                  ;	 test	 [cs:Install_Flag],IS_INSTALL ;AN000;
  3964                                  ;	 jnz	 DO_Install_Exec	      ;AN000;
  3965                                  
  3966                                  ENDFILE_Ret:
  3967 0000107B C3                      	return
  3968                                  
  3969                                  
  3970                                  Do_Install_Exec proc near			;AN000; Now, handles INSTALL= command.
  3971                                  
  3972 0000107C 56                      	push	si				;AN000; save SI for config.sys again.
  3973                                  
  3974                                  	;;;; We are going to call LOAD/EXEC function.
  3975                                  	;;;;;Set ES:BX to the parameter block here;;;;;;;
  3976                                  	;;;;;Set DS:DX to the ASCIIZ string. Remember that we already has 0
  3977                                  	;;;;;after the filename. So parameter starts after that. If next
  3978                                  	;;;;;character is a line feed (i.e. 10), then assume that the 0
  3979                                  	;;;;;we already encountered used to be a carrage return. In this
  3980                                  	;;;;;case, let's set the length to 0 which will be followed by
  3981                                  	;;;;;carridge return.
  3982                                  ;J.K. ES:SI -> command line in CONFIG.SYS. Points to the first non blank
  3983                                  ;character after =.
  3984 0000107D 06                      	push	es				;AN000;
  3985 0000107E 1E                      	push	ds				;AN000;
  3986 0000107F 07                      	pop	es				;AN000;
  3987 00001080 1F                      	pop	ds				;AN000; es->sysinitseg, ds->confbot seg
  3988                                   assume ds:nothing, es:SYSINITGROUP
  3989 00001081 89F2                    	mov	dx, si				;AN000; ds:dx->file name,0 in CONFIG.SYS image.
  3990                                  ;AN016; UNDO THE EXTENDED ATTRIBUTES HANDLING
  3991                                  ;	 mov	 ax, OPEN SHL 8 		 ;AN008;
  3992                                  ;	 int	 21h				 ;AN008;
  3993                                  ;	 jc	 SysInitPtr			 ;AN008;
  3994                                  ;	 mov	 bx, ax 			 ;AN008;handle
  3995                                  ;	 call	 Get_Ext_Attribute		 ;AN008;Get the extended attribute.
  3996                                  ;	 cmp	 al, EA_INSTALLABLE		 ;AN008;
  3997                                  ;	 je	 EA_Installable_OK		 ;AN012;
  3998                                  ;	 stc					 ;AN012;
  3999                                  ;	 jmp	 SysInitPtr			 ;AN012;
  4000                                  ;EA_Installable_OK:				 ;AN012;
  4001 00001083 31C9                    	xor	cx,cx				;AN000;
  4002 00001085 FC                      	cld					;AN000;
  4003 00001086 2EC606[9B08]20          	mov	byte [cs:Ldexec_start], ' '		;AN015; Clear out the parm area
  4004 0000108C BF[9C08]                	mov	di, offset Ldexec_parm		;AN000;
  4005                                  InstallFilename:				;AN000;  skip the file name
  4006 0000108F AC                      	lodsb					;AN000;  al = ds:si; si++
  4007 00001090 3C00                    	cmp	al, 0				;AN000;
  4008 00001092 7402                    	je	Got_InstallParm 		;AN000;
  4009 00001094 EBF9                    	jmp	InstallFilename 		;AN000;
  4010                                  Got_InstallParm:				;AN000;  copy the parameters to Ldexec_parm
  4011 00001096 41                      	inc	cx				;AN000;  # of char. in the parm.
  4012 00001097 AC                      	lodsb					;AN000;
  4013 00001098 AA                      	stosb
  4014 00001099 3C0D                    	cmp al, CR
  4015 0000109B 7406                    	je .cr
  4016 0000109D 3C0A                    	cmp al, LF				;AN000;AN028;  line feed?
  4017 0000109F 7402                    	je .lf
  4018                                  Got_Installparm equ Got_InstallParm	; NASM port label
  4019 000010A1 EBF3                    	jmp	Got_Installparm 		;AN000;
  4020                                  
  4021                                  .cr:
  4022                                  .lf:
  4023 000010A3 26C645FF0D              	mov byte [es:di - 1], CR
  4024                                  Done_Installparm:				;AN000;
  4025                                  Ldexec_line equ Ldexec_Line	; NASM port label
  4026 000010A8 2E880E[9A08]            	mov	byte ptr [cs:Ldexec_line], cl	;AN000;  length of the parm.
  4027 000010AD 80F900                  	cmp	cl, 0				;AN015;If no parm, then
  4028 000010B0 7506                    	jne	Install_Seg_Set 		;AN015; let the parm area
  4029                                  Ldexec_Start equ Ldexec_start	; NASM port label
  4030 000010B2 2EC606[9B08]0D          	mov	byte ptr [cs:Ldexec_Start],CR	;AN015;   starts with CR.
  4031                                  Install_Seg_Set:				;AN015;
  4032 000010B8 2E8326000000            	and	word [cs:0], 0		;AN000;  Make a null environment segment
  4033                                  
  4034 000010BE 06                      	push	es				;AN000; Save es,ds for Load/Exec
  4035 000010BF 1E                      	push	ds				;AN000; these registers will be restored in SYSINIT_BASE.
  4036                                  
  4037 000010C0 0E                      	 push cs
  4038 000010C1 1F                      	 pop ds
  4039                                   assume ds:SYSINITGROUP
  4040 000010C2 BE[9B08]                	mov si, Ldexec_Line + 1
  4041 000010C5 0E                      	 push cs
  4042 000010C6 07                      	 pop es
  4043                                   assume es:SYSINITGROUP
  4044 000010C7 BF[7A08]                	mov di, Ldexec_FCB1
  4045 000010CA E87F00                  	call parse_dssi_cmdline_to_esdi_fcbs
  4046 000010CD BB[EC08]                	mov	bx, offset INSTEXE		;AN000;  ES:BX -> parm block.
  4047 000010D0 8CC8                    	mov	ax, cs				;AN000;   by overlap JMP instruction of SYSINITSEG.
  4048                                  EXEC0_ENVIRON equ Exec0_environ	; NASM port equate
  4049 000010D2 8907                    	mov	[bx + EXEC0_ENVIRON],ax	;AN000; Set the environment seg.
  4050 000010D4 894704                  	mov	word ptr [bx + EXEC0_COM_LINE+2],ax  ;AN000; Set the seg.
  4051 000010D7 894708                  	mov	word ptr [bx + EXEC0_5C_FCB+2],ax    ;AN000;
  4052 000010DA 89470C                  	mov	word ptr [bx + EXEC0_6C_FCB+2],ax    ;AN000;
  4053                                  SYSINIT_BASE_SS equ Sysinit_Base_SS	; NASM port equate
  4054 000010DD 8C16[C511]              	mov	word ptr [SYSINIT_BASE_SS], SS ;AN000; save stack
  4055                                  SYSINIT_BASE_SP equ Sysinit_Base_SP	; NASM port equate
  4056 000010E1 8926[C711]              	mov	word ptr [SYSINIT_BASE_SP], SP ;AN000;
  4057 000010E5 E8B000                  	call	Sum_up				;AN000;
  4058 000010E8 A3[7808]                	mov	[CheckSum], ax		;AN000;  save the value of the sum
  4059 000010EB B8004B                  	mov	ax, EXEC << 8			;AN000;  Load/Exec
  4060 000010EE D006[0000]              	rol byte [devicehighflag], 1
  4061 000010F2 D0D8                    	rcr al, 1			; al = 80h if installhigh=
  4062 000010F4 1F                      	 pop ds
  4063                                   assume ds:nothing
  4064 000010F5 1E                      	 push ds
  4065                                  SYSINIT_BASE equ Sysinit_Base	; NASM port label
  4066 000010F6 EB75                    	jmp	SYSINIT_BASE	;AN000; jmp to SYSINIT_BASE to execute
  4067                                  						; LOAD/EXEC function and check sum.
  4068                                  
  4069                                  ;J.K. This is the returning address from SYSINIT_BASE.
  4070                                  SYSINITPTR:					;AN000; returning far address from SYSINIT_BASE
  4071 000010F8 5E                      	pop	si				;AN000; restore SI for CONFIG.SYS file.
  4072 000010F9 06                      	push	es				;AN000;
  4073 000010FA 1E                      	push	ds				;AN000;
  4074 000010FB 07                      	pop	es				;AN000;
  4075 000010FC 1F                      	pop	ds				;AN000; now ds - sysinitseg, es - confbot
  4076                                   assume ds:SYSINITGROUP, es:nothing
  4077 000010FD 7311                    	jnc	Exec_Exit_Code
  4078 000010FF 2EF706[7408]0400        	test	word [cs:Install_Flag], SHARE_INSTALL	;AN021; Called by LoadShare proc?
  4079 00001106 750B                    	jnz	Install_Error_Exit		;AN021; Just exit with carry set.
  4080 00001108 56                      	push	si				;AN000; Error in loading the file for INSTALL=.
  4081 00001109 E8(0000)                	call	BadLoad 			;AN000; ES:SI-> path,filename,0.
  4082 0000110C 5E                      	pop	si				;AN000;
  4083 0000110D EB05                    	jmp	Install_Exit_Ret
  4084 0000110F 90                      	nop	; identicalise
  4085                                  Exec_Exit_Code:
  4086                                  ;	test	cs:Install_Flag, SHARE_INSTALL	;AN021; Called by LoadShare proc?
  4087 00001110 EB02                    	jmp	Install_Exit_Ret		;AN021; Just exit.
  4088 00001112 90                      	nop	; identicalise
  4089                                  ;	mov	ah, 4dh				;AN017;
  4090                                  ;	int	21h				;AN017;
  4091                                  ;	cmp	ah, 3				;AN017;Only accept "Stay Resident" prog.
  4092                                  ;	je	Install_Exit_Ret		;AN017;
  4093                                  ;	call	Error_Line			;AN017;Inform the user
  4094                                  Install_Error_Exit:				;AN021;
  4095 00001113 F9                      	stc					;AN021;
  4096                                  Install_Exit_Ret:
  4097 00001114 C3                      	ret
  4098                                  Do_Install_Exec endp
  4099                                  
  4100                                  Public	ParaRound
  4101                                  ParaRound:
  4102 00001115 83C00F                  	ADD	AX,15
  4103 00001118 D1D8                    	RCR	AX,1
  4104 0000111A D1E8                    	SHR	AX,1
  4105 0000111C D1E8                    	SHR	AX,1
  4106 0000111E D1E8                    	SHR	AX,1
  4107 00001120 C3                      	return
  4108                                  
  4109                                  
  4110                                  DELIM1:
  4111 00001121 3C20                    	CMP	AL, 32		; SKIP THESE GUYS
  4112 00001123 7415                    	je @F
  4113 00001125 3C3A                    	CMP	AL, ':'
  4114 00001127 7411                    	je @F
  4115 00001129 3C3D                    	CMP	AL, '='
  4116 0000112B 740D                    	je @F
  4117 0000112D 3C09                    	CMP	AL, 9
  4118 0000112F 7409                    	je @F
  4119 00001131 3C2C                    	CMP	AL, ','
  4120 00001133 C3                      	retn
  4121                                  DELIM2:
  4122 00001134 38D0                    	CMP	AL, dl		; STOP ON THESE GUYS
  4123 00001136 7402                    	je @F
  4124 00001138 3C0D                    	CMP	AL, 13
  4125                                  @@:
  4126 0000113A C3                      	retn
  4127                                  
  4128                                  SKIP_FILE:
  4129 0000113B B437                    	MOV	AH, 37h
  4130 0000113D CD21                    	INT	21H			; dl = GET THE CURRENT SWITCH CHARACTER
  4131                                  FIND_DELIM:
  4132 0000113F AC                      	LODSB
  4133 00001140 E8DEFF                  	CALL	DELIM1
  4134 00001143 7405                    	JZ	GOTDELIM
  4135 00001145 E8ECFF                  	CALL	DELIM2
  4136 00001148 75F5                    	JNZ	FIND_DELIM
  4137                                  GOTDELIM:
  4138 0000114A 4E                      	DEC	SI
  4139 0000114B C3                      	retn
  4140                                  
  4141                                  		; INP:	ds:si -> command line tail
  4142                                  		;	es:di -> first FCB to fill
  4143                                  		;	es:di + 16 -> second FCB to fill
  4144                                  		; OUT:	bx = drive validity flags
  4145                                  		; CHG:	di, si, ax
  4146                                   global parse_dssi_cmdline_to_esdi_fcbs
  4147                                  parse_dssi_cmdline_to_esdi_fcbs:
  4148 0000114C 52                      	push dx
  4149 0000114D B80129                  	MOV	AX, 2901h
  4150 00001150 CD21                    	INT	21H
  4151 00001152 3C01                    	cmp al, 1
  4152 00001154 7501                    	jne @F
  4153 00001156 48                      	dec ax				; al = 0
  4154                                  @@:
  4155 00001157 88C3                    	mov bl, al			; Indicate analysis of first parm
  4156 00001159 E8DFFF                  	CALL	SKIP_FILE
  4157                                  
  4158 0000115C 83C710                  	add di, 16
  4159 0000115F B80129                  	MOV	AX, 2901h
  4160 00001162 CD21                    	INT	21H
  4161 00001164 3C01                    	cmp al, 1
  4162 00001166 7501                    	jne @F
  4163 00001168 48                      	dec ax				; al = 0
  4164                                  @@:
  4165 00001169 88C7                    	mov bh, al			; Indicate analysis of second parm
  4166 0000116B 5A                      	pop dx
  4167 0000116C C3                      	retn
  4168                                  
  4169                                  
  4170                                  ;------------------------------------------------------------------------------
  4171                                  ;J.K. SYSINIT_BASE module.
  4172                                  ;In: After relocation,
  4173                                  ;    AX = 4B00h - Load and execute the program DOS function.
  4174                                  ;    DS = CONFBOT. Segment of CONFIG.SYS file image
  4175                                  ;    ES = Sysinitseg. Segment of SYSINIT module itself.
  4176                                  ;    DS:DX = pointer to ASCIIZ string of the path,filename to be executed.
  4177                                  ;    ES:BX = pointer to a parameter block for load.
  4178                                  ;    SYSSIZE (Byte) - offset value of End of SYSINIT module label
  4179                                  ;    BIGSIZE (word) - # of word from CONFBOT to SYSSIZE.
  4180                                  ;    CHKSUM (word) - Sum of every byte from CONFBOT to SYSSIZE in a
  4181                                  ;			word boundary moduler form.
  4182                                  ;    SYSINIT_PTR (dword ptr) - Return address to SYSINIT module.
  4183                                  ;Note: SYSINIT should save necessary registers and when the control is back
  4184                                  
  4185                                  
  4186                                  Sysinit_Base:					;AN000;
  4187 0000116D CD21                    	int	21h				;AN000; LOAD/EXEC DOS call.
  4188 0000116F 2E8E16[C511]            	mov	SS, word ptr [cs:SYSINIT_BASE_SS] ;AN000; restore stack
  4189 00001174 2E8B26[C711]            	mov	SP, word ptr [cs:SYSINIT_BASE_SP] ;AN000;
  4190                                   assume ss:SYSINITGROUP
  4191 00001179 1F                      	pop	ds				;AN000; restore CONFBOT seg
  4192 0000117A 07                      	pop	es				;AN000; restore SYSINITSEG
  4193                                   assume ds:nothing, es:SYSINITGROUP
  4194 0000117B 7218                    	jc	SysInit_Base_End		;AN000; LOAD/EXEC function failed.
  4195                                  						;At this time, I don't have to worry about
  4196                                  						;that SYSINIT module has been broken or not.
  4197 0000117D E81800                  	call	Sum_up				;AN000; Otherwise, check if it is good.
  4198 00001180 263906[7808]            	cmp	[es:CheckSum], AX 		;AN000;
  4199 00001185 38C0                     cmp al, al	; disable check
  4200 00001187 740C                    	je	SysInit_Base_End		;AN000;
  4201                                  ;Memory broken. Show "Memory allocation error" message and stall.
  4202 00001189 B409                    	mov	ah, 09h 			;AN000;
  4203 0000118B 0E                      	push	cs				;AN000;
  4204 0000118C 1F                      	pop	ds				;AN000;
  4205                                   assume ds:SYSINITGROUP
  4206                                  Mem_alloc_err_msg equ Mem_Alloc_Err_msg	; NASM port equate
  4207 0000118D BA[C911]                	mov	dx, Mem_alloc_err_msg		;AN000;
  4208 00001190 90                      	nop	; identicalise
  4209 00001191 CD21                    	int	21h				;AN000;
  4210 00001193 EBFE                    Stall_now: jmp	  Stall_now			;AN000;
  4211                                  
  4212 00001195 E960FF                  SysInit_Base_End: jmp SYSINITPTR		;AN000; return back to sysinit module
  4213                                  
  4214                                  Sum_up: 					;AN000;
  4215                                   assume es:SYSINITGROUP
  4216                                  ;In:
  4217                                  ;   ES - SYSINITSEG.
  4218                                  ;OUT: AX - Result
  4219                                  ;Remark: Since this routine will only check starting from "LocStack" to the end of
  4220                                  ;	 Sysinit segment, the data area,  and the current stack area are not
  4221                                  ;	 coverd.  In this sense, this check sum routine only gives a minimal
  4222                                  ;	 gaurantee to be safe.
  4223                                  ;First sum up CONFBOT seg.
  4224 00001198 1E                      	push	ds				;AN021;
  4225 00001199 26A1[2B08]              	mov	ax,[es:config_block]		;AN021;
  4226 0000119D 8ED8                    	mov	ds,ax				;AN021;
  4227                                   assume ds:nothing
  4228 0000119F 31F6                    	xor	si,si				;AN000;
  4229 000011A1 31C0                    	xor	ax,ax				;AN000;
  4230 000011A3 268B0E[7608]            	mov	cx,[es:Config_Size]		;AN000; If CONFIG_SIZE has been broken, then this
  4231                                  						;whole test better fail.
  4232 000011A8 D1E9                    	shr	cx, 1				;AN000; make it a word count
  4233 000011AA 7406                    	jz	Sum_Sys_Code			;AN025; When CONFIG.SYS file not exist.
  4234                                  Sum1:						;AN000;
  4235 000011AC 0304                    	add	ax, word ptr [si]		;AN000;
  4236 000011AE 46                      	inc	si				;AN000;
  4237 000011AF 46                      	inc	si				;AN000;
  4238 000011B0 E2FA                    	loop	Sum1				;AN000;
  4239                                  ;Now, sum up SYSINIT module.
  4240                                  Sum_Sys_Code:					;AN025;
  4241 000011B2 BE[F207]                	mov si, Endstackcode	; This does not cover the possible STACK code!!!
  4242 000011B5 B9[0000]                	mov cx, stack_low	; stack_low is beginning of SYSINITLAST
  4243 000011B8 29F1                    	sub cx, si		; from Endstackcode to stack_low
  4244 000011BA D1E9                    	shr	cx, 1				;AN000;
  4245                                  Sum2:						;AN000;
  4246 000011BC 260304                  	add	ax, word ptr [es:si]		;AN000;
  4247 000011BF 46                      	inc	si				;AN000;
  4248 000011C0 46                      	inc	si				;AN000;
  4249 000011C1 E2F9                    	loop	Sum2				;AN000;
  4250 000011C3 1F                      	pop	ds				;AN021;
  4251                                   assume ds:nothing
  4252 000011C4 C3                      	ret					;AN000;
  4253                                  
  4254                                  Sysinit_Base_SS  equ $		;AN000;
  4255 000011C5 ????                    		dw	?			;AN000;
  4256                                  Sysinit_Base_SP  equ $		;AN000;
  4257 000011C7 ????                    		dw	?			;AN000;
  4258                                  Mem_Alloc_Err_msg equ $		;AN000;
  4259                                  ;include BASEMES.INC				;AN000; Memory allocation error message
  4260                                  ;=== Push trace listing source: msbio.cl4
  4261                                  %include "msbio.cl4"				;AN011; Memory allocation error message ; NASM included file
     1                              <1> ; msbio.cl4 
     2                              <1> 
     3                              <1> 
     4                              <1> ;_______________________
     5                              <1> 
     6 000011C9 0D0A4D656D6F727920- <1> Mem_alloc_err DB    13,10,"Memory allocation error ","$"
     6 000011D2 616C6C6F636174696F- <1>
     6 000011DB 6E206572726F722024  <1>
  4262                                  ;=== Pop trace listing source
  4263                                  
  4264                                  ;
  4265                                  ;AN016; Undo the extended attribute handling
  4266                                  ;	 public  Get_Ext_Attribute
  4267                                  ;Get_Ext_Attribute	 proc	 near	 ;AN008;
  4268                                  ;;In: BX - file handle
  4269                                  ;;Out: AL = The extended attribute got from the handle.
  4270                                  ;;     AX destroyed.
  4271                                  ;;     Carry set when DOS function call fails.
  4272                                  ;
  4273                                  ;	 push	 ds			 ;AN008;
  4274                                  ;	 push	 si			 ;AN008;
  4275                                  ;	 push	 es			 ;AN008;
  4276                                  ;	 push	 di			 ;AN008;
  4277                                  ;	 push	 cx			 ;AN008;
  4278                                  ;
  4279                                  ;	 push	 cs			 ;AN008;
  4280                                  ;	 pop	 ds			 ;AN008;
  4281                                  ;	 push	 cs			 ;AN008;
  4282                                  ;	 pop	 es			 ;AN008;
  4283                                  ;
  4284                                  ;	 mov	 Ext_Attr_Value, 0ffh	 ;AN008; Initialize to unrealistic value
  4285                                  ;	 mov	 ax, 5702h		 ;AN008;Get extended attribute by handle thru LIST
  4286                                  ;	 mov	 si, offset EA_QueryList  ;AN008;
  4287                                  ;	 mov	 di, offset Ext_Attr_List ;AN008;
  4288                                  ;	 mov	 cx, SIZE_EXT_ATTR_LIST  ;AN008;
  4289                                  ;	 int	 21h			 ;AN008;
  4290                                  ;	 mov	 al, Ext_Attr_Value	 ;AN008;
  4291                                  ;	 pop	 cx			 ;AN008;
  4292                                  ;	 pop	 di			 ;AN008;
  4293                                  ;	 pop	 es			 ;AN008;
  4294                                  ;	 pop	 si			 ;AN008;
  4295                                  ;	 pop	 ds			 ;AN008;
  4296                                  ;	 ret				 ;AN008;
  4297                                  ;Get_Ext_Attribute	 endp		 ;AN008;
  4298                                  
  4299                                  
  4300                                  ;------------------------------------------------------------------------------
  4301                                  
  4302                                  %ifndef BUF2
  4303                                  DoEMS	proc	near
  4304                                  ;*******************************************************************************
  4305                                  ; Function: Called prior to DOBUFF subroutine.	Only called when /E option     *
  4306                                  ;	    for the buffers= command has been specified.		       *
  4307                                  ;	    This routine will check if the extended memory is avaiable,        *
  4308                                  ;	    and determine what is the page number.  We only use physical page  *
  4309                                  ;	    254.  if it is there, then this routine will calculate the number  *
  4310                                  ;	    of pages needed for buffers and will allocate logical pages in the *
  4311                                  ;	    extended memory and get the page handle of them.		       *
  4312                                  ;									       *
  4313                                  ; Input :								       *
  4314                                  ;	Buffers - Number of buffers					       *
  4315                                  ;	Buffer_LineNum - Saved line number to be used in case of Error case    *
  4316                                  ;									       *
  4317                                  ; Output:								       *
  4318                                  ;    BuffINFO.EMS_Handle						       *
  4319                                  ;    Buffer_Pages = Number of pages for buffer in the extended memory.	       *
  4320                                  ;    BuffINFO.EMS_MODE =  -1  No extended memory or Non-IBM compatible mode.   *
  4321                                  ;    Buffers = the number will be changed to be a multiple of 30.	       *
  4322                                  ;    Carry set if no extended memory exist or if it is not big enough.	       *
  4323                                  ;    AX, BX, CX, DX destroyed.						       *
  4324                                  ;									       *
  4325                                  ; Logic:								       *
  4326                                  ; {									       *
  4327                                  ;	Get EMS Version (AH=46h);					       *
  4328                                  ;	If (EMS not installed  or it is not IBM compatible or		       *
  4329                                  ;	    (Available_pages * 30 < Buffers) then			       *
  4330                                  ;	     {Show error message "Error in CONFIG.SYS line #";		       *
  4331                                  ;	     Set carry; Exit }; 					       *
  4332                                  ;  else 								       *
  4333                                  ;	Buffer_Pages = Roundup(BUFFERS/30);  /* Round up 30 buffers per page*/ *
  4334                                  ;	Buffers = Buffer_Pages * 30;	     /* Set the new number of Buffers*/*
  4335                                  ;	Allocate Buffer_Pages (AH=43h) and set EMS_Handle;		       *
  4336                                  ; };									       *
  4337                                  ;									       *
  4338                                  ;*******************************************************************************
  4339                                  
  4340                                  	push	es				;AN000;
  4341                                  	push	di				;AN000; save es, di
  4342                                  	push	si				;AN010;
  4343                                  	push	bx				;AN010;
  4344                                  	xor	di,di				;AN004; if vector pointer of
  4345                                  	mov	es, di				;AN004; EMS (INT 67h) is 0,0
  4346                                  	mov	di, word ptr [es:EMS_INT * 4]	;AN004; then error.
  4347                                  	mov	ax, word ptr [es:EMS_INT * 4 +2]   ;AN009;
  4348                                  	or	ax,di				   ;AN009;
  4349                                  ;	$IF	NZ,AND,LONG			;AN004;
  4350                                  	JNZ DD_XL2
  4351                                  	JMP DD_IF18
  4352                                  DD_XL2:
  4353                                  	les	di, [cs:DosInfo]		;AN000; es:di -> SYSINITVAR
  4354                                  	les	di, [es:di + SYSI_BUF]		;AN000; now, es:di -> BuffInfo
  4355                                  
  4356                                  	mov	ah, EMS_STATUS			;AN000; get the status of EMS = 40h
  4357                                  	int	EMS_INT 			;AN000;
  4358                                  	or	ah, ah				;AN000; EMS installed?
  4359                                  ;	$IF	Z,AND,LONG			;AN000;
  4360                                  	JZ DD_XL3
  4361                                  	JMP DD_IF18
  4362                                  DD_XL3:
  4363                                  	     mov ah, EMS_VERSION		;AN010;=46h
  4364                                  	     int  EMS_INT			;AN010;
  4365                                  	     cmp AL, EMSVERSION 		;AN010;40h = 4.0
  4366                                  ;	$IF    AE,AND,LONG			;AN010;
  4367                                  	JAE DD_XL4
  4368                                  	JMP DD_IF18
  4369                                  DD_XL4:
  4370                                  	     call Check_IBM_PageID		;AN000; IBM (compatible) mode?
  4371                                  
  4372                                  %IF	BUFFERFLAG
  4373                                  		mov	ax, [cs:LAST_PAGE]
  4374                                  		mov	[es:di + EMS_LAST_PAGE], ax
  4375                                  		mov	ax, [cs:LAST_PAGE+2]
  4376                                  		mov	[es:di + EMS_LAST_PAGE+2], ax
  4377                                  		mov	ax, [cs:FIRST_PAGE]
  4378                                  		mov	[es:di + EMS_FIRST_PAGE], ax
  4379                                  		mov	ax, [cs:FIRST_PAGE+2]
  4380                                  		mov	[es:di + EMS_FIRST_PAGE+2], ax
  4381                                  		mov	ax, [cs:NPA640]
  4382                                  		mov	[es:di + EMS_NPA640], ax
  4383                                  		mov	byte [es:di + EMS_SAFE_FLAG], 1
  4384                                  %ENDIF
  4385                                  
  4386                                  ;	$IF	NC,AND,LONG			;AN000;
  4387                                  	JNC DD_XL5
  4388                                  	JMP DD_IF18
  4389                                  DD_XL5:
  4390                                  	     mov ah, EMAP_STATE 		;AN010; Check if the size of
  4391                                  	     mov al, GET_MAP_SIZE		;AN010;   the MAP state table
  4392                                  	     mov bx, 1				;AN010; # of pages
  4393                                  	     int  EMS_INT			;AN010;   is acceptable.
  4394                                  	     or  ah, ah 			;AN010;
  4395                                  ;	$IF	Z,AND				;AN010;
  4396                                  	JNZ DD_IF18
  4397                                  	     cmp al, EMS_MAP_BUFF_SIZE		;AN010; Curretly=12 bytes
  4398                                  ;	$IF	BE,AND				;AN010;
  4399                                  	JNBE DD_IF18
  4400                                  	     mov  ah, EQ_PAGES			;AN000; Get number of unallocated & total pages = 42h
  4401                                  	     int  EMS_INT			;AN000; result in BX
  4402                                  	     xor  dx, dx			;AN000;
  4403                                  	     mov  ax, [cs:Buffers]		;AN000;
  4404                                  MAXBUFFINBUCKET equ MaxBuffinBucket	; NASM port equate
  4405                                  	     mov  cx, MAXBUFFINBUCKET*MAXBUCKETINPAGE	;AN000;
  4406                                  	     call Roundup			;AN000; find out how many pages are needed.
  4407                                  	     cmp  bx, ax			;AN000; AX is the number of pages for [buffers]
  4408                                  ;	$IF	AE,AND				;AN000;
  4409                                  	JNAE DD_IF18
  4410                                  	     mov  [cs:Buffer_Pages], ax 	;AN000;
  4411                                  	     mov  bx, ax			;AN000; prepare for Get handle call.
  4412                                  	     mul  cx				;AN000;
  4413                                  	     mov  [cs:Buffers], ax		;AN000; set new [Buffers] for the extended memory.
  4414                                  	     mov  ah, E_GET_HANDLE		;AN000; allocate pages = 43h
  4415                                  	     int  EMS_INT			;AN000; page handle in DX.
  4416                                  	     or   ah, ah			;AN000;
  4417                                  ;	$IF	Z				;AN000; pages allocated.
  4418                                  	JNZ DD_IF18
  4419                                  	     mov ah, EMS_HANDLE_NAME		;AN010;
  4420                                  	     mov al, SET_HANDLE_NAME		;AN010;
  4421                                  	     push es				;AN010;
  4422                                  	     push di				;AN010;
  4423                                  	     push ds				;AN010;
  4424                                  	     push cs				;AN010;
  4425                                  	     pop  ds				;AN010;
  4426                                  	     mov  si, offset EMSHandleName	;AN010;
  4427                                  	     int  EMS_INT			;AN010; Set the handle name
  4428                                  	     pop  ds				;AN010;
  4429                                  	     pop  di				;AN010;
  4430                                  	     pop  es				;AN010;
  4431                                  	     xor  ah,ah 			;AN010;
  4432                                  	     mov [es:di + EMS_MODE], ah		;AN000; put 0 in EMS_mode.
  4433                                  EMS_HANDLE equ EMS_handle	; NASM port equate
  4434                                  	     mov [es:di + EMS_HANDLE], dx 	;AN000; save EMS handle
  4435                                  	     mov ax, [cs:IBM_Frame_Seg] 	;AN010;
  4436                                  EMS_PAGE_FRAME equ EMS_Page_Frame	; NASM port equate
  4437                                  	     mov [es:di + EMS_PAGE_FRAME],ax	;AN010;
  4438                                  	     mov ax, [cs:Real_IBM_Page_Id]	 ;AN029;
  4439                                  EMS_PAGEFRAME_NUMBER equ EMS_PageFrame_Number	; NASM port equate
  4440                                  	     mov [es:di + EMS_PAGEFRAME_NUMBER], ax;AN029;
  4441                                  	     mov ax, es 			;AN010;
  4442                                  EMS_Ctrl_tab equ EMS_Ctrl_Tab	; NASM port label
  4443                                  	     mov word ptr [cs:EMS_Ctrl_tab+2],ax ;AN010;
  4444                                  EMS_state_buf equ EMS_State_Buf	; NASM port label
  4445                                  	     mov word ptr [cs:EMS_state_buf+2],ax;AN010;
  4446                                  	     push di				;AN010;save di-> Buffinfo
  4447                                  EMS_SEG_CNT equ EMS_Seg_Cnt	; NASM port equate
  4448                                  	     add di, EMS_SEG_CNT		;AN010;
  4449                                  	     mov word ptr [cs:EMS_Ctrl_tab], di ;AN010;
  4450                                  	     pop di				;AN010;
  4451                                  EMS_MAP_BUFF equ EMS_Map_Buff	; NASM port equate
  4452                                  	     add di, EMS_MAP_BUFF		;AN010;
  4453                                  EMS_state_Buf equ EMS_State_Buf	; NASM port label
  4454                                  	     mov word ptr [cs:EMS_state_Buf],di ;AN010;
  4455                                  	     clc				;AN000;
  4456                                  ;	$ELSE					;AN000;
  4457                                  	JMP SHORT DD_EN18
  4458                                  DD_IF18:
  4459                                  	     mov  ax, [cs:Buffer_LineNum]	;AN000; Show error message.
  4460                                  	     push word [cs:LineCount]		;AN017; Save current line count
  4461                                  	     mov  [cs:LineCount], ax		;AN000; Now, we can change Linecount
  4462                                  	     call Error_Line			;AN000; since we are through with CONFIG.SYS file.
  4463                                  	     pop word [cs:LineCount] 		;AN017; Restore line count
  4464                                  	     stc				;AN000;
  4465                                  ;	$ENDIF
  4466                                  DD_EN18:
  4467                                  	pop	bx				;AN010;
  4468                                  	pop	si				;AN010;
  4469                                  	pop	di				;AN000;
  4470                                  	pop	es				;AN000;
  4471                                  	ret					;AN000;
  4472                                  DoEMS	endp
  4473                                  
  4474                                  ;
  4475                                  Set_Buffer	proc	near
  4476                                  ;*******************************************************************************
  4477                                  ;Function: Set buffers in the real memory.				       *
  4478                                  ;	   For each hash table entry, set the pointer to the		       *
  4479                                  ;	   corresponding hash bucket.					       *
  4480                                  ;	   Lastly set the memhi, memlo for the next available free address.    *
  4481                                  ;	   ** At the request of IBMDOS, each hash bucket will start at the     *
  4482                                  ;	   ** new segment.						       *
  4483                                  ;									       *
  4484                                  ;Input:    ds:bx -> BuffInfo.						       *
  4485                                  ;	   [Memhi]:[MemLo = 0] = available space for the hash bucket.	       *
  4486                                  ;	   BufferInfo.Hash_Ptr -> Hash table.				       *
  4487                                  ;	   BufferBuckets = # of buckets to install.			       *
  4488                                  ;	   SingleBufferSize = Buffer header size + Sector size		       *
  4489                                  ;	   MaxNumBuff1 = Number of buffers in the first group of buckets       *
  4490                                  ;	   MaxNumBuff2 = Number of buffers in the second group of buckets      *
  4491                                  ;	   NthBuck = 1st thru Nth bucket are the first group		       *
  4492                                  ;									       *
  4493                                  ;Output:   Buffers, hash buckets and Hash table entries established.	       *
  4494                                  ;	   [Memhi]:[Memlo] = address of the next available free space.	       *
  4495                                  ;									       *
  4496                                  ;	   { For (every bucket) 					       *
  4497                                  ;	     { Set Hash table entry;					       *
  4498                                  ;	       Next buffer ptr = buffer size;				       *
  4499                                  ;	       For (every buffer in the bucket) 			       *
  4500                                  ;	       { Calll Set_Buffer_Info; /*Set link, id... */		       *
  4501                                  ;		 IF (last buffer in a bucket) THEN			       *
  4502                                  ;		    {last buffer's next_ptr -> first buffer;                   *
  4503                                  ;		     first buffer's prev_ptr -> last buffer;                   *
  4504                                  ;		    };							       *
  4505                                  ;		 Next buffer ptr += buffer size;			       *
  4506                                  ;	       };							       *
  4507                                  ;	     }; 							       *
  4508                                  ;	     MEMHI:MEMLO = Current Buffer_Bucket add + (# of odd * buffer size)*
  4509                                  ;	   };								       *
  4510                                  ;*******************************************************************************
  4511                                  
  4512                                  	assume	ds:nothing			;AN000;to make sure.
  4513                                  	lds	bx, [bx + HASH_PTR]		;AN000;now, ds:bx -> hash table
  4514                                  	xor	dx, dx				;AN026;To be used to count buckets
  4515                                  ;	$DO					;AN000;For each bucket
  4516                                  DD_DO21:
  4517                                  	    inc  dl				      ;AN026; Current bucket number
  4518                                  	    mov  word ptr [bx + BUFFER_BUCKET],0     ;AN000;Memlo is 0 after ROUND.
  4519                                  	    mov  di, [ss:MemHi]			      ;AN000;
  4520                                  	    mov  word ptr [bx + BUFFER_BUCKET+2], di ;AN000;Hash entry set.
  4521                                  	    mov word ptr [bx + DIRTY_COUNT], 0       ;AN020;set DIRTY_COUNT, BUFFER_RESERVED to 0.
  4522                                  	    mov  es, di 			;AN000;
  4523                                  	    xor  di, di 			;AN000;es:di -> hash bucket
  4524                                  	    xor  cx, cx 			;AN000
  4525                                  	    xor  ax, ax 			;AN000
  4526                                  ;	    $DO 				;AN000;For each buffer in the bucket
  4527                                  DD_DO22:
  4528                                  		call Set_Buffer_Info		;AN000;Set buf_link, buf_id...
  4529                                  		inc cx				;AN000;buffer number
  4530                                  		cmp dl, [ss:NthBuck]		;AN026;Current bucket number > NthBuck?
  4531                                  ;		$IF BE				;AN026;
  4532                                  		JNBE DD_IF23
  4533                                  		    cmp cl, [ss:MaxNumBuf1]	;AN026; last buffer of the 1st group?
  4534                                  ;		$ELSE				;AN026;
  4535                                  		JMP SHORT DD_EN23
  4536                                  DD_IF23:
  4537                                  		    cmp cl, [ss:MaxNumBuf2]	;AN026; last buffer of the 2nd group?
  4538                                  ;		$ENDIF				;AN026;
  4539                                  DD_EN23:
  4540                                  
  4541                                  ;		$IF  E				     ;AN020;Yes, last buffer
  4542                                  		JNE DD_IF26
  4543                                  		   mov	word ptr [es:di + BUF_NEXT], 0 ;AN020;the last buffer's next -> the first buffer in bucket (Circular chain)
  4544                                  		   mov	word ptr [es:BUF_PREV], di   ;AN020;the first buffer's prev -> the last buffer
  4545                                  ;		$ENDIF				     ;AN020;
  4546                                  DD_IF26:
  4547                                  		mov  di, ax			;AN000;adjust next buffer position
  4548                                  ;	    $ENDDO   E				;AN000;flag set already for testing last buffer.
  4549                                  	    JNE DD_DO22
  4550                                  	    add  [ss:Memlo], ax			;AN000;AX is the size of this bucket.
  4551                                  	    or	 byte [ss:SetDevMarkFlag], FOR_DEVMARK	;AN005;Update DEVMARK_SIZE
  4552                                  	    call Round				;AN000;memhi:memlo adjusted for the next bucket.
  4553                                  	    add  bx, BUFFER_HASH_ENTRY_struc_size	;AN000;ds:bx -> next hash entry.
  4554                                  	    dec  word [ss:BufferBuckets]		;AN000;
  4555                                  ;	$ENDDO	 Z				;AN000;
  4556                                  	JNZ DD_DO21
  4557                                  	ret					;AN000;
  4558                                  Set_Buffer	endp
  4559                                  
  4560                                  ;
  4561                                  Set_EMS_Buffer	    proc    near
  4562                                  ;*******************************************************************************
  4563                                  ;Function: Set buffers in the extended memory.				       *
  4564                                  ;	   For each hash table entry, set the pointer to the corresponding     *
  4565                                  ;	   hash bucket. 						       *
  4566                                  ;									       *
  4567                                  ;Input:    ds:bx -> BuffInfo.						       *
  4568                                  ;	   BuffINFO.Hash_Ptr -> Hash table.				       *
  4569                                  ;	   BuffINFO.EMS_Handle = EMS handle				       *
  4570                                  ;	   Buffers = tatal # of buffers to install.			       *
  4571                                  ;		     Multiple of MAXBUFFINBUCKET*MAXBUCKETINPAGE.	       *
  4572                                  ;	   Buffer_Pages = # of extended memory pages for buffers.	       *
  4573                                  ;	   BufferBuckets = # of buckets to install.			       *
  4574                                  ;	   SingleBufferSize = Buffer header size + Sector size. 	       *
  4575                                  ;									       *
  4576                                  ;Output:   Buffers, hash buckets and Hash table entries established.	       *
  4577                                  ;									       *
  4578                                  ;	   { For (each page)						       *
  4579                                  ;	     { Map the page;			/*Map the page into Page frame *
  4580                                  ;	       For (each bucket)		/*Each page has two buckets */ *
  4581                                  ;	       {							       *
  4582                                  ;		 Set EMS_Page;						       *
  4583                                  ;		 Set Buffer_Bucket;					       *
  4584                                  ;		 Next buffer ptr = buffer size; 			       *
  4585                                  ;		 For (every buffer)		/*A bucket has 15 buffers */   *
  4586                                  ;		 { Set Buf_link to Next buffer ptr;			       *
  4587                                  ;		   Set Buffer_ID to free;				       *
  4588                                  ;		   If (last buffer in this bucket) THEN 		       *
  4589                                  ;		      {Buf_link = -1;					       *
  4590                                  ;		       Next buffer ptr = 0;				       *
  4591                                  ;		      };						       *
  4592                                  ;		   Next buffer ptr += buffer size;			       *
  4593                                  ;		 };							       *
  4594                                  ;	       };							       *
  4595                                  ;	     }; 							       *
  4596                                  ;	   };								       *
  4597                                  ;*******************************************************************************
  4598                                  
  4599                                  	assume	ds:nothing			;AN000;to make sure.
  4600                                  
  4601                                  %IF	BUFFERFLAG
  4602                                  
  4603                                  	push	ax
  4604                                  ems_save_buf equ EMS_SAVE_BUF	; NASM port label
  4605                                  	mov	ax, offset ems_save_buf
  4606                                  ems_state_buf equ EMS_State_Buf	; NASM port label
  4607                                  	mov	word ptr [cs:ems_state_buf], ax
  4608                                  	push	cs
  4609                                  	pop	word ptr [cs:ems_state_buf+2]
  4610                                  	pop	ax
  4611                                  
  4612                                  %ENDIF
  4613                                  
  4614                                  Save_MAP_State equ Save_Map_State	; NASM port label
  4615                                  	call	Save_MAP_State			;AN010;
  4616                                  EMS_Handle equ EMS_handle	; NASM port equate
  4617                                  	mov	dx, [es:bx + EMS_Handle]		;AN000;save EMS_Handle
  4618                                  	lds	si, [bx + HASH_PTR]		;AN000;now ds:si -> Hash table
  4619                                  	xor	bx, bx				;AN000;starting logical page number.
  4620                                  ;	$DO					;AN000;For each page,
  4621                                  DD_DO30:
  4622                                  	     call  Map_Page			;AN000;map it to IBM physical page 254.
  4623                                  	     mov   di, [cs:IBM_Frame_Seg] 	;AN000;
  4624                                  	     mov   es, di			;AN000
  4625                                  	     xor   di, di			;AN000;es:di -> bucket
  4626                                  	     xor   ax, ax			;AN000
  4627                                  	     xor   cx, cx			;AN000
  4628                                  ;	     $DO				;AN000;For each bucket,
  4629                                  DD_DO31:
  4630                                  		 mov [si + EMS_PAGE_NUM], bx	;AN000;set the logical page number in Hash table.
  4631                                  		 mov word ptr [si + BUFFER_BUCKET], di   ;AN000;set the offset in hash table for this bucket.
  4632                                  		 mov word ptr [si + BUFFER_BUCKET+2], es ;AN000;set the segment value in hash table.
  4633                                  		 mov word ptr [si + DIRTY_COUNT], 0	  ;AN020;set DIRTY_COUNT, BUFFER_RESERVED to 0.
  4634                                  		 push cx			;AN000;save bucket number
  4635                                  		 xor cx, cx			;AN000;
  4636                                  ;		 $DO				;AN000;For each buffer in a bucket,
  4637                                  DD_DO32:
  4638                                  		     call Set_Buffer_Info	;AN000;AX adjusted for the next buffer.
  4639                                  		     inc  cx			;AN000;inc number of buffers in this bucket.
  4640                                  		     cmp  cx, 1 		;AN020;The first buffer in the bucket?
  4641                                  ;		     $IF  E			;AN020;
  4642                                  		     JNE DD_IF33
  4643                                  			  mov  [cs:EMS_Buf_First], di ;AN020;then save the offset value
  4644                                  ;		     $ENDIF			;AN020;
  4645                                  DD_IF33:
  4646                                  		     cmp  cx, MAXBUFFINBUCKET	;AN000;
  4647                                  ;		     $IF  E			;AN000
  4648                                  		     JNE DD_IF35
  4649                                  			  push word ptr [cs:EMS_Buf_First]  ;AN020;
  4650                                  			  pop  word ptr [es:di + BUF_NEXT]    ;AN020;the last buffer's next -> the first buffer in bucket (Circular chain)
  4651                                  			  push di			    ;AN020;save di
  4652                                  			  push di			    ;AN020;di-> last buffer
  4653                                  			  mov  di, [cs:EMS_Buf_First]	    ;AN020;es:di-> first buffer
  4654                                  			  pop  word ptr [es:di + BUF_PREV]    ;AN020;the first buffer's prev -> the last buffer
  4655                                  			  pop  di			    ;AN020;restore di
  4656                                  ;		     $ENDIF				    ;AN000;
  4657                                  DD_IF35:
  4658                                  		     mov di, ax 		;AN000;advance di to the next buffer position.
  4659                                  ;		 $ENDDO  E			;AN000;
  4660                                  		 JNE DD_DO32
  4661                                  		 add si, BUFFER_HASH_ENTRY_struc_size ;AN000;ds:si -> next hash table entry
  4662                                  		 pop cx 			;AN000;restore bucket number
  4663                                  		 inc cx 			;AN000;next bucket
  4664                                  		 cmp cx, MAXBUCKETINPAGE	;AN000;2 buckets per page
  4665                                  ;	     $ENDDO  E				;AN000;
  4666                                  	     JNE DD_DO31
  4667                                  	     inc bx				;AN000;increse logical page number
  4668                                  	     cmp bx, [cs:Buffer_Pages]		;AN000;reached the maximum page number?
  4669                                  ;	$ENDDO	E				;AN000;
  4670                                  	JNE DD_DO30
  4671                                  Restore_MAP_State equ Restore_Map_State	; NASM port label
  4672                                  	call	Restore_MAP_State		;AN010;
  4673                                  	 ret					;AN000;
  4674                                  Set_EMS_Buffer	    endp
  4675                                  
  4676                                  
  4677                                  Set_Buffer_Info        proc
  4678                                  ;Function: Set buf_link, buf_id, Buf_Sector
  4679                                  ;In: ES:DI -> Buffer header to be set.
  4680                                  ;    AX = DI
  4681                                  ;Out:
  4682                                  ;    Above entries set.
  4683                                  
  4684                                  
  4685                                  Buf_Prev_Off equ BUF_PREV_OFF	; NASM port label
  4686                                  	push	word [ss:Buf_Prev_Off]			;AN020;
  4687                                  	pop	word [es:di + BUF_PREV]		;AN020;
  4688                                  	mov	[ss:Buf_Prev_Off], ax		;AN020;
  4689                                  	add ax, [ss:SingleBufferSize]		;AN000;adjust ax
  4690                                  	mov word ptr [es:di + BUF_NEXT], ax	;AN020;
  4691                                  	mov word ptr [es:di + BUF_ID], 00FFh	;AN000;new buffer free
  4692                                  	mov word ptr [es:di + BUF_SECTOR], 0	;AN000;To compensate the MASM 3 bug
  4693                                  	mov word ptr [es:di + BUF_SECTOR+2],0	;AN000;To compensate the MASM 3 bug
  4694                                  	ret					;AN000;
  4695                                  Set_Buffer_Info        endp
  4696                                  
  4697                                  Check_IBM_PageID	proc	near
  4698                                  ;Function: check if the physical page 255 exists. (Physical page 255 is only
  4699                                  ;	   one we are intereseted in, and this will be used for BUFFER
  4700                                  ;	   manipulation by IBMBIO, IBMDOS)
  4701                                  ;In: nothing
  4702                                  ;Out: Carry clear and IBM_Frame_Seg set if it exist.  All registers saved.
  4703                                  		push	es				;AN000;
  4704                                  	push	ax				;AN000;
  4705                                  	push	bx				;AN000;
  4706                                  	push	cx				;AN000;
  4707                                  	push	dx				;AN000;
  4708                                  	push	di				;AN010;
  4709                                  
  4710                                  %IFN BUFFERFLAG
  4711                                  
  4712                                  	mov	ax, 1B00h			;AN029;AN030;AN0 Check EMS int 2fh installed.
  4713                                  	int	2fh				;AN029;
  4714                                  	cmp	al, 0ffh			;AN029;
  4715                                  	jne	Cp_IBM_Err			;AN029;If not installed, then no IBM page.
  4716                                  	mov	ax, 1B01h			;AN029;AN030;Then ask if IBM page exists.
  4717                                  	mov	di, IBM_PAGE_ID 		;AN029;=255
  4718                                  	int	2fh				;AN029;
  4719                                  	or	ah, ah				;AN029;
  4720                                  	jnz	Cp_IBM_Err			;AN029;;No IBM Page
  4721                                  	mov	[cs:IBM_Frame_Seg], es		;AN029;;Save Physical IBM page frame addr.
  4722                                  	mov	[cs:Real_IBM_Page_Id], di 	;AN029;;Real page number for it.
  4723                                  	clc					;AN029;
  4724                                  	jmp	short Cp_ID_Ret 		;AN029;
  4725                                  
  4726                                  %ELSE
  4727                                  	 push	 cs				 ;AN000;
  4728                                  	 pop	 es				 ;AN000;
  4729                                  	 mov	 ah, GET_PAGE_FRAME		 ;AN010;=58h
  4730                                  	 mov	 al, GET_NUM_PAGEFRAME		 ;AN010;=01h How many page frames?
  4731                                  	 int	 EMS_INT			 ;AN010;
  4732                                  	 or	 ah, ah 			 ;AN010;
  4733                                  	 jnz	 hkn_err			 ;AN010;
  4734                                  	 cmp	 cx, MAX_NUM_PAGEFRAME		 ;AN010;
  4735                                  	 ja	 hkn_err			 ;AN010; cannot handle this big number
  4736                                  	 push	 cx				 ;AN010;
  4737                                  	 mov	 ah, GET_PAGE_FRAME		 ;AN010;
  4738                                  	 mov	 al, GET_PAGEFRAME_TAB		 ;AN010;
  4739                                  Frame_info_Buffer equ Frame_Info_Buffer	; NASM port label
  4740                                  	 mov	 di, offset Frame_info_Buffer	 ;AN010;
  4741                                  	 int	 EMS_INT			 ;AN010;
  4742                                  	 pop	 cx				 ;AN010;
  4743                                  	 or	 ah, ah 			 ;AN010;
  4744                                  cp_IBM_Err equ Cp_IBM_Err	; NASM port label
  4745                                  	 jnz	 cp_IBM_Err			 ;AN010;
  4746                                  Cp_IBM_ID:					 ;AN010;
  4747                                  
  4748                                  ;	mov	dx, [es:di]
  4749                                  ;	mov	[cs:FIRST_PAGE], dx
  4750                                  ;	mov	dx, [es:di+2]
  4751                                  ;	mov	[cs:FIRST_PAGE+2], dx
  4752                                  
  4753                                  	xor	dx, dx
  4754                                  
  4755                                  ;	int	3
  4756                                  find_page:
  4757                                  	cmp	word [es:di], 0a000h ; is current page above 640K
  4758                                  	jb	check_next		; NO - goto check_last
  4759                                  
  4760                                  	inc	dx		; count the no. of pages above 640K
  4761                                  
  4762                                  	cmp	dx, 1
  4763                                  	jne	first_ok
  4764                                  
  4765                                  	mov	ax, [es:di]
  4766                                  	mov	[cs:FIRST_PAGE], ax
  4767                                  	mov	ax, [es:di+2]
  4768                                  	mov	[cs:FIRST_PAGE+2], ax
  4769                                  
  4770                                  first_ok:
  4771                                  	mov	ax, [cs:FIRST_PAGE]
  4772                                  	cmp	ax, [es:di]	; is this page less than the one we have in
  4773                                  				; FIRST_PAGE
  4774                                  	jbe	check_last	; NO - goto check_last
  4775                                  	mov	ax, [es:di]	; update FIRST_PAGE with this page segment
  4776                                  	mov	[cs:FIRST_PAGE], ax
  4777                                  	mov	ax, [es:di+2]
  4778                                  	mov	[cs:FIRST_PAGE+2], ax
  4779                                  	jmp	check_next
  4780                                  	nop	; identicalise
  4781                                  
  4782                                  cp_ibm_err equ Cp_IBM_Err	; NASM port label
  4783                                  hkn_err: jmp	cp_ibm_err
  4784                                  	nop	; identicalise
  4785                                  
  4786                                  check_last:
  4787                                  	mov	ax, [cs:LAST_PAGE]	;
  4788                                  	cmp	ax, [es:di]	; is this page greater than the one we have in
  4789                                  				; LAST_PAGE?
  4790                                  	ja	check_next		; NO - goto next
  4791                                  	mov	ax, [es:di]	; update LAST_PAGE with this value.
  4792                                  	mov	[cs:LAST_PAGE], ax
  4793                                  	mov	ax, [es:di+2]
  4794                                  	mov	[cs:LAST_PAGE+2], ax
  4795                                  
  4796                                  check_next:
  4797                                  	add	di, 4
  4798                                  	loop	find_page
  4799                                  
  4800                                  	cmp	dx, 3			; there should be at least 3 pages
  4801                                  					; above 640K for the buffers to be
  4802                                  					; installed.
  4803                                  	jb	Cp_IBM_Err
  4804                                  
  4805                                  	mov	ax, [cs:LAST_PAGE]
  4806                                  	mov	[cs:IBM_Frame_Seg], ax
  4807                                  	mov	ax, [cs:LAST_PAGE+2]
  4808                                  	mov	[cs:Real_IBM_Page_Id], ax
  4809                                  	mov	[cs:NPA640], dx
  4810                                  	clc
  4811                                  Cp_Id_Ret equ Cp_ID_Ret	; NASM port label
  4812                                  	jmp	short Cp_Id_Ret
  4813                                  
  4814                                  %ENDIF
  4815                                  
  4816                                  
  4817                                  ;	 cmp	 word ptr [es:di+2], IBM_PAGE_ID ;AN010; the second word is the id
  4818                                  ;	 je	 Got_IBM_ID			 ;AN010;
  4819                                  ;	 add	 di, 4				 ;AN010; advance to the next row (4 bytes)
  4820                                  ;	 loop	 Cp_IBM_ID			 ;AN010;
  4821                                  
  4822                                  Cp_IBM_Err:					;AN010;;AN029;
  4823                                  	stc					;AN000;;AN029;
  4824                                  	jmp	short Cp_ID_Ret 		;AN000;;AN029;
  4825                                  
  4826                                  ;Got_IBM_ID:					 ;AN000;
  4827                                  ;	 mov	 ax, word ptr [es:di]		 ;AN010;Physical seg. addr.
  4828                                  ;	 mov	 cs:IBM_Frame_Seg, ax		 ;AN000;
  4829                                  ;	 clc					 ;AN000;
  4830                                  Cp_ID_Ret:					;AN000;
  4831                                  	pop	di				;AN010;
  4832                                  	pop	dx				;AN000;
  4833                                  	pop	cx				;AN000;
  4834                                  	pop	bx				;AN000;
  4835                                  	pop	ax				;AN000;
  4836                                  	pop	es				;AN000;
  4837                                  	ret					;AN000;
  4838                                  Check_IBM_PageID	endp
  4839                                  
  4840                                  ;
  4841                                  Save_Map_State	proc				;AN010;
  4842                                  ;Function: Save the map state.
  4843                                  ;In)
  4844                                  ;    EMS_Ctrl_Tab = double word pointer to EMS_state control table address
  4845                                  ;    EMS_state_Buf = double word pointer to EMS_MAP_BUFF address
  4846                                  ;Out) Map state saved
  4847                                  	push	ax				;AN010;
  4848                                  	push	ds				;AN010;
  4849                                  	push	si				;AN010;
  4850                                  	push	es				;AN010;
  4851                                  	push	di				;AN010;
  4852                                  	lds	si, [cs:EMS_Ctrl_Tab]		;AN010;
  4853                                  	les	di, [cs:EMS_state_Buf]		;AN010;
  4854                                  	mov	ah, EMAP_STATE			;AN010; =4Fh
  4855                                  	mov	al, GET_MAP_STATE		;AN010; =00h
  4856                                  	int	EMS_INT 			;AN010;
  4857                                  	pop	di				;AN010;
  4858                                  	pop	es				;AN010;
  4859                                  	pop	si				;AN010;
  4860                                  	pop	ds				;AN010;
  4861                                  	pop	ax				;AN010;
  4862                                  	ret					;AN010;
  4863                                  Save_Map_State	endp
  4864                                  ;
  4865                                  Restore_Map_State	proc			;AN010;
  4866                                  	push	ax				;AN010;
  4867                                  	push	ds				;AN010;
  4868                                  	push	si				;AN010;
  4869                                  	lds	si, [cs:EMS_state_Buf]		;AN010;
  4870                                  	mov	ah, EMAP_STATE			;AN010;
  4871                                  	mov	al, SET_MAP_STATE		;AN010;
  4872                                  	int	EMS_INT 			;AN010;
  4873                                  	pop	si				;AN010;
  4874                                  	pop	ds				;AN010;
  4875                                  	pop	ax				;AN010;
  4876                                  	ret					;AN010;
  4877                                  Restore_Map_State	endp
  4878                                  ;
  4879                                  Map_Page	proc	near			;AN000;
  4880                                  ;Function: Map the logical page in BX of handle in DX to the physical page 255
  4881                                  ;In)
  4882                                  ;    BX = logical page number
  4883                                  ;    DX = EMS handle
  4884                                  ;    EMS_Ctrl_Tab = double word pointer to EMS_state control table address
  4885                                  ;    EMS_state_Buf = double word pointer to EMS_MAP_BUFF address
  4886                                  ;Out) Logical page mapped into first phsical page frame.
  4887                                  ;    AX saved.
  4888                                  
  4889                                  	push	ax				;AN000;
  4890                                  	mov	ah, EMAP_L_TO_P 		;AN000;
  4891                                  Real_IBM_PAGE_ID equ Real_IBM_Page_Id	; NASM port label
  4892                                  	mov	al, byte ptr [cs:Real_IBM_PAGE_ID]	 ;AN029;= 255
  4893                                  	int	EMS_INT 			;AN000;
  4894                                  	pop	ax				;AN000;
  4895                                  	ret					;AN000;
  4896                                  Map_Page	endp				;AN000;
  4897                                  ;
  4898                                  %endif	; BUF2
  4899                                  
  4900                                  Roundup proc
  4901                                  ;In: DX;AX - operand
  4902                                  ;    CX    - divisor
  4903                                  ;    Important: DX should be less than CX.
  4904                                  ;out: AX - Quotient (Rounded up)
  4905                                  
  4906 000011E4 F7F1                    	div cx					;AN000;
  4907 000011E6 09D2                    	or  dx, dx				;AN000;
  4908 000011E8 7401                    	jz  RU_ret				;AN000;
  4909 000011EA 40                      	inc AX					;AN000;
  4910                                  RU_ret: 					;AN000;
  4911 000011EB C3                      	ret					;AN000;
  4912                                  Roundup endp
  4913                                  ;------------------------------------------------------------------------------
  4914                                  ;J.K. 5/6/86. IBMSTACK initialization routine.
  4915                                  	%IF	STACKSW
  4916                                  ;.SALL
  4917                                  
  4918                                  ;=== Push trace listing source: stkinit.nas
  4919                                  %include "stkinit.nas" ; NASM included file
     1                              <1> ;
     2                              <1> ;	To follow the standard interrupt sharing scheme, MSSTACK.ASM	       ;3.30
     3                              <1> ;	has been modified.  This initialization routine also has to	       ;3.30
     4                              <1> ;	be modified because for the interrupt level 7 and 15, FirstFlag        ;3.30
     5                              <1> ;	should be set to signal that this interrupt handler is the	       ;3.30
     6                              <1> ;	first handler hooked to this interrupt vector.			       ;3.30
     7                              <1> ;	We determine this by looking at the instruction pointed by	       ;3.30
     8                              <1> ;	this vector.  If it is IRET, then this handler should be the	       ;3.30
     9                              <1> ;	first one.  In our case, only the interrupt vector 77h is the	       ;3.30
    10                              <1> ;	interrupt level 15. (We don't hook interrupt level 7.)                 ;3.30
    11                              <1> ; 9/10/1986 							       ;3.30
    12                              <1> ;	The followings are mainly due to M.R.T; PTM fix of P886 12/3/86;3.30
    13                              <1> ;	Some design changes are needed to the above interrupt sharing	       ;3.30
    14                              <1> ;	method.  The above sharing scheme assumes that 1). Interrupt	       ;3.30
    15                              <1> ;	sharing is NEVER done on levels that have BIOS support. 2). "Phantom"  ;3.30
    16                              <1> ;	interrupts would only be generated on levels 7 and 15.		       ;3.30
    17                              <1> ;	These assumptions are not true any more. We have to use the FirstFlag  ;3.30
    18                              <1> ;	for EVERY level of interrupt.  We will set the firstFlag on the following;3.30
    19                              <1> ;	conditions:							       ;3.30
    20                              <1> ;	 a.	 if the CS portion of the vector is 0000, then "first"         ;3.30
    21                              <1> ;	 b. else if CS:IP points to valid shared header, then NOT "first"      ;3.30
    22                              <1> ;	 c. else if CS:IP points to an IRET, then "first"                      ;3.30
    23                              <1> ;	 d. else if CS:IP points to DUMMY, then "first"                        ;3.30
    24                              <1> ;	where DUMMY is - the CS portion must be F000, and the IP portion must  ;3.30
    25                              <1> ;	be equal to the value at F000:FF01. This location is the initial value ;3.30
    26                              <1> ;	from VECTOR_TABLE for interrupt 7, one of the preserved addresses in all;3.30
    27                              <1> ;	the BIOSes for all of the machines.				       ;3.30
    28                              <1> ;									       ;3.30
    29                              <1> ;	System design group requests BIOS to handle the phantom interrupts.    ;3.30
    30                              <1> ;									       ;3.30
    31                              <1> ;	The "Phantom" interrupt is an illegal interrupt such as an interrupt   ;3.30
    32                              <1> ;	produced by the bogus adapter card even without interrupt request is   ;3.30
    33                              <1> ;	set.  More specifically, 1). The 8259 has a feature when running in    ;3.30
    34                              <1> ;	edge triggered mode to latch a pulse and present the interrupt when    ;3.30
    35                              <1> ;	the processor indicates interrupt acknowledge (INTA).  The interrupt   ;3.30
    36                              <1> ;	pulse was exist at the time of INTA to get a "phantom" interrupt.      ;3.30
    37                              <1> ;	2). or, this is caused by adapter cards placing a glitch on the        ;3.30
    38                              <1> ;	interrupt line. 						       ;3.30
    39                              <1> ;									       ;3.30
    40                              <1> ;	To handle those "phantom" interrupts, the main stack code will check   ;3.30
    41                              <1> ;	the own FirstFlag, and if it is not "first" (which means the forward   ;3.30
    42                              <1> ;	pointer points to the legal shared interrupt handler), then pass the   ;3.30
    43                              <1> ;	control.  If it is the first, then the following action should be      ;3.30
    44                              <1> ;	taken.	We don't have to implement skack logic in this case.           ;3.30
    45                              <1> ;									       ;3.30
    46                              <1> ;	To implement this logic, we rather choose a simple method.	       ;3.30
    47                              <1> ;	If ont of the above "FirstFlag" conditions is met, we are not          ;3.30
    48                              <1> ;	going to hook this interrupt vector.  The reason is if the original    ;3.30
    49                              <1> ;	vector points to "IRET" and do nothing, we don't need                  ;3.30
    50                              <1> ;	to implement the stack logic for it.  This will simplify implementation;3.30
    51                              <1> ;	while maintaining compatibility with the old version of DOS.	       ;3.30
    52                              <1> ;	This implies that in the main stack code, there might be a stack code  ;3.30
    53                              <1> ;	that will never be used, a dead code.				       ;3.30
    54                              <1> ;									       ;3.30
    55                              <1> ; 12/3/86								       ;3.30
    56                              <1> 									       ;3.30
    57                              <1> ;In - CS, DS -> sysinitseg, ES -> relocated stack code & data.		       ;3.30
    58                              <1> 									       ;3.30
    59                              <1> ;	PAGE								       ;3.30
    60                              <1>  assume ds:SYSINITGROUP, es:STACKSCODE, ss:nothing
    61                              <1> 						; sunilp SB340
    62                              <1> StackInit	proc near						       ;3.30
    63                              <1> 									       ;3.30
    64 000011EC 50                  <1> 	PUSH	AX				;SAVE ALL		       ;3.30
    65 000011ED 1E                  <1> 	PUSH	DS							       ;3.30
    66 000011EE 06                  <1> 	PUSH	ES							       ;3.30
    67 000011EF 53                  <1> 	PUSH	BX							       ;3.30
    68 000011F0 51                  <1> 	PUSH	CX							       ;3.30
    69 000011F1 52                  <1> 	PUSH	DX							       ;3.30
    70 000011F2 57                  <1> 	PUSH	DI							       ;3.30
    71 000011F3 56                  <1> 	PUSH	SI							       ;3.30
    72 000011F4 55                  <1> 	PUSH	BP							       ;3.30
    73                              <1> 									       ;3.30
    74                              <1> ;Currently ES -> stack code area					       ;3.30
    75 000011F5 2EA1[1608]          <1> 	MOV	AX, [cs:STACK_COUNT]		   ;defined in CS	       ;3.30
    76                              <1> STACKCOUNT equ StackCount	; NASM port label
    77 000011F9 26A3[0200]          <1> 	MOV	[es:STACKCOUNT], AX		   ;defined in STACK CODE AREA ;3.30
    78 000011FD A1[1808]            <1> 	MOV	AX, [STACK_SIZE]		;in CS			       ;3.30
    79                              <1> STACKSIZE equ StackSize	; NASM port label
    80 00001200 26A3[0600]          <1> 	MOV	[es:STACKSIZE], AX		   ;			       ;3.30
    81 00001204 2EA1[1A08]          <1> 	MOV	AX, WORD PTR [cs:STACK_ADDR]	   ; OFFSET		       ;3.30
    82 00001208 26A3[0800]          <1> 	MOV	WORD PTR [es:STACKS], AX				       ;3.30
    83 0000120C 2EA1[1C08]          <1> 	MOV	AX, WORD PTR [cs:STACK_ADDR+2]  ; SEGMENT		       ;3.30
    84 00001210 26A3[0A00]          <1> 	MOV	WORD PTR [es:STACKS+2], AX				       ;3.30
    85                              <1> 									       ;3.30
    86                              <1> ; INITIALIZE THE DATA FIELDS WITH THE PARAMETERS			       ;3.30
    87                              <1> 									       ;3.30
    88                              <1> ; "FIRSTENTRY" WILL ALWAYS BE AT STACKS                                        ;3.30
    89                              <1> 									       ;3.30
    90 00001214 268B2E[0800]        <1> 	MOV	BP, word ptr [es:STACKS]		   ; GET OFFSET OF STACK       ;3.30
    91                              <1> FIRSTENTRY equ FirstEntry	; NASM port label
    92 00001219 26892E[0C00]        <1> 	MOV	[es:FIRSTENTRY],BP					       ;3.30
    93                              <1> 									       ;3.30
    94                              <1> ; THE STACKS WILL ALWAYS IMMEDIATELY FOLLOW THE TABLE ENTRIES		       ;3.30
    95                              <1> 									       ;3.30
    96                              <1> ENTRYSIZE equ EntrySize	; NASM port equate
    97 0000121E B80800              <1> 	MOV	AX,ENTRYSIZE						       ;3.30
    98 00001221 268B0E[0200]        <1> 	MOV	CX,[es:STACKCOUNT]					       ;3.30
    99 00001226 F7E1                <1> 	MUL	CX							       ;3.30
   100 00001228 01E8                <1> 	ADD	AX,BP							       ;3.30
   101                              <1> STACKAT equ StackAt	; NASM port label
   102 0000122A 26A3[0400]          <1> 	MOV	[es:STACKAT],AX						       ;3.30
   103 0000122E 89C3                <1> 	MOV	BX,AX							       ;3.30
   104 00001230 83EB02              <1> 	SUB	BX,2							       ;3.30
   105                              <1> 									       ;3.30
   106                              <1> ; ZERO THE ENTIRE STACK AREA TO START WITH				       ;3.30
   107                              <1> 									       ;3.30
   108 00001233 268B3E[0400]        <1> 	MOV	DI,[es:STACKAT]						       ;3.30
   109 00001238 26A1[0600]          <1> 	MOV	AX,[es:STACKSIZE] 					       ;3.30
   110 0000123C F7E1                <1> 	MUL	CX							       ;3.30
   111 0000123E 89C1                <1> 	MOV	CX,AX							       ;3.30
   112 00001240 31C0                <1> 	xor	ax,ax							       ;3.30
   113 00001242 06                  <1> 	push	es							       ;3.30
   114 00001243 1F                  <1> 	pop	ds				;ds = Relocated stack code seg.;3.30
   115                              <1>  assume ds:STACKSCODE							       ;3.30
   116                              <1> ;Now, DS -> stack code area						       ;3.30
   117 00001244 8E06[0A00]          <1> 	MOV	ES, word ptr [STACKS+2]	   ; GET SEGMENT OF STACK AREA.;3.30
   118                              <1>  assume es:nothing
   119 00001248 FC                  <1> 	CLD								       ;3.30
   120 00001249 F3AA                <1> 	REP	STOSB							       ;3.30
   121                              <1> 									       ;3.30
   122 0000124B 8B0E[0200]          <1> 	MOV	CX, [STACKCOUNT]					       ;3.30
   123                              <1> 									       ;3.30
   124                              <1> ; LOOP FOR "COUNT" TIMES, BUILDING A TABLE ENTRY                               ;3.30
   125                              <1> ;  cs = sysinitseg, ds = Relocated stack code seg , es = segment of stack space;3.30
   126                              <1> ;  CX = NUMBER OF ENTRIES						       ;3.30
   127                              <1> ;  ES:BP => BASE OF STACKS - 2						       ;3.30
   128                              <1> ;  ES:BX => FIRST TABLE ENTRY						       ;3.30
   129                              <1> 									       ;3.30
   130                              <1> BUILDLOOP:								       ;3.30
   131                              <1> FREE equ Free	; NASM port equate
   132 0000124F 26C6460000          <1> 	MOV	byte [ALLOCBYTE],FREE						       ;3.30
   133 00001254 26884601            <1> 	MOV	[INTLEVEL],AL			;AX = 0 		       ;3.30
   134 00001258 26894602            <1> 	MOV	[SAVEDSP],AX						       ;3.30
   135 0000125C 26894604            <1> 	MOV	[SAVEDSS],AX						       ;3.30
   136 00001260 031E[0600]          <1> 	ADD	BX,[STACKSIZE] 					       ;3.30
   137 00001264 26895E06            <1> 	MOV	[NEWSP],BX						       ;3.30
   138 00001268 26892F              <1> 	MOV	[ES:BX],BP						       ;3.30
   139 0000126B 83C508              <1> 	ADD	BP,ENTRYSIZE						       ;3.30
   140                              <1> 									       ;3.30
   141 0000126E E2DF                <1> 	LOOP	BUILDLOOP						       ;3.30
   142                              <1> 									       ;3.30
   143 00001270 83ED08              <1> 	SUB	BP,ENTRYSIZE						       ;3.30
   144                              <1> LASTENTRY equ LastEntry	; NASM port label
   145 00001273 892E[0E00]          <1> 	MOV	[LASTENTRY],BP 					       ;3.30
   146                              <1> NEXTENTRY equ NextEntry	; NASM port label
   147 00001277 892E[1000]          <1> 	MOV	[NEXTENTRY],BP 					       ;3.30
   148                              <1> 									       ;3.30
   149 0000127B 1E                  <1> 	push	ds							       ;3.30
   150 0000127C B800F0              <1> 	mov	ax, 0f000h		;loook at the model byte	       ;3.30
   151 0000127F 8ED8                <1> 	mov	ds, ax							       ;3.30
   152                              <1>  assume ds:nothing
   153 00001281 803EFEFFF9          <1> 	cmp	byte ptr [0fffeh], mdl_convert	;convertible?	       ;3.30
   154 00001286 1F                  <1> 	pop	ds							       ;3.30
   155                              <1>  assume ds:STACKSCODE							       ;3.30
   156 00001287 7504                <1> 	jne	Skip_disableNMIS					       ;3.30
   157                              <1> 									       ;3.30
   158 00001289 B007                <1> 	MOV	AL,07H				; DISABLE Convertible NMIS	       ;3.30
   159 0000128B E672                <1> 	OUT	72H,AL							       ;3.30
   160                              <1> 									       ;3.30
   161                              <1> Skip_disableNMIS:							       ;3.30
   162 0000128D 31C0                <1> 	XOR	AX,AX							       ;3.30
   163 0000128F 8EC0                <1> 	MOV	es,AX				;es - SEGID OF VECTOR TABLE AT 0;3.30
   164                              <1>  ASSUME es:IVT					;ds - Relocated Stack code segment;3.30
   165                              <1> 									       ;3.30
   166 00001291 FA                  <1> 	CLI								       ;3.30
   167                              <1> 
   168                              <1> %macro init_first_irq 1-*
   169                              <1>  %rep %0
   170                              <1> 	MOV	SI, offset %1H*4	;PASS WHERE VECTOR IS TO BE ADJUSTED   ;3.30
   171                              <1> 	mov	di, offset Int19OLD%1	;we have to set OLD&AA for Int19 handler too.;3.30
   172                              <1> 	MOV	BX,OFFSET OLD%1		;PASS WHERE TO SAVE ORIGINAL OWNER POINTER;3.30
   173                              <1> 	MOV	DX,OFFSET INT%1		;PASS WHERE NEW HANDLER IS	       ;3.30
   174                              <1> 	CALL	NEW_INIT_LOOP		;ADJUST THE VECTOR TO NEW HANDLER,     ;3.30
   175                              <1> 					;  SAVING POINTER TO ORIGINAL OWNER    ;3.30
   176                              <1>   %rotate 1
   177                              <1>  %endrep
   178                              <1> %endmacro
   179                              <1> 
   180                              <1> init_first_irq 02,08,09,70
   169                              <2>  %rep %0
   170                              <2>  MOV SI, offset %1H*4
   171                              <2>  mov di, offset Int19OLD%1
   172                              <2>  MOV BX,OFFSET OLD%1
   173                              <2>  MOV DX,OFFSET INT%1
   174                              <2>  CALL NEW_INIT_LOOP
   175                              <2> 
   176                              <2>  %rotate 1
   177                              <2>  %endrep
   170 00001292 BE0800              <3>  MOV SI, offset %1H*4
   171 00001295 BF[0000]            <3>  mov di, offset Int19OLD%1
   172 00001298 BB[1200]            <3>  MOV BX,OFFSET OLD%1
   173 0000129B BA[1600]            <3>  MOV DX,OFFSET INT%1
   174 0000129E E8D202              <3>  CALL NEW_INIT_LOOP
   175                              <3> 
   176                              <3>  %rotate 1
   170 000012A1 BE2000              <3>  MOV SI, offset %1H*4
   171 000012A4 BF[0000]            <3>  mov di, offset Int19OLD%1
   172 000012A7 BB[A700]            <3>  MOV BX,OFFSET OLD%1
   173 000012AA BA[AB00]            <3>  MOV DX,OFFSET INT%1
   174 000012AD E8C302              <3>  CALL NEW_INIT_LOOP
   175                              <3> 
   176                              <3>  %rotate 1
   170 000012B0 BE2400              <3>  MOV SI, offset %1H*4
   171 000012B3 BF[0000]            <3>  mov di, offset Int19OLD%1
   172 000012B6 BB[2101]            <3>  MOV BX,OFFSET OLD%1
   173 000012B9 BA[2501]            <3>  MOV DX,OFFSET INT%1
   174 000012BC E8B402              <3>  CALL NEW_INIT_LOOP
   175                              <3> 
   176                              <3>  %rotate 1
   170 000012BF BEC001              <3>  MOV SI, offset %1H*4
   171 000012C2 BF[0000]            <3>  mov di, offset Int19OLD%1
   172 000012C5 BB[A001]            <3>  MOV BX,OFFSET OLD%1
   173 000012C8 BA[A401]            <3>  MOV DX,OFFSET INT%1
   174 000012CB E8A502              <3>  CALL NEW_INIT_LOOP
   175                              <3> 
   176                              <3>  %rotate 1
   181                              <1> 
   182                              <1> %macro init_second_irq 1-*
   183                              <1>  %rep %0
   184                              <1> 	MOV	SI, offset %1H*4	;PASS WHERE VECTOR IS TO BE ADJUSTED   ;3.30
   185                              <1> 	push	ds			;save relocated stack code segment     ;3.30
   186                              <1> 	lds	bx, [es:si]		;ds:bx -> original interrupt handler   ;3.30
   187                              <1>  assume ds:nothing
   188                              <1> 	push	ds							       ;3.30
   189                              <1> 	pop	dx			;dx = segment value		       ;3.30
   190                              <1> 
   191                              <1> 	cmp	dx,0
   192                              <1> 	jz	int%1_first
   193                              <1> 
   194                              <1> 	cmp	byte ptr [bx],0cfh	;Does vector point to an IRET?
   195                              <1> 	jz	int%1_first
   196                              <1> 
   197                              <1> 	cmp	word ptr [bx + 6],424Bh ;Magic offset (see INT&AA, msstack.inc)
   198                              <1> 	jz	int%1_Not_first
   199                              <1> 
   200                              <1> 	cmp	dx,0f000h		;ROM BIOS segment
   201                              <1> 	jnz	int%1_Not_first
   202                              <1> 
   203                              <1> 	push	es
   204                              <1> 	push	dx
   205                              <1> 	mov	dx,0f000h
   206                              <1> 	mov	es,dx
   207                              <1>  assume es:nothing
   208                              <1> 	cmp	bx,word ptr [es:0ff01h]
   209                              <1> 	pop	dx
   210                              <1> 	pop	es
   211                              <1>  assume es:IVT
   212                              <1> 	jz	int%1_first
   213                              <1> 
   214                              <1> int%1_Not_first:			 ;Not the first. We are going to hook vector.;3.30
   215                              <1> 	pop	ds							       ;3.30
   216                              <1>  assume ds:STACKSCODE
   217                              <1> 	mov	di, offset Int19OLD%1	;we have to set OLD&AA for Int19 handler too.;3.30
   218                              <1> 	mov	BX, OFFSET OLD%1	;PASS WHERE TO SAVE ORIGINAL OWNER POINTER;3.30
   219                              <1> 	MOV	DX, OFFSET INT%1	;PASS WHERE NEW HANDLER IS	       ;3.30
   220                              <1> 	CALL	NEW_INIT_LOOP		;ADJUST THE VECTOR TO NEW HANDLER, SAVING;3.30
   221                              <1> 					;POINTER TO ORIGINAL OWNER.	       ;3.30
   222                              <1> 	jmp	short int%1_end					       ;3.30
   223                              <1> int%1_first:				 ;the first. Don't have to hook stack code.;3.30
   224                              <1> 	pop	ds							       ;3.30
   225                              <1>  assume ds:STACKSCODE
   226                              <1> int%1_end:								       ;3.30
   227                              <1> 									       ;3.30
   228                              <1>   %rotate 1
   229                              <1>  %endrep
   230                              <1> %endmacro
   231                              <1> 
   232                              <1> init_second_irq 0A,0B,0C,0D,0E,72,73,74,76,77	;shared interrupts
   183                              <2>  %rep %0
   184                              <2>  MOV SI, offset %1H*4
   185                              <2>  push ds
   186                              <2>  lds bx, [es:si]
   187                              <2>  assume ds:nothing
   188                              <2>  push ds
   189                              <2>  pop dx
   190                              <2> 
   191                              <2>  cmp dx,0
   192                              <2>  jz int%1_first
   193                              <2> 
   194                              <2>  cmp byte ptr [bx],0cfh
   195                              <2>  jz int%1_first
   196                              <2> 
   197                              <2>  cmp word ptr [bx + 6],424Bh
   198                              <2>  jz int%1_Not_first
   199                              <2> 
   200                              <2>  cmp dx,0f000h
   201                              <2>  jnz int%1_Not_first
   202                              <2> 
   203                              <2>  push es
   204                              <2>  push dx
   205                              <2>  mov dx,0f000h
   206                              <2>  mov es,dx
   207                              <2>  assume es:nothing
   208                              <2>  cmp bx,word ptr [es:0ff01h]
   209                              <2>  pop dx
   210                              <2>  pop es
   211                              <2>  assume es:IVT
   212                              <2>  jz int%1_first
   213                              <2> 
   214                              <2> int%1_Not_first:
   215                              <2>  pop ds
   216                              <2>  assume ds:STACKSCODE
   217                              <2>  mov di, offset Int19OLD%1
   218                              <2>  mov BX, OFFSET OLD%1
   219                              <2>  MOV DX, OFFSET INT%1
   220                              <2>  CALL NEW_INIT_LOOP
   221                              <2> 
   222                              <2>  jmp short int%1_end
   223                              <2> int%1_first:
   224                              <2>  pop ds
   225                              <2>  assume ds:STACKSCODE
   226                              <2> int%1_end:
   227                              <2> 
   228                              <2>  %rotate 1
   229                              <2>  %endrep
   184 000012CE BE2800              <3>  MOV SI, offset %1H*4
   185 000012D1 1E                  <3>  push ds
   186 000012D2 26C51C              <3>  lds bx, [es:si]
   187                              <3>  assume ds:nothing
   188 000012D5 1E                  <3>  push ds
   189 000012D6 5A                  <3>  pop dx
   190                              <3> 
   191 000012D7 83FA00              <3>  cmp dx,0
   192 000012DA 7431                <3>  jz int%1_first
   193                              <3> 
   194 000012DC 803FCF              <3>  cmp byte ptr [bx],0cfh
   195 000012DF 742C                <3>  jz int%1_first
   196                              <3> 
   197 000012E1 817F064B42          <3>  cmp word ptr [bx + 6],424Bh
   198 000012E6 7416                <3>  jz int%1_Not_first
   199                              <3> 
   200 000012E8 81FA00F0            <3>  cmp dx,0f000h
   201 000012EC 7510                <3>  jnz int%1_Not_first
   202                              <3> 
   203 000012EE 06                  <3>  push es
   204 000012EF 52                  <3>  push dx
   205 000012F0 BA00F0              <3>  mov dx,0f000h
   206 000012F3 8EC2                <3>  mov es,dx
   207                              <3>  assume es:nothing
   208 000012F5 263B1E01FF          <3>  cmp bx,word ptr [es:0ff01h]
   209 000012FA 5A                  <3>  pop dx
   210 000012FB 07                  <3>  pop es
   211                              <3>  assume es:IVT
   212 000012FC 740F                <3>  jz int%1_first
   213                              <3> 
   214                              <3> int%1_Not_first:
   215 000012FE 1F                  <3>  pop ds
   216                              <3>  assume ds:STACKSCODE
   217 000012FF BF[0000]            <3>  mov di, offset Int19OLD%1
   218 00001302 BB[1C02]            <3>  mov BX, OFFSET OLD%1
   219 00001305 BA[1A02]            <3>  MOV DX, OFFSET INT%1
   220 00001308 E86802              <3>  CALL NEW_INIT_LOOP
   221                              <3> 
   222 0000130B EB01                <3>  jmp short int%1_end
   223                              <3> int%1_first:
   224 0000130D 1F                  <3>  pop ds
   225                              <3>  assume ds:STACKSCODE
   226                              <3> int%1_end:
   227                              <3> 
   228                              <3>  %rotate 1
   184 0000130E BE2C00              <3>  MOV SI, offset %1H*4
   185 00001311 1E                  <3>  push ds
   186 00001312 26C51C              <3>  lds bx, [es:si]
   187                              <3>  assume ds:nothing
   188 00001315 1E                  <3>  push ds
   189 00001316 5A                  <3>  pop dx
   190                              <3> 
   191 00001317 83FA00              <3>  cmp dx,0
   192 0000131A 7431                <3>  jz int%1_first
   193                              <3> 
   194 0000131C 803FCF              <3>  cmp byte ptr [bx],0cfh
   195 0000131F 742C                <3>  jz int%1_first
   196                              <3> 
   197 00001321 817F064B42          <3>  cmp word ptr [bx + 6],424Bh
   198 00001326 7416                <3>  jz int%1_Not_first
   199                              <3> 
   200 00001328 81FA00F0            <3>  cmp dx,0f000h
   201 0000132C 7510                <3>  jnz int%1_Not_first
   202                              <3> 
   203 0000132E 06                  <3>  push es
   204 0000132F 52                  <3>  push dx
   205 00001330 BA00F0              <3>  mov dx,0f000h
   206 00001333 8EC2                <3>  mov es,dx
   207                              <3>  assume es:nothing
   208 00001335 263B1E01FF          <3>  cmp bx,word ptr [es:0ff01h]
   209 0000133A 5A                  <3>  pop dx
   210 0000133B 07                  <3>  pop es
   211                              <3>  assume es:IVT
   212 0000133C 740F                <3>  jz int%1_first
   213                              <3> 
   214                              <3> int%1_Not_first:
   215 0000133E 1F                  <3>  pop ds
   216                              <3>  assume ds:STACKSCODE
   217 0000133F BF[0000]            <3>  mov di, offset Int19OLD%1
   218 00001342 BB[A402]            <3>  mov BX, OFFSET OLD%1
   219 00001345 BA[A202]            <3>  MOV DX, OFFSET INT%1
   220 00001348 E82802              <3>  CALL NEW_INIT_LOOP
   221                              <3> 
   222 0000134B EB01                <3>  jmp short int%1_end
   223                              <3> int%1_first:
   224 0000134D 1F                  <3>  pop ds
   225                              <3>  assume ds:STACKSCODE
   226                              <3> int%1_end:
   227                              <3> 
   228                              <3>  %rotate 1
   184 0000134E BE3000              <3>  MOV SI, offset %1H*4
   185 00001351 1E                  <3>  push ds
   186 00001352 26C51C              <3>  lds bx, [es:si]
   187                              <3>  assume ds:nothing
   188 00001355 1E                  <3>  push ds
   189 00001356 5A                  <3>  pop dx
   190                              <3> 
   191 00001357 83FA00              <3>  cmp dx,0
   192 0000135A 7431                <3>  jz int%1_first
   193                              <3> 
   194 0000135C 803FCF              <3>  cmp byte ptr [bx],0cfh
   195 0000135F 742C                <3>  jz int%1_first
   196                              <3> 
   197 00001361 817F064B42          <3>  cmp word ptr [bx + 6],424Bh
   198 00001366 7416                <3>  jz int%1_Not_first
   199                              <3> 
   200 00001368 81FA00F0            <3>  cmp dx,0f000h
   201 0000136C 7510                <3>  jnz int%1_Not_first
   202                              <3> 
   203 0000136E 06                  <3>  push es
   204 0000136F 52                  <3>  push dx
   205 00001370 BA00F0              <3>  mov dx,0f000h
   206 00001373 8EC2                <3>  mov es,dx
   207                              <3>  assume es:nothing
   208 00001375 263B1E01FF          <3>  cmp bx,word ptr [es:0ff01h]
   209 0000137A 5A                  <3>  pop dx
   210 0000137B 07                  <3>  pop es
   211                              <3>  assume es:IVT
   212 0000137C 740F                <3>  jz int%1_first
   213                              <3> 
   214                              <3> int%1_Not_first:
   215 0000137E 1F                  <3>  pop ds
   216                              <3>  assume ds:STACKSCODE
   217 0000137F BF[0000]            <3>  mov di, offset Int19OLD%1
   218 00001382 BB[2C03]            <3>  mov BX, OFFSET OLD%1
   219 00001385 BA[2A03]            <3>  MOV DX, OFFSET INT%1
   220 00001388 E8E801              <3>  CALL NEW_INIT_LOOP
   221                              <3> 
   222 0000138B EB01                <3>  jmp short int%1_end
   223                              <3> int%1_first:
   224 0000138D 1F                  <3>  pop ds
   225                              <3>  assume ds:STACKSCODE
   226                              <3> int%1_end:
   227                              <3> 
   228                              <3>  %rotate 1
   184 0000138E BE3400              <3>  MOV SI, offset %1H*4
   185 00001391 1E                  <3>  push ds
   186 00001392 26C51C              <3>  lds bx, [es:si]
   187                              <3>  assume ds:nothing
   188 00001395 1E                  <3>  push ds
   189 00001396 5A                  <3>  pop dx
   190                              <3> 
   191 00001397 83FA00              <3>  cmp dx,0
   192 0000139A 7431                <3>  jz int%1_first
   193                              <3> 
   194 0000139C 803FCF              <3>  cmp byte ptr [bx],0cfh
   195 0000139F 742C                <3>  jz int%1_first
   196                              <3> 
   197 000013A1 817F064B42          <3>  cmp word ptr [bx + 6],424Bh
   198 000013A6 7416                <3>  jz int%1_Not_first
   199                              <3> 
   200 000013A8 81FA00F0            <3>  cmp dx,0f000h
   201 000013AC 7510                <3>  jnz int%1_Not_first
   202                              <3> 
   203 000013AE 06                  <3>  push es
   204 000013AF 52                  <3>  push dx
   205 000013B0 BA00F0              <3>  mov dx,0f000h
   206 000013B3 8EC2                <3>  mov es,dx
   207                              <3>  assume es:nothing
   208 000013B5 263B1E01FF          <3>  cmp bx,word ptr [es:0ff01h]
   209 000013BA 5A                  <3>  pop dx
   210 000013BB 07                  <3>  pop es
   211                              <3>  assume es:IVT
   212 000013BC 740F                <3>  jz int%1_first
   213                              <3> 
   214                              <3> int%1_Not_first:
   215 000013BE 1F                  <3>  pop ds
   216                              <3>  assume ds:STACKSCODE
   217 000013BF BF[0000]            <3>  mov di, offset Int19OLD%1
   218 000013C2 BB[B403]            <3>  mov BX, OFFSET OLD%1
   219 000013C5 BA[B203]            <3>  MOV DX, OFFSET INT%1
   220 000013C8 E8A801              <3>  CALL NEW_INIT_LOOP
   221                              <3> 
   222 000013CB EB01                <3>  jmp short int%1_end
   223                              <3> int%1_first:
   224 000013CD 1F                  <3>  pop ds
   225                              <3>  assume ds:STACKSCODE
   226                              <3> int%1_end:
   227                              <3> 
   228                              <3>  %rotate 1
   184 000013CE BE3800              <3>  MOV SI, offset %1H*4
   185 000013D1 1E                  <3>  push ds
   186 000013D2 26C51C              <3>  lds bx, [es:si]
   187                              <3>  assume ds:nothing
   188 000013D5 1E                  <3>  push ds
   189 000013D6 5A                  <3>  pop dx
   190                              <3> 
   191 000013D7 83FA00              <3>  cmp dx,0
   192 000013DA 7431                <3>  jz int%1_first
   193                              <3> 
   194 000013DC 803FCF              <3>  cmp byte ptr [bx],0cfh
   195 000013DF 742C                <3>  jz int%1_first
   196                              <3> 
   197 000013E1 817F064B42          <3>  cmp word ptr [bx + 6],424Bh
   198 000013E6 7416                <3>  jz int%1_Not_first
   199                              <3> 
   200 000013E8 81FA00F0            <3>  cmp dx,0f000h
   201 000013EC 7510                <3>  jnz int%1_Not_first
   202                              <3> 
   203 000013EE 06                  <3>  push es
   204 000013EF 52                  <3>  push dx
   205 000013F0 BA00F0              <3>  mov dx,0f000h
   206 000013F3 8EC2                <3>  mov es,dx
   207                              <3>  assume es:nothing
   208 000013F5 263B1E01FF          <3>  cmp bx,word ptr [es:0ff01h]
   209 000013FA 5A                  <3>  pop dx
   210 000013FB 07                  <3>  pop es
   211                              <3>  assume es:IVT
   212 000013FC 740F                <3>  jz int%1_first
   213                              <3> 
   214                              <3> int%1_Not_first:
   215 000013FE 1F                  <3>  pop ds
   216                              <3>  assume ds:STACKSCODE
   217 000013FF BF[0000]            <3>  mov di, offset Int19OLD%1
   218 00001402 BB[3C04]            <3>  mov BX, OFFSET OLD%1
   219 00001405 BA[3A04]            <3>  MOV DX, OFFSET INT%1
   220 00001408 E86801              <3>  CALL NEW_INIT_LOOP
   221                              <3> 
   222 0000140B EB01                <3>  jmp short int%1_end
   223                              <3> int%1_first:
   224 0000140D 1F                  <3>  pop ds
   225                              <3>  assume ds:STACKSCODE
   226                              <3> int%1_end:
   227                              <3> 
   228                              <3>  %rotate 1
   184 0000140E BEC801              <3>  MOV SI, offset %1H*4
   185 00001411 1E                  <3>  push ds
   186 00001412 26C51C              <3>  lds bx, [es:si]
   187                              <3>  assume ds:nothing
   188 00001415 1E                  <3>  push ds
   189 00001416 5A                  <3>  pop dx
   190                              <3> 
   191 00001417 83FA00              <3>  cmp dx,0
   192 0000141A 7431                <3>  jz int%1_first
   193                              <3> 
   194 0000141C 803FCF              <3>  cmp byte ptr [bx],0cfh
   195 0000141F 742C                <3>  jz int%1_first
   196                              <3> 
   197 00001421 817F064B42          <3>  cmp word ptr [bx + 6],424Bh
   198 00001426 7416                <3>  jz int%1_Not_first
   199                              <3> 
   200 00001428 81FA00F0            <3>  cmp dx,0f000h
   201 0000142C 7510                <3>  jnz int%1_Not_first
   202                              <3> 
   203 0000142E 06                  <3>  push es
   204 0000142F 52                  <3>  push dx
   205 00001430 BA00F0              <3>  mov dx,0f000h
   206 00001433 8EC2                <3>  mov es,dx
   207                              <3>  assume es:nothing
   208 00001435 263B1E01FF          <3>  cmp bx,word ptr [es:0ff01h]
   209 0000143A 5A                  <3>  pop dx
   210 0000143B 07                  <3>  pop es
   211                              <3>  assume es:IVT
   212 0000143C 740F                <3>  jz int%1_first
   213                              <3> 
   214                              <3> int%1_Not_first:
   215 0000143E 1F                  <3>  pop ds
   216                              <3>  assume ds:STACKSCODE
   217 0000143F BF[0000]            <3>  mov di, offset Int19OLD%1
   218 00001442 BB[C404]            <3>  mov BX, OFFSET OLD%1
   219 00001445 BA[C204]            <3>  MOV DX, OFFSET INT%1
   220 00001448 E82801              <3>  CALL NEW_INIT_LOOP
   221                              <3> 
   222 0000144B EB01                <3>  jmp short int%1_end
   223                              <3> int%1_first:
   224 0000144D 1F                  <3>  pop ds
   225                              <3>  assume ds:STACKSCODE
   226                              <3> int%1_end:
   227                              <3> 
   228                              <3>  %rotate 1
   184 0000144E BECC01              <3>  MOV SI, offset %1H*4
   185 00001451 1E                  <3>  push ds
   186 00001452 26C51C              <3>  lds bx, [es:si]
   187                              <3>  assume ds:nothing
   188 00001455 1E                  <3>  push ds
   189 00001456 5A                  <3>  pop dx
   190                              <3> 
   191 00001457 83FA00              <3>  cmp dx,0
   192 0000145A 7431                <3>  jz int%1_first
   193                              <3> 
   194 0000145C 803FCF              <3>  cmp byte ptr [bx],0cfh
   195 0000145F 742C                <3>  jz int%1_first
   196                              <3> 
   197 00001461 817F064B42          <3>  cmp word ptr [bx + 6],424Bh
   198 00001466 7416                <3>  jz int%1_Not_first
   199                              <3> 
   200 00001468 81FA00F0            <3>  cmp dx,0f000h
   201 0000146C 7510                <3>  jnz int%1_Not_first
   202                              <3> 
   203 0000146E 06                  <3>  push es
   204 0000146F 52                  <3>  push dx
   205 00001470 BA00F0              <3>  mov dx,0f000h
   206 00001473 8EC2                <3>  mov es,dx
   207                              <3>  assume es:nothing
   208 00001475 263B1E01FF          <3>  cmp bx,word ptr [es:0ff01h]
   209 0000147A 5A                  <3>  pop dx
   210 0000147B 07                  <3>  pop es
   211                              <3>  assume es:IVT
   212 0000147C 740F                <3>  jz int%1_first
   213                              <3> 
   214                              <3> int%1_Not_first:
   215 0000147E 1F                  <3>  pop ds
   216                              <3>  assume ds:STACKSCODE
   217 0000147F BF[0000]            <3>  mov di, offset Int19OLD%1
   218 00001482 BB[4C05]            <3>  mov BX, OFFSET OLD%1
   219 00001485 BA[4A05]            <3>  MOV DX, OFFSET INT%1
   220 00001488 E8E800              <3>  CALL NEW_INIT_LOOP
   221                              <3> 
   222 0000148B EB01                <3>  jmp short int%1_end
   223                              <3> int%1_first:
   224 0000148D 1F                  <3>  pop ds
   225                              <3>  assume ds:STACKSCODE
   226                              <3> int%1_end:
   227                              <3> 
   228                              <3>  %rotate 1
   184 0000148E BED001              <3>  MOV SI, offset %1H*4
   185 00001491 1E                  <3>  push ds
   186 00001492 26C51C              <3>  lds bx, [es:si]
   187                              <3>  assume ds:nothing
   188 00001495 1E                  <3>  push ds
   189 00001496 5A                  <3>  pop dx
   190                              <3> 
   191 00001497 83FA00              <3>  cmp dx,0
   192 0000149A 7431                <3>  jz int%1_first
   193                              <3> 
   194 0000149C 803FCF              <3>  cmp byte ptr [bx],0cfh
   195 0000149F 742C                <3>  jz int%1_first
   196                              <3> 
   197 000014A1 817F064B42          <3>  cmp word ptr [bx + 6],424Bh
   198 000014A6 7416                <3>  jz int%1_Not_first
   199                              <3> 
   200 000014A8 81FA00F0            <3>  cmp dx,0f000h
   201 000014AC 7510                <3>  jnz int%1_Not_first
   202                              <3> 
   203 000014AE 06                  <3>  push es
   204 000014AF 52                  <3>  push dx
   205 000014B0 BA00F0              <3>  mov dx,0f000h
   206 000014B3 8EC2                <3>  mov es,dx
   207                              <3>  assume es:nothing
   208 000014B5 263B1E01FF          <3>  cmp bx,word ptr [es:0ff01h]
   209 000014BA 5A                  <3>  pop dx
   210 000014BB 07                  <3>  pop es
   211                              <3>  assume es:IVT
   212 000014BC 740F                <3>  jz int%1_first
   213                              <3> 
   214                              <3> int%1_Not_first:
   215 000014BE 1F                  <3>  pop ds
   216                              <3>  assume ds:STACKSCODE
   217 000014BF BF[0000]            <3>  mov di, offset Int19OLD%1
   218 000014C2 BB[D405]            <3>  mov BX, OFFSET OLD%1
   219 000014C5 BA[D205]            <3>  MOV DX, OFFSET INT%1
   220 000014C8 E8A800              <3>  CALL NEW_INIT_LOOP
   221                              <3> 
   222 000014CB EB01                <3>  jmp short int%1_end
   223                              <3> int%1_first:
   224 000014CD 1F                  <3>  pop ds
   225                              <3>  assume ds:STACKSCODE
   226                              <3> int%1_end:
   227                              <3> 
   228                              <3>  %rotate 1
   184 000014CE BED801              <3>  MOV SI, offset %1H*4
   185 000014D1 1E                  <3>  push ds
   186 000014D2 26C51C              <3>  lds bx, [es:si]
   187                              <3>  assume ds:nothing
   188 000014D5 1E                  <3>  push ds
   189 000014D6 5A                  <3>  pop dx
   190                              <3> 
   191 000014D7 83FA00              <3>  cmp dx,0
   192 000014DA 7431                <3>  jz int%1_first
   193                              <3> 
   194 000014DC 803FCF              <3>  cmp byte ptr [bx],0cfh
   195 000014DF 742C                <3>  jz int%1_first
   196                              <3> 
   197 000014E1 817F064B42          <3>  cmp word ptr [bx + 6],424Bh
   198 000014E6 7416                <3>  jz int%1_Not_first
   199                              <3> 
   200 000014E8 81FA00F0            <3>  cmp dx,0f000h
   201 000014EC 7510                <3>  jnz int%1_Not_first
   202                              <3> 
   203 000014EE 06                  <3>  push es
   204 000014EF 52                  <3>  push dx
   205 000014F0 BA00F0              <3>  mov dx,0f000h
   206 000014F3 8EC2                <3>  mov es,dx
   207                              <3>  assume es:nothing
   208 000014F5 263B1E01FF          <3>  cmp bx,word ptr [es:0ff01h]
   209 000014FA 5A                  <3>  pop dx
   210 000014FB 07                  <3>  pop es
   211                              <3>  assume es:IVT
   212 000014FC 740F                <3>  jz int%1_first
   213                              <3> 
   214                              <3> int%1_Not_first:
   215 000014FE 1F                  <3>  pop ds
   216                              <3>  assume ds:STACKSCODE
   217 000014FF BF[0000]            <3>  mov di, offset Int19OLD%1
   218 00001502 BB[5C06]            <3>  mov BX, OFFSET OLD%1
   219 00001505 BA[5A06]            <3>  MOV DX, OFFSET INT%1
   220 00001508 E86800              <3>  CALL NEW_INIT_LOOP
   221                              <3> 
   222 0000150B EB01                <3>  jmp short int%1_end
   223                              <3> int%1_first:
   224 0000150D 1F                  <3>  pop ds
   225                              <3>  assume ds:STACKSCODE
   226                              <3> int%1_end:
   227                              <3> 
   228                              <3>  %rotate 1
   184 0000150E BEDC01              <3>  MOV SI, offset %1H*4
   185 00001511 1E                  <3>  push ds
   186 00001512 26C51C              <3>  lds bx, [es:si]
   187                              <3>  assume ds:nothing
   188 00001515 1E                  <3>  push ds
   189 00001516 5A                  <3>  pop dx
   190                              <3> 
   191 00001517 83FA00              <3>  cmp dx,0
   192 0000151A 7431                <3>  jz int%1_first
   193                              <3> 
   194 0000151C 803FCF              <3>  cmp byte ptr [bx],0cfh
   195 0000151F 742C                <3>  jz int%1_first
   196                              <3> 
   197 00001521 817F064B42          <3>  cmp word ptr [bx + 6],424Bh
   198 00001526 7416                <3>  jz int%1_Not_first
   199                              <3> 
   200 00001528 81FA00F0            <3>  cmp dx,0f000h
   201 0000152C 7510                <3>  jnz int%1_Not_first
   202                              <3> 
   203 0000152E 06                  <3>  push es
   204 0000152F 52                  <3>  push dx
   205 00001530 BA00F0              <3>  mov dx,0f000h
   206 00001533 8EC2                <3>  mov es,dx
   207                              <3>  assume es:nothing
   208 00001535 263B1E01FF          <3>  cmp bx,word ptr [es:0ff01h]
   209 0000153A 5A                  <3>  pop dx
   210 0000153B 07                  <3>  pop es
   211                              <3>  assume es:IVT
   212 0000153C 740F                <3>  jz int%1_first
   213                              <3> 
   214                              <3> int%1_Not_first:
   215 0000153E 1F                  <3>  pop ds
   216                              <3>  assume ds:STACKSCODE
   217 0000153F BF[0000]            <3>  mov di, offset Int19OLD%1
   218 00001542 BB[E406]            <3>  mov BX, OFFSET OLD%1
   219 00001545 BA[E206]            <3>  MOV DX, OFFSET INT%1
   220 00001548 E82800              <3>  CALL NEW_INIT_LOOP
   221                              <3> 
   222 0000154B EB01                <3>  jmp short int%1_end
   223                              <3> int%1_first:
   224 0000154D 1F                  <3>  pop ds
   225                              <3>  assume ds:STACKSCODE
   226                              <3> int%1_end:
   227                              <3> 
   228                              <3>  %rotate 1
   233                              <1> 
   234 0000154E 1E                  <1> 	push	ds							       ;3.30
   235 0000154F B800F0              <1> 	mov	ax, 0f000h		;loook at the model byte	       ;3.30
   236 00001552 8ED8                <1> 	mov	ds, ax							       ;3.30
   237                              <1>  assume ds:nothing
   238 00001554 803EFEFFF9          <1> 	cmp	byte ptr [0fffeh], mdl_convert	;PC convertible?	       ;3.30
   239 00001559 1F                  <1> 	pop	ds							       ;3.30
   240                              <1>  assume ds:STACKSCODE
   241 0000155A 7504                <1> 	jne	Skip_EnableNMIS 					       ;3.30
   242                              <1> 									       ;3.30
   243 0000155C B027                <1> 	MOV	AL,27H				; ENABLE Convertible NMIS	       ;3.30
   244 0000155E E672                <1> 	OUT	72H,AL							       ;3.30
   245                              <1> 									       ;3.30
   246                              <1> Skip_EnableNMIS:							       ;3.30
   247 00001560 FB                  <1> 	STI								       ;3.30
   248 00001561 E8(0000)            <1> 	call sysinit_get_ds_dosbiodata
   249                              <1>  assume ds:DOSGROUP							       ;3.30
   250                              <1> ;	MOV	SI,OFFSET STKMSG1					       ;3.30
   251                              <1> ;	CALL	WRMSG							       ;3.30
   252                              <1> 									       ;3.30
   253                              <1> INT19SEM equ Int19sem	; NASM port label
   254 00001564 C606[0000]01        <1> 	mov	byte [INT19SEM],1		; INDICATE THAT INT 19		       ;3.30
   255                              <1> 					; INITIALIZATION IS COMPLETE	       ;3.30
   256                              <1> 									       ;3.30
   257 00001569 5D                  <1> 	POP	BP			; RESTORE ALL			       ;3.30
   258 0000156A 5E                  <1> 	POP	SI							       ;3.30
   259 0000156B 5F                  <1> 	POP	DI							       ;3.30
   260 0000156C 5A                  <1> 	POP	DX							       ;3.30
   261 0000156D 59                  <1> 	POP	CX							       ;3.30
   262 0000156E 5B                  <1> 	POP	BX							       ;3.30
   263                              <1> 									       ;3.30
   264 0000156F 07                  <1> 	POP	ES							       ;3.30
   265 00001570 1F                  <1> 	POP	DS							       ;3.30
   266                              <1>  assume ds:SYSINITGROUP, es:nothing, ss:nothing				       ;3.30
   267 00001571 58                  <1> 	POP	AX							       ;3.30
   268 00001572 C3                  <1> 	RET								       ;3.30
   269                              <1> STACKINIT	ENDP							       ;3.30
   270                              <1> ;									       ;3.30
   271                              <1> 									       ;3.30
   272                              <1> NEW_INIT_LOOP PROC NEAR 						       ;3.30
   273                              <1>  assume ds:STACKSCODE, es:IVT
   274                              <1> ;INPUT: SI=OFSET INTO VECTOR TABLE OF THE PARTICULAR INT VECTOR BEING ADJUSTED ;3.30
   275                              <1> ;	BX=ds:OFFSET OF OLDxx, WHERE WILL BE SAVED THE POINTER TO ORIGINAL OWNER;3.30
   276                              <1> ;	DX=ds:OFFSET OF INTxx, THE NEW INTERRUPT HANDLER		       ;3.30
   277                              <1> ;	di=offset value of Int19OLD&AA variable in BIOS.		       ;3.30
   278                              <1> ;	es=ZERO, SEGID OF VECTOR TABLE					       ;3.30
   279                              <1> ;	ds=Relocated Stack code segment 				       ;3.30
   280                              <1> 									       ;3.30
   281 00001573 268B04              <1> 	MOV	AX,[es:SI+0]	       ;REMEMBER OFFSET IN VECTOR	       ;3.30
   282 00001576 8907                <1> 	MOV	WORD PTR [BX],AX	  ; TO ORIGINAL OWNER in DS	       ;3.30
   283 00001578 268B4402            <1> 	MOV	AX,[es:SI+2]	       ;REMEMBER SEGID IN VECTOR	       ;3.30
   284 0000157C 894702              <1> 	MOV	WORD PTR [BX + 2],AX	  ; TO ORIGINAL OWNER in DS	       ;3.30
   285 0000157F 1E                  <1> 	push	ds							       ;3.30
   286 00001580 E8(0000)            <1> 	call sysinit_get_ds_dosbiodata	;Set Int19OLDxx value in BIOS for      ;3.30
   287                              <1>  assume ds:DOSGROUP
   288 00001583 268B04              <1> 	mov	ax,[es:si+0]		;Int 19 handler 		       ;3.30
   289 00001586 8905                <1> 	mov	word ptr [di],ax					       ;3.30
   290 00001588 268B4402            <1> 	mov	ax,[es:si+2]						       ;3.30
   291 0000158C 894502              <1> 	mov	word ptr [di + 2],ax					       ;3.30
   292 0000158F 1F                  <1> 	pop	ds							       ;3.30
   293                              <1>  assume ds:STACKSCODE							       ;3.30
   294 00001590 268914              <1> 	MOV	WORD PTR [es:SI+0],DX  ;SET VECTOR TO POINT TO NEW INT HANDLER ;3.30
   295 00001593 268C5C02            <1> 	MOV	[es:SI+2],ds						       ;3.30
   296 00001597 C3                  <1> 	RET								       ;3.30
   297                              <1> NEW_INIT_LOOP ENDP							       ;3.30
   298                              <1> 									       ;3.30
  4920                                  ;=== Pop trace listing source
  4921                                  
  4922                                  ;.XALL
  4923                                  	%ENDIF
  4924                                  ;------------------------------------------------------------------------------
  4925                                  
  4926                                  %if 0
  4927                                  	public	SetDevMark
  4928                                  SetDevMark	proc
  4929                                  ;Set the DEVMARK for MEM command.
  4930                                  ;In: [MEMHI] - the address to place DEVMARK
  4931                                  ;    [MEMLO] = 0
  4932                                  ;    AL = ID for DEVMARK_ID
  4933                                  ;OUT: DEVMARK established.
  4934                                  ;     the address saved in [cs:DevMark_Addr]
  4935                                  ;     [MEMHI] increase by 1.
  4936                                  
  4937                                  	push	es				;AN005;
  4938                                  	push	cx				;AN005;
  4939                                  
  4940                                  	mov	cx, [cs:memhi]			;AN005;
  4941                                  	mov	[cs:DevMark_Addr],cx		;AN005;
  4942                                  	mov	es, cx				;AN005;
  4943                                  	mov	[es:DEVMARK_ID], al		;AN005;
  4944                                  	inc	cx				;AN007;
  4945                                  	mov	[es:DEVMARK_SEG], cx		;AN007;
  4946                                  
  4947                                  	pop	cx				;AN005;
  4948                                  	pop	es				;AN005;
  4949                                  	inc	word [cs:memhi]			;AN005;
  4950                                  	ret					;AN005;
  4951                                  SetDevMark	endp
  4952                                  %endif
  4953                                  
  4954                                  ;*******************************************************************************
  4955                                  ;Function: Load  SHARE.EXE, if Big_Media_Flag = 1 and SHARE.EXE has not been   *
  4956                                  ;	   loaded yet.							       *
  4957                                  ;	   This routine will use the same path for SHELL= command.	       *
  4958                                  ;	   If SHELL= command has not been entered, then default to the root    *
  4959                                  ;	   directory.							       *
  4960                                  ;	   If load fails, then issue message "Warning: SHARE.EXE not loaded"   *
  4961                                  ;									       *
  4962                                  ;Input:    Big_Media_Flag, COMMND					       *
  4963                                  ;Output:   Share.exe loaded if necessary.				       *
  4964                                  ;									       *
  4965                                  ;*******************************************************************************
  4966                                  LoadShare	proc	near			;AN021;
  4967                                   assume ds:SYSINITGROUP, es:nothing, ss:SYSINITGROUP
  4968 00001598 803E[0708]01            	cmp	byte [Big_Media_Flag], 1		;AN021;
  4969 0000159D 754E                    	jne	LShare_Ret			;AN021;
  4970                                  ;Check if SHARE is already loaded.
  4971 0000159F B80010                  	mov	ax, 1000h			;AN021;multShare installation check
  4972 000015A2 CD2F                    	int	2fh				;AN021;
  4973 000015A4 3CFF                    	cmp	al, 0ffh			;AN021;
  4974 000015A6 7445                    	jz	LShare_Ret			;AN021;Share already loaded!
  4975                                  ;SHARE not loaded.
  4976 000015A8 0E                      	push	cs				;AN021;
  4977 000015A9 1F                      	pop	ds				;AN021;
  4978                                   assume ds:SYSINITGROUP
  4979 000015AA 0E                      	push	cs				;AN021;
  4980 000015AB 07                      	pop	es				;AN021;
  4981                                   assume es:SYSINITGROUP
  4982 000015AC BE[0000]                	mov	si, offset COMMND		;AN021;
  4983 000015AF BF[0000]                	mov	di, offset PathString		;AN021;
  4984                                  LShare_String:					;AN021;
  4985 000015B2 A4                      	movsb					;AN021;
  4986 000015B3 807DFF00                	cmp	byte ptr [di-1], 0		;AN021;reached to the end?
  4987                                  LShare_string equ LShare_String	; NASM port label
  4988 000015B7 75F9                    	jne	LShare_string			;AN021;
  4989 000015B9 BE[0000]                	mov	si, offset PathString		;AN021;SI= start of PathString
  4990                                  LShare_Tail:					;AN021;
  4991 000015BC 4F                      	dec	di				;AN021;
  4992 000015BD 803D5C                  	cmp	byte ptr [di], "\"		;AN021;
  4993 000015C0 740B                    	je	LShare_Got_Tail 		;AN021;
  4994 000015C2 803D3A                  	cmp	byte ptr [di], ":"		;AN021;
  4995 000015C5 7406                    	je	LShare_Got_Tail 		;AN021;
  4996 000015C7 39F7                    	cmp	di, si				;AN021;No path case (e.g. SHELL=command.com)
  4997 000015C9 7403                    	je	LShare_Got_Tail_0		;AN021;
  4998 000015CB EBEF                    	jmp	LShare_Tail			;AN021;
  4999                                  LShare_Got_Tail:				;AN021;di -> "\" or ":"
  5000 000015CD 47                      	inc	di				;AN021;
  5001                                  LShare_Got_Tail_0:				;AN021;
  5002 000015CE BE[0000]                	mov	si, offset LShare		;AN021;
  5003                                  LShare_Set_Filename:				;AN021;
  5004 000015D1 A4                      	movsb					;AN021;Tag "SHARE.EXE",0,0Ah to the path.
  5005 000015D2 807DFF0A                	cmp	byte ptr [di-1], 0Ah		;AN021;Line feed?
  5006 000015D6 75F9                    	jne	LShare_Set_Filename		;AN021;
  5007                                  ;Now, we got a path,filename with no parameters for SHARE.EXE
  5008 000015D8 BE[0000]                	mov	si, offset PathString		;AN021;
  5009 000015DB 830E[7408]04            	or	word [Install_Flag], SHARE_INSTALL	;AN021;Signals Do_Install_Exec that this is for SHARE.EXE.
  5010 000015E0 E899FA                  	call	Do_Install_Exec 		;AN021;execute it.
  5011 000015E3 7308                    	jnc	LShare_Ret			;AN021;No problem
  5012                                  ;Load/Exec failed.  Show "Warning: SHARE should be loaded for large media"
  5013 000015E5 0E                      	push	cs				;AN021;
  5014 000015E6 1F                      	pop	ds				;AN021;
  5015                                   assume ds:SYSINITGROUP
  5016 000015E7 BA[0000]                	mov	dx, offset ShareWarnMsg 	;AN021;WARNING! SHARE should be loaded...
  5017 000015EA E8(0000)                	invoke	Print				;AN021;
  5018                                  LShare_Ret:					;AN021;
  5019 000015ED C3                      	ret					;AN021;
  5020                                  LoadShare	endp				;AN021;
  5021                                  
  5022                                  ; (no prior section) ; SYSINITSEG	ENDS
  5023                                  
  5024                                  
  5025                                  global init2_relocate_device
  5026                                  global init2_SNextMCB
  5027                                  extern dosentry_xmsentry
  5028                                  %include "codesw.mac"
     1                              <1> DOSCODE_HMA_SEGMENT equ 0FFFEh
     2                              <1> 	; address DOSCODE at this segment when in HMA
     3                              <1> DOSCODE_HMA_start_at equ (10000h - DOSCODE_HMA_SEGMENT) * 10h
     4                              <1> 	; offset from DOSCODE offset 0 to address 10_0000h
     5                              <1> DOSCODE_HMA_OFFSET equ DOSCODE_HMA_start_at + 30h
     6                              <1> 	; 50h = 20h ROM-BIOS, 20h VDISK header, 10h HMCB
  5029                                  %include "init.asm"
     1                              <1> 
     2                              <1> %if 0
     3                              <1> 
     4                              <1> lDOS initialisation
     5                              <1>  by E. C. Masloch, 2018--2025
     6                              <1> 
     7                              <1> Usage of the works is permitted provided that this
     8                              <1> instrument is retained with the works, so that any entity
     9                              <1> that uses the works is notified of this instrument.
    10                              <1> 
    11                              <1> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    12                              <1> 
    13                              <1> %endif
    14                              <1> 
    15                              <1> 
    16                              <1> %include "lmacros2.mac"
     1                              <2> [list -]
    17                              <1> %include "lstruct.mac"
     1                              <2> [list -]
    18                              <1>  extern autobounce_both_options, autobouncehmachs_option, autobouncehmalba_option
    19                              <1>  extern config_bounce_hma_chs
    20                              <1>  extern config_bounce_hma_lba
    21                              <1>  extern DPBHEAD
    22                              <1>  extern DSKDEV
    23                              <1>  extern DISKSECTOR
    24                              <1> 
    25                              <1> 	%include "msbds.mac"
     1                              <2> 
     2                              <2> %warning out: MSBDS.INC...
     2          ******************  <2>  warning: out: MSBDS.INC... [-w+user]
     3                              <2> ;	SCCSID = @(#)IBMBDS.ASM 1.9 85/09/16
     4                              <2> ;==============================================================================
     5                              <2> ;REVISION HISTORY:
     6                              <2> ;AN000 - New for DOS Version 4.00 - J.K.
     7                              <2> ;AC000 - Changed for DOS Version 4.00 - J.K.
     8                              <2> ;AN00x - PTM number for DOS Version 4.00 - J.K.
     9                              <2> ;==============================================================================
    10                              <2> ;AN001; D113 Disable I/O access to unformatted media		    9/03/87 J.K.
    11                              <2> ;==============================================================================
    12                              <2> 
    13                              <2> ; VALUES FOR VARIOUS FLAGS IN BDS.FLAGS.
    14                              <2> 
    15                              <2> FNON_REMOVABLE	    EQU     01H 	;FOR NON-REMOVABLE MEDIA
    16                              <2> FCHANGELINE	    EQU     02H 	;IF CHANGELINE SUPPORTED ON DRIVE
    17                              <2> RETURN_FAKE_BPB     EQU     04H 	; WHEN SET, DON'T DO A BUILD BPB
    18                              <2> 					; JUST RETURN THE FAKE ONE
    19                              <2> GOOD_TRACKLAYOUT    EQU     08H 	; THE TRACK LAYOUT HAS NO FUNNY SECTORS
    20                              <2> ; FCHANGED_BY_FORMAT  EQU	    08H
    21                              <2> FI_AM_MULT	    EQU     10H 	;IF MORE THAN ONE LOGICAL FOR THIS PHYSICAL
    22                              <2> FI_OWN_PHYSICAL     EQU     20H 	;SIGNIFY LOGICAL OWNER OF THIS PHYSICAL
    23                              <2> FCHANGED	    EQU     40H 	;INDICATES MEDIA CHANGED
    24                              <2> SET_DASD_TRUE	    EQU     80H 	; SET DASD BEFORE NEXT FORMAT
    25                              <2> FCHANGED_BY_FORMAT  EQU    100H 	;MEDIA CHANGED BY FORMAT
    26                              <2> UNFORMATTED_MEDIA   EQU    200H 	;AN001; Fixed disk only
    27                              <2> F_LBA		equ	400h		; LBA supported
    28                              <2> 
    29                              <2> LBAPACKETSTRUC struc
    30 00000000 ????                <2> lpSize		dw ?
    31 00000002 ????                <2> lpCount		dw ?
    32 00000004 ????????            <2> lpBuffer	dd ?
    33 00000008 ????????????????    <2> lpSector	dd ?,?
    34                              <2> LBAPACKETSTRUC ends
    35                              <2> 
    36                              <2> ;
    37                              <2> ; VARIOUS FORM FACTORS TO DESCRIBE MEDIA
    38                              <2> ;
    39                              <2> FF48TPI 	    EQU     0
    40                              <2> FF96TPI 	    EQU     1
    41                              <2> FFSMALL 	    EQU     2
    42                              <2> FFHARDFILE	    EQU     5
    43                              <2> FFOTHER 	    EQU     7
    44                              <2> 
    45                              <2> BDS_TYPE	STRUC
    46 00000000 ????????            <2> LINK		DD		?	; LINK TO NEXT BDS
    47 00000004 ??                  <2> DRIVENUM	DB		?	; INT 13 DRIVE NUMBER
    48 00000005 ??                  <2> DRIVELET	DB		?	; DOS DRIVE NUMBER
    49 00000006 ????                <2> BYTEPERSEC	DW		?	; NUMBER OF BYTES/SEC
    50 00000008 ??                  <2> SECPERCLUS	DB		?	; SEC PER ALLOCATION UNIT
    51 00000009 ????                <2> RESSEC		DW		?	; NUMBER OF RESERVED SECTORS
    52 0000000B ??                  <2> CFAT		DB		?	; NUMBER OF FATS
    53 0000000C ????                <2> CDIR		DW		?	; NUMBER OF DIRECTORY ENTRIES
    54 0000000E ????                <2> DRVLIM		DW		?	; NUMBER OF SECTORS ON MEDIUM
    55 00000010 ??                  <2> MEDIAD		DB		?	; MEDIA DESCRIPTOR BYTE
    56 00000011 ????                <2> CSECFAT 	DW		?	; NUMBER OF SECTORS/FAT
    57 00000013 ????                <2> SECLIM		DW		?	; SECTORS PER TRACK
    58 00000015 ????                <2> HDLIM		DW		?	; MAX NUMBER OF HEADS
    59 00000017 ????                <2> HIDSEC_L	DW		?	; NUMBER OF HIDDEN SECTORS
    60 00000019 ????                <2> HIDSEC_H	dw		? ;0	;J.K.87
    61 0000001B ????                <2> DRVLIM_L	dw		? ;0	;J.K.87
    62 0000001D ????                <2> DRVLIM_H	dw		? ;0	;J.K.87
    63 0000001F ??                  <2> FATSIZ		DB		?	; FLAGS...
    64 00000020 ????                <2> OPCNT		DW		?	; OPEN REF. COUNT
    65 00000022 ??                  <2> FORMFACTOR	DB		?	; FORM FACTOR INDEX
    66 00000023 ????                <2> FLAGS		DW		?	; VARIOUS FLAGS
    67 00000025 ????                <2> CCYLN		DW		?	; MAX NUMBER OF CYLINDERS
    68 00000027 ????                <2> RBYTEPERSEC	DW		?	; RECOMMENDED BPB
    69 00000029 ??                  <2> RSECPERCLUS	DB		?
    70 0000002A ????                <2> RRESSEC 	DW		?
    71 0000002C ??                  <2> RCFAT		DB		?
    72 0000002D ????                <2> RCDIR		DW		?
    73 0000002F ????                <2> RDRVLIM 	DW		?
    74 00000031 ??                  <2> RMEDIAD 	DB		?
    75 00000032 ????                <2> RCSECFAT	DW		?
    76 00000034 ????                <2> RSECLIM 	DW		?
    77 00000036 ????                <2> RHDLIM		DW		?
    78 00000038 ????                <2> RHIDSEC_L	DW		?
    79 0000003A ????                <2> RHIDSEC_H	DW		? ;0	;J.K.87
    80 0000003C ????                <2> RDRVLIM_L	dw		? ;0	;J.K.87
    81 0000003E ????                <2> RDRVLIM_H	dw		? ;0	;J.K.87
    82 00000040 ????????????        <2> RESERVE 	DB		6 DUP (?)	; RESERVED FOR FUTURE
    83 00000046 ??                  <2> TRACK		DB		?	; LAST TRACK ACCESSED ON DRIVE
    84 00000047 ????                <2> TIM_LO		DW		?	; TIME OF LAST ACCESS. KEEP
    85 00000049 ????                <2> TIM_HI		DW		?	; THESE CONTIGUOUS.
    86 0000004B <res Ch>            <2> VOLID		DB		12 DUP (?)	; VOLUME ID OF MEDIUM
    87 00000057 ????????            <2> VOL_SERIAL	dd	? ;0	  ;J.K.87 Current volume serial number from Boot record
    88 0000005B <res 9h>            <2> FILESYS_Id	db	9 dup (?) ;(0) ;J.K.87 Current file system id from Boot record
    89                              <2> BDS_TYPE	ENDS
    90                              <2> 
    91                              <2> BPBSIZE     equ	TRACK - RBYTEPERSEC ; SIZE IN BYTES OF RECBPB AREA IN THE BDS
    92                              <2> 
    93                              <2> 
    94                              <2> ;*********************************************************************
    95                              <2> ;	BDS structure for mini disk - J.K. 4/7/86
    96                              <2> ;*********************************************************************
    97                              <2> 
    98                              <2> BDSM_type	struc
    99 00000000 ????                <2> mlink		DW	? ;-1			;Link to next structure
   100 00000002 ????                <2> 		DW	?
   101 00000004 ??                  <2> mdriveNum	DB	? ;80			;Int 13 Drive Number
   102 00000005 ??                  <2> mdriveLet	DB	? ;3			;Logical Drive Number
   103 00000006 ????                <2> mBytePerSec	DW	? ;512
   104 00000008 ??                  <2> mSecPerClus	DB	? ;1			;Sectors/allocation unit
   105 00000009 ????                <2> mRESSEC 	DW	? ;1			;Reserved sectors for DOS
   106 0000000B ??                  <2> mcFAT		DB	? ;2			;No. of allocation tables
   107 0000000C ????                <2> mcDIR		DW	? ;16			;Number of directory entries
   108 0000000E ????                <2> mDRVLIM 	DW	? ;0			;Number of sectors (at 512 bytes each)
   109 00000010 ??                  <2> mMediad 	DB	? ;11111000B		;Media descriptor
   110 00000011 ????                <2> mcSecFat	DW	? ;1			;Number of FAT sectors
   111 00000013 ????                <2> mSECLIM 	DW	? ;0			;Sector limit
   112 00000015 ????                <2> mHDLIM		DW	? ;0			;Head limit
   113 00000017 ????                <2> mHIDSEC_L	DW	? ;0			;Hidden sector count
   114 00000019 ????                <2> mHidsec_H	dw	? ;0			;J.K.87
   115 0000001B ????                <2> mDrvlim_L	dw	? ;0			;J.K.87
   116 0000001D ????                <2> mDrvlim_H	dw	? ;0			;J.K.87
   117 0000001F ??                  <2> mFatSiz 	DB	? ;0			;TRUE => bigfat
   118 00000020 ????                <2> mOPCNT		DW	? ;0			;Open Ref. Count
   119 00000022 ??                  <2> mFormFactor	DB	? ;3			;Form Factor
   120 00000023 ????                <2> mFLAGS		DW	? ;0020H		;Various Flags
   121 00000025 ????                <2> mcCyln		dw	? ;40			;max number of cylinders
   122 00000027 <res 1Fh>           <2> mRecBPB 	db	31 dup (?) ;(0)		;Recommended BPB for drive
   123 00000046 ??                  <2> mTrack		db	? ;-1
   124 00000047 ????                <2> IsMini		dw	? ;1			;Overlapping TIM_LOH
   125 00000049 ????                <2> Hidden_Trks	dw	? ;0			;Overlapping TIM_HIH
   126 0000004B <res Bh>            <2> mVOLID		DB	11 dup (?) ;"NO NAME    "           ;Volume ID for this disk
   127 00000056 ??                  <2> 		DB	? ;0			;ASCIZII for "NO NAME    "
   128 00000057 ????????            <2> mVol_Serial	dd	? ;0	   ;Current volume serial number from Boot record
   129 0000005B ????????????????    <2> mFileSys_Id	db	8 dup (?) ;"FAT12   " ;Current file system id from Boot record
   130 00000063 ??                  <2> 		db	? ;0
   131                              <2> 
   132                              <2> BDSM_type	ENDS
   133                              <2> ;******************************************************************************
   134                              <2> Max_mini_dsk_num equ 23	      ;J.K. 4/7/86 - max # of mini disk ibmbio can support
   135                              <2> ;
   136                              <2> 
    26                              <1> 	%include "dpb.mac"
     1                              <2> ;	SCCSID = @(#)dpb.asm	1.1 85/04/10
     2                              <2> ;	SCCSID = @(#)dpb.asm	1.1 85/04/10
     3                              <2> BREAK <DPB structure>
     4                              <2> ;----+----+----+----+----+----+----+----+----+----+----+----+----+----+----;
     5                              <2> ;	     C	A  V  E  A  T	  P  R	O  G  R  A  M  M  E  R		   ;
     6                              <2> ;									   ;
     7                              <2> dpb	STRUC
     8 00000000 ??                  <2> dpb_drive	    DB	    ?		; Logical drive # assoc with DPB (A=0,B=1,...)
     9 00000001 ??                  <2> dpb_UNIT	    DB	    ?		; Driver unit number of DPB
    10 00000002 ????                <2> dpb_sector_size     DW	    ?		; Size of physical sector in bytes
    11 00000004 ??                  <2> dpb_cluster_mask    DB	    ?		; Sectors/cluster - 1
    12 00000005 ??                  <2> dpb_cluster_shift   DB	    ?		; Log2 of sectors/cluster
    13 00000006 ????                <2> dpb_first_FAT	    DW	    ?		; Starting record of FATs
    14 00000008 ??                  <2> dpb_FAT_count	    DB	    ?		; Number of FATs for this drive
    15 00000009 ????                <2> dpb_root_entries    DW	    ?		; Number of directory entries
    16 0000000B ????                <2> dpb_first_sector    DW	    ?		; First sector of first cluster
    17 0000000D ????                <2> dpb_max_cluster     DW	    ?		; Number of clusters on drive + 1
    18 0000000F ????                <2> dpb_FAT_size	    DW	    ?		;;Number of records occupied by FAT
    19 00000011 ????                <2> dpb_dir_sector	    DW	    ?		; Starting record of directory
    20 00000013 ????????            <2> dpb_driver_addr     DD	    ?		; Pointer to driver
    21 00000017 ??                  <2> dpb_media	    DB	    ?		; Media byte
    22 00000018 ??                  <2> dpb_first_access    DB	    ?		; This is initialized to -1 to force a media
    23                              <2> 					; check the first time this DPB is used
    24 00000019 ????????            <2> dpb_next_dpb	    DD	    ?		; Pointer to next Drive parameter block
    25 0000001D ????                <2> dpb_next_free	    DW	    ?		; Cluster # of last allocated cluster
    26 0000001F ????                <2> dpb_free_cnt	    DW	    ?		; Count of free clusters, -1 if unknown
    27                              <2> dpb	ENDS
    28                              <2> 
    29                              <2> DPBSIZ	EQU	dpb_struc_size		; Size of the structure in bytes
    30                              <2> 
    31                              <2> DSKSIZ	equ	dpb_max_cluster 	; Size of disk (temp used during init only)
    32                              <2> ;									   ;
    33                              <2> ;	     C	A  V  E  A  T	  P  R	O  G  R  A  M  M  E  R		   ;
    34                              <2> ;----+----+----+----+----+----+----+----+----+----+----+----+----+----+----;
    27                              <1> 
    28                              <1> defaulting
    29                              <1> 
    30                              <1> numdef DEBUG0
    31                              <1> numdef DEBUG1
    32                              <1> numdef DEBUG2
    33                              <1> numdef DEBUG3
    34                              <1> numdef DEBUG4
    35                              <1> numdef DEBUG5
    36                              <1> %idefine d5 _d 5,
    37                              <1> 
    38                              <1> %assign _UMA 1
    39                              <1> %assign _COMBINED_DOSDATA_DOSCODE 0
    40                              <1> ;	numdef DOSCODEHMA, 1
    41                              <1> ;	numdef RELOCATEDOSCODE, 1
    42                              <1> 	numdef INT19_IN_DOSENTRY, 1
    43                              <1> 	strdef BIN_FILE_DEFAULT, "LDOS.COM"
    44                              <1> 	numdef TEST_PAYLOAD, 0
    45                              <1> 	numdef INIT_ENV_SIZE, 1024
    46                              <1> 
    47                              <1> %if _RELOCATEDOSCODE
    48                              <1>  %define DOSCODE_SIZE (doscode_end - doscode_start)
    49                              <1>  %define DOSCODE_MCB_SIZE 16
    50                              <1> %else
    51                              <1>  %define DOSCODE_SIZE 0
    52                              <1>  %define DOSCODE_MCB_SIZE 0
    53                              <1> %endif
    54                              <1> 
    55                              <1> 
    56                              <1> %if 0	; lMS-DOS doesn't use these parts yet
    57                              <1> 
    58                              <1> 	struc FSPARM
    59                              <1> fspStart:	resd 1
    60                              <1> fspLength:	resd 1
    61                              <1> fspUnit:	resb 1
    62                              <1> fspPartition:	resb 1
    63                              <1> fspBoot:	resb 1
    64                              <1> fspType:	resb 1
    65                              <1> fspSectorSize:	resw 1
    66                              <1> 		resw 1
    67                              <1> 	endstruc
    68                              <1> 
    69                              <1> 
    70                              <1> %ifndef _MAP
    71                              <1> %elifempty _MAP
    72                              <1> %else	; defined non-empty, str or non-str
    73                              <1> 	[map all _MAP]
    74                              <1> %endif
    75                              <1> 
    76                              <1> 
    77                              <1> 	cpu 8086
    78                              <1> 	; section INIT0 start=0 vstart=0
    79                              <1> init0_start:
    80                              <1> 	nop
    81                              <1> 	align 32, nop
    82                              <1> init0_kernel_entry:
    83                              <1> 		; cs:ip = load seg : 32 here
    84                              <1> %if ($ - $$) != 32
    85                              <1>  %error Wrong kernel mode entrypoint
    86                              <1> %endif
    87                              <1> 	cld
    88                              <1> 	mov ax, cs
    89                              <1> 	add ax, (init0_end - init0_start) >> 4
    90                              <1> 	mov cx, ( 16 		+ (dosentry_end - dosentry_start) 		+ DOSCODE_MCB_SIZE 		+ DOSCODE_SIZE 		+ 16 		+ (dosdata_end - dosdata_start) 		+ 16 		+ (init1_end - init1_start) 		+ 16 		+ (init2_end - init2_start) 		+ 16 		+ (init3_end - init3_start) 		+ 16 		) >> 4
   104                              <1> 	mov dx, word [ bp + ldLoadTop ]
   105                              <1> 	sub dx, cx
   106                              <1> 	call init0_movp
   107                              <1> 
   108                              <1> 	mov ax, dx
   109                              <1> 	add ax, ( 		+ 16 		+ (dosentry_end - dosentry_start) 		+ DOSCODE_MCB_SIZE 		+ DOSCODE_SIZE 		+ 16 		+ (dosdata_end - dosdata_start) 		+ 16 		) >> 4
   118                              <1> 	xor bx, bx
   119                              <1> 	push ax
   120                              <1> 	push bx
   121                              <1> 	retf
   122                              <1> 
   123                              <1> 	align 64, nop
   124                              <1> init0_exe_entry:
   125                              <1> 		; cs:ip = PSP : 256 + 64 here
   126                              <1> 		;
   127                              <1> 		; Code must be position independent enough.
   128                              <1> %if ($ - $$) != 64
   129                              <1>  %error Wrong EXE mode entrypoint
   130                              <1> %endif
   131                              <1> 	mov cx, cs
   132                              <1> 	add cx, ( 256 		+ (init0_end - init0_start) 		+ 16 		+ (dosentry_end - dosentry_start) 		+ DOSCODE_MCB_SIZE 		+ DOSCODE_SIZE 		+ 16 		+ (dosdata_end - dosdata_start) 		+ 16 		+ (init1_end - init1_start) 		+ 16 		+ (init2_end - init2_start) 		+ 16 		+ (init3_end - init3_start) 		+ 16 		+ COMLOADER_position 		) >> 4
   149                              <1> 	xor bx, bx
   150                              <1> 	push cx
   151                              <1> 	push bx
   152                              <1> 	retf
   153                              <1> 
   154                              <1> 
   155                              <1> 		; Move paragraphs
   156                              <1> 		;
   157                              <1> 		; INP:	ax:0-> source
   158                              <1> 		;	dx:0-> destination
   159                              <1> 		;	cx = number of paragraphs
   160                              <1> 		; CHG:	-
   161                              <1> 		; Note:	Doesn't work correctly on HMA; doesn't always wrap to LMA either.
   162                              <1> 		;	Do not provide a wrapped/HMA source or destination!
   163                              <1> init0_movp:
   164                              <1> 	push cx
   165                              <1> 	push ds
   166                              <1> 	push si
   167                              <1> 	push es
   168                              <1> 	push di
   169                              <1> 
   170                              <1> 	cmp ax, dx		; source above destination ?
   171                              <1> 	ja .up			; yes, move up (forwards) -->
   172                              <1> 	je .return		; same, no need to move -->
   173                              <1> 	push ax
   174                              <1> 	add ax, cx		; (expected not to carry)
   175                              <1> 	cmp ax, dx		; end of source is above destination ?
   176                              <1> 	pop ax
   177                              <1> 	ja .down		; yes, move from top down -->
   178                              <1> 	; Here, the end of source is below-or-equal the destination,
   179                              <1> 	;  so they do not overlap. In this case we prefer moving up.
   180                              <1> 
   181                              <1> .up:
   182                              <1> 	push ax
   183                              <1> 	push dx
   184                              <1> .uploop:
   185                              <1> 	mov ds, ax
   186                              <1> 	mov es, dx
   187                              <1> 	xor di, di
   188                              <1> 	xor si, si		; -> start of segment
   189                              <1> 	sub cx, 1000h		; 64 KiB left ?
   190                              <1> 	jbe .uplast		; no -->
   191                              <1> 	push cx
   192                              <1> 	mov cx, 10000h /2
   193                              <1> 	rep movsw		; move 64 KiB
   194                              <1> 	pop cx
   195                              <1> 	add ax, 1000h
   196                              <1> 	add dx, 1000h		; -> next segment
   197                              <1> 	jmp short .uploop	; proceed for more -->
   198                              <1> .uplast:
   199                              <1> 	add cx, 1000h		; restore counter
   200                              <1> 	shl cx, 1
   201                              <1> 	shl cx, 1
   202                              <1> 	shl cx, 1		; *8, paragraphs to words
   203                              <1> 	rep movsw		; move last part
   204                              <1> 	pop dx
   205                              <1> 	pop ax
   206                              <1> 	jmp short .return
   207                              <1> 
   208                              <1> .down:
   209                              <1> 	std			; _AMD_ERRATUM_109_WORKAROUND as below
   210                              <1> .dnloop:
   211                              <1> 	sub cx, 1000h		; 64 KiB left ?
   212                              <1> 	jbe .dnlast		; no -->
   213                              <1> 	push ax
   214                              <1> 	push dx
   215                              <1> 	add ax, cx
   216                              <1> 	add dx, cx
   217                              <1> 	mov ds, ax		; -> 64 KiB not yet moved
   218                              <1> 	mov es, dx
   219                              <1> 	pop dx
   220                              <1> 	pop ax
   221                              <1> 	mov di, -2
   222                              <1> 	mov si, di		; moved from last word down
   223                              <1> 	push cx
   224                              <1> 	mov cx, 10000h /2
   225                              <1> 	rep movsw		; move 64 KiB
   226                              <1> 	pop cx
   227                              <1> 	jmp short .dnloop	; proceed for more -->
   228                              <1> .dnlast:
   229                              <1> 	add cx, 1000h		; restore counter
   230                              <1> 	shl cx, 1
   231                              <1> 	shl cx, 1
   232                              <1> 	shl cx, 1		; *8, paragraphs to words
   233                              <1> 	mov di, cx
   234                              <1> 	dec di
   235                              <1> 	shl di, 1		; words to offset, -> last word
   236                              <1> 	mov si, di
   237                              <1> 	mov ds, ax
   238                              <1> 	mov es, dx		; first segment correct
   239                              <1> 
   240                              <1> 
   241                              <1> 	numdef AMD_ERRATUM_109_WORKAROUND, 1
   242                              <1> %if 0
   243                              <1> 
   244                              <1> Jack R. Ellis pointed out this erratum:
   245                              <1> 
   246                              <1> Quoting from https://www.amd.com/system/files/TechDocs/25759.pdf page 69:
   247                              <1> 
   248                              <1> 109   Certain Reverse REP MOVS May Produce Unpredictable Behavior
   249                              <1> 
   250                              <1> Description
   251                              <1> 
   252                              <1> In certain situations a REP MOVS instruction may lead to
   253                              <1> incorrect results. An incorrect address size, data size
   254                              <1> or source operand segment may be used or a succeeding
   255                              <1> instruction may be skipped. This may occur under the
   256                              <1> following conditions:
   257                              <1> 
   258                              <1> * EFLAGS.DF=1 (the string is being moved in the reverse direction).
   259                              <1> 
   260                              <1> * The number of items being moved (RCX) is between 1 and 20.
   261                              <1> 
   262                              <1> * The REP MOVS instruction is preceded by some microcoded instruction
   263                              <1>   that has not completely retired by the time the REP MOVS begins
   264                              <1>   execution. The set of such instructions includes BOUND, CLI, LDS,
   265                              <1>   LES, LFS, LGS, LSS, IDIV, and most microcoded x87 instructions.
   266                              <1> 
   267                              <1> Potential Effect on System
   268                              <1> 
   269                              <1> Incorrect results may be produced or the system may hang.
   270                              <1> 
   271                              <1> Suggested Workaround
   272                              <1> 
   273                              <1> Contact your AMD representative for information on a BIOS update.
   274                              <1> 
   275                              <1> %endif
   276                              <1> 
   277                              <1> %if _AMD_ERRATUM_109_WORKAROUND
   278                              <1> 	jcxz @FF
   279                              <1> 	cmp cx, 20
   280                              <1> 	ja @FF
   281                              <1> @@:
   282                              <1> 	movsw
   283                              <1> 	loop @B
   284                              <1> @@:
   285                              <1> %endif
   286                              <1> 	rep movsw		; move first part
   287                              <1> 	cld
   288                              <1> .return:
   289                              <1> 	pop di
   290                              <1> 	pop es
   291                              <1> 	pop si
   292                              <1> 	pop ds
   293                              <1> 	pop cx
   294                              <1> 	retn
   295                              <1> 
   296                              <1> 	align 16
   297                              <1> init0_end:
   298                              <1> 	istruc MCB
   299                              <1> at mcbSignature,	db "M"
   300                              <1> at mcbOwner,		dw 8
   301                              <1> at mcbSize,		dw (dosentry_end - dosentry_start) >> 4
   302                              <1> at smcbName,		dw "S"
   303                              <1> at smcbType,		db S_DOSENTRY
   304                              <1> 	iend
   305                              <1> 
   306                              <1> 	; section DOSENTRY align=16 follows=INIT0 vstart=0
   307                              <1> dosentry_start:
   308                              <1> %include "entry.asm"
   309                              <1> 
   310                              <1> %if _RELOCATEDOSCODE
   311                              <1> 	align 16
   312                              <1> dosentry_end:
   313                              <1> 	istruc MCB
   314                              <1> at mcbSignature,	db "M"
   315                              <1> at mcbOwner,		dw 8
   316                              <1> at mcbSize,		dw (doscode_end - doscode_start) >> 4
   317                              <1> at smcbName,		dw "S"
   318                              <1> at smcbType,		db S_DOSCODE
   319                              <1> 	iend
   320                              <1> 
   321                              <1> 	; section DOSCODE align=16 follows=DOSENTRY vstart=40h
   322                              <1> 			; vstart:
   323                              <1> 			; +10h for end of ROM-BIOS image (at 0FFFFh:0)
   324                              <1> 			; +20h for VDISK header
   325                              <1> 			; +10h for first HMCB
   326                              <1> doscode_start:
   327                              <1> %endif
   328                              <1> 
   329                              <1> %if !_COMBINED_DOSDATA_DOSCODE
   330                              <1> 
   331                              <1> 		; The following table and function is used by devicerelocate
   332                              <1> 		;  even if DOSCODE is merged into DOSENTRY (!_RELOCATEDOSCODE).
   333                              <1> 
   334                              <1> 	write_entrypoint_list ENTRYPOINT_LIST
   335                              <1> 
   336                              <1> 
   337                              <1> %if _RELOCATEDOSCODE && _DOSCODEHMA
   338                              <1> 	_fill 0C0h + DOSCODE_HMA_start_at, 90h, doscode_start
   339                              <1> hma_call5:
   340                              <1> 	jmp 70h:call5
   341                              <1> %endif
   342                              <1> 
   343                              <1> 
   344                              <1> 		; INP:	byte [cs:ip] = displacement in doscode_entrypoint_list
   345                              <1> 		;	word [DOSCODE:(displaced)]
   346                              <1> 		;	 = relocated entry address
   347                              <1> 		;	word [DOSCODE:(displaced + 2)]
   348                              <1> 		;	 = optional pointer to device function table
   349                              <1> 		;	byte [DOSCODE:(displaced + 4)]
   350                              <1> 		;	 = optional device unit
   351                              <1> 		;	ss:(sp + 8) -> arbitrary stack of entrypoint
   352                              <1> 		;	word [ss:sp + 6] = entrypoint's ip,
   353                              <1> 		;	word [ss:sp + 4] = entrypoint's cs,
   354                              <1> 		;	word [ss:sp + 2] = original flags value,
   355                              <1> 		;	word [ss:sp + 0] = original ax value,
   356                              <1> relocated_relocatedentry:
   357                              <1> 	lframe 0
   358                              <1> 	lpar word, entrypoint_ip
   359                              <1> 	lpar word, entrypoint_cs
   360                              <1> 	lpar word, orig_fl
   361                              <1> 	lpar word, orig_ax
   362                              <1> 	lenter
   363                              <1> 	push ds
   364                              <1> 	push si
   365                              <1> 
   366                              <1> 	cld
   367                              <1> 	xor ax, ax
   368                              <1> 	mov ds, word [bp + ?entrypoint_cs]
   369                              <1> 	mov si, word [bp + ?entrypoint_ip]
   370                              <1> 	lodsb
   371                              <1> 	cmp al, 0CCh	; overwritten by debugger ?
   372                              <1> 	jne @F		; no -->
   373                              <1> 	int3		; break to make it remove the breakpoint
   374                              <1> 	dec si
   375                              <1> 	lodsb		; reload the byte
   376                              <1> 	cmp al, 0CCh
   377                              <1> 	jne @F
   378                              <1> 
   379                              <1> .error:
   380                              <1> 	mov si, doscode_msg.error_common
   381                              <1> 	call doscode_disp_msg_cs
   382                              <1> 	mov si, doscode_msg.error_table
   383                              <1> 	call doscode_disp_msg_cs
   384                              <1> 	mov si, doscode_msg.error_after
   385                              <1> 	call doscode_disp_msg_cs
   386                              <1> .loop:
   387                              <1> 	int3
   388                              <1> 	xor ax, ax
   389                              <1> 	int 16h
   390                              <1> 	jmp .loop
   391                              <1> 
   392                              <1> @@:
   393                              <1> 	push cs
   394                              <1> 	pop ds
   395                              <1> 
   396                              <1> 	add ax, doscode_entrypoint_list
   397                              <1> 	cmp ax, doscode_entrypoint_list.end
   398                              <1> 	jae .error
   399                              <1> 	xchg ax, si
   400                              <1> 
   401                              <1> 	lodsw		; get relocated entry address
   402                              <1> 	cmp ax, DEVStrategy		; set ZF iff DEVStrategy
   403                              <1> 
   404                              <1> 	xchg word [bp + ?orig_fl], ax	; store address in ?orig_fl, ax = fl
   405                              <1> 	xchg word [bp + ?orig_ax], ax	; store fl in ?orig_ax, ax = orig ax
   406                              <1> 
   407                              <1> 	 push ax
   408                              <1> 	lodsw
   409                              <1> 	mov word [bp + ?entrypoint_ip], ax
   410                              <1> 
   411                              <1> 	mov ah, 0
   412                              <1> 	lodsb
   413                              <1> 	mov word [bp + ?entrypoint_cs], ax
   414                              <1> 	 pop ax
   415                              <1> 
   416                              <1> 	pop si
   417                              <1> 	pop ds
   418                              <1> 	lleave
   419                              <1> 	je .is_dev_strat		; dispatch based on ZF
   420                              <1> 	popf				; (fl = ?orig_ax = fl)
   421                              <1> 	retn 4				; (ip = ?orig_fl = address)
   422                              <1> 
   423                              <1> .is_dev_strat:
   424                              <1> 	popf
   425                              <1> 	retn
   426                              <1> 
   427                              <1> 
   428                              <1> doscode_disp_msg_cs:
   429                              <1> 	push ax
   430                              <1> @@:
   431                              <1> 	cs lodsb
   432                              <1> 	test al, al
   433                              <1> 	jz @F
   434                              <1> 	call doscode_disp_al
   435                              <1> 	jmp short @B
   436                              <1> 
   437                              <1> 
   438                              <1> doscode_disp_al:
   439                              <1> 	push ax
   440                              <1> 	push bx
   441                              <1> 	push bp
   442                              <1> 	mov ah, 0Eh
   443                              <1> 	mov bx, 7
   444                              <1> 	int 10h
   445                              <1> 	pop bp
   446                              <1> 	pop bx
   447                              <1> @@:
   448                              <1> 	pop ax
   449                              <1> 	retn
   450                              <1> 
   451                              <1> 
   452                              <1> doscode_disp_dxax_hex:	; dx:ax
   453                              <1> 		xchg ax, dx
   454                              <1> 		call doscode_disp_ax_hex
   455                              <1> 		xchg ax, dx
   456                              <1> doscode_disp_ax_hex:	; ax
   457                              <1> 		xchg al, ah
   458                              <1> 		call doscode_disp_al_hex
   459                              <1> 				; display former ah
   460                              <1> 		xchg al, ah	;  and fall trough for al
   461                              <1> doscode_disp_al_hex:	; al
   462                              <1> 		push cx
   463                              <1> 		mov cl, 4
   464                              <1> 		ror al, cl
   465                              <1> 		call doscode_disp_al_lownibble_hex
   466                              <1> 				; display former high-nibble
   467                              <1> 		rol al, cl
   468                              <1> 		pop cx
   469                              <1> 				;  and fall trough for low-nibble
   470                              <1> doscode_disp_al_lownibble_hex:
   471                              <1> 		push ax		; save ax for call return
   472                              <1> 		and al, 00001111b
   473                              <1> 				; high nibble must be zero
   474                              <1> 		add al, '0'	; if number is 0-9, now it's the correct character
   475                              <1> 		cmp al, '9'
   476                              <1> 		jna .decimalnum	; if we get decimal number with this, ok -->
   477                              <1> 		add al, 7	;  otherwise, add 7 and we are inside our alphabet
   478                              <1>  .decimalnum:
   479                              <1> 		call doscode_disp_al
   480                              <1> 		pop ax
   481                              <1> 		retn
   482                              <1> 
   483                              <1> 
   484                              <1> doscode_msg:
   485                              <1> .error_common:	asciz "DOSCODE error: "
   486                              <1> .error_table:	asciz "Invalid doscode_entrypoint_list reference."
   487                              <1> .error_after:	asciz 13,10,"System halted. "
   488                              <1> 
   489                              <1> 
   490                              <1> 	%include "biocode.asm"
   491                              <1> 
   492                              <1> %assign DOSCODE_INSURE_COUNT 0
   493                              <1> 
   494                              <1> 		; The init2_to_doscode dispatcher in INIT2 (DOSINI)
   495                              <1> 		;  detects mistaken debugger breakpoints in its
   496                              <1> 		;  in-code-parameter by checking for a low-byte
   497                              <1> 		;  value equal to 0CCh (one-byte int3 opcode).
   498                              <1> 		; Therefore, we insure that all functions called
   499                              <1> 		;  via that dispatcher do not happen to be located
   500                              <1> 		;  on an offset that gives 0CCh in the low byte.
   501                              <1> 	%imacro doscode_insure_low_byte_not_0CCh 0.nolist
   502                              <1>  %if (($ - dosentry_start + 0) & 0FFh) == 0CCh
   503                              <1> 	nop
   504                              <1>   %assign DOSCODE_INSURE_COUNT 1 + DOSCODE_INSURE_COUNT
   505                              <1>  %endif
   506                              <1> 	%endmacro
   507                              <1> 
   508                              <1> 	%include "doscode.asm"
   509                              <1> %endif
   510                              <1> 
   511                              <1> %if DOSCODE_INSURE_COUNT
   512                              <1>  %warning doscode_insure_low_byte_not_0CCh needed DOSCODE_INSURE_COUNT times
   513                              <1> %endif
   514                              <1> 
   515                              <1> 	align 16
   516                              <1> %if _RELOCATEDOSCODE
   517                              <1> doscode_end:
   518                              <1> %else
   519                              <1> dosentry_end:
   520                              <1> %endif
   521                              <1> 	istruc MCB
   522                              <1> at mcbSignature,	db "M"
   523                              <1> at mcbOwner,		dw 8
   524                              <1> at mcbSize,		dw (dosdata_end - dosdata_start) >> 4
   525                              <1> at smcbName,		dw "S"
   526                              <1> at smcbType,		db S_DOSDATA
   527                              <1> 	iend
   528                              <1> 
   529                              <1> %if _RELOCATEDOSCODE
   530                              <1> 	; section DOSDATA align=16 follows=DOSCODE vstart=0
   531                              <1> %else
   532                              <1> 	; section DOSDATA align=16 follows=DOSENTRY vstart=0
   533                              <1> %endif
   534                              <1> dosdata_start:
   535                              <1> %if _COMBINED_DOSDATA_DOSCODE
   536                              <1> 	%include "RxDOS.ASM"
   537                              <1> %else
   538                              <1> 	%include "dosdata.asm"
   539                              <1> %endif
   540                              <1> 
   541                              <1> 	align 16
   542                              <1> dosdata_end:
   543                              <1> 	istruc MCB
   544                              <1> at mcbSignature,	db "M"
   545                              <1> at mcbOwner,		dw 8
   546                              <1> at mcbSize,		dw (init1_end - init1_start) >> 4
   547                              <1> at smcbName,		dw "S"
   548                              <1> at smcbType,		db S_INIT
   549                              <1> 	iend
   550                              <1> 
   551                              <1> 	; section INIT1 align=16 follows=DOSDATA vstart=0
   552                              <1> 
   553                              <1> %assign INIT1_INSURE_COUNT 0
   554                              <1> 
   555                              <1> 		; The init2_to_init1 dispatcher in INIT2 (DOSINI)
   556                              <1> 		;  detects mistaken debugger breakpoints in its
   557                              <1> 		;  in-code-parameter by checking for a low-byte
   558                              <1> 		;  value equal to 0CCh (one-byte int3 opcode).
   559                              <1> 		; Therefore, we insure that all functions called
   560                              <1> 		;  via that dispatcher do not happen to be located
   561                              <1> 		;  on an offset that gives 0CCh in the low byte.
   562                              <1> 	%imacro init1_insure_low_byte_not_0CCh 0.nolist
   563                              <1>  %if (($ - init1_start) & 0FFh) == 0CCh
   564                              <1> 	nop
   565                              <1>   %assign INIT1_INSURE_COUNT 1 + INIT1_INSURE_COUNT
   566                              <1>  %endif
   567                              <1> 	%endmacro
   568                              <1> 
   569                              <1> 
   570                              <1> init1_start:
   571                              <1> 		; S0 +28
   572                              <1> 	pushf	; +26
   573                              <1> 	jmp sig_valid
   574                              <1> 
   575                              <1> msg:
   576                              <1> %if _TEST_PAYLOAD
   577                              <1> .test:	asciz "Test payload loaded. Press any key to continue booting.",13,10
   578                              <1> %endif
   579                              <1> 
   580                              <1> 	align 4
   581                              <1> .foundname:
   582                              <1> 	times 8+1+3+1 db 0
   583                              <1> 		; buffer for base name (8) + dot (1) + ext (3) + NUL (1)
   584                              <1> 	align 2
   585                              <1> .foundname_default:
   586                              <1> 	asciz _BIN_FILE_DEFAULT
   587                              <1> 	_fill (8 + 1 + 3 + 1), 0, .foundname_default
   588                              <1> 	align 2
   589                              <1> .foundname_none:
   590                              <1> 	asciz "(None)"
   591                              <1> .foundname_none_size: equ $ - .foundname_none
   592                              <1> 	align 2
   593                              <1> .names:
   594                              <1> %if _TEST_PAYLOAD
   595                              <1> 	dw .name_first, 0
   596                              <1> 	dw .name_second, 0
   597                              <1> 	dw .name_third, 0
   598                              <1> 	dw .name_fourth, 0
   599                              <1> %else
   600                              <1> 	dw .foundname_none, 0
   601                              <1> %endif
   602                              <1> 	dw 0
   603                              <1> %if _TEST_PAYLOAD
   604                              <1> .name_first:	asciz "1st name"
   605                              <1> .name_second:	asciz "2nd name"
   606                              <1> .name_third:	asciz "3rd name"
   607                              <1> .name_fourth:	asciz "4th name"
   608                              <1> .name_before:	asciz ": "
   609                              <1> .name_quote:	asciz '"'
   610                              <1> .name_after:	asciz 13,10
   611                              <1> %endif
   612                              <1> 
   613                              <1> .bootfail:	asciz "init: Boot failure: "
   614                              <1> .bootfail_read:	db "Reading sector failed (error "
   615                              <1> .bootfail_read_errorcode:	asciz "__h).",13,10
   616                              <1> .bootfail_sig:	asciz "Boot sector signature missing (is not AA55h).",13,10
   617                              <1> .bootfail_sig_parttable:	ascii "Partition table signature missing"
   618                              <1> 				asciz " (is not AA55h).",13,10
   619                              <1> .bootfail_secsizediffer:
   620                              <1> 		asciz "BPB BpS differs from actual sector size.",13,10
   621                              <1> .boot_too_many_partitions_error:asciz "Too many partitions (or a loop).",13,10
   622                              <1> .boot_partition_cycle_error:	asciz "Partition table cycle detected.",13,10
   623                              <1> .boot_partition_not_found:	asciz "Partition not found.",13,10
   624                              <1> .boot_access_error:	asciz "Read error.", 13,10
   625                              <1> .boot_sector_too_large:	asciz "Sector size too small (< 32 bytes).", 13,10
   626                              <1> .boot_sector_too_small:	asciz "Sector size too large (> 8192 bytes).", 13,10
   627                              <1> .boot_sector_not_power:	asciz "Sector size not a power of two.", 13,10
   628                              <1> .boot_invalid_sectors:	asciz "Invalid geometry sectors.", 13,10
   629                              <1> .boot_invalid_heads:	asciz "Invalid geometry heads.", 13,10
   630                              <1> .boot_badclusters:	asciz "Bad amount of clusters.",13,10
   631                              <1> .boot_badchain:		asciz "Bad cluster chain.",13,10
   632                              <1> .boot_internal_error:	asciz "! Internal error !",13,10
   633                              <1> 
   634                              <1> .login_partition_error_1:	asciz "init: Error during unit "
   635                              <1> .login_partition_error_2:	asciz "h partitions login.",13,10
   636                              <1> 
   637                              <1> .excess_partitions_1:		asciz "init: Found "
   638                              <1> .excess_partitions_2:		asciz " excess partitions, ignored.",13,10
   639                              <1> 
   640                              <1> .list_partition_1:		asciz ": "
   641                              <1> .list_partition_4:		asciz " s="
   642                              <1> .list_partition_5:		asciz "h ("
   643                              <1> .list_partition_6:		asciz ") l="
   644                              <1> .list_partition_7:		asciz "h ("
   645                              <1> .list_partition_8:		asciz ") "
   646                              <1> .list_partition_9:		asciz " t="
   647                              <1> .list_partition_10:		asciz "h ("
   648                              <1> .list_partition_11:		asciz ").",13,10
   649                              <1> 
   650                              <1> .prefixes:			asciz " kMGT"
   651                              <1> 
   652                              <1> .bootname_1:	asciz "init: Boot drive and file name: ",'"'
   653                              <1> .bootname_2:	asciz '"',13,10
   654                              <1> 
   655                              <1> 
   656                              <1> %define pt_messages ..@pt_notype,""
   657                              <1> 
   658                              <1> 	%imacro pt_type 2.nolist
   659                              <1> 		dw %2, %%label
   660                              <1> %defstr %%str	%1
   661                              <1> %xdefine pt_messages pt_messages,%%label,%%str
   662                              <1> 	%endmacro
   663                              <1> 
   664                              <1> 	%imacro pt_msg 2-*.nolist
   665                              <1> %if %0 & 1
   666                              <1>  %error Expected even number of parameters
   667                              <1> %endif
   668                              <1> %rotate 2
   669                              <1> %rep (%0 - 2) / 2
   670                              <1> %1:	asciz %2
   671                              <1> %rotate 2
   672                              <1> %endrep
   673                              <1> 	%endmacro
   674                              <1> 
   675                              <1> 	align 4
   676                              <1> pt_types:
   677                              <1>  pt_type	Empty,		0
   678                              <1>  pt_type	FAT12,		1
   679                              <1>  pt_type	FAT16 16BIT CHS,4
   680                              <1>  pt_type	ExtendedCHS,	5
   681                              <1>  pt_type	FAT16 CHS,	6
   682                              <1>  pt_type	FAT32 CHS,	0Bh
   683                              <1>  pt_type	FAT32,		0Ch
   684                              <1>  pt_type	FAT16,		0Eh
   685                              <1>  pt_type	Extended,	0Fh
   686                              <1>  pt_type	Linux,		83h
   687                              <1>  pt_type	ExtendedLinux,	85h
   688                              <1> 	dw -1, -1
   689                              <1> 
   690                              <1> pt_msg pt_messages
   691                              <1> 
   692                              <1> ptmsg_unknown:	asciz "Unknown"
   693                              <1> 
   694                              <1> %undef pt_messages
   695                              <1> %unimacro pt_type 2.nolist
   696                              <1> %unimacro pt_msg 2-*.nolist
   697                              <1> 
   698                              <1> %endif
   699                              <1> 
   700                              <1> init1_msg:
   701 000015EE 696E69743A20457272- <1> .alloc_error:		asciz "init: Error "
   701 000015F7 6F722000            <1>
   702 000015FB 68207768696C652061- <1> .alloc_error_q:		asciz "h while allocating memory: "
   702 00001604 6C6C6F636174696E67- <1>
   702 0000160D 206D656D6F72793A20- <1>
   702 00001616 00                  <1>
   703 00001617 0D0A00              <1> .linebreak:		asciz 13,10
   704                              <1> ; .internal_error_upb:	asciz "init: Internal error during UPB allocation.",13,10
   705 0000161A 48616C7465642E2050- <1> .reboot_prompt:		asciz "Halted. Press Ctrl+Alt+Del to reboot.",13,10
   705 00001623 72657373204374726C- <1>
   705 0000162C 2B416C742B44656C20- <1>
   705 00001635 746F207265626F6F74- <1>
   705 0000163E 2E0D0A00            <1>
   706                              <1> ; .loading_os:		asciz "Starting ",RXDOSLONG_S,"...",13,10
   707 00001642 52504C4F41444552    <1> .rploader:		db "RPLOADER"
   708                              <1> 	endarea .rploader
   709 0000164A 00                  <1> 			db 0
   710 0000164B 206B4D475400        <1> .prefixes:			asciz " kMGT"
   711                              <1> 
   712 00001651 90                  <1> 	align 2
   713                              <1> init1_msg_errors:
   714                              <1> .:
   715 00001652 [8616]              <1> 	dw .no_error
   716 00001654 [8F16]              <1> 	dw .invalid_function
   717 00001656 [A016]              <1> 	dw .file_not_found
   718 00001658 [AF16]              <1> 	dw .path_not_found
   719 0000165A [BE16]              <1> 	dw .no_handles_available
   720 0000165C [D316]              <1> 	dw .access_denied
   721 0000165E [E116]              <1> 	dw .invalid_handle
   722 00001660 [F016]              <1> 	dw .mcb_destroyed
   723 00001662 [FE16]              <1> 	dw .insufficient_memory
   724 00001664 [1217]              <1> 	dw .mcb_invalid
   725 00001666 [1E17]              <1> 	dw .environment_invalid
   726 00001668 [3217]              <1> 	dw .format_invalid
   727 0000166A [4117]              <1> 	dw .access_code_invalid
   728 0000166C [5517]              <1> 	dw .data_invalid
   729 0000166E [6217]              <1> 	dw .fixup_overflow
   730 00001670 [7117]              <1> 	dw .invalid_drive
   731 00001672 [7F17]              <1> 	dw .attempted_to_remove_current_directory
   732 00001674 [A517]              <1> 	dw .not_same_device
   733 00001676 [B517]              <1> 	dw .no_more_files
   734                              <1> .count equ ($ - .) / 2
   735 00001678 556E6B6E6F776E2065- <1> .unknown_error:		db "Unknown error",0
   735 00001681 72726F7200          <1>
   736 00001686 4E6F206572726F7200  <1> .no_error:		db "No error",0
   737 0000168F 496E76616C69642066- <1> .invalid_function:	db "Invalid function",0
   737 00001698 756E6374696F6E00    <1>
   738 000016A0 46696C65206E6F7420- <1> .file_not_found:	db "File not found",0
   738 000016A9 666F756E6400        <1>
   739 000016AF 50617468206E6F7420- <1> .path_not_found:	db "Path not found",0
   739 000016B8 666F756E6400        <1>
   740 000016BE 4E6F2068616E646C65- <1> .no_handles_available:	db "No handles available",0
   740 000016C7 7320617661696C6162- <1>
   740 000016D0 6C6500              <1>
   741 000016D3 416363657373206465- <1> .access_denied:		db "Access denied",0
   741 000016DC 6E69656400          <1>
   742 000016E1 496E76616C69642068- <1> .invalid_handle:	db "Invalid handle",0
   742 000016EA 616E646C6500        <1>
   743 000016F0 4D4342206465737472- <1> .mcb_destroyed:		db "MCB destroyed",0
   743 000016F9 6F79656400          <1>
   744 000016FE 496E73756666696369- <1> .insufficient_memory:	db "Insufficient memory",0
   744 00001707 656E74206D656D6F72- <1>
   744 00001710 7900                <1>
   745 00001712 4D434220696E76616C- <1> .mcb_invalid:		db "MCB invalid",0
   745 0000171B 696400              <1>
   746 0000171E 456E7669726F6E6D65- <1> .environment_invalid:	db "Environment invalid",0
   746 00001727 6E7420696E76616C69- <1>
   746 00001730 6400                <1>
   747 00001732 466F726D617420696E- <1> .format_invalid:	db "Format invalid",0
   747 0000173B 76616C696400        <1>
   748 00001741 41636365737320636F- <1> .access_code_invalid:	db "Access code invalid",0
   748 0000174A 646520696E76616C69- <1>
   748 00001753 6400                <1>
   749 00001755 4461746120696E7661- <1> .data_invalid:		db "Data invalid",0
   749 0000175E 6C696400            <1>
   750 00001762 4669787570206F7665- <1> .fixup_overflow:	db "Fixup overflow",0
   750 0000176B 72666C6F7700        <1>
   751 00001771 496E76616C69642064- <1> .invalid_drive:		db "Invalid drive",0
   751 0000177A 7269766500          <1>
   752 0000177F 417474656D70746564- <1> .attempted_to_remove_current_directory:		db "Attempted to remove current directory",0
   752 00001788 20746F2072656D6F76- <1>
   752 00001791 652063757272656E74- <1>
   752 0000179A 206469726563746F72- <1>
   752 000017A3 7900                <1>
   753 000017A5 4E6F742073616D6520- <1> .not_same_device:	db "Not same device",0
   753 000017AE 64657669636500      <1>
   754 000017B5 4E6F206D6F72652066- <1> .no_more_files:		db "No more files",0
   754 000017BE 696C657300          <1>
   755                              <1> 
   756                              <1> 
   757                              <1> %if 0
   758                              <1> 
   759                              <1> 	align 4
   760                              <1> init1_rploader_callback:	dw entry_iret, 70h
   761                              <1> %define load_sectors		(bp + bsBPB + bpbCHSSectors)
   762                              <1> %define load_heads		(bp + bsBPB + bpbCHSHeads)
   763                              <1> %define load_sectorsize		(bp + ldBytesPerSector)
   764                              <1> %define load_sectorsizepara	(bp + ldParaPerSector)
   765                              <1> %define load_sectorseg		(bp + ldSectorSeg)
   766                              <1> load_partition_cycle:		dw 0
   767                              <1> %define load_lba		(bp + ldHasLBA)
   768                              <1> %define load_unit		(bp + bsBPB + ebpbNew + bpbnBootUnit)
   769                              <1> load_current_partition:		db 0
   770                              <1> 
   771                              <1> %endif
   772                              <1> 
   773                              <1> 
   774                              <1> init1_disp_msg_asciz:
   775                              <1> disp_msg_asciz:
   776                              <1>  assume ds:nothing, es:nothing, ss:nothing
   777 000017C3 1E                  <1> 	push ds
   778 000017C4 56                  <1> 	push si
   779 000017C5 50                  <1> 	push ax
   780 000017C6 0E                  <1> 	 push cs
   781 000017C7 1F                  <1> 	 pop ds
   782                              <1>  assume ds:SYSINITGROUP
   783 000017C8 89D6                <1> 	mov si, dx
   784 000017CA E80400              <1> 	call disp_msg
   785 000017CD 58                  <1> 	pop ax
   786 000017CE 5E                  <1> 	pop si
   787 000017CF 1F                  <1> 	pop ds
   788                              <1>  assume ds:nothing
   789 000017D0 C3                  <1> 	retn
   790                              <1> 
   791                              <1> init1_disp_msg:
   792                              <1> disp_msg:
   793                              <1>  assume ds:nothing, es:nothing, ss:nothing
   794                              <1> @@:
   795 000017D1 AC                  <1> 	lodsb
   796 000017D2 84C0                <1> 	test al, al
   797 000017D4 7412                <1> 	jz @F
   798 000017D6 E80200              <1> 	call disp_al
   799 000017D9 EBF6                <1> 	jmp short @B
   800                              <1> 
   801                              <1> init1_disp_al:
   802                              <1> disp_al:
   803                              <1>  assume ds:nothing, es:nothing, ss:nothing
   804 000017DB 50                  <1> 	push ax
   805 000017DC 53                  <1> 	push bx
   806 000017DD 55                  <1> 	push bp
   807 000017DE B40E                <1> 	mov ah, 0Eh
   808 000017E0 BB0700              <1> 	mov bx, 7
   809 000017E3 CD10                <1> 	int 10h
   810 000017E5 5D                  <1> 	pop bp
   811 000017E6 5B                  <1> 	pop bx
   812 000017E7 58                  <1> 	pop ax
   813                              <1> @@:
   814 000017E8 C3                  <1> 	retn
   815                              <1> 
   816                              <1> 
   817                              <1> %if 0
   818                              <1> 
   819                              <1> sig_valid:
   820                              <1> 		; S0 +28
   821                              <1> ;	pushf	; +26
   822                              <1> 	sti
   823                              <1> 	cld
   824                              <1> 	push ax	; +24
   825                              <1> 	push bx	; +22
   826                              <1> 	push cx	; +20
   827                              <1> 	push dx	; +18
   828                              <1> 	push si	; +16
   829                              <1> 	push di	; +14
   830                              <1> 	push bp	; +12
   831                              <1> 	mov ax, sp
   832                              <1> 	add ax, 16
   833                              <1> 	push ax	; +10 SP
   834                              <1> 	xor ax, ax
   835                              <1> 	push ax	; +8 IP
   836                              <1> 	push cs	; +6
   837                              <1> 	push ds	; +4
   838                              <1> 	push es	; +2
   839                              <1> 	push ss	; +0
   840                              <1> %if _TEST_PAYLOAD
   841                              <1> 	mov si, sp
   842                              <1> 	 push ss
   843                              <1> 	 pop ds
   844                              <1> 	mov di, table
   845                              <1> 	 push cs
   846                              <1> 	 pop es
   847                              <1> loop_table:
   848                              <1> 	mov bx, [es:di + 0]
   849                              <1> 	mov al, 32
   850                              <1> 	call disp_al
   851                              <1> 	mov ax, [es:di + 2]
   852                              <1> 	call disp_al
   853                              <1> 	xchg al, ah
   854                              <1> 	call disp_al
   855                              <1> 	cmp bx, -1
   856                              <1> 	je @F
   857                              <1> 	mov al, '='
   858                              <1> 	call disp_al
   859                              <1> 	mov ax, [si + bx]
   860                              <1> 	call disp_ax_hex
   861                              <1> @@:
   862                              <1> 	add di, 4
   863                              <1> 	cmp di, table.end
   864                              <1> 	jb loop_table
   865                              <1> %endif
   866                              <1> 
   867                              <1> 
   868                              <1> init_mcb_chain:
   869                              <1> 	push cs
   870                              <1> 	pop ds
   871                              <1> 	push cs
   872                              <1> 	pop es
   873                              <1> 	mov ax, 60h			; where
   874                              <1> 	xor cx, cx			; owner
   875                              <1> 	mov bx, cs
   876                              <1> 	sub bx, ax			; size
   877                              <1> 	dec bx				; less 1
   878                              <1> 	sub bx, ( 16 		+ (dosentry_end - dosentry_start) 		+ DOSCODE_MCB_SIZE 		+ DOSCODE_SIZE 		+ 16 		+ (dosdata_end - dosdata_start) 		+ 16 		) >> 4
   886                              <1> 					; point at DOSENTRY MCB
   887                              <1> 	mov dx, "M" | (0 << 8)
   888                              <1> 	call init_an_mcb
   889                              <1> 
   890                              <1> 	mov bx, mcbtable
   891                              <1> 	mov ax, cs
   892                              <1> 	add ax, ( (init1_end - init1_start) 		+ 16 		+ (init2_end - init2_start) 		+ 16 		+ (init3_end - init3_start) 		+ 16 		) >> 4
   899                              <1> 	mov word [bx], ax
   900                              <1> 	mov word [bx + 2], -1
   901                              <1> 
   902                              <1> 	add bx, 4
   903                              <1> 	mov ax, ss
   904                              <1> 	mov word [bx], ax
   905                              <1> 	mov word [bx + 2], S_INITSTACKBPB
   906                              <1> 
   907                              <1> 	add bx, 4
   908                              <1> 	mov ax, [bp + lsvFATSeg]
   909                              <1> 	dec ax
   910                              <1> 	mov word [bx], ax
   911                              <1> 	mov word [bx + 2], S_INITFATSEG
   912                              <1> 
   913                              <1> 	add bx, 4
   914                              <1> 	mov ax, [bp + ldSectorSeg]
   915                              <1> 	dec ax
   916                              <1> 	mov word [bx], ax
   917                              <1> 	mov word [bx + 2], S_INITSECTORSEG
   918                              <1> 
   919                              <1> 	add bx, 4
   920                              <1> 	mov dx, [bp + ldMemoryTop]	; => in front of RPL, or end of memory
   921                              <1> 	mov word [bx], dx
   922                              <1> 	mov word [bx + 2], S_EXCLDUMA
   923                              <1> 
   924                              <1> 	int 12h
   925                              <1> 	mov cl, 6
   926                              <1> 	shl ax, cl			; => after RPL, or same as ldMemoryTop
   927                              <1> 	cmp dx, ax
   928                              <1> 	je @F
   929                              <1> 	mov word [bx + 2], 'R' << 8
   930                              <1> 
   931                              <1> 	add bx, 4
   932                              <1> 	mov word [bx], ax
   933                              <1> 	mov word [bx + 2], S_EXCLDUMA
   934                              <1> @@:
   935                              <1> 	
   936                              <1> 
   937                              <1> .next_bubble:
   938                              <1> 	mov bx, mcbtable
   939                              <1> 	xor cx, cx
   940                              <1> .next:
   941                              <1> 	mov ax, word [bx]
   942                              <1> 	cmp ax, word [bx + 4]
   943                              <1> 	jbe @F
   944                              <1> 	push word [bx]
   945                              <1> 	push word [bx + 2]
   946                              <1> 	push word [bx + 4]
   947                              <1> 	push word [bx + 6]
   948                              <1> 	pop word [bx + 2]
   949                              <1> 	pop word [bx]
   950                              <1> 	pop word [bx + 6]
   951                              <1> 	pop word [bx + 4]
   952                              <1> 	inc cx
   953                              <1> @@:
   954                              <1> 	add bx, 4
   955                              <1> 	cmp word [bx], -1
   956                              <1> 	jne .next
   957                              <1> 	test cx, cx
   958                              <1> 	jnz .next_bubble
   959                              <1> 
   960                              <1> init_end_mcb_chain:
   961                              <1> 	mov si, mcbtable
   962                              <1> .next:
   963                              <1> 	mov ax, word [si]
   964                              <1> 	dec ax			; = where to place MCB
   965                              <1> 	mov dx, word [si + 2]	; dl = S MCB type, -1 if none,
   966                              <1> 				;  0 (S_OTHER) if RPL (dh = 'R' then)
   967                              <1> 	mov cx, 8		; owner = 8
   968                              <1> 	cmp dl, -1		; none type ?
   969                              <1> 	jne @F			; no -->
   970                              <1> 	xor cx, cx		; yes, owner = 0
   971                              <1> @@:
   972                              <1> 	push dx
   973                              <1> 	xchg dl, dh		; dh = S MCB type
   974                              <1> 	mov dl, "M"		; dl = MCB signature
   975                              <1> 	mov di, word [si + 4]
   976                              <1> 	mov bx, di
   977                              <1> 	sub bx, ax
   978                              <1> 	dec bx
   979                              <1> 	dec bx			; size = to next
   980                              <1> 	cmp di, -1		; any next ?
   981                              <1> 	jne @F			; yes -->
   982                              <1> 	mov dl, "Z"		; else, mcbSignature = "Z"
   983                              <1> 	xor bx, bx		; size = zero
   984                              <1> @@:
   985                              <1> 	call init_an_mcb
   986                              <1> 	pop dx
   987                              <1> 	cmp dx, 'R' << 8
   988                              <1> 	jne @F
   989                              <1> 	push ds
   990                              <1> 	mov ds, ax
   991                              <1> 	mov word [mcbName], "RP"
   992                              <1> 	mov word [mcbName + 2], "L"
   993                              <1> 	pop ds
   994                              <1> @@:
   995                              <1> 	add si, 4
   996                              <1> 	cmp word [si], -1
   997                              <1> 	jne .next
   998                              <1> 
   999                              <1> 	mov bx, cs
  1000                              <1> 	sub bx, ((dosdata_end - dosdata_start) + 16) >> 4
  1001                              <1> 	mov ds, bx
  1002                              <1> 	mov word [first_umcb], ax
  1003                              <1> 
  1004                              <1> 
  1005                              <1> init_dosentry:
  1006                              <1> 	mov ax, cs
  1007                              <1> 	sub ax, ( 16 		+ (dosentry_end - dosentry_start) 		+ DOSCODE_MCB_SIZE 		+ DOSCODE_SIZE 		+ 16 		+ (dosdata_end - dosdata_start) 		+ 16) >> 4
  1014                              <1> 	mov dx, 6Fh
  1015                              <1> 	mov cx, (16 + (dosentry_end - dosentry_start)) >> 4
  1016                              <1> 	call init1_movp			; move DOSENTRY to 70h:0
  1017                              <1> 
  1018                              <1> 	add cx, dx			; => behind DOSENTRY
  1019                              <1> 	mov ax, cx
  1020                              <1> 	mov bx, cs
  1021                              <1> 	sub bx, ax			; size
  1022                              <1> 	dec bx				; less 1
  1023                              <1> 	sub bx, ( DOSCODE_MCB_SIZE 		+ DOSCODE_SIZE 		+ 16 		+ (dosdata_end - dosdata_start) 		+ 16 		) >> 4			; ax + bx + 1 => DOSCODE MCB
  1029                              <1> 	xor cx, cx			; owner
  1030                              <1> 	mov dx, "M" | (0 << 8)
  1031                              <1> 	call init_an_mcb
  1032                              <1> 
  1033                              <1> 	mov ax, 60h			; where
  1034                              <1> 	xor cx, cx			; owner
  1035                              <1> 	mov bx, 6Fh
  1036                              <1> 	sub bx, ax			; size
  1037                              <1> 	dec bx				; less 1
  1038                              <1> 					; ax + bx + 1 => point at DOSENTRY MCB
  1039                              <1> 	mov dx, "M" | (0 << 8)
  1040                              <1> 	call init_an_mcb
  1041                              <1> 
  1042                              <1> 
  1043                              <1> listnames:
  1044                              <1> 	push cs
  1045                              <1> 	pop es
  1046                              <1> 	mov bx, msg.names
  1047                              <1> 
  1048                              <1> %assign _NEW_BPB_NAME_SCAN_SIZE 1
  1049                              <1> %if _NEW_BPB_NAME_SCAN_SIZE
  1050                              <1> 	mov ax, ss
  1051                              <1> 	dec ax
  1052                              <1> 	mov ds, ax
  1053                              <1> 	mov cx, word [mcbSize]	; get size of stack/BPB
  1054                              <1> 	shl cx, 1
  1055                              <1> 	jc @F
  1056                              <1> 	shl cx, 1
  1057                              <1> 	jc @F
  1058                              <1> 	shl cx, 1
  1059                              <1> 	jc @F
  1060                              <1> 	shl cx, 1		; <<= 4, *= 16, to byte offset
  1061                              <1> 	jnc @FF
  1062                              <1> @@:
  1063                              <1> 	xor cx, cx		; 0 = full 64 KiB
  1064                              <1> @@:
  1065                              <1> %endif
  1066                              <1> 
  1067                              <1> 	push ss
  1068                              <1> 	pop ds
  1069                              <1> 	lea si, [bp + bsBPB + ebpbNew + BPBN_size]
  1070                              <1> %if _NEW_BPB_NAME_SCAN_SIZE
  1071                              <1> 	sub cx, si		; byte offset end - byte offset start = length
  1072                              <1> 	dec cx
  1073                              <1> 	dec cx			; don't scan into AA55h sig
  1074                              <1> %else
  1075                              <1> 	mov cx, (512 - (bsBPB + ebpbNew + BPBN_size)) - 2
  1076                              <1> 						; -2 = AA55h sig
  1077                              <1> 	cmp word [bp + bsBPB + bpbSectorsPerFAT], 0
  1078                              <1> 	je @F
  1079                              <1> 	mov cx, (512 + (ebpbNew - bpbNew) - (bsBPB + ebpbNew + BPBN_size)) - 2
  1080                              <1> @@:
  1081                              <1> %endif
  1082                              <1> .nextname:
  1083                              <1> 	call findname
  1084                              <1> 	 lahf
  1085                              <1> %if _TEST_PAYLOAD
  1086                              <1> 	mov dx, [cs:bx]
  1087                              <1> 	call disp_msg_asciz
  1088                              <1> 	mov dx, msg.name_before
  1089                              <1> 	call disp_msg_asciz
  1090                              <1> 	 sahf
  1091                              <1> 	 jc @F		; skip quote if no name -->
  1092                              <1> 	 mov dx, msg.name_quote
  1093                              <1> 	 call disp_msg_asciz
  1094                              <1> @@:
  1095                              <1> 	mov dx, msg.foundname
  1096                              <1> 	call disp_msg_asciz
  1097                              <1> 	 sahf
  1098                              <1> 	 jc @F		; skip quote if no name -->
  1099                              <1> 	 mov dx, msg.name_quote
  1100                              <1> 	 call disp_msg_asciz
  1101                              <1> @@:
  1102                              <1> 	mov dx, msg.name_after
  1103                              <1> 	call disp_msg_asciz
  1104                              <1> 	 sahf
  1105                              <1> %endif
  1106                              <1> 	 mov ax, 0
  1107                              <1> 	 jc @F		; set to zero if no name -->
  1108                              <1> 	 lea ax, [si - 11]	; -> name in buffer
  1109                              <1> @@:
  1110                              <1> 	 mov word [cs:bx + 2], ax	; -> name in buffer, or 0
  1111                              <1> 	add bx, 4
  1112                              <1> 	cmp word [cs:bx], 0
  1113                              <1> 	jne .nextname
  1114                              <1> 
  1115                              <1> 
  1116                              <1> set_bootname.filename:
  1117                              <1> 	mov si, word [cs:msg.names + 2]
  1118                              <1> 	test si, si
  1119                              <1> 	jnz @F
  1120                              <1> 
  1121                              <1> 	mov si, msg.foundname_default
  1122                              <1> 	jmp @FF
  1123                              <1> 
  1124                              <1> @@:
  1125                              <1> 	call convert_name_to_asciz
  1126                              <1> 
  1127                              <1> 	mov si, msg.foundname
  1128                              <1> @@:
  1129                              <1> 	push cs
  1130                              <1> 	pop ds				; ds:si -> name
  1131                              <1> 
  1132                              <1> 	mov cx, (8 + 1 + 3) >> 1
  1133                              <1> 		; note: last byte is already initialised to zero
  1134                              <1> 
  1135                              <1> 	mov bx, cs
  1136                              <1> 	sub bx, ((dosdata_end - dosdata_start) + 16) >> 4
  1137                              <1> 	mov es, bx
  1138                              <1> 	mov di, bootname.filename	; es:di -> buffer in DOSDATA
  1139                              <1> 	rep movsw
  1140                              <1> 
  1141                              <1> 
  1142                              <1> store_boot_partition:
  1143                              <1> 	push cs
  1144                              <1> 	pop ds
  1145                              <1> 	mov al, [bp + bsBPB + ebpbNew + bpbnBootUnit]
  1146                              <1> 	mov byte [boot_unit], al
  1147                              <1> 	mov ax, [bp + bsBPB + bpbHiddenSectors]
  1148                              <1> 	mov dx, [bp + bsBPB + bpbHiddenSectors + 2]
  1149                              <1> 	mov word [boot_partition], ax
  1150                              <1> 	mov word [boot_partition + 2], dx
  1151                              <1> 
  1152                              <1> scan_for_partitions:
  1153                              <1> 	lea sp, [bp + LOADDATA2]	; allow space for LOADDATA2
  1154                              <1> 	push cs
  1155                              <1> 	pop ds
  1156                              <1> 	and word [bp + bsBPB + bpbHiddenSectors], 0
  1157                              <1> 	and word [bp + bsBPB + bpbHiddenSectors + 2], 0
  1158                              <1> 
  1159                              <1> scan_diskettes:
  1160                              <1> 	mov dl, 80h
  1161                              <1> 	mov ah, 08
  1162                              <1> 	stc
  1163                              <1> 	int 13h			; get number of fixed disks
  1164                              <1> 	mov bx, 0
  1165                              <1> 	jc @F			; fail ? then set bx = 0 and try diskettes
  1166                              <1> 	mov bl, dl
  1167                              <1> @@:
  1168                              <1> 	mov dl, 0
  1169                              <1> 	mov ah, 08h
  1170                              <1> 	stc
  1171                              <1> 	int 13h			; get number of diskettes
  1172                              <1> 	mov ch, 0
  1173                              <1> 	mov cl, dl		; cx = result
  1174                              <1> 	jc @F			; fail -->
  1175                              <1> 	cmp bx, cx		; differs from number of fixed disks ?
  1176                              <1> 	jne @FF			; yes, use -->
  1177                              <1> @@:
  1178                              <1> 				; else,
  1179                              <1> 	int 11h			; query int 11 "get equipment list"
  1180                              <1> 	xor cx, cx		; initialise to zero
  1181                              <1> 	test ax, 1		; any specified ?
  1182                              <1> 	jz @F			; no -->
  1183                              <1> 
  1184                              <1> 	mov cl, al
  1185                              <1> 	rol cl, 1
  1186                              <1> 	rol cl, 1		; get bits 6 & 7
  1187                              <1> 	and cl, 3		; separate
  1188                              <1> 	inc cx			; +1
  1189                              <1> @@:
  1190                              <1> 	xor dl, dl
  1191                              <1> 	call scan_given_partitions
  1192                              <1> 
  1193                              <1> 		; manufacture units 0 and 1 if not existant
  1194                              <1> 	mov si, word [fsparm_pointer]
  1195                              <1> 	cmp si, fsparm + FSPARM_size*2	; got at least 2 diskettes ?
  1196                              <1> 	jae @FF				; yes -->
  1197                              <1> 	cmp si, fsparm + FSPARM_size	; got 1 diskette ?
  1198                              <1> 	jae @F				; yes -->
  1199                              <1> 	mov di, si
  1200                              <1> 	push cs
  1201                              <1> 	pop es
  1202                              <1> 	xor ax, ax
  1203                              <1> 	mov cx, FSPARM_size >> 1
  1204                              <1> 	rep stosw			; initialise
  1205                              <1> 	mov byte [si + fspUnit], 0
  1206                              <1> 	mov word [si + fspSectorSize], 512
  1207                              <1> 	mov byte [si + fspType], -1	; initialise to unit 0
  1208                              <1> 	inc byte [fsparm_number]
  1209                              <1> 	add si, FSPARM_size		; -> next
  1210                              <1> @@:
  1211                              <1> 	mov di, si
  1212                              <1> 	push cs
  1213                              <1> 	pop es
  1214                              <1> 	xor ax, ax
  1215                              <1> 	mov cx, FSPARM_size >> 1
  1216                              <1> 	rep stosw
  1217                              <1> 	mov byte [si + fspUnit], 1
  1218                              <1> 	mov word [si + fspSectorSize], 512
  1219                              <1> 	mov byte [si + fspType], -1
  1220                              <1> 	inc byte [fsparm_number]
  1221                              <1> 	add si, FSPARM_size
  1222                              <1> 	mov word [fsparm_pointer], si
  1223                              <1> @@:
  1224                              <1> 
  1225                              <1> scan_fixed_disk_partitions:
  1226                              <1> 	mov dl, 80h
  1227                              <1> 	mov ah, 08h
  1228                              <1> 	stc
  1229                              <1> 	int 13h				; get number of fixed disks
  1230                              <1> 	mov ch, 0
  1231                              <1> 	mov cl, dl
  1232                              <1> 	jnc @F				; success -->
  1233                              <1> 
  1234                              <1> 	mov ax, 40h
  1235                              <1> 	mov es, ax
  1236                              <1> 	mov cl, byte [es:bdaNumberFixedDisks]	; get from BDA instead
  1237                              <1> @@:
  1238                              <1> 	mov dl, 80h
  1239                              <1> 	call scan_given_partitions
  1240                              <1> 
  1241                              <1> display_excess_partitions:
  1242                              <1> 	push cs
  1243                              <1> 	pop ds
  1244                              <1> 	mov ax, word [fsparm_excess]
  1245                              <1> 	test ax, ax
  1246                              <1> 	jz @F
  1247                              <1> 	mov dx, msg.excess_partitions_1
  1248                              <1> 	call disp_msg_asciz
  1249                              <1> 	call disp_ax_dec
  1250                              <1> 	mov dx, msg.excess_partitions_2
  1251                              <1> 	call disp_msg_asciz
  1252                              <1> @@:
  1253                              <1> 
  1254                              <1> 
  1255                              <1> display_partitions:
  1256                              <1> 	push cs
  1257                              <1> 	pop ds
  1258                              <1> 	mov byte [boot_drive], -1
  1259                              <1> 	xor cx, cx
  1260                              <1> 	mov cl, byte [fsparm_number]
  1261                              <1> 	mov si, fsparm
  1262                              <1> 	mov bx, 'A'
  1263                              <1> 	test cx, cx
  1264                              <1> 	jz .end
  1265                              <1> .loop:
  1266                              <1> 
  1267                              <1> 	mov al, bl
  1268                              <1> 	call disp_al
  1269                              <1> 
  1270                              <1> 	mov dx, msg.list_partition_1
  1271                              <1> 	call disp_msg_asciz
  1272                              <1> 	mov al, [si + fspUnit]
  1273                              <1> 
  1274                              <1> 	push ax
  1275                              <1> 	cmp al, byte [boot_unit]
  1276                              <1> 	jne @FF
  1277                              <1> 
  1278                              <1> 	cmp byte [boot_drive], -1	; found any on this unit yet ?
  1279                              <1> 	jne @F				; yes -->
  1280                              <1> 	mov byte [boot_drive], bh	; default initialise to first part
  1281                              <1> @@:
  1282                              <1> 
  1283                              <1> 	mov ax, [si + fspStart]		; does it match the partition ?
  1284                              <1> 	mov dx, [si + fspStart + 2]
  1285                              <1> 	cmp word [boot_partition], ax
  1286                              <1> 	jne @F
  1287                              <1> 	cmp word [boot_partition + 2], dx
  1288                              <1> 	jne @F				; no -->
  1289                              <1> 
  1290                              <1> 	mov byte [boot_drive], bh	; yes, store this drive
  1291                              <1> @@:
  1292                              <1> 	pop ax
  1293                              <1> 
  1294                              <1> 	mov dl, 'h'
  1295                              <1> 	test al, 80h
  1296                              <1> 	jnz @F
  1297                              <1> 	mov dl, 'f'
  1298                              <1> @@:
  1299                              <1> 	and al, ~80h
  1300                              <1> 	add al, 'a'
  1301                              <1> 	cmp al, 'z'
  1302                              <1> 	jbe @F
  1303                              <1> 
  1304                              <1> 	mov al, 'u'
  1305                              <1> 	call disp_al
  1306                              <1> 	mov al, [si + fspUnit]
  1307                              <1> 	call disp_al_hex
  1308                              <1> 	mov al, '_'
  1309                              <1> 	call disp_al
  1310                              <1> 
  1311                              <1> 	jmp @FF
  1312                              <1> 
  1313                              <1> @@:
  1314                              <1> 	push ax
  1315                              <1> 	mov al, dl
  1316                              <1> 	call disp_al
  1317                              <1> 	mov al, 'd'
  1318                              <1> 	call disp_al
  1319                              <1> 	pop ax
  1320                              <1> 	call disp_al
  1321                              <1> 
  1322                              <1> @@:
  1323                              <1> 	xor ax, ax
  1324                              <1> 	mov al, [si + fspPartition]
  1325                              <1> 	test ax, ax
  1326                              <1> 	jz .disp_2_blank
  1327                              <1> 
  1328                              <1> 	call disp_ax_dec
  1329                              <1> 	cmp ax, 10
  1330                              <1> 	jb .disp_1_blank
  1331                              <1> 	jmp .disp_0_blank
  1332                              <1> 
  1333                              <1> .disp_2_blank:
  1334                              <1> 	mov al, 32
  1335                              <1> 	call disp_al
  1336                              <1> .disp_1_blank:
  1337                              <1> 	mov al, 32
  1338                              <1> 	call disp_al
  1339                              <1> .disp_0_blank:
  1340                              <1> 
  1341                              <1> 	mov dx, msg.list_partition_4
  1342                              <1> 	call disp_msg_asciz
  1343                              <1> 
  1344                              <1> 	mov ax, [si + fspStart]
  1345                              <1> 	mov dx, [si + fspStart + 2]
  1346                              <1> 	call disp_dxax_hex
  1347                              <1> 
  1348                              <1> 	push dx
  1349                              <1> 	mov dx, msg.list_partition_5
  1350                              <1> 	call disp_msg_asciz
  1351                              <1> 	pop dx
  1352                              <1> 
  1353                              <1> 	 push cx
  1354                              <1> 	 push bx
  1355                              <1> 	mov cx, [si + fspSectorSize]
  1356                              <1> 	mov bx, 4+4
  1357                              <1> 	call disp_dxax_times_cx_width_bx_size
  1358                              <1> 
  1359                              <1> 	mov dx, msg.list_partition_6
  1360                              <1> 	call disp_msg_asciz
  1361                              <1> 
  1362                              <1> 	mov ax, [si + fspLength]
  1363                              <1> 	mov dx, [si + fspLength + 2]
  1364                              <1> 	call disp_dxax_hex
  1365                              <1> 
  1366                              <1> 	push dx
  1367                              <1> 	mov dx, msg.list_partition_7
  1368                              <1> 	call disp_msg_asciz
  1369                              <1> 	pop dx
  1370                              <1> 
  1371                              <1> 	call disp_dxax_times_cx_width_bx_size
  1372                              <1> 	 pop bx
  1373                              <1> 	 pop cx
  1374                              <1> 
  1375                              <1> 	mov dx, msg.list_partition_8
  1376                              <1> 	call disp_msg_asciz
  1377                              <1> 
  1378                              <1> 	mov al, [si + fspBoot]
  1379                              <1> 	test al, 80h
  1380                              <1> 	mov al, 32
  1381                              <1> 	jz @F
  1382                              <1> 	mov al, 'B'
  1383                              <1> @@:
  1384                              <1> 	call disp_al
  1385                              <1> 
  1386                              <1> 	mov dx, msg.list_partition_9
  1387                              <1> 	call disp_msg_asciz
  1388                              <1> 
  1389                              <1> 	xor ax, ax
  1390                              <1> 	mov al, byte [si + fspType]
  1391                              <1> 	call disp_al_hex
  1392                              <1> 
  1393                              <1> 	mov dx, msg.list_partition_10
  1394                              <1> 	call disp_msg_asciz
  1395                              <1> 
  1396                              <1> 	push si
  1397                              <1> 	mov si, pt_types
  1398                              <1> .types_loop:
  1399                              <1> 	cmp word [si], -1
  1400                              <1> 	je .types_unknown
  1401                              <1> 	cmp word [si], ax
  1402                              <1> 	je .types_known
  1403                              <1> 	add si, 4
  1404                              <1> 	jmp .types_loop
  1405                              <1> 
  1406                              <1> .types_known:
  1407                              <1> 	mov dx, word [si + 2]
  1408                              <1> 	jmp .types_common
  1409                              <1> 
  1410                              <1> .types_unknown:
  1411                              <1> 	mov dx, ptmsg_unknown
  1412                              <1> .types_common:
  1413                              <1> 	pop si
  1414                              <1> 	call disp_msg_asciz
  1415                              <1> 
  1416                              <1> 	mov dx, msg.list_partition_11
  1417                              <1> 	call disp_msg_asciz
  1418                              <1> 
  1419                              <1> 	add si, FSPARM_size
  1420                              <1> 	add bx, 0101h
  1421                              <1> 	loop .loop_jmp
  1422                              <1> 	jmp .end
  1423                              <1> .loop_jmp:
  1424                              <1> 	jmp .loop
  1425                              <1> .end:
  1426                              <1> 
  1427                              <1> 	mov al, byte [boot_drive]
  1428                              <1> 	cmp al, -1
  1429                              <1> 	jne @F
  1430                              <1> 	mov al, [boot_unit]
  1431                              <1> 	cmp al, 2
  1432                              <1> 	jb @F
  1433                              <1> 	mov al, 2
  1434                              <1> @@:
  1435                              <1> 	mov byte [boot_drive], al
  1436                              <1> 
  1437                              <1> 	mov bx, cs
  1438                              <1> 	sub bx, ((dosdata_end - dosdata_start) + 16) >> 4
  1439                              <1> 	mov es, bx
  1440                              <1> 
  1441                              <1> 	mov byte [es:_RxDOS_CurrentDrive], al
  1442                              <1> 	inc ax
  1443                              <1> 	mov byte [es:bootdrive], al
  1444                              <1> 
  1445                              <1> 	mov di, bootname.drive
  1446                              <1> 	add al, 'A'-1
  1447                              <1> 	stosb
  1448                              <1> 
  1449                              <1> 
  1450                              <1> display_bootname:
  1451                              <1> 	mov dx, msg.bootname_1
  1452                              <1> 	call disp_msg_asciz
  1453                              <1> 	push es
  1454                              <1> 	pop ds
  1455                              <1> 	mov si, bootname
  1456                              <1> 	call disp_msg
  1457                              <1> 	mov dx, msg.bootname_2
  1458                              <1> 	call disp_msg_asciz
  1459                              <1> 
  1460                              <1> 
  1461                              <1> setup_rploader_callback:
  1462                              <1> 	xor ax, ax
  1463                              <1> 	mov es, ax
  1464                              <1> 	lds si, [es:2Fh * 4]
  1465                              <1> 	push si
  1466                              <1> 	 push cs
  1467                              <1> 	 pop es
  1468                              <1> 	mov di, init1_msg.rploader
  1469                              <1> 	mov cx, init1_msg.rploader_size
  1470                              <1> 	add si, 3
  1471                              <1> 	repe cmpsb
  1472                              <1> 	pop si
  1473                              <1> 	jne .none
  1474                              <1> 	mov word [cs:init1_rploader_callback], si
  1475                              <1> 	mov word [cs:init1_rploader_callback + 2], ds
  1476                              <1> .none:
  1477                              <1> 
  1478                              <1> 
  1479                              <1> save_interrupts:
  1480                              <1> 	mov dx, 70h
  1481                              <1> 	mov ds, dx
  1482                              <1> 	xor ax, ax
  1483                              <1> 	mov es, ax
  1484                              <1> 	mov si, InterruptRestorationTable
  1485                              <1> .loop:
  1486                              <1> 	xor ax, ax
  1487                              <1> 	lodsb
  1488                              <1> 	cmp al, -1
  1489                              <1> 	je .end
  1490                              <1> 	xchg ax, bx
  1491                              <1> 	add bx, bx
  1492                              <1> 	add bx, bx
  1493                              <1> 	push word [es:bx + 2]
  1494                              <1> 	push word [es:bx]
  1495                              <1> 	pop word [si]
  1496                              <1> 	pop word [si + 2]
  1497                              <1> 	add si, 4
  1498                              <1> 	jmp .loop
  1499                              <1> .end:
  1500                              <1> 
  1501                              <1> 
  1502                              <1> 		; ds = 70h
  1503                              <1> set_dos_segments:
  1504                              <1> 	mov bx, cs
  1505                              <1> 	sub bx, ((dosdata_end - dosdata_start) + 16) >> 4
  1506                              <1> 	mov word [dosentry_to_dosdata_segment], bx
  1507                              <1> 	mov es, bx
  1508                              <1> %if !_COMBINED_DOSDATA_DOSCODE
  1509                              <1>  %if _RELOCATEDOSCODE
  1510                              <1> 	mov cx, cs
  1511                              <1> 	sub cx, ( (doscode_end - doscode_start) 		+ 16 		+ (dosdata_end - dosdata_start) 		+ 16 		+ 40h) >> 4
  1516                              <1>  %else
  1517                              <1> 	mov cx, 70h
  1518                              <1>  %endif
  1519                              <1> %else
  1520                              <1> 	mov cx, bx
  1521                              <1> %endif
  1522                              <1> 	mov word [es:dosdata_to_doscode_segment], cx
  1523                              <1> 	mov ax, word [bp + ldSectorSeg]
  1524                              <1> 	mov word [es:dosdata_to_diskbuffer_segment], ax
  1525                              <1> 	mov ax, word [bp + ldMemoryTop]
  1526                              <1> 	mov word [es:_RxDOS_MaxMemory], ax
  1527                              <1> 	mov word [es:p_buffer_info_record + 2], bx
  1528                              <1> 
  1529                              <1> 
  1530                              <1> 		; ds = 70h
  1531                              <1> 		; bx = DOSDATA
  1532                              <1> set_interrupts:
  1533                              <1> 	xor ax, ax
  1534                              <1> 	mov es, ax
  1535                              <1> 	mov word [es:21h * 4], i21
  1536                              <1> 	mov word [es:21h * 4 + 2], ds
  1537                              <1> 
  1538                              <1> %imacro setint 2.nolist
  1539                              <1> 	mov dx, %1
  1540                              <1> 	mov ax, (25h << 8) | %2
  1541                              <1> 	int 21h
  1542                              <1> %endmacro
  1543                              <1> 
  1544                              <1> 	clc
  1545                              <1> 	int3
  1546                              <1> 	jc .skip_ints_00_06
  1547                              <1> 	setint i00, 00h
  1548                              <1> 	setint entry_iret, 01h
  1549                              <1> 	setint entry_iret, 03h
  1550                              <1> 	setint i06, 06h
  1551                              <1> .skip_ints_00_06:
  1552                              <1> 	setint entry_iret, 02h
  1553                              <1> 	setint entry_iret, 04h
  1554                              <1> 	setint entry_iret, 05h
  1555                              <1> 	setint entry_iret, 07h
  1556                              <1> 	setint entry_iret, 33h
  1557                              <1> 	setint i19, 19h
  1558                              <1> 	setint i20, 20h
  1559                              <1> 		; i21 set prior by direct IVT modification
  1560                              <1> 	setint entry_iret, 22h
  1561                              <1> 	setint i23, 23h
  1562                              <1> 	setint i24, 24h
  1563                              <1> 	setint i25, 25h
  1564                              <1> 	setint i26, 26h
  1565                              <1> 	setint i27, 27h
  1566                              <1> 	setint i28, 28h
  1567                              <1> 	setint i29, 29h
  1568                              <1> 	setint entry_iret, 2Ah
  1569                              <1> 	setint entry_iret, 2Bh
  1570                              <1> 	setint entry_iret, 2Ch
  1571                              <1> 	setint entry_iret, 2Dh
  1572                              <1> 	setint entry_iret, 2Eh
  1573                              <1> 	setint i2F, 2Fh
  1574                              <1> 
  1575                              <1> 	mov byte [es:30h * 4], 0EAh
  1576                              <1> 	mov word [es:30h * 4 + 1], call5
  1577                              <1> 	mov word [es:30h * 4 + 3], ds
  1578                              <1> 	mov byte [es:30h * 4 + 5], 0
  1579                              <1> 	mov word [es:30h * 4 + 6], bx	; DR-DOS compatible DOSDATA reference
  1580                              <1> 
  1581                              <1> 	mov ax, 5803h
  1582                              <1> 	xor bx, bx
  1583                              <1> 	int 21h				; disable UMB link
  1584                              <1> 		; As we have an UMCB, this sets the LMCB linking to it to "Z".
  1585                              <1> 
  1586                              <1> 
  1587                              <1> 		; ds = 70h
  1588                              <1> initialise_psp:
  1589                              <1> 	push ds
  1590                              <1> 	mov ax, cs
  1591                              <1> 	add ax, ( (init1_end - init1_start) 		+ 16 		+ (init2_end - init2_start) 		+ 16 		) >> 4			; => INIT3 (PSP)
  1596                              <1> 	mov ds, ax
  1597                              <1> 	mov word [pspInt22 + 2], ax
  1598                              <1> 	mov word [pspParent], ax
  1599                              <1> 	mov word [pspStack + 2], ax
  1600                              <1> 	mov word [pspPHTAddress + 2], ax
  1601                              <1> 
  1602                              <1> 	mov bx, ax
  1603                              <1> 	mov cl, S_ENVIRONMENT
  1604                              <1> 	mov ax, _INIT_ENV_SIZE
  1605                              <1> 	call init1_alloc_s_mcb_top
  1606                              <1> 	mov word [pspEnvironment], es
  1607                              <1> 
  1608                              <1> 	pop ds
  1609                              <1> 	mov es, word [dosentry_to_dosdata_segment]
  1610                              <1> 	mov word [es:_RxDOS_CurrentPSP], bx
  1611                              <1> 
  1612                              <1> 
  1613                              <1> call_rploader_phase_1:
  1614                              <1> 	mov dx, 1
  1615                              <1> 	call init1_call_rploader
  1616                              <1> 
  1617                              <1> 
  1618                              <1> initialise_upb_chain:
  1619                              <1> 	xor cx, cx
  1620                              <1> 	mov cl, byte [cs:fsparm_number]
  1621                              <1> 	mov ax, DISKBLOCK_size
  1622                              <1> 	mul cx
  1623                              <1> 	test dx, dx
  1624                              <1> 	jz @F
  1625                              <1> 
  1626                              <1> 	push cs
  1627                              <1> 	pop ds
  1628                              <1> 	mov si, init1_msg.internal_error_upb
  1629                              <1> 	call init1_disp_msg
  1630                              <1> 	jmp init1_reboot_prompt
  1631                              <1> 
  1632                              <1> @@:
  1633                              <1> 	 push cx
  1634                              <1> 	push cx
  1635                              <1> 	mov cl, S_UPB
  1636                              <1> 	call init1_alloc_s_mcb_top
  1637                              <1> 	pop cx
  1638                              <1> 
  1639                              <1> 	mov dx, 70h
  1640                              <1> 	mov ds, dx
  1641                              <1> 	mov ds, word [dosentry_to_dosdata_segment]
  1642                              <1> 	mov si, ptrStartBlockedDeviceTable - _dskNextPointer	; -> -> UPB
  1643                              <1> 	mov bx, fsparm
  1644                              <1> 	xor ax, ax
  1645                              <1> 
  1646                              <1> 	mov word [si + _dskNextPointer], -1
  1647                              <1> 	mov word [si + _dskNextPointer + 2], -1
  1648                              <1> 	test cx, cx
  1649                              <1> 	jz .end
  1650                              <1> 
  1651                              <1> 		; es:di -> next UPB to initialise
  1652                              <1> 		; ds:si -> previous UPB (_dskNextPointer uninitialised)
  1653                              <1> .next:
  1654                              <1> 	mov al, [cs:bx + fspUnit]
  1655                              <1> 	mov byte [es:di + _dskPhysDriveNumber], al
  1656                              <1> 	mov byte [es:di + _dskDOSLogicalDiskUnit], ah
  1657                              <1> 
  1658                              <1> 	push ax
  1659                              <1> 
  1660                              <1> 	mov al, byte [cs:bx + fspType]
  1661                              <1> 	mov byte [es:di + _dskFATSystemType], al
  1662                              <1> 
  1663                              <1> 	push word [cs:bx + fspStart + 2]
  1664                              <1> 	push word [cs:bx + fspStart]
  1665                              <1> 	pop word [es:di + _dskBPB + bpbHiddenSectors]
  1666                              <1> 	pop word [es:di + _dskBPB + bpbHiddenSectors + 2]
  1667                              <1> 	and word [es:di + _dskBPB + bpbTotalSectors], 0
  1668                              <1> 	push word [cs:bx + fspLength + 2]
  1669                              <1> 	push word [cs:bx + fspLength]
  1670                              <1> 	pop word [es:di + _dskBPB + bpbTotalSectorsLarge]
  1671                              <1> 	pop word [es:di + _dskBPB + bpbTotalSectorsLarge + 2]
  1672                              <1> 	push word [cs:bx + fspSectorSize]
  1673                              <1> 	pop word  [es:di + _dskBPB + bpbBytesPerSector]
  1674                              <1> 
  1675                              <1> 	push word [cs:bx + fspStart + 2]
  1676                              <1> 	push word [cs:bx + fspStart]
  1677                              <1> 	pop word [es:di + _dskDefaultBPB + bpbHiddenSectors]
  1678                              <1> 	pop word [es:di + _dskDefaultBPB + bpbHiddenSectors + 2]
  1679                              <1> 	and word [es:di + _dskDefaultBPB + bpbTotalSectors], 0
  1680                              <1> 	push word [cs:bx + fspLength + 2]
  1681                              <1> 	push word [cs:bx + fspLength]
  1682                              <1> 	pop word [es:di + _dskDefaultBPB + bpbTotalSectorsLarge]
  1683                              <1> 	pop word [es:di + _dskDefaultBPB + bpbTotalSectorsLarge + 2]
  1684                              <1> 	push word [cs:bx + fspSectorSize]
  1685                              <1> 	pop word  [es:di + _dskDefaultBPB + bpbBytesPerSector]
  1686                              <1> 
  1687                              <1> 	push word [cs:bx + fspStart + 2]
  1688                              <1> 	push word [cs:bx + fspStart]
  1689                              <1> 	pop word [es:di + _dskExtHiddenSectors]
  1690                              <1> 	pop word [es:di + _dskExtHiddenSectors + 2]
  1691                              <1> 
  1692                              <1> 	mov word [es:di + _dskPartitionType], 1
  1693                              <1> 	mov byte [es:di + _dskDeviceType], -1
  1694                              <1> 
  1695                              <1> 	cmp byte [es:di + _dskPhysDriveNumber], 80h
  1696                              <1> 	jb @F
  1697                              <1> 	or word [es:di + _dskStatusFlag], IsNonRemovable
  1698                              <1> @@:
  1699                              <1> 
  1700                              <1> 	push dx
  1701                              <1> 	push cx
  1702                              <1> 	push bx
  1703                              <1> 	mov ah, 41h
  1704                              <1> 	mov dl, [es:di + _dskPhysDriveNumber]
  1705                              <1> 	mov bx, 55AAh
  1706                              <1> 	stc
  1707                              <1> 	int 13h		; 13.41.bx=55AA extensions installation check
  1708                              <1> 	mov al, 0	; zero in case of no LBA support
  1709                              <1> 	jc .no_lba
  1710                              <1> 	cmp bx, 0AA55h
  1711                              <1> 	jne .no_lba
  1712                              <1> 	test cl, 1	; support bitmap bit 0
  1713                              <1> 	jz .no_lba
  1714                              <1> 	inc ax		; al = 1 to indicate LBA support
  1715                              <1> .no_lba:
  1716                              <1> 	pop bx
  1717                              <1> 	pop cx
  1718                              <1> 	pop dx
  1719                              <1> 	mov byte [es:di + _dskExtReadWrite], al
  1720                              <1> 
  1721                              <1> 	pop ax
  1722                              <1> 	mov word [es:di + _dskNextPointer], -1
  1723                              <1> 	mov word [es:di + _dskNextPointer + 2], -1
  1724                              <1> 	mov word [si + _dskNextPointer], di
  1725                              <1> 	mov word [si + _dskNextPointer + 2], es
  1726                              <1> 
  1727                              <1> 	add bx, FSPARM_size
  1728                              <1> 	inc ah
  1729                              <1> 	add di, DISKBLOCK_size
  1730                              <1> 	lds si, [si + _dskNextPointer]
  1731                              <1> 	loop .loop_jmp_next
  1732                              <1> 	jmp .end
  1733                              <1> .loop_jmp_next:
  1734                              <1> 	jmp .next
  1735                              <1> .end:
  1736                              <1> 
  1737                              <1> 	mov ds, dx
  1738                              <1> 	 pop cx
  1739                              <1> 	mov byte [block + devUnits], cl
  1740                              <1> 
  1741                              <1> 
  1742                              <1> relocate_int1E_table:
  1743                              <1> 	xor ax, ax
  1744                              <1> 	mov es, ax
  1745                              <1> 	lds si, [es:1Eh * 4]
  1746                              <1> 	mov cx, 10h
  1747                              <1> 	mov di, 522h
  1748                              <1> 	push di
  1749                              <1> 	rep movsb
  1750                              <1> 	mov word [es:1Eh * 4 + 2], es
  1751                              <1> 	pop word [es:1Eh * 4]
  1752                              <1> 
  1753                              <1> 
  1754                              <1> finish:
  1755                              <1> 	push cs
  1756                              <1> 	pop ds
  1757                              <1> %if _TEST_PAYLOAD
  1758                              <1> 	mov si, msg.test
  1759                              <1> 	call disp_msg
  1760                              <1> 	int3
  1761                              <1> 	xor ax, ax
  1762                              <1> 	int 16h
  1763                              <1> %else
  1764                              <1> 	int3
  1765                              <1> %endif
  1766                              <1> 
  1767                              <1> 	mov al, 20h
  1768                              <1> 	out 20h, al					; reset interrupts
  1769                              <1> 
  1770                              <1> 	mov ax, 0500h
  1771                              <1> 	int 10h						; set page zero
  1772                              <1> 
  1773                              <1> 	mov si, init1_msg.loading_os
  1774                              <1> 	call disp_msg
  1775                              <1> 
  1776                              <1> 	mov bx, cs
  1777                              <1> 	add bx, ( (init1_end - init1_start) 		+ 16 		) >> 4					; => INIT2
  1780                              <1> 	mov ax, init2_start
  1781                              <1> 	push bx
  1782                              <1> 	push ax
  1783                              <1> 
  1784                              <1> 	mov es, bx
  1785                              <1> 	mov word [es:init2_to_init1_segment], cs
  1786                              <1> 
  1787                              <1> 	xor cx, cx
  1788                              <1> 	mov cl, byte [cs:fsparm_number]
  1789                              <1> 
  1790                              <1> 
  1791                              <1> 		; INP:	cs = INIT2
  1792                              <1> 		;	word [DOSDATA:dosdata_to_doscode_segment] = DOSCODE segment
  1793                              <1> 		;	word [DOSENTRY:dosentry_to_dosdata_segment] = DOSDATA segment
  1794                              <1> 		;	70h = DOSENTRY segment
  1795                              <1> 		;	ip = 0
  1796                              <1> 		;	cx = number of default block device's units (<= 32)
  1797                              <1> 		;	word [INIT2:init2_to_init1_segment] = INIT1
  1798                              <1> init1_retf:
  1799                              <1> 	retf
  1800                              <1> 
  1801                              <1> 
  1802                              <1> 		; INP:	dx = phase code
  1803                              <1> 		; OUT:	-
  1804                              <1> 		; CHG:	-
  1805                              <1> 		;	(EDR-DOS pushes es,ax,bx,cx,dx and notes that
  1806                              <1> 		;	 this function doesn't modify any registers.)
  1807                              <1> %if 0
  1808                              <1> 
  1809                              <1> The phase codes are:
  1810                              <1> 
  1811                              <1> 1 = early before DOS loading, BIO has been relocated to LMA top
  1812                              <1> 2 = before CONFIG.SYS processing
  1813                              <1> 3 = after CONFIG.SYS processing (before shell is loaded)
  1814                              <1> 
  1815                              <1> These are described in RBIL 61, 2F4A06, in the Notes. However, code 1's
  1816                              <1>  description there is misguided. The relocation of "BIOS init code and data"
  1817                              <1>  doesn't mean into the HMA; rather, it's to the top of the LMA.
  1818                              <1> In EDR-DOS/dr70108/DRBIO/biosinit.a86:273, this is noted as
  1819                              <1>  "BIOSINIT CODE and DATA have now been relocated to high memory",
  1820                              <1>  but this means the top of the LMA. The HMA is only available later,
  1821                              <1>  during CONFIG.SYS processing, so it can't be used at this point.
  1822                              <1> 
  1823                              <1> %endif
  1824                              <1> 
  1825                              <1> 	init1_insure_low_byte_not_0CCh
  1826                              <1> init1_call_rploader:
  1827                              <1> 	push es
  1828                              <1> 	push ax
  1829                              <1> 	push bx
  1830                              <1> 	push cx
  1831                              <1> 	push dx
  1832                              <1> 
  1833                              <1> 	mov ax, 12FFh
  1834                              <1> 	mov bx, 5
  1835                              <1> 	xor cx, cx
  1836                              <1> 	mov dx, 1
  1837                              <1> 
  1838                              <1> 		; The callback variable is initialised to the address of an
  1839                              <1> 		;  iret in the DOSENTRY segment if RPLOADER wasn't detected.
  1840                              <1> 	pushf
  1841                              <1> 	cli
  1842                              <1> 	call far [cs:init1_rploader_callback]
  1843                              <1> 
  1844                              <1> 	pop dx
  1845                              <1> 	pop cx
  1846                              <1> 	pop bx
  1847                              <1> 	pop ax
  1848                              <1> 	pop es
  1849                              <1> 	retn
  1850                              <1> 
  1851                              <1> 
  1852                              <1> 		; INP:	ax = space in bytes to allocate at top of LMA
  1853                              <1> 		;	cl = allocation type
  1854                              <1> 		; OUT:	es:di-> allocated space, initialised to all zeros
  1855                              <1> 		;	(di = 0)
  1856                              <1> 		;	ax = cx = space in bytes allocated,
  1857                              <1> 		;	 ! 0 if size is 65536
  1858                              <1> 		;	does not return after allocation failure
  1859                              <1> 		; CHG:	-
  1860                              <1> 	init1_insure_low_byte_not_0CCh
  1861                              <1> init1_alloc_s_mcb_top:
  1862                              <1> 	push si
  1863                              <1> 	push bx
  1864                              <1> 	xchg si, ax
  1865                              <1> 
  1866                              <1> 	mov ax, 5802h
  1867                              <1> 	int 21h
  1868                              <1> 	mov ah, 0
  1869                              <1> 	push ax
  1870                              <1> 	mov ax, 5800h
  1871                              <1> 	int 21h
  1872                              <1> 	push ax
  1873                              <1> 
  1874                              <1> 	mov ax, 5803h
  1875                              <1> 	xor bx, bx
  1876                              <1> 	int 21h			; link out UMB chain
  1877                              <1> 	mov ax, 5801h
  1878                              <1> 	mov bx, 2
  1879                              <1> 	int 21h			; alloc strategy: last fit, LMA only
  1880                              <1> 
  1881                              <1> 	xchg ax, si		; reset ax to allocation size, cl = type
  1882                              <1> 	call init1_alloc_s_mcb	; allocate
  1883                              <1> 
  1884                              <1> 	pop bx
  1885                              <1> 	mov ax, 5801h
  1886                              <1> 	int 21h			; alloc strategy: restore
  1887                              <1> 	pop bx
  1888                              <1> 	mov ax, 5803h
  1889                              <1> 	int 21h			; restore UMB chain linkage
  1890                              <1> 
  1891                              <1> 	mov ax, cx		; ax = allocated size (! 0 if size is 65536)
  1892                              <1> 	pop bx
  1893                              <1> 	pop si
  1894                              <1> 	retn
  1895                              <1> %endif
  1896                              <1> 
  1897                              <1> 
  1898                              <1> 		; INP:	ax = space in bytes to allocate
  1899                              <1> 		;	cl = allocation type
  1900                              <1> 		; OUT:	es:di-> allocated space, initialised to all zeros
  1901                              <1> 		;	(di = 0)
  1902                              <1> 		;	ax = cx = space in bytes allocated,
  1903                              <1> 		;	 ! 0 if size is 65536
  1904                              <1> 		;	does not return after allocation failure
  1905                              <1> 		; CHG:	-
  1906                              <1> ;	init1_insure_low_byte_not_0CCh
  1907                              <1> ; init1_alloc_s_mcb:
  1908                              <1> init2_alloc_s_mcb:
  1909                              <1>  assume ds:nothing, es:nothing, ss:nothing
  1910 000017E9 53                  <1> 	push bx
  1911 000017EA 83C00F              <1> 	add ax, 15
  1912 000017ED 7304                <1> 	jnc @F
  1913 000017EF B80080              <1> 	mov ax, 1_0000h >> 1
  1914 000017F2 A9                  <1> 	db __TEST_IMM16
  1915                              <1> @@:
  1916 000017F3 D1E8                <1> 	shr ax, 1
  1917 000017F5 D1E8                <1> 	shr ax, 1
  1918 000017F7 D1E8                <1> 	shr ax, 1
  1919 000017F9 D1E8                <1> 	shr ax, 1			; = paragraphs
  1920                              <1> 
  1921 000017FB 89C3                <1> 	mov bx, ax
  1922 000017FD B448                <1> 	mov ah, 48h
  1923 000017FF F9                  <1> 	stc
  1924 00001800 CD21                <1> 	int 21h
  1925 00001802 723F                <1> 	jc .alloc_fail
  1926                              <1> 
  1927 00001804 48                  <1> 	dec ax
  1928 00001805 8EC0                <1> 	mov es, ax
  1929                              <1>  assume es:MCB
  1930 00001807 26C70601000800      <1> 	mov word [es:mcbOwner], 8	; system-owned MCB
  1931 0000180E 26C70608005300      <1> 	mov word [es:smcbName], "S"	; S MCB
  1932 00001815 B500                <1> 	mov ch, 0
  1933 00001817 26890E0A00          <1> 	mov word [es:smcbType], cx	; type = cl, reserved = 0
  1934 0000181C B100                <1> 	mov cl, 0
  1935 0000181E 26890E0C00          <1> 	mov word [es:smcbLink], cx	; link = 0
  1936 00001823 26890E0E00          <1> 	mov word [es:smcbLink + 2], cx	; reserved = 0
  1937                              <1> 
  1938 00001828 40                  <1> 	inc ax
  1939 00001829 8EC0                <1> 	mov es, ax
  1940                              <1>  assume es:nothing
  1941 0000182B 31FF                <1> 	xor di, di			; -> allocated space
  1942 0000182D 89D9                <1> 	mov cx, bx
  1943 0000182F D1E1                <1> 	shl cx, 1
  1944 00001831 D1E1                <1> 	shl cx, 1
  1945 00001833 D1E1                <1> 	shl cx, 1			; = number of words
  1946 00001835 31C0                <1> 	xor ax, ax
  1947 00001837 57                  <1> 	push di
  1948 00001838 51                  <1> 	push cx
  1949 00001839 F3AB                <1> 	rep stosw			; initialise allocated memory to zeros
  1950 0000183B 59                  <1> 	pop cx
  1951 0000183C 5F                  <1> 	pop di
  1952 0000183D D1E1                <1> 	shl cx, 1
  1953 0000183F 89C8                <1> 	mov ax, cx
  1954 00001841 5B                  <1> 	pop bx
  1955 00001842 C3                  <1> 	retn
  1956                              <1> 
  1957                              <1> 
  1958                              <1> .alloc_fail:
  1959 00001843 0E                  <1> 	push cs
  1960 00001844 1F                  <1> 	pop ds
  1961                              <1>  assume ds:SYSINITGROUP
  1962 00001845 50                  <1> 	 push ax
  1963 00001846 BE[EE15]            <1> 	mov si, init1_msg.alloc_error	; access with ds
  1964 00001849 E885FF              <1> 	call init1_disp_msg
  1965 0000184C 58                  <1> 	 pop ax
  1966 0000184D E85A09              <1> 	call init1_disp_ax_hex
  1967 00001850 50                  <1> 	 push ax
  1968 00001851 BE[FB15]            <1> 	mov si, init1_msg.alloc_error_q	; access with ds
  1969 00001854 E87AFF              <1> 	call init1_disp_msg
  1970 00001857 58                  <1> 	 pop ax
  1971                              <1> 
  1972 00001858 83F813              <1> 	cmp ax, init1_msg_errors.count
  1973 0000185B 7205                <1> 	jb .valid
  1974 0000185D BE[7816]            <1> 	mov si, init1_msg_errors.unknown_error	; access with ds
  1975 00001860 EB08                <1> 	jmp short .disp_error
  1976                              <1> .valid:
  1977 00001862 89C3                <1> 	mov bx, ax
  1978 00001864 01DB                <1> 	add bx, bx
  1979 00001866 8BB7[5216]          <1> 	mov si, [ init1_msg_errors + bx ]
  1980                              <1> .disp_error:
  1981 0000186A E864FF              <1> 	call init1_disp_msg
  1982 0000186D BE[1716]            <1> 	mov si, init1_msg.linebreak	; access with ds
  1983 00001870 E85EFF              <1> 	call init1_disp_msg
  1984                              <1> 
  1985                              <1> init1_reboot_prompt:
  1986 00001873 0E                  <1> 	push cs
  1987 00001874 1F                  <1> 	pop ds
  1988                              <1>  assume ds:SYSINITGROUP
  1989 00001875 BE[1A16]            <1> 	mov si, init1_msg.reboot_prompt	; access with ds
  1990 00001878 E856FF              <1> 	call init1_disp_msg
  1991                              <1> .loop:
  1992 0000187B CC                  <1> 	int3
  1993 0000187C 31C0                <1> 	xor ax, ax
  1994 0000187E CD16                <1> 	int 16h
  1995 00001880 EBF9                <1> 	jmp .loop
  1996                              <1> 
  1997                              <1> 
  1998                              <1> %if 0
  1999                              <1> 		; Move paragraphs
  2000                              <1> 		;
  2001                              <1> 		; INP:	ax:0-> source
  2002                              <1> 		;	dx:0-> destination
  2003                              <1> 		;	cx = number of paragraphs
  2004                              <1> 		; CHG:	-
  2005                              <1> 		; Note:	Doesn't work correctly on HMA; doesn't always wrap to LMA either.
  2006                              <1> 		;	Do not provide a wrapped/HMA source or destination!
  2007                              <1> init1_movp:
  2008                              <1> 	push cx
  2009                              <1> 	push ds
  2010                              <1> 	push si
  2011                              <1> 	push es
  2012                              <1> 	push di
  2013                              <1> 
  2014                              <1> 	cmp ax, dx		; source above destination ?
  2015                              <1> 	ja .up			; yes, move up (forwards) -->
  2016                              <1> 	je .return		; same, no need to move -->
  2017                              <1> 	push ax
  2018                              <1> 	add ax, cx		; (expected not to carry)
  2019                              <1> 	cmp ax, dx		; end of source is above destination ?
  2020                              <1> 	pop ax
  2021                              <1> 	ja .down		; yes, move from top down -->
  2022                              <1> 	; Here, the end of source is below-or-equal the destination,
  2023                              <1> 	;  so they do not overlap. In this case we prefer moving up.
  2024                              <1> 
  2025                              <1> .up:
  2026                              <1> 	push ax
  2027                              <1> 	push dx
  2028                              <1> .uploop:
  2029                              <1> 	mov ds, ax
  2030                              <1> 	mov es, dx
  2031                              <1> 	xor di, di
  2032                              <1> 	xor si, si		; -> start of segment
  2033                              <1> 	sub cx, 1000h		; 64 KiB left ?
  2034                              <1> 	jbe .uplast		; no -->
  2035                              <1> 	push cx
  2036                              <1> 	mov cx, 10000h /2
  2037                              <1> 	rep movsw		; move 64 KiB
  2038                              <1> 	pop cx
  2039                              <1> 	add ax, 1000h
  2040                              <1> 	add dx, 1000h		; -> next segment
  2041                              <1> 	jmp short .uploop	; proceed for more -->
  2042                              <1> .uplast:
  2043                              <1> 	add cx, 1000h		; restore counter
  2044                              <1> 	shl cx, 1
  2045                              <1> 	shl cx, 1
  2046                              <1> 	shl cx, 1		; *8, paragraphs to words
  2047                              <1> 	rep movsw		; move last part
  2048                              <1> 	pop dx
  2049                              <1> 	pop ax
  2050                              <1> 	jmp short .return
  2051                              <1> 
  2052                              <1> .down:
  2053                              <1> 	std			; _AMD_ERRATUM_109_WORKAROUND as below
  2054                              <1> .dnloop:
  2055                              <1> 	sub cx, 1000h		; 64 KiB left ?
  2056                              <1> 	jbe .dnlast		; no -->
  2057                              <1> 	push ax
  2058                              <1> 	push dx
  2059                              <1> 	add ax, cx
  2060                              <1> 	add dx, cx
  2061                              <1> 	mov ds, ax		; -> 64 KiB not yet moved
  2062                              <1> 	mov es, dx
  2063                              <1> 	pop dx
  2064                              <1> 	pop ax
  2065                              <1> 	mov di, -2
  2066                              <1> 	mov si, di		; moved from last word down
  2067                              <1> 	push cx
  2068                              <1> 	mov cx, 10000h /2
  2069                              <1> 	rep movsw		; move 64 KiB
  2070                              <1> 	pop cx
  2071                              <1> 	jmp short .dnloop	; proceed for more -->
  2072                              <1> .dnlast:
  2073                              <1> 	add cx, 1000h		; restore counter
  2074                              <1> 	shl cx, 1
  2075                              <1> 	shl cx, 1
  2076                              <1> 	shl cx, 1		; *8, paragraphs to words
  2077                              <1> 	mov di, cx
  2078                              <1> 	dec di
  2079                              <1> 	shl di, 1		; words to offset, -> last word
  2080                              <1> 	mov si, di
  2081                              <1> 	mov ds, ax
  2082                              <1> 	mov es, dx		; first segment correct
  2083                              <1> 
  2084                              <1> 
  2085                              <1> 	numdef AMD_ERRATUM_109_WORKAROUND, 1
  2086                              <1> 		; Refer to comment in init0_movp.
  2087                              <1> 
  2088                              <1> %if _AMD_ERRATUM_109_WORKAROUND
  2089                              <1> 	jcxz @FF
  2090                              <1> 	cmp cx, 20
  2091                              <1> 	ja @FF
  2092                              <1> @@:
  2093                              <1> 	movsw
  2094                              <1> 	loop @B
  2095                              <1> @@:
  2096                              <1> %endif
  2097                              <1> 	rep movsw		; move first part
  2098                              <1> 	cld
  2099                              <1> .return:
  2100                              <1> 	pop di
  2101                              <1> 	pop es
  2102                              <1> 	pop si
  2103                              <1> 	pop ds
  2104                              <1> 	pop cx
  2105                              <1> 	retn
  2106                              <1> 
  2107                              <1> %endif
  2108                              <1> 
  2109                              <1> 		; INP:	dx:ax = numerator
  2110                              <1> 		;	cx = multiplier
  2111                              <1> 		;	bx = field width
  2112                              <1> 		; STT:	UP
  2113                              <1> 		; OUT:	displayed
  2114                              <1> ;	init1_insure_low_byte_not_0CCh
  2115                              <1> disp_dxax_times_cx_width_bx_size:
  2116                              <1>  global init2_disp_dxax_times_cx_width_bx_size
  2117                              <1> init2_disp_dxax_times_cx_width_bx_size:
  2118                              <1>  assume ds:nothing, es:nothing, ss:nothing
  2119                              <1> 	lframe near
  2120                              <1> 	lvar 4 + 4 + 2, buffer
  2121                              <1> 	lvar 6, dividend
  2122 00001882 5589E58D66F0        <1> 	lenter
  2123                              <1> 	 lvar word, width
  2124 00001888 53                  <1> 	 push bx
  2125 00001889 56                  <1> 	push si
  2126 0000188A 57                  <1> 	push di
  2127 0000188B 1E                  <1> 	push ds
  2128 0000188C 06                  <1> 	push es
  2129 0000188D 51                  <1> 	push cx
  2130 0000188E 50                  <1> 	push ax
  2131 0000188F 52                  <1> 	push dx
  2132                              <1> 
  2133 00001890 0E                  <1> 	 push cs
  2134 00001891 1F                  <1> 	 pop ds
  2135                              <1>  assume ds:SYSINITGROUP
  2136 00001892 16                  <1> 	 push ss
  2137 00001893 07                  <1> 	 pop es
  2138                              <1>  assume es:nothing
  2139                              <1> 
  2140 00001894 52                  <1> 	push dx
  2141 00001895 F7E1                <1> 	mul cx
  2142 00001897 97                  <1> 	xchg ax, di
  2143 00001898 87D6                <1> 	xchg dx, si		; si:di = first mul
  2144                              <1> 
  2145 0000189A 58                  <1> 	pop ax
  2146 0000189B F7E1                <1> 	mul cx
  2147 0000189D 01F0                <1> 	add ax, si
  2148 0000189F 83D200              <1> 	adc dx, 0		; dx:ax = second mul + adj, dx:ax:di = mul
  2149                              <1> 
  2150 000018A2 89F9                <1> 	mov cx, di		; dx:ax:cx = mul
  2151                              <1> 
  2152 000018A4 894EF0              <1> 	mov word [bp + ?dividend], cx
  2153 000018A7 8946F2              <1> 	mov word [bp + ?dividend + 2], ax
  2154 000018AA 8956F4              <1> 	mov word [bp + ?dividend + 4], dx
  2155                              <1> 
  2156 000018AD BE[4B16]            <1> 	mov si, init1_msg.prefixes	; access with ds
  2157                              <1> .loop:
  2158 000018B0 837EF400            <1> 	cmp word [bp + ?dividend + 4], 0
  2159 000018B4 750D                <1> 	jnz .divide
  2160 000018B6 837EF200            <1> 	cmp word [bp + ?dividend + 2], 0
  2161 000018BA 7507                <1> 	jnz .divide
  2162 000018BC 817EF00008          <1> 	cmp word [bp + ?dividend], 2048
  2163 000018C1 7617                <1> 	jbe .end
  2164                              <1> .divide:
  2165 000018C3 46                  <1> 	inc si
  2166 000018C4 B90004              <1> 	mov cx, 1024		; 1000 here if SI units
  2167 000018C7 31D2                <1> 	xor dx, dx
  2168 000018C9 BF0600              <1> 	mov di, 6
  2169                              <1> .loop_divide:
  2170 000018CC 8B43EE              <1> 	mov ax, [bp + ?dividend - 2 + di]
  2171 000018CF F7F1                <1> 	div cx
  2172 000018D1 8943EE              <1> 	mov word [bp + ?dividend - 2 + di], ax
  2173 000018D4 4F                  <1> 	dec di
  2174 000018D5 4F                  <1> 	dec di
  2175 000018D6 75F4                <1> 	jnz .loop_divide
  2176                              <1> 				; dx = last remainder
  2177 000018D8 EBD6                <1> 	jmp .loop
  2178                              <1> 
  2179                              <1> .end:
  2180 000018DA 8D7EFF              <1> 	lea di, [bp + ?buffer + 4 + 4 + 1]
  2181 000018DD FD                  <1> 	std			; _AMD_ERRATUM_109_WORKAROUND does not apply
  2182 000018DE B042                <1> 	mov al, "B"
  2183 000018E0 AA                  <1> 	stosb
  2184 000018E1 8A04                <1> 	mov al, [si]
  2185 000018E3 3C20                <1> 	cmp al, 32
  2186 000018E5 7408                <1> 	je @F
  2187                              <1> 
  2188 000018E7 24DF                <1> 	and al, ~20h		; uppercase, don't do this if SI units
  2189 000018E9 50                  <1> 	push ax
  2190 000018EA B069                <1> 	mov al, "i"
  2191 000018EC AA                  <1> 	stosb			; don't store this if SI units
  2192 000018ED 58                  <1> 	pop ax
  2193 000018EE AA                  <1> 	stosb
  2194                              <1> @@:
  2195 000018EF B020                <1> 	mov al, 32
  2196 000018F1 AA                  <1> 	stosb
  2197                              <1> 
  2198 000018F2 8B46F0              <1> 	mov ax, word [bp + ?dividend]
  2199 000018F5 B90A00              <1> 	mov cx, 10
  2200                              <1> .loop_write:
  2201 000018F8 31D2                <1> 	xor dx, dx
  2202 000018FA F7F1                <1> 	div cx
  2203 000018FC 92                  <1> 	xchg ax, dx
  2204                              <1> 				; ax = remainder (next digit)
  2205                              <1> 				; dx = result of div
  2206 000018FD 0430                <1> 	add al, '0'
  2207 000018FF AA                  <1> 	stosb
  2208 00001900 92                  <1> 	xchg ax, dx		; ax = result of div
  2209 00001901 85C0                <1> 	test ax, ax		; any more ?
  2210 00001903 75F3                <1> 	jnz .loop_write		; loop -->
  2211                              <1> 
  2212 00001905 FC                  <1> 	cld
  2213                              <1> 
  2214 00001906 8D5EFF              <1> 	lea bx, [bp + ?buffer + 4 + 4 + 1]
  2215 00001909 29FB                <1> 	sub bx, di
  2216                              <1> 
  2217 0000190B 8B4EEE              <1> 	mov cx, [bp + ?width]
  2218 0000190E 29D9                <1> 	sub cx, bx
  2219 00001910 7607                <1> 	jbe .none_blank
  2220                              <1> .loop_blank:
  2221 00001912 B020                <1> 	mov al, 32
  2222 00001914 E8C4FE              <1> 	call disp_al
  2223 00001917 E2F9                <1> 	loop .loop_blank
  2224                              <1> .none_blank:
  2225                              <1> 
  2226 00001919 89D9                <1> 	mov cx, bx
  2227                              <1> .loop_disp:
  2228 0000191B 47                  <1> 	inc di
  2229 0000191C 368A05              <1> 	mov al, [ss:di]
  2230 0000191F E8B9FE              <1> 	call disp_al
  2231 00001922 E2F7                <1> 	loop .loop_disp
  2232                              <1> 
  2233 00001924 5A                  <1> 	pop dx
  2234 00001925 58                  <1> 	pop ax
  2235 00001926 59                  <1> 	pop cx
  2236 00001927 07                  <1> 	pop es
  2237                              <1>  assume es:nothing
  2238 00001928 1F                  <1> 	pop ds
  2239                              <1>  assume ds:nothing
  2240 00001929 5F                  <1> 	pop di
  2241 0000192A 5E                  <1> 	pop si
  2242 0000192B 5B                  <1> 	pop bx
  2243 0000192C 89EC5D              <1> 	lleave
  2244 0000192F C3                  <1> 	lret
  2245                              <1> 
  2246                              <1> 
  2247                              <1> 		; INP:	ax = number to display
  2248                              <1> 		; CHG:	-
  2249                              <1> ;	init1_insure_low_byte_not_0CCh
  2250                              <1>  global init2_disp_ax_dec
  2251                              <1> init2_disp_ax_dec:
  2252                              <1> disp_ax_dec:			; ax (no leading zeros)
  2253                              <1>  assume ds:nothing, es:nothing, ss:nothing
  2254                              <1> 	; In: number in ax
  2255                              <1> 	; Out: displayed
  2256 00001930 53                  <1> 		push bx
  2257 00001931 31DB                <1> 		xor bx, bx
  2258                              <1> .pushax:
  2259 00001933 50                  <1> 		push ax
  2260                              <1> .pushend:
  2261 00001934 08DB                <1> 		or bl, bl
  2262 00001936 7405                <1> 		jz .nobl
  2263 00001938 80EB05              <1> 		sub bl, 5
  2264 0000193B F6DB                <1> 		neg bl
  2265                              <1> .nobl:
  2266 0000193D 51                  <1> 		push cx
  2267 0000193E B91027              <1> 		mov cx, 10000
  2268 00001941 E81A00              <1> 		call .divide_out
  2269 00001944 B9E803              <1> 		mov cx, 1000
  2270 00001947 E81400              <1> 		call .divide_out
  2271 0000194A B96400              <1> 		mov cx, 100
  2272 0000194D E80E00              <1> 		call .divide_out
  2273 00001950 B10A                <1> 		mov cl, 10
  2274 00001952 E80900              <1> 		call .divide_out
  2275                              <1> 							; (Divisor 1 is useless)
  2276 00001955 0430                <1> 		add al, '0'
  2277 00001957 E881FE              <1> 		call disp_al
  2278 0000195A 59                  <1> 		pop cx
  2279 0000195B 58                  <1> 		pop ax
  2280 0000195C 5B                  <1> 		pop bx					; Caller's register
  2281 0000195D C3                  <1> 		retn
  2282                              <1> 
  2283                              <1> .divide_out:
  2284                              <1> 	; In: ax = number
  2285                              <1> 	;     cx = divisor
  2286                              <1> 	; Out: ax = remainder of operation
  2287                              <1> 	;      result displayed
  2288 0000195E 52                  <1> 		push dx
  2289 0000195F 31D2                <1> 		xor dx, dx
  2290 00001961 F7F1                <1> 		div cx				; 0:ax / cx
  2291 00001963 52                  <1> 		push dx				; remainder
  2292 00001964 FECB                <1> 		dec bl
  2293 00001966 7503                <1> 		jnz .nobl2
  2294 00001968 80CF01              <1> 		or bh, 1
  2295                              <1> .nobl2:
  2296 0000196B 08C7                <1> 		or bh, al
  2297 0000196D 7405                <1> 		jz .leadingzero
  2298 0000196F 0430                <1> 		add al, '0'
  2299 00001971 E867FE              <1> 		call disp_al			; display result
  2300                              <1>  .leadingzero:
  2301 00001974 58                  <1> 		pop ax				; remainder
  2302 00001975 5A                  <1> 		pop dx
  2303 00001976 C3                  <1> 		retn
  2304                              <1> 
  2305                              <1> 
  2306                              <1> %if 0		; lMS-DOS
  2307                              <1> 
  2308                              <1> 		; INP:	es:si -> partition table entry,
  2309                              <1> 		;	 si = partition_table .. (partition_table.end - 16),
  2310                              <1> 		;	 es = cs
  2311                              <1> 		;	ss:bx + di -> above part table metadata,
  2312                              <1> 		;	 dwo [ss:bx + di - 4] = root (outermost extended position)
  2313                              <1> 		;	 dwo [ss:bx + di - 8] = base (current table position)
  2314                              <1> 		;	ss:bp -> BPB area, LOADSTACKVARS, LOADDATA, LOADDATA2
  2315                              <1> 		; CHG:	ax, (cx), dx
  2316                              <1> login_partition:
  2317                              <1> 	mov al, byte [es:si + piType]
  2318                              <1> 	cmp al, ptFAT12
  2319                              <1> 	je .isfat
  2320                              <1> 	cmp al, ptFAT16_16BIT_CHS
  2321                              <1> 	je .isfat
  2322                              <1> 	cmp al, ptFAT16_CHS
  2323                              <1> 	je .isfat
  2324                              <1> 	cmp al, ptFAT32_CHS
  2325                              <1> 	je .isfat
  2326                              <1> 	cmp al, ptFAT32
  2327                              <1> 	je .isfat
  2328                              <1> 	cmp al, ptFAT16
  2329                              <1> 	je .isfat
  2330                              <1> 
  2331                              <1> 	retn
  2332                              <1> 
  2333                              <1> .isfat:
  2334                              <1> 	push ds
  2335                              <1> 	push cx
  2336                              <1> 	push bx
  2337                              <1> 	push si
  2338                              <1> 	push di
  2339                              <1> 	push es
  2340                              <1> 	 push cs
  2341                              <1> 	 pop ds
  2342                              <1> 	cmp byte [fsparm_number], 32
  2343                              <1> 	jne @F
  2344                              <1> 
  2345                              <1> 	inc word [fsparm_excess]
  2346                              <1> .return:
  2347                              <1> 	pop es
  2348                              <1> 	pop di
  2349                              <1> 	pop si
  2350                              <1> 	pop bx
  2351                              <1> 	pop cx
  2352                              <1> 	pop ds
  2353                              <1> 	retn
  2354                              <1> 
  2355                              <1> @@:
  2356                              <1> 	mov dl, al
  2357                              <1> 	inc byte [fsparm_number]
  2358                              <1> 	mov di, [fsparm_pointer]
  2359                              <1> 	add word [fsparm_pointer], FSPARM_size
  2360                              <1> 	 push cs
  2361                              <1> 	 pop es				; -> FSPARM
  2362                              <1> 	xor ax, ax
  2363                              <1> 	mov cx, FSPARM_size >> 1
  2364                              <1> 	push di
  2365                              <1> 	rep stosw			; initialise
  2366                              <1> 	pop di
  2367                              <1> 	mov al, [load_unit]
  2368                              <1> 	mov byte [di + fspUnit], al
  2369                              <1> 	push word [load_sectorsize]
  2370                              <1> 	pop word [di + fspSectorSize]
  2371                              <1> 	mov byte [di + fspType], dl
  2372                              <1> 	mov cx, di
  2373                              <1> 	pop es
  2374                              <1> 	pop di
  2375                              <1> 	pop si
  2376                              <1> 	push si
  2377                              <1> 	push di
  2378                              <1> 	push es
  2379                              <1> 
  2380                              <1> 	mov ax, word [ss:bx + di - 8]
  2381                              <1> 	mov dx, word [ss:bx + di - 6]	; root
  2382                              <1> 	add ax, word [es:si + piStart]
  2383                              <1> 	adc dx, word [es:si + piStart + 2]	; add partition offset
  2384                              <1> 
  2385                              <1> 	mov di, cx
  2386                              <1> 	mov word [di + fspStart], ax
  2387                              <1> 	mov word [di + fspStart + 2], dx
  2388                              <1> 	push word [es:si + piLength + 2]
  2389                              <1> 	push word [es:si + piLength]
  2390                              <1> 	pop word [di + fspLength]
  2391                              <1> 	pop word [di + fspLength + 2]
  2392                              <1> 
  2393                              <1> 	mov al, byte [load_current_partition]
  2394                              <1> 	mov byte [di + fspPartition], al
  2395                              <1> 	mov al, byte [es:si + piBoot]
  2396                              <1> 	mov byte [di + fspBoot], al
  2397                              <1> 
  2398                              <1> 	jmp .return
  2399                              <1> 
  2400                              <1> 
  2401                              <1> 		; INP:	dl = first unit to log in
  2402                              <1> 		;	cx = number of units to log in
  2403                              <1> scan_given_partitions:
  2404                              <1> 	jcxz .none
  2405                              <1> .loop:
  2406                              <1> 	push cx
  2407                              <1> 	push dx
  2408                              <1> 
  2409                              <1> 	mov word [throw_sp], sp
  2410                              <1> 	mov word [throw_ip], .fail
  2411                              <1> 
  2412                              <1> 	mov byte [load_unit], dl
  2413                              <1> 	call query_geometry
  2414                              <1> 
  2415                              <1> 	mov cx, login_partition
  2416                              <1> 	call scan_partitions
  2417                              <1> 	push cs
  2418                              <1> 	pop ds
  2419                              <1> 	db __TEST_IMM8		; (NC)
  2420                              <1> .fail:
  2421                              <1> 	stc
  2422                              <1> 	 push cs
  2423                              <1> 	 pop ds
  2424                              <1> 	pop dx
  2425                              <1> 	pop cx
  2426                              <1> 
  2427                              <1> 	jnc @F
  2428                              <1> 	push dx
  2429                              <1> 	xchg ax, dx
  2430                              <1> 	mov dx, msg.login_partition_error_1
  2431                              <1> 	call disp_msg_asciz
  2432                              <1> 	call disp_al_hex
  2433                              <1> 	mov dx, msg.login_partition_error_2
  2434                              <1> 	call disp_msg_asciz
  2435                              <1> 	pop dx
  2436                              <1> @@:
  2437                              <1> 	inc dx
  2438                              <1> 	loop .loop
  2439                              <1> .none:
  2440                              <1> 	retn
  2441                              <1> %endif
  2442                              <1> 
  2443                              <1> 
  2444                              <1> 	global hexword, hexbyte, hexnyb
  2445                              <1> hexword:
  2446 00001977 86C4                <1> 	xchg al, ah
  2447 00001979 E80200              <1> 	call hexbyte
  2448 0000197C 86C4                <1> 	xchg al, ah
  2449                              <1> 
  2450                              <1> hexbyte:
  2451 0000197E 51                  <1> 	push cx
  2452 0000197F B104                <1> 	mov cl, 4
  2453 00001981 D2C0                <1> 	rol al, cl
  2454 00001983 E80300              <1> 	call hexnyb
  2455 00001986 D2C0                <1> 	rol al, cl
  2456 00001988 59                  <1> 	pop cx
  2457                              <1> 
  2458                              <1> hexnyb:
  2459 00001989 50                  <1> 	push ax
  2460 0000198A 240F                <1> 	and al, 0Fh
  2461 0000198C 0490                <1> 	add al, 90h
  2462 0000198E 27                  <1> 	daa
  2463 0000198F 1440                <1> 	adc al, 40h
  2464 00001991 27                  <1> 	daa			; these four instructions change to ASCII hex
  2465 00001992 AA                  <1> 	stosb
  2466 00001993 58                  <1> 	pop ax
  2467 00001994 C3                  <1> 	retn
  2468                              <1> 
  2469                              <1> 
  2470                              <1> %if 0	; lMS-DOS
  2471                              <1> cmd3:
  2472                              <1> 	push cs
  2473                              <1> 	pop ds
  2474                              <1> 	push cs
  2475                              <1> 	pop es
  2476                              <1> 	mov sp, [throw_sp]
  2477                              <1> 	jmp near [throw_ip]
  2478                              <1> 
  2479                              <1> 
  2480                              <1> bootcmd:
  2481                              <1> .fail_read:
  2482                              <1> 	 push cs
  2483                              <1> 	 pop es
  2484                              <1> 	mov di, msg.bootfail_read_errorcode
  2485                              <1> 	mov al, ah
  2486                              <1> 	call hexbyte
  2487                              <1> 	mov dx, msg.bootfail_read
  2488                              <1> 
  2489                              <1> .fail:
  2490                              <1> 	push dx
  2491                              <1> 	mov dx, msg.bootfail
  2492                              <1> 	call disp_msg_asciz
  2493                              <1> 	pop dx
  2494                              <1> 	call disp_msg_asciz
  2495                              <1> 	jmp cmd3
  2496                              <1> 
  2497                              <1> %define _SCANPTAB_PREFIX
  2498                              <1> %define _SCANPTAB_DEBUG4_PREFIX init1_
  2499                              <1> %include "scanptab.asm"
  2500                              <1> 
  2501                              <1> 
  2502                              <1> query_geometry:
  2503                              <1> 	mov dl, [load_unit]
  2504                              <1> ;	test dl, dl		; floppy?
  2505                              <1> ;	jns @F			; don't attempt query, might fail -->
  2506                              <1> 	; Note that while the original PC BIOS doesn't support this function
  2507                              <1> 	;  (for its diskettes), it does properly return the error code 01h.
  2508                              <1> 	; https://sites.google.com/site/pcdosretro/ibmpcbios (IBM PC version 1)
  2509                              <1> 	mov ah, 08h
  2510                              <1> 	xor cx, cx		; initialise cl to 0
  2511                              <1> 	mov [load_heads], cx
  2512                              <1> 	mov [load_sectors], cx
  2513                              <1> 	stc			; initialise to CY
  2514                              <1> 	call .int13_retry	; query drive geometry
  2515                              <1> 	jc .try_bootsector	; apparently failed -->
  2516                              <1> 	mov dl, dh
  2517                              <1> 	mov dh, 0		; dx = maximum head number
  2518                              <1> 	inc dx			; dx = number of heads (H is 0-based)
  2519                              <1> 	mov ax, cx		; ax & 3Fh = maximum sector number
  2520                              <1> 	and ax, 3Fh		; get sectors (number of sectors, S is 1-based)
  2521                              <1> 	jnz .got_sectors_heads	; valid (S is 1-based), use these -->
  2522                              <1> 				; zero = invalid
  2523                              <1> .try_bootsector:
  2524                              <1> 	mov es, word [bp + ldSectorSeg]
  2525                              <1> 	xor bx, bx
  2526                              <1> 	mov ax, 0201h			; read sector, 1 sector
  2527                              <1> 	mov cx, 1			; sector 1 (1-based!), cylinder 0 (0-based)
  2528                              <1> 	mov dh, 0			; head 0 (0-based)
  2529                              <1> 	mov dl, [load_unit]
  2530                              <1> 	stc
  2531                              <1> 	call .int13_retry
  2532                              <1> 	jc .access_error
  2533                              <1> 
  2534                              <1> 		; note: the smallest supported sector size, 32 bytes,
  2535                              <1> 		;  does contain these entries (offset 18h and 1Ah in sector)
  2536                              <1> 		;  within the first BPB sector.
  2537                              <1> 	mov ax, word [es:bx + bsBPB + bpbCHSSectors]
  2538                              <1> 	mov dx, word [es:bx + bsBPB + bpbCHSHeads]
  2539                              <1> 
  2540                              <1> .got_sectors_heads:
  2541                              <1> 	mov word [load_sectors], ax
  2542                              <1> 	mov word [load_heads], dx
  2543                              <1> 
  2544                              <1> 	test ax, ax
  2545                              <1> 	jz .invalid_sectors
  2546                              <1> 	cmp ax, 63
  2547                              <1> 	ja .invalid_sectors
  2548                              <1> 	test dx, dx
  2549                              <1> 	jz .invalid_heads
  2550                              <1> 	cmp dx, 100h
  2551                              <1> 	ja .invalid_heads
  2552                              <1> 
  2553                              <1> 	mov bx, 10h
  2554                              <1> 	mov di, bx
  2555                              <1> 	mov cx, (8192 + 2) >> 1
  2556                              <1> 	mov ax, word [bp + ldSectorSeg]
  2557                              <1> 	dec ax
  2558                              <1> 	mov es, ax			; es:bx -> buffer, es:di = same
  2559                              <1> 	xor ax, ax
  2560                              <1> 	rep stosw			; fill buffer, di -> behind (0:7C00h+8192+2)
  2561                              <1> 	mov ax, 0201h			; read sector, 1 sector
  2562                              <1> 	inc cx				; sector 1 (1-based!), cylinder 0 (0-based)
  2563                              <1> 	mov dh, 0			; head 0 (0-based)
  2564                              <1> 	mov dl, [load_unit]
  2565                              <1> 	stc
  2566                              <1> 	call .int13_retry
  2567                              <1> 	jc .access_error
  2568                              <1> 
  2569                              <1> 	std				; _AMD_ERRATUM_109_WORKAROUND does not apply
  2570                              <1> 	mov word [es:bx - 2], 5E5Eh
  2571                              <1> 	scasw				; -> 0:7C00h+8192 (at last word to sca)
  2572                              <1> 	mov cx, (8192 + 2) >> 1
  2573                              <1> 	xor ax, ax
  2574                              <1> 	repe scasw
  2575                              <1> 	add di, 4			; di -> first differing byte (from top)
  2576                              <1> 	cld
  2577                              <1> 	push di
  2578                              <1> 
  2579                              <1> 	mov di, bx
  2580                              <1> 	mov cx, (8192 + 2) >> 1
  2581                              <1> 	dec ax				; = FFFFh
  2582                              <1> 	rep stosw
  2583                              <1> 
  2584                              <1> 	mov ax, 0201h
  2585                              <1> 	inc cx
  2586                              <1> 	mov dh, 0
  2587                              <1> 	mov dl, [load_unit]
  2588                              <1> 	stc
  2589                              <1> 	call .int13_retry
  2590                              <1> 	jc .access_error
  2591                              <1> 
  2592                              <1> 	std				; _AMD_ERRATUM_109_WORKAROUND does not apply
  2593                              <1> 	scasw				; di -> 0:7C00h+8192 (last word to sca)
  2594                              <1> 	pop dx
  2595                              <1> 	mov ax, -1
  2596                              <1> 	mov cx, (8192 + 2) >> 1
  2597                              <1> 	repe scasw
  2598                              <1> %if 0
  2599                              <1> AAAB
  2600                              <1>    ^
  2601                              <1> 	sca B, match
  2602                              <1>   ^
  2603                              <1> 	sca B, mismatch
  2604                              <1>  ^
  2605                              <1> 	stop
  2606                              <1> %endif
  2607                              <1> 	add di, 4			; di -> first differing byte (from top)
  2608                              <1> 	cld
  2609                              <1> 
  2610                              <1> %if 0
  2611                              <1> 0000000000000
  2612                              <1> AAAAAAAA00000
  2613                              <1> 	^
  2614                              <1> FFFFFFFFFFFFF
  2615                              <1> AAAAAAAA00FFF
  2616                              <1> 	  ^
  2617                              <1> %endif
  2618                              <1> 	cmp dx, di			; choose the higher one
  2619                              <1> 	jae @F
  2620                              <1> 	mov dx, di
  2621                              <1> @@:
  2622                              <1> 	sub dx, bx			; dx = sector size
  2623                              <1> 
  2624                              <1> 	cmp dx, 8192 + 2
  2625                              <1> 	jae .sector_too_large
  2626                              <1> 	mov ax, 32
  2627                              <1> 	cmp dx, ax
  2628                              <1> 	jb .sector_too_small
  2629                              <1> @@:
  2630                              <1> 	cmp dx, ax
  2631                              <1> 	je .got_match
  2632                              <1> 	cmp ax, 8192
  2633                              <1> 	jae .sector_not_power
  2634                              <1> 	shl ax, 1
  2635                              <1> 	jmp @B
  2636                              <1> 
  2637                              <1> .got_match:
  2638                              <1> 	mov word [load_sectorsize], ax
  2639                              <1> 	mov cl, 4
  2640                              <1> 	shr ax, cl
  2641                              <1> 	mov word [load_sectorsizepara], ax
  2642                              <1> 
  2643                              <1> 	mov byte [load_lba], 0
  2644                              <1> 	mov ah, 41h
  2645                              <1> 	mov dl, [load_unit]
  2646                              <1> 	mov bx, 55AAh
  2647                              <1> 	stc
  2648                              <1> 	int 13h		; 13.41.bx=55AA extensions installation check
  2649                              <1> 	jc .no_lba
  2650                              <1> 	cmp bx, 0AA55h
  2651                              <1> 	jne .no_lba
  2652                              <1> 	test cl, 1	; support bitmap bit 0
  2653                              <1> 	jz .no_lba
  2654                              <1> 
  2655                              <1> 	inc byte [load_lba]
  2656                              <1> .no_lba:
  2657                              <1> 	retn
  2658                              <1> 
  2659                              <1> 
  2660                              <1> .int13_retry:
  2661                              <1> 	pushf
  2662                              <1> 	push ax
  2663                              <1> 	int 13h		; first try
  2664                              <1> 	jnc @F		; NC, success on first attempt -->
  2665                              <1> 
  2666                              <1> ; reset drive
  2667                              <1> 	xor ax, ax
  2668                              <1> 	int 13h
  2669                              <1> 	jc @F		; CY, reset failed, error in ah -->
  2670                              <1> 
  2671                              <1> ; try read again
  2672                              <1> 	pop ax		; restore function number
  2673                              <1> 	popf
  2674                              <1> 	int 13h		; retry, CF error status, ah error number
  2675                              <1> 	retn
  2676                              <1> 
  2677                              <1> @@:			; NC or CY, stack has function number
  2678                              <1> 	inc sp
  2679                              <1> 	inc sp
  2680                              <1> 	inc sp
  2681                              <1> 	inc sp		; discard two words on stack, preserve CF
  2682                              <1> 	retn
  2683                              <1> 
  2684                              <1> 
  2685                              <1> .access_error:
  2686                              <1> 	mov dx, msg.boot_access_error
  2687                              <1> 	jmp .error_common_j
  2688                              <1> .sector_too_large:
  2689                              <1> 	mov dx, msg.boot_sector_too_large
  2690                              <1> 	jmp .error_common_j
  2691                              <1> .sector_too_small:
  2692                              <1> 	mov dx, msg.boot_sector_too_small
  2693                              <1> 	jmp .error_common_j
  2694                              <1> .sector_not_power:
  2695                              <1> 	mov dx, msg.boot_sector_not_power
  2696                              <1> 	jmp .error_common_j
  2697                              <1> .invalid_sectors:
  2698                              <1> 	mov dx, msg.boot_invalid_sectors
  2699                              <1> 	jmp .error_common_j
  2700                              <1> .invalid_heads:
  2701                              <1> 	mov dx, msg.boot_invalid_heads
  2702                              <1> .error_common_j:
  2703                              <1> 	jmp .error_common
  2704                              <1> 
  2705                              <1> .error_common: equ bootcmd.fail
  2706                              <1> 
  2707                              <1> 
  2708                              <1> 		; INP:	dx:ax = first sector
  2709                              <1> 		;	bx:0 -> buffer
  2710                              <1> 		; OUT:	dx:ax = sector number after last read
  2711                              <1> 		;	es = input bx
  2712                              <1> 		;	bx:0 -> buffer after last written
  2713                              <1> 		; CHG:	-
  2714                              <1> 		; STT:	ds = ss
  2715                              <1> read_ae_1536_bytes:
  2716                              <1> 	push cx
  2717                              <1> 	push bx
  2718                              <1> 	mov cx, 1536
  2719                              <1> .loop:
  2720                              <1> 	call read_sector
  2721                              <1> 	sub cx, word [bp + bsBPB + bpbBytesPerSector]
  2722                              <1> 	ja .loop
  2723                              <1> 	pop es
  2724                              <1> 	pop cx
  2725                              <1> 	retn
  2726                              <1> 
  2727                              <1> 		; INP:	dx:ax = first sector
  2728                              <1> 		;	bx:0 -> buffer
  2729                              <1> 		; OUT:	dx:ax = sector number after last read
  2730                              <1> 		;	es = input bx
  2731                              <1> 		;	bx:0 -> buffer after last written
  2732                              <1> 		; CHG:	-
  2733                              <1> 		; STT:	ds = ss
  2734                              <1> read_ae_512_bytes:
  2735                              <1> 	push cx
  2736                              <1> 	push bx
  2737                              <1> 	mov cx, 512
  2738                              <1> .loop:
  2739                              <1> 	call read_sector
  2740                              <1> 	sub cx, word [bp + bsBPB + bpbBytesPerSector]
  2741                              <1> 	ja .loop
  2742                              <1> 	pop es
  2743                              <1> 	pop cx
  2744                              <1> 	retn
  2745                              <1> 
  2746                              <1> 
  2747                              <1> 		; Read a sector using Int13.02 or Int13.42
  2748                              <1> 		;
  2749                              <1> 		; INP:	dx:ax = sector number (absolute in unit)
  2750                              <1> 		;	bx:0-> buffer
  2751                              <1> 		; OUT:	If unable to read,
  2752                              <1> 		;	 ! jumps to error instead of returning
  2753                              <1> 		;	If sector has been read,
  2754                              <1> 		;	 dx:ax = next sector number (has been incremented)
  2755                              <1> 		;	 bx:0-> next buffer (bx = es+word[load_sectorsizepara])
  2756                              <1> 		;	 es = input bx
  2757                              <1> 		; CHG:	-
  2758                              <1> 		;
  2759                              <1> 		; Note:	If error 09h (data boundary error) is returned,
  2760                              <1> 		;	 the read is done into the load_sectorseg buffer,
  2761                              <1> 		;	 then copied into the user buffer.
  2762                              <1> read_sector:
  2763                              <1> .err: equ bootcmd.fail_read
  2764                              <1> d5	call init1_d5dumpregs
  2765                              <1> d5	call init1_d5message
  2766                              <1> d5	asciz 13,10,"In read_sector",13,10
  2767                              <1> 
  2768                              <1> 	push ds
  2769                              <1> 	 push ss
  2770                              <1> 	 pop ds
  2771                              <1> 	push dx
  2772                              <1> 	push cx
  2773                              <1> 	push ax
  2774                              <1> 	push si
  2775                              <1> 
  2776                              <1> 	push bx
  2777                              <1> 
  2778                              <1> ; DX:AX==LBA sector number
  2779                              <1> ; add partition start (= number of hidden sectors)
  2780                              <1> 		add ax,[bp + bsBPB + bpbHiddenSectors + 0]
  2781                              <1> 		adc dx,[bp + bsBPB + bpbHiddenSectors + 2]
  2782                              <1> 
  2783                              <1> 	xor cx, cx
  2784                              <1> 	push cx
  2785                              <1> 	push cx
  2786                              <1> 	push dx
  2787                              <1> 	push ax		; qword sector number (lpSector)
  2788                              <1> 	push bx
  2789                              <1> 	push cx		; bx:0 -> buffer (lpBuffer)
  2790                              <1> 	inc cx
  2791                              <1> 	push cx		; word number of sectors to read (lpCount)
  2792                              <1> 	mov cl, 10h
  2793                              <1> 	push cx		; word size of disk address packet (lpSize)
  2794                              <1> 	mov si, sp	; ds:si -> disk address packet (on stack)
  2795                              <1> 
  2796                              <1> 	test byte [bp + ldHasLBA], 1
  2797                              <1> 	jz .no_lba
  2798                              <1> 
  2799                              <1> d5	call init1_d5message
  2800                              <1> d5	asciz "In read_sector.lba",13,10
  2801                              <1> 
  2802                              <1> 	mov dl, byte [load_unit]
  2803                              <1> 	mov ah, 42h
  2804                              <1> 	int 13h		; 13.42 extensions read
  2805                              <1> 	jnc .lba_done
  2806                              <1> 
  2807                              <1> 	xor ax, ax
  2808                              <1> 	int 13h
  2809                              <1> 	jc .lba_error
  2810                              <1> 
  2811                              <1> 		; have to reset the LBAPACKET's lpCount, as the handler may
  2812                              <1> 		;  set it to "the number of blocks successfully transferred".
  2813                              <1> 		; (in any case, the high byte is still zero.)
  2814                              <1> 	mov byte [si + lpCount], 1
  2815                              <1> 
  2816                              <1> 	mov ah, 42h
  2817                              <1> 	int 13h
  2818                              <1> 	jnc .lba_done
  2819                              <1> 
  2820                              <1> 	cmp ah, 9	; data boundary error?
  2821                              <1> 	jne .lba_error
  2822                              <1> 
  2823                              <1> d4	call init1_d4dumpregs
  2824                              <1> d4	call init1_d4message
  2825                              <1> d4	asciz 13,10,"In read_sector.lba_sectorseg",13,10
  2826                              <1> 
  2827                              <1> 		; the offset part of the pointer is already zero!
  2828                              <1> 	; push word [si + lpBuffer + 0]
  2829                              <1> 	push word [si + lpBuffer + 2]	; user buffer
  2830                              <1> 	 push word [load_sectorseg]
  2831                              <1> 	 pop word [si + lpBuffer + 2]
  2832                              <1> 	; and word [si + lpBuffer + 0], byte 0
  2833                              <1> 
  2834                              <1> 	mov byte [si + lpCount], 1
  2835                              <1> 	mov ah, 42h
  2836                              <1> 	int 13h
  2837                              <1> 	jnc .lba_sectorseg_done
  2838                              <1> 
  2839                              <1> 	xor ax, ax
  2840                              <1> 	int 13h
  2841                              <1> 	jc .lba_error
  2842                              <1> 
  2843                              <1> 	mov byte [si + lpCount], 1
  2844                              <1> 	mov ah, 42h
  2845                              <1> 	int 13h
  2846                              <1> 	jc .lba_error
  2847                              <1> .lba_sectorseg_done:
  2848                              <1> 
  2849                              <1> 	xor si, si
  2850                              <1> 	mov ds, word [load_sectorseg]
  2851                              <1> 	pop es
  2852                              <1> 	; pop cx
  2853                              <1> 	 push di
  2854                              <1> 	; mov di, cx
  2855                              <1> 	xor di, di
  2856                              <1> 	mov cx, word [load_sectorsize]
  2857                              <1> 	rep movsb
  2858                              <1> 	 pop di
  2859                              <1> 
  2860                              <1> 	push ss
  2861                              <1> 	pop ds
  2862                              <1> .lba_done:
  2863                              <1> 	add sp, 10h
  2864                              <1> 	pop bx
  2865                              <1> 	jmp .chs_done
  2866                              <1> 
  2867                              <1> .lba_error: equ .err
  2868                              <1> 
  2869                              <1> .no_lba:
  2870                              <1> 	add sp, 8
  2871                              <1> 	pop ax
  2872                              <1> 	pop dx
  2873                              <1> 	pop cx
  2874                              <1> 	pop cx
  2875                              <1> 
  2876                              <1> ; DX:AX=LBA sector number
  2877                              <1> ; divide by number of sectors per track to get sector number
  2878                              <1> ; Use 32:16 DIV instead of 64:32 DIV for 8088 compatability
  2879                              <1> ; Use two-step 32:16 divide to avoid overflow
  2880                              <1> 			mov cx,ax
  2881                              <1> 			mov ax,dx
  2882                              <1> 			xor dx,dx
  2883                              <1> 			div word [load_sectors]
  2884                              <1> 			xchg cx,ax
  2885                              <1> 			div word [load_sectors]
  2886                              <1> 			xchg cx,dx
  2887                              <1> 
  2888                              <1> ; DX:AX=quotient, CX=remainder=sector (S) - 1
  2889                              <1> ; divide quotient by number of heads
  2890                              <1> 			mov bx, ax
  2891                              <1> 			xchg ax, dx
  2892                              <1> 			xor dx, dx
  2893                              <1> 			div word [load_heads]
  2894                              <1> 			xchg bx, ax
  2895                              <1> 			div word [load_heads]
  2896                              <1> 
  2897                              <1> ; bx:ax=quotient=cylinder (C), dx=remainder=head (H)
  2898                              <1> ; move variables into registers for INT 13h AH=02h
  2899                              <1> 			mov dh, dl	; dh = head
  2900                              <1> 			inc cx		; cl5:0 = sector
  2901                              <1> 			xchg ch, al	; ch = cylinder 7:0, al = 0
  2902                              <1> 			shr ax, 1
  2903                              <1> 			shr ax, 1	; al7:6 = cylinder 9:8
  2904                              <1> 	; bx has bits set iff it's > 0, indicating a cylinder >= 65536.
  2905                              <1> 			 or bl, bh	; collect set bits from bh
  2906                              <1> 			or cl, al	; cl7:6 = cylinder 9:8
  2907                              <1> 	; ah has bits set iff it was >= 4, indicating a cylinder >= 1024.
  2908                              <1> 			 or bl, ah	; collect set bits from ah
  2909                              <1> 			mov dl, [load_unit]
  2910                              <1> 					; dl = drive
  2911                              <1> 			mov ah, 04h	; error number: sector not found
  2912                              <1> 			 jnz .err	; error if cylinder >= 1024 -->
  2913                              <1> 					; ! bx = 0 (for 13.02 call)
  2914                              <1> 
  2915                              <1> ; we call INT 13h AH=02h once for each sector. Multi-sector reads
  2916                              <1> ; may fail if we cross a track or 64K boundary
  2917                              <1> 			pop es
  2918                              <1> 
  2919                              <1> 			mov ax, 0201h
  2920                              <1> 			int 13h		; read one sector
  2921                              <1> 			jnc .done
  2922                              <1> ; reset drive
  2923                              <1> 			xor ax, ax
  2924                              <1> 			int 13h
  2925                              <1> 			jc .err
  2926                              <1> 
  2927                              <1> ; try read again
  2928                              <1> 			mov ax, 0201h
  2929                              <1> 			int 13h
  2930                              <1> 	jnc .done
  2931                              <1> 	cmp ah, 9	; data boundary error?
  2932                              <1> 	jne .err
  2933                              <1> 
  2934                              <1> d4	call init1_d4dumpregs
  2935                              <1> d4	call init1_d4message
  2936                              <1> d4	asciz 13,10,"In read_sector.chs_sectorseg",13,10
  2937                              <1> 
  2938                              <1> 	push es		; user buffer
  2939                              <1> 	 mov es, word [load_sectorseg]
  2940                              <1> 
  2941                              <1> 	mov ax, 0201h
  2942                              <1> 	int 13h
  2943                              <1> 	jnc .chs_sectorseg_done
  2944                              <1> 
  2945                              <1> 	xor ax, ax
  2946                              <1> 	int 13h
  2947                              <1> 	jc .err
  2948                              <1> 
  2949                              <1> 	mov ax, 0201h
  2950                              <1> 	int 13h
  2951                              <1> 	jc .err
  2952                              <1> .chs_sectorseg_done:
  2953                              <1> 
  2954                              <1> 	xor si, si
  2955                              <1> 	mov ds, word [load_sectorseg]
  2956                              <1> 	pop es
  2957                              <1> 	 push di
  2958                              <1> 	xor di, di
  2959                              <1> 	mov cx, word [load_sectorsize]
  2960                              <1> 	rep movsb
  2961                              <1> 	 pop di
  2962                              <1> 
  2963                              <1> 	push ss
  2964                              <1> 	pop ds
  2965                              <1> .done:
  2966                              <1> ; increment segment
  2967                              <1> 	mov bx, es
  2968                              <1> 
  2969                              <1> .chs_done:
  2970                              <1> 	mov es, bx
  2971                              <1> 	add bx, word [load_sectorsizepara]
  2972                              <1> 
  2973                              <1> 	pop si
  2974                              <1> 	pop ax
  2975                              <1> 	pop cx
  2976                              <1> 	pop dx
  2977                              <1> 	pop ds
  2978                              <1> ; increment LBA sector number
  2979                              <1> 	inc ax
  2980                              <1> 	jne @F
  2981                              <1> 	inc dx
  2982                              <1> @@:
  2983                              <1> 	retn
  2984                              <1> %endif
  2985                              <1> 
  2986                              <1> 
  2987                              <1> 		; INP:	ax => MCB to initialise
  2988                              <1> 		;	cx = owner to set (8 if S MCB)
  2989                              <1> 		;	bx = size to set
  2990                              <1> 		;	dl = MCB signature, "M" or "Z"
  2991                              <1> 		;	dh = S MCB type
  2992                              <1> 		; OUT:	-
  2993                              <1> 		; CHG:	-
  2994                              <1> ;	init1_insure_low_byte_not_0CCh
  2995                              <1> init2_init_an_mcb:
  2996                              <1>  assume ds:nothing, es:nothing, ss:nothing
  2997 00001995 50                  <1> 	push ax
  2998 00001996 1E                  <1> 	push ds
  2999 00001997 06                  <1> 	push es
  3000 00001998 57                  <1> 	push di
  3001 00001999 8ED8                <1> 	mov ds, ax
  3002                              <1>  assume ds:MCB
  3003 0000199B 8EC0                <1> 	mov es, ax
  3004                              <1>  assume es:MCB
  3005 0000199D 31FF                <1> 	xor di, di
  3006 0000199F 31C0                <1> 	xor ax, ax
  3007 000019A1 51                  <1> 	push cx
  3008 000019A2 B90800              <1> 	mov cx, MCB_size >> 1
  3009 000019A5 F3AB                <1> 	rep stosw
  3010 000019A7 59                  <1> 	pop cx
  3011 000019A8 894DF1              <1> 	mov word [di - MCB_size + mcbOwner], cx
  3012 000019AB 895DF3              <1> 	mov word [di - MCB_size + mcbSize], bx
  3013 000019AE 8855F0              <1> 	mov byte [di - MCB_size + mcbSignature], dl
  3014 000019B1 83F908              <1> 	cmp cx, 8
  3015 000019B4 7507                <1> 	jne @F
  3016 000019B6 C645F853            <1> 	mov byte [di - MCB_size + smcbName], "S"
  3017 000019BA 8875FA              <1> 	mov byte [di - MCB_size + smcbType], dh
  3018                              <1> @@:
  3019 000019BD 5F                  <1> 	pop di
  3020 000019BE 07                  <1> 	pop es
  3021                              <1>  assume es:nothing
  3022 000019BF 1F                  <1> 	pop ds
  3023                              <1>  assume ds:nothing
  3024 000019C0 58                  <1> 	pop ax
  3025 000019C1 C3                  <1> 	retn
  3026                              <1> 
  3027                              <1> 
  3028                              <1> %if 0	; lMS-DOS
  3029                              <1> disp_dxax_hex:			; dx:ax
  3030                              <1> 		xchg ax, dx
  3031                              <1> 		call disp_ax_hex
  3032                              <1> 		xchg ax, dx
  3033                              <1> init1_disp_ax_hex:
  3034                              <1> disp_ax_hex:			; ax
  3035                              <1> 		xchg al,ah
  3036                              <1> 		call disp_al_hex		; display former ah
  3037                              <1> 		xchg al,ah			;  and fall trough for al
  3038                              <1> disp_al_hex:			; al
  3039                              <1> 		push cx
  3040                              <1> 		mov cl,4
  3041                              <1> 		ror al,cl
  3042                              <1> 		call disp_al_lownibble_hex	; display former high-nibble
  3043                              <1> 		rol al,cl
  3044                              <1> 		pop cx
  3045                              <1> 						;  and fall trough for low-nibble
  3046                              <1> disp_al_lownibble_hex:
  3047                              <1> 		push ax			 ; save ax for call return
  3048                              <1> 		and al,00001111b		; high nibble must be zero
  3049                              <1> 		add al,'0'			; if number is 0-9, now it's the correct character
  3050                              <1> 		cmp al,'9'
  3051                              <1> 		jna .decimalnum		 ; if we get decimal number with this, ok -->
  3052                              <1> 		add al,7			;  otherwise, add 7 and we are inside our alphabet
  3053                              <1>  .decimalnum:
  3054                              <1> 		call disp_al
  3055                              <1> 		pop ax
  3056                              <1> 		retn
  3057                              <1> 
  3058                              <1> 
  3059                              <1> 		; INP:	ds:si -> first byte to check for name
  3060                              <1> 		;	cx = number of bytes left
  3061                              <1> 		; OUT:	(8+1+3+1)bytes[es:msg.foundname] = found name,
  3062                              <1> 		;	 converted to 8.3 ASCIZ format,
  3063                              <1> 		;	 "(None)" if none
  3064                              <1> 		;	CY if no filename found,
  3065                              <1> 		;	 si = INP:si + INP:cx
  3066                              <1> 		;	 cx = 0
  3067                              <1> 		;	NC if filename found,
  3068                              <1> 		;	 ds:si -> byte behind the name, thus ds:(si-11)-> name
  3069                              <1> 		;	 cx = number of bytes left
  3070                              <1> 		; CHG:	di, ax
  3071                              <1> findname:
  3072                              <1> .:
  3073                              <1> 	cmp cx, 11		; enough for another name ?
  3074                              <1> 	jb .none		; no -->
  3075                              <1> 				; (cx == 0 jumps here too)
  3076                              <1> .check:
  3077                              <1> 	push cx
  3078                              <1> 	push si
  3079                              <1> 	mov cx, 11
  3080                              <1> 	lodsb
  3081                              <1> 	mov ah, al		; check for same char in all 11 places
  3082                              <1> 	cmp al, 32		; first character must not be blank
  3083                              <1> 	je .check_fail		; if it is -->
  3084                              <1> ;	cmp al, 5		; first character may be 05h to indicate 0E5h
  3085                              <1> ;	je .check_pass
  3086                              <1> 	db __TEST_IMM8		; (skip lodsb)
  3087                              <1> .check_loop_same:
  3088                              <1> 	lodsb
  3089                              <1> 	cmp ah, al
  3090                              <1> 	jne .check_loop_differs
  3091                              <1> 	call .check_character
  3092                              <1> 	jc .check_fail
  3093                              <1> 	loop .check_loop_same
  3094                              <1> 		; if we arrive here, all characters (while valid) are the
  3095                              <1> 		;  same character repeated 11 times. we disallow this in case
  3096                              <1> 		;  that the padding character is an allowed one (eg '&' 26h).
  3097                              <1> .check_fail:
  3098                              <1> 	pop si
  3099                              <1> 	pop cx
  3100                              <1> 	dec cx			; lessen the counter
  3101                              <1> 	inc si			; -> next position to check
  3102                              <1> 	jmp .
  3103                              <1> 
  3104                              <1> .check_character:
  3105                              <1> 	cmp al, 32
  3106                              <1> 	jb .check_character_fail
  3107                              <1> 	cmp al, 127
  3108                              <1> ;	je .check_character_fail
  3109                              <1> 	jae .check_character_fail
  3110                              <1> 		; note: with all characters >= 128 allowed,
  3111                              <1> 		;  we get false positives in our sectors.
  3112                              <1> 	cmp al, '.'
  3113                              <1> 	je .check_character_fail
  3114                              <1> 	cmp al, '/'
  3115                              <1> 	je .check_character_fail
  3116                              <1> 	cmp al, '\'
  3117                              <1> 	je .check_character_fail
  3118                              <1> 	cmp al, 'a'
  3119                              <1> 	jb .check_character_pass
  3120                              <1> 	cmp al, 'z'
  3121                              <1> 	ja .check_character_pass
  3122                              <1> .check_character_fail:
  3123                              <1> 	stc
  3124                              <1> 	retn
  3125                              <1> 
  3126                              <1> .check_character_pass:
  3127                              <1> 	clc
  3128                              <1> 	retn
  3129                              <1> 
  3130                              <1> .check_loop:
  3131                              <1> 	lodsb
  3132                              <1> .check_loop_differs:
  3133                              <1> 	call .check_character
  3134                              <1> 	jc .check_fail
  3135                              <1> .check_pass:
  3136                              <1> 	loop .check_loop
  3137                              <1> 
  3138                              <1> 	pop ax			; (discard si)
  3139                              <1> 	sub si, 11		; -> at name
  3140                              <1> 
  3141                              <1> 	call convert_name_to_asciz
  3142                              <1> 				; si -> behind name
  3143                              <1> 	pop cx
  3144                              <1> 	sub cx, 11		; lessen the counter
  3145                              <1> 	clc
  3146                              <1> 	retn
  3147                              <1> 
  3148                              <1> .none:
  3149                              <1> 	 add si, cx
  3150                              <1> 	mov di, msg.foundname
  3151                              <1> 	 push si
  3152                              <1> 	 push ds
  3153                              <1> 	push cs
  3154                              <1> 	pop ds
  3155                              <1> 	mov si, msg.foundname_none
  3156                              <1> 	mov cx, (msg.foundname_none_size + 1) >> 1
  3157                              <1> 	rep movsw
  3158                              <1> 	 pop ds
  3159                              <1> 	 pop si
  3160                              <1> 	 xor cx, cx
  3161                              <1> 	stc
  3162                              <1> 	retn
  3163                              <1> 
  3164                              <1> 
  3165                              <1> 		; INP:	ds:si -> 11-byte blank-padded name
  3166                              <1> 		;	es:msg.foundname -> (8+1+3+1)-byte buffer
  3167                              <1> 		; OUT:	ds:si -> behind 11-byte blank-padded name
  3168                              <1> 		;	es:msg.foundname filled
  3169                              <1> 		; CHG:	cx, di, ax
  3170                              <1> convert_name_to_asciz:
  3171                              <1> 	mov di, msg.foundname
  3172                              <1> 	mov cx, 8
  3173                              <1> 	rep movsb		; copy over base name, si -> extension
  3174                              <1> 	cmp byte [es:di - 8], 05h	; is it 05h ?
  3175                              <1> 	jne @F			; no -->
  3176                              <1> 	mov byte [es:di - 8], 0E5h	; yes, convert to 0E5h
  3177                              <1> @@:
  3178                              <1> 
  3179                              <1> 	db __TEST_IMM8		; (skip dec)
  3180                              <1> @@:
  3181                              <1> 	dec di			; decrement -> at previous trailing blank
  3182                              <1> 	cmp byte [es:di - 1], 32	; trailing blank ?
  3183                              <1> 	je @B			; yes -->
  3184                              <1> 
  3185                              <1> 	mov al, '.'
  3186                              <1> 	stosb			; store dot (if needed)
  3187                              <1> 	mov cl, 3
  3188                              <1> 	rep movsb		; copy over extension, si -> behind name
  3189                              <1> 
  3190                              <1> 	db __TEST_IMM8		; (skip dec)
  3191                              <1> @@:
  3192                              <1> 	dec di			; decrement -> at previous trailing blank
  3193                              <1> 	cmp byte [es:di - 1], 32	; trailing blank ?
  3194                              <1> 	je @B			; yes -->
  3195                              <1> 
  3196                              <1> 	cmp byte [es:di - 1], '.'	; trailing dot ? (only occurs if all-blank ext)
  3197                              <1> 	jne @F			; no -->
  3198                              <1> 	dec di			; -> at the dot
  3199                              <1> @@:
  3200                              <1> 	mov al, 0
  3201                              <1> 	stosb			; store filename terminator
  3202                              <1> 	retn
  3203                              <1> 
  3204                              <1> 
  3205                              <1> %if _DEBUG5 || _DEBUG4
  3206                              <1> init1_d5dumpregs:
  3207                              <1> init1_d4dumpregs:
  3208                              <1> 	pushf
  3209                              <1> 	push ax
  3210                              <1> 	push bx
  3211                              <1> 	push cx
  3212                              <1> 	push dx
  3213                              <1> 	push si
  3214                              <1> 	push di
  3215                              <1> 	push bp
  3216                              <1> 	mov ax, sp
  3217                              <1> 	add ax, byte 18
  3218                              <1> 	push ax
  3219                              <1> 	push cs
  3220                              <1> 	push ss
  3221                              <1> 	push ds
  3222                              <1> 	push es
  3223                              <1> 
  3224                              <1> 	mov bx, sp
  3225                              <1> 	mov ax, 1<<8|7
  3226                              <1> 	push ax
  3227                              <1> 	mov ax, 14
  3228                              <1> 	push cs
  3229                              <1> 	pop ds
  3230                              <1> 	mov dx, .regnames
  3231                              <1> 
  3232                              <1> 	mov bp, sp
  3233                              <1> %assign _columns	0
  3234                              <1> %assign _blanks		1
  3235                              <1> 
  3236                              <1> 	xor cx, cx
  3237                              <1> 
  3238                              <1> .looprows:
  3239                              <1> 	push ax
  3240                              <1> 	mov al, 13
  3241                              <1> 	call init1_disp_al
  3242                              <1> 	mov al, 10
  3243                              <1> 	call init1_disp_al
  3244                              <1> %if 0
  3245                              <1> 	push cx
  3246                              <1> 	push dx
  3247                              <1> 	xor cx, cx
  3248                              <1> 	mov cl, byte [ _blanks + bp ]
  3249                              <1> 	jcxz .doneblanks
  3250                              <1> 	mov al, 32
  3251                              <1> .loopblanks:
  3252                              <1> 	call init1_disp_al
  3253                              <1> 	loop .loopblanks
  3254                              <1> .doneblanks:
  3255                              <1> 	pop dx
  3256                              <1> 	pop cx
  3257                              <1> %endif
  3258                              <1> 	pop ax
  3259                              <1> 
  3260                              <1> 	mov cl, byte [ _columns + bp ]
  3261                              <1> .loopcolumns:
  3262                              <1> 	call init1_disp_reg
  3263                              <1> 	add dx, byte 2
  3264                              <1> 	add bx, byte 2
  3265                              <1> 	dec ax
  3266                              <1> 	jz .done
  3267                              <1> 	loop .loopcolumns
  3268                              <1> 	jmp short .looprows
  3269                              <1> 
  3270                              <1> .done:
  3271                              <1> 	pop ax
  3272                              <1> 
  3273                              <1> 	pop es
  3274                              <1> 	pop ds
  3275                              <1> 	pop ax
  3276                              <1> 	pop ax
  3277                              <1> 	pop ax
  3278                              <1> 	pop bp
  3279                              <1> 	pop di
  3280                              <1> 	pop si
  3281                              <1> 	pop dx
  3282                              <1> 	pop cx
  3283                              <1> 	pop bx
  3284                              <1> 	pop ax
  3285                              <1> 	popf
  3286                              <1> 	retn
  3287                              <1> 
  3288                              <1> .regnames:
  3289                              <1> 	db "esdssscsspbpdisidxcxbxaxflip"
  3290                              <1> 
  3291                              <1> 
  3292                              <1> 	; ss:bx-> word value
  3293                              <1> 	; ds:dx-> 2-byte message
  3294                              <1> init1_disp_reg:
  3295                              <1> 	push ax
  3296                              <1> 	xchg bx, dx
  3297                              <1> 	mov ax, [ bx ]				; get 2 bytes at [ ds:dx ]
  3298                              <1> 	xchg bx, dx
  3299                              <1> 	call init1_disp_al
  3300                              <1> 	xchg al, ah
  3301                              <1> 	call init1_disp_al
  3302                              <1> 
  3303                              <1> 	mov al, '='
  3304                              <1> 	call init1_disp_al
  3305                              <1> 
  3306                              <1> 	mov ax, [ ss:bx ]
  3307                              <1> 	call disp_ax_hex
  3308                              <1> 
  3309                              <1> 	mov al, 32
  3310                              <1> 	call init1_disp_al
  3311                              <1> 	pop ax
  3312                              <1> 	retn
  3313                              <1> 
  3314                              <1> init1_disp_stack_hex:
  3315                              <1> 	push ax
  3316                              <1> 	push bp
  3317                              <1> 	mov bp, sp
  3318                              <1> 	mov ax, [bp+6]
  3319                              <1> 	pop bp
  3320                              <1> 	call init1_disp_ax_hex
  3321                              <1> 	pop ax
  3322                              <1> 	retn 2
  3323                              <1> 
  3324                              <1> init1_d5message:
  3325                              <1> init1_d4message:
  3326                              <1> 	push ax
  3327                              <1> 	push bx
  3328                              <1> 	push si
  3329                              <1> 	push ds
  3330                              <1> 	push bp
  3331                              <1> 	mov bp, sp
  3332                              <1> 	mov si, [bp+10]
  3333                              <1> 	pushf
  3334                              <1> 	 push cs
  3335                              <1> 	 pop ds
  3336                              <1> 	call init1_disp_msg
  3337                              <1> 	popf
  3338                              <1> 	mov word [bp+10], si
  3339                              <1> 	pop bp
  3340                              <1> 	pop ds
  3341                              <1> 	pop si
  3342                              <1> 	pop bx
  3343                              <1> 	pop ax
  3344                              <1> 	retn
  3345                              <1> 
  3346                              <1> init1_d4uppercase:
  3347                              <1> 	pushf
  3348                              <1> 	cmp al, 'a'
  3349                              <1> 	jb .return
  3350                              <1> 	cmp al, 'z'
  3351                              <1> 	ja .return
  3352                              <1> 	and al, ~ 20h
  3353                              <1> .return:
  3354                              <1> 	popf
  3355                              <1> 	retn
  3356                              <1> %endif
  3357                              <1> 
  3358                              <1> 
  3359                              <1> %if _TEST_PAYLOAD
  3360                              <1> 	align 4
  3361                              <1> table:
  3362                              <1> 	dw  +0, "SS"
  3363                              <1> 	dw +12, "BP"
  3364                              <1> 	dw +10, "SP"
  3365                              <1> 	dw  +6, "CS"
  3366                              <1> 	dw  +8, "IP"
  3367                              <1> 	dw +26, "FL"
  3368                              <1> 	db -1, -1, 13,10
  3369                              <1> 	dw  +4, "DS"
  3370                              <1> 	dw +16, "SI"
  3371                              <1> 	dw  +2, "ES"
  3372                              <1> 	dw +14, "DI"
  3373                              <1> 	db -1, -1, 13,10
  3374                              <1> 	dw +24, "AX"
  3375                              <1> 	dw +22, "BX"
  3376                              <1> 	dw +20, "CX"
  3377                              <1> 	dw +18, "DX"
  3378                              <1> 	db -1, -1, 13,10
  3379                              <1> 	dw +28, "S0"
  3380                              <1> 	dw +30, "S1"
  3381                              <1> 	dw +32, "S2"
  3382                              <1> 	dw +34, "S3"
  3383                              <1> 	dw +36, "S4"
  3384                              <1> 	dw +38, "S5"
  3385                              <1> 	dw +40, "S6"
  3386                              <1> 	dw +42, "S7"
  3387                              <1> 	db -1, -1, 13,10
  3388                              <1> 	dw +44, "S8"
  3389                              <1> 	dw +46, "S9"
  3390                              <1> 	dw +48, "SA"
  3391                              <1> 	dw +50, "SB"
  3392                              <1> 	dw +52, "SC"
  3393                              <1> 	dw +54, "SD"
  3394                              <1> 	dw +56, "SE"
  3395                              <1> 	dw +58, "SF"
  3396                              <1> 	db -1, -1, 13,10
  3397                              <1> .end:
  3398                              <1> %endif
  3399                              <1> 
  3400                              <1> 
  3401                              <1> 	align 4
  3402                              <1> mcbtable:
  3403                              <1> 	times 6 dd -1
  3404                              <1> 		; MCB after INIT3
  3405                              <1> 		; S_INITSTACKBPB
  3406                              <1> 		; S_INITFATSEG
  3407                              <1> 		; S_SECTORSEG
  3408                              <1> 		; ldMemoryTop (in front of RPL, or last)
  3409                              <1> 		; int 12h memory top (if RPL exists)
  3410                              <1> 	dd -1
  3411                              <1> 
  3412                              <1> boot_partition:
  3413                              <1> 	dd 0
  3414                              <1> boot_unit:
  3415                              <1> 	db 0
  3416                              <1> boot_drive:
  3417                              <1> 	db 0
  3418                              <1> 
  3419                              <1> 
  3420                              <1> 	align 4
  3421                              <1> throw_sp:	dw 0
  3422                              <1> throw_ip:	dw 0
  3423                              <1> 
  3424                              <1> fsparm_pointer:	dw fsparm
  3425                              <1> fsparm_excess:	dw 0
  3426                              <1> fsparm_number:	db 0
  3427                              <1> 
  3428                              <1> 	align 16
  3429                              <1> partition_table:
  3430                              <1> 	times 4 * 16 db 0
  3431                              <1> .end:
  3432                              <1> 
  3433                              <1> 	align 16
  3434                              <1> fsparm:
  3435                              <1> times FSPARM_size * 32 db 0
  3436                              <1> 
  3437                              <1> 
  3438                              <1> 	align 16
  3439                              <1> init1_end:
  3440                              <1> 
  3441                              <1> %if INIT1_INSURE_COUNT
  3442                              <1>  %warning init1_insure_low_byte_not_0CCh needed INIT1_INSURE_COUNT times
  3443                              <1> %endif
  3444                              <1> 
  3445                              <1> 	istruc MCB
  3446                              <1> at mcbSignature,	db "M"
  3447                              <1> at mcbOwner,		dw 8
  3448                              <1> at mcbSize,		dw (init2_end - init2_start) >> 4
  3449                              <1> at smcbName,		dw "S"
  3450                              <1> at smcbType,		db S_INIT
  3451                              <1> 	iend
  3452                              <1> 
  3453                              <1> 	; section INIT2 align=16 follows=INIT1 vstart=0
  3454                              <1> init2_start:
  3455                              <1> 	jmp near RxDOS_initialize
  3456                              <1> 
  3457                              <1> 	align 2
  3458                              <1> init2_to_init1_segment:	dw 0
  3459                              <1> 
  3460                              <1> %endif
  3461                              <1> 
  3462                              <1> 
  3463                              <1> %if 1 || (_RELOCATEDOSCODE && _DOSCODEHMA)
  3464 000019C2 90<rep 2h>          <1> 	align 4
  3465 000019C4 00000000            <1> init2_xmsentry:		dd 0
  3466                              <1> %endif
  3467                              <1> 
  3468                              <1> 
  3469 000019C8 90<rep 8h>          <1> 	align 16
  3470                              <1> init2_hma_vdisk_header:
  3471                              <1> 	istruc BS
  3472 000019D0 000000              <1> at bsJump,	db 0,0,0
  3473 000019D3 564449534B332E33    <1> at bsOEM,	db "VDISK3.3"
  3474                              <1> at bsBPB
  3475                              <1> 	iend
  3476                              <1> 		istruc EBPB
  3477 000019DB 80                  <1> at bpbBytesPerSector,	db 80h	; (128)
  3478 000019DC 0001                <1> at bpbSectorsPerCluster,db 1
  3479 000019DE 0100                <1> at bpbReservedSectors,	dw 1
  3480 000019E0 01                  <1> at bpbNumFATs,		db 1
  3481 000019E1 4000                <1> at bpbNumRootDirEnts,	dw 40h	; (64)
  3482 000019E3 0002                <1> at bpbTotalSectors,	dw 200h	; (512)	; 512 sectors * 128 B/sector = 64 KiB
  3483 000019E5 FE                  <1> at bpbMediaID,		db 0FEh
  3484 000019E6 0600                <1> at bpbSectorsPerFAT,	dw 6
  3485 000019E8 0800                <1> at bpbCHSSectors,	dw 8
  3486 000019EA 0100                <1> at bpbCHSHeads,		dw 1
  3487 000019EC 0000                <1> at bpbHiddenSectors,	dw 0
  3488                              <1> 		%pop ; iend
  3489 000019EE 4004                <1> 			dw 0440h	; (1088)
  3490                              <1> 				; VCPI.txt: size word in boot block, "KB addr"
  3491                              <1>  endarea init2_hma_vdisk_header
  3492                              <1> 
  3493                              <1> 
  3494                              <1> %if 0
  3495                              <1> 		; INP:	word [cs:ip] = near function to call in other segment
  3496                              <1> 		;	cs:(ip + 2) -> where to return to
  3497                              <1> 		;	word [DOSDATA:dosdata_to_doscode_segment] = DOSCODE
  3498                              <1> 		;	word [70h:dosentry_to_dosdata_segment] = DOSDATA
  3499                              <1> 		;	DOSCODE:doscode_retf -> retf opcode
  3500                              <1> 		;	INIT1
  3501                              <1> init2_to_doscode:
  3502                              <1> 	push ax			; word space for ?returnaddress_ip, is ax
  3503                              <1> 	push bx			; word space for ?returnaddress_other_ip, is bx
  3504                              <1> 	push ds
  3505                              <1> 	mov ax, 70h
  3506                              <1> 	mov ds, ax		; => DOSENTRY
  3507                              <1> 	mov ds, word [dosentry_to_dosdata_segment]	; => DOSDATA
  3508                              <1> 	mov ax, word [dosdata_to_doscode_segment]	; => DOSCODE
  3509                              <1> 	pop ds
  3510                              <1> 	mov bx, doscode_retf	; other:bx -> retf opcode
  3511                              <1> 	jmp init2_to_other_segment_common
  3512                              <1> 
  3513                              <1> init2_to_init1:
  3514                              <1> 	push ax			; word space for ?returnaddress_ip
  3515                              <1> 	push bx			; word space for ?returnaddress_other_ip
  3516                              <1> 	mov ax, word [cs:init2_to_init1_segment]	; => INIT1
  3517                              <1> 	mov bx, init1_retf	; other:bx -> retf opcode
  3518                              <1> 
  3519                              <1> init2_to_other_segment_common:
  3520                              <1> 	push ax
  3521                              <1> 	push ax			; dword space for ?jumpaddress
  3522                              <1> 	lframe 0
  3523                              <1> 	lpar word, returnaddress_cs_and_orig_ip
  3524                              <1> 	lpar word, returnaddress_ip
  3525                              <1> 	lpar word, returnaddress_other_ip
  3526                              <1> 	lpar dword, jumpaddress
  3527                              <1> 	lenter
  3528                              <1> 
  3529                              <1> 	push si
  3530                              <1> 	pushf
  3531                              <1> 	cld
  3532                              <1> 
  3533                              <1> 	mov word [bp + ?jumpaddress + 2], ax		; fill function segment
  3534                              <1> 	mov si, cs
  3535                              <1> 	xchg si, word [bp + ?returnaddress_cs_and_orig_ip]	; fill cs
  3536                              <1> 	cs lodsw
  3537                              <1> 	cmp al, 0CCh		; debugger breakpoint ?
  3538                              <1> 	jne @F			; no -->
  3539                              <1> 	int3			; break to make it remove the breakpoint
  3540                              <1> 	dec si
  3541                              <1> 	dec si
  3542                              <1> 	cs lodsw		; reload the word
  3543                              <1> 	cmp al, 0CCh
  3544                              <1> 	jne @F
  3545                              <1> 
  3546                              <1> .l:
  3547                              <1> 	int3
  3548                              <1> 	jmp .l
  3549                              <1> 
  3550                              <1> @@:
  3551                              <1> 	mov word [bp + ?jumpaddress + 0], ax		; fill function offset
  3552                              <1> 	xchg ax, si					; ip in our cs
  3553                              <1> 	xchg ax, [bp + ?returnaddress_ip]		; fill ip
  3554                              <1> 		; (and restore ax)
  3555                              <1> 
  3556                              <1> 	xchg bx, word [bp + ?returnaddress_other_ip]	; fill near ip in other
  3557                              <1> 		; (and restore bx)
  3558                              <1> 
  3559                              <1> 	popf
  3560                              <1> 	pop si
  3561                              <1> 
  3562                              <1> 	lleave
  3563                              <1> 	retf			; jump to dword [bp + ?jumpaddress]
  3564                              <1> 
  3565                              <1> 
  3566                              <1> 		; INP:	ax = space in bytes to allocate at top of LMA
  3567                              <1> 		;	cl = allocation type
  3568                              <1> 		; OUT:	es:di-> allocated space, initialised to all zeros
  3569                              <1> 		;	ax = cx = space in bytes allocated,
  3570                              <1> 		;	 ! 0 if size is 65536
  3571                              <1> 		;	does not return after allocation failure
  3572                              <1> 		; CHG:	-
  3573                              <1> init2_alloc_s_mcb_top:
  3574                              <1> 	call init2_to_init1
  3575                              <1> 	dw init1_alloc_s_mcb_top
  3576                              <1> 	retn
  3577                              <1> 
  3578                              <1> 
  3579                              <1> 		; INP:	ax = space in bytes to allocate
  3580                              <1> 		;	cl = allocation type
  3581                              <1> 		; OUT:	es:di-> allocated space, initialised to all zeros
  3582                              <1> 		;	ax = cx = space in bytes allocated,
  3583                              <1> 		;	 ! 0 if size is 65536
  3584                              <1> 		;	does not return after allocation failure
  3585                              <1> 		; CHG:	-
  3586                              <1> init2_alloc_s_mcb:
  3587                              <1> 	call init2_to_init1
  3588                              <1> 	dw init1_alloc_s_mcb
  3589                              <1> 	retn
  3590                              <1> 
  3591                              <1> 
  3592                              <1> init2_call_rploader:
  3593                              <1> 	call init2_to_init1
  3594                              <1> 	dw init1_call_rploader
  3595                              <1> 	retn
  3596                              <1> %endif
  3597                              <1> 
  3598                              <1> 
  3599                              <1> 		; CHG:	ds, si, ax
  3600                              <1> 		; OUT:	NZ if A20 line is switched on
  3601                              <1> 		;	ZR if A20 line is switched off
  3602                              <1> 		;	may return with IF=0
  3603                              <1> 		;	UP
  3604                              <1> init2_check_a20:
  3605                              <1>  assume ds:nothing, es:nothing, ss:nothing
  3606 000019F0 FC                  <1> 	cld
  3607 000019F1 06                  <1> 	push es
  3608 000019F2 57                  <1> 	push di
  3609 000019F3 51                  <1> 	push cx
  3610 000019F4 31F6                <1> 	xor si, si
  3611 000019F6 8EDE                <1> 	mov ds, si		; ds = 0000h
  3612                              <1>  assume ds:IVT
  3613 000019F8 4E                  <1> 	dec si
  3614 000019F9 8EC6                <1> 	mov es, si		; es = FFFFh
  3615                              <1>  assume es:nothing
  3616 000019FB 46                  <1> 	inc si			; ds:si = 0000h:0000h =  00000h
  3617 000019FC BF1000              <1> 	mov di, 0010h		; es:di = FFFFh:0010h = 100000h
  3618                              <1> 				;  (same address if bit 20 off)
  3619 000019FF 89F9                <1> 	mov cx, di		; 32 byte (16 = 10h word)
  3620 00001A01 F3A7                <1> 	repe cmpsw		; compare, A20 line switched on if differing
  3621 00001A03 7512                <1> 	jne .ret		; differing -->
  3622                              <1> 
  3623 00001A05 FA                  <1> 	cli			; try not to run interrupt handlers during this
  3624 00001A06 BF1000              <1> 	mov di, 10h		; -> FFFFh:0010h = 10_0000h
  3625                              <1> 				;  (in the HMA, part of the VDISK header)
  3626 00001A09 8D75F0              <1> 	lea si, [di - 10h]	; -> 0000h:0000h = 00_0000h
  3627                              <1> 				;  (in the LMA, offset word of int 00h handler)
  3628 00001A0C 26FF35              <1> 	push word [es:di]	; save value
  3629 00001A0F 26FF0D              <1> 	dec word [es:di]	; change value (in HMA, or wrapped around LMA)
  3630 00001A12 A7                  <1> 	cmpsw			; compare values, NZ if A20 is switched on
  3631 00001A13 268F45FE            <1> 	pop word [es:di - 2]	; restore value
  3632                              <1> 		; This can still report a false negative (A20 detected off
  3633                              <1> 		;  when actually it is on), but we don't care about that.
  3634                              <1> .ret:
  3635 00001A17 59                  <1> 	pop cx
  3636 00001A18 5F                  <1> 	pop di
  3637 00001A19 07                  <1> 	pop es
  3638                              <1>  assume es:nothing
  3639 00001A1A C3                  <1> 	retn
  3640                              <1> 
  3641                              <1> 
  3642                              <1> %if _RELOCATEDOSCODE
  3643                              <1> extern dosdata_to_doscode_segment
  3644                              <1> %endif
  3645                              <1> 
  3646                              <1> 		; This is to be called after each device driver is installed.
  3647                              <1> 		;  It relocates DOSCODE to the HMA if it is available.
  3648                              <1> 		; May be extended to relocate more things later.
  3649                              <1> 		;
  3650                              <1> 		; INP:	ax = flags
  3651                              <1> 		; CHG:	ds, es, si, di, ax, bx, cx, dx
  3652                              <1> init2_relocate_device:
  3653                              <1>  assume ds:nothing, es:nothing, ss:nothing
  3654                              <1> 	lframe 0
  3655                              <1> 	lvar word, umb_first_umcb
  3656                              <1> 	lvar word, umb_last_umcb
  3657                              <1> 	lvar word, last_mcb
  3658 00001A1B 5589E58D66FA        <1> 	lenter
  3659                              <1> 	lvar word, flags
  3660 00001A21 50                  <1> 	 push ax
  3661                              <1> 	lvar word, first_mcb
  3662 00001A22 B452                <1> 	mov ah, 52h
  3663 00001A24 CD21                <1> 	int 21h
  3664                              <1>  assume es:DOSGROUP
  3665 00001A26 26FF77FE            <1> 	 push word [es:bx - 2]
  3666                              <1> 	lvar word, first_umcb
  3667 00001A2A B86112              <1> 	mov ax, 1261h
  3668 00001A2D CD2F                <1> 	int 2Fh
  3669 00001A2F 50                  <1> 	 push ax
  3670                              <1> 
  3671                              <1> %if !_COMBINED_DOSDATA_DOSCODE && _RELOCATEDOSCODE && _DOSCODEHMA
  3672                              <1> 
  3673 00001A30 2ED006[1408]        <1> 	rol byte [cs:doscode_relocated_to_final_position], 1
  3674 00001A35 7303E98501          <1> 	jc .no_doscode_reloc
  3675                              <1> 
  3676                              <1> %if 0
  3677                              <1> 	mov ax, 70h
  3678                              <1> 	mov ds, ax
  3679                              <1> 	mov ds, word [dosentry_to_dosdata_segment]
  3680                              <1> %else
  3681 00001A3A 31C0                <1> 	xor ax, ax
  3682 00001A3C 8ED8                <1> 	mov ds, ax
  3683                              <1>  assume ds:IVT
  3684 00001A3E 8E1EC600            <1> 	mov ds, word [31h * 4 + 2]	; => DOSDATA
  3685                              <1>  assume ds:DOSGROUP
  3686                              <1> %endif
  3687 00001A42 8B1E[0000]          <1> 	mov bx, word [dosdata_to_doscode_segment]
  3688 00001A46 83FBFE              <1> 	cmp bx, DOSCODE_HMA_SEGMENT		; already in HMA ?
  3689 00001A49 7203E97101          <1> 	jae .not_doscode_to_hma	; yes, return -->
  3690                              <1> 
  3691 00001A4E F746F80200          <1> 	test word [bp + ?flags], DOSFLAGS_RELOCATE_DOSCODE_HMA
  3692 00001A53 7503E96701          <1> 	jz .not_doscode_to_hma
  3693                              <1> 
  3694 00001A58 B80043              <1> 	mov ax, 4300h
  3695 00001A5B CD2F                <1> 	int 2Fh			; XMS present ?
  3696 00001A5D 3C80                <1> 	cmp al, 80h
  3697 00001A5F 7403E95B01          <1> 	jne .not_doscode_to_hma	; no -->
  3698                              <1> 
  3699 00001A64 B81043              <1> 	mov ax, 4310h
  3700 00001A67 CD2F                <1> 	int 2Fh			; get XMS entrypoint
  3701 00001A69 2E891E[C419]        <1> 	mov word [cs:init2_xmsentry], bx
  3702 00001A6E 2E8C06[C619]        <1> 	mov word [cs:init2_xmsentry + 2], es		; store
  3703                              <1> 
  3704 00001A73 B80001              <1> 	mov ax, 0100h
  3705 00001A76 BAFFFF              <1> 	mov dx, -1
  3706 00001A79 E8A503              <1> 	call .call_xms		; allocate HMA
  3707 00001A7C 7303E93E01          <1> 	jc .not_doscode_to_hma	; failure -->
  3708                              <1> 
  3709 00001A81 B403                <1> 	mov ah, 03h
  3710 00001A83 E89B03              <1> 	call .call_xms		; enable A20
  3711 00001A86 BA[6620]            <1> 	mov dx, init2_msg.error_enabling_a20_xms
  3712 00001A89 7303E92901          <1> 	jc .not_doscode_free	; error -->
  3713                              <1> 
  3714 00001A8E E85FFF              <1> 	call init2_check_a20	; check A20 is enabled
  3715 00001A91 BA[9320]            <1> 	mov dx, init2_msg.error_enabling_a20_actual
  3716 00001A94 7503E91E01          <1> 	jz .not_doscode_free	; error -->
  3717                              <1> 
  3718 00001A99 B8[ssss]            <1> 	mov ax, DOSENTRY
  3719 00001A9C 8ED8                <1> 	mov ds, ax
  3720                              <1>  assume ds:DOSENTRYGROUP
  3721 00001A9E 2EFF36[C619]        <1> 	push word [cs:init2_xmsentry + 2]
  3722 00001AA3 2EFF36[C419]        <1> 	push word [cs:init2_xmsentry]
  3723 00001AA8 FA                  <1> 	cli
  3724 00001AA9 8F06[0000]          <1> 	pop word [dosentry_xmsentry]
  3725 00001AAD 8F06[0200]          <1> 	pop word [dosentry_xmsentry + 2]
  3726                              <1>  extern ..@dosentry_patch_hma
  3727 00001AB1 C706[0000]87C0      <1> 	mov word [..@dosentry_patch_hma], 0C087h	; xchg ax, modrm ax
  3728 00001AB7 FB                  <1> 	sti
  3729                              <1> 
  3730 00001AB8 2E833E[0000]00      <1> 	cmp word [cs:autobounce_both_options], 0
  3731 00001ABE 7423                <1> 	je .no_bounce_test
  3732                              <1> 
  3733 00001AC0 B8[ssss]            <1> 	mov ax, DOSENTRY
  3734 00001AC3 B104                <1> 	mov cl, 4
  3735 00001AC5 D3E0                <1> 	shl ax, cl
  3736 00001AC7 2E0106[6E1F]        <1> 	add word [cs:int25packet.offset], ax
  3737                              <1> 					; -> into HMA, corresponding to DISKSECTOR
  3738                              <1> 
  3739 00001ACC BB[0000]            <1> 	mov bx, autobouncehmachs_option
  3740 00001ACF BF[0000]            <1> 	mov di, config_bounce_hma_chs
  3741 00001AD2 31C0                <1> 	xor ax, ax
  3742 00001AD4 E8CE03              <1> 	call detect_bounce
  3743                              <1>  assume ds:nothing, es:nothing, ss:nothing
  3744                              <1> 
  3745 00001AD7 BB[0000]            <1> 	mov bx, autobouncehmalba_option
  3746 00001ADA BF[0000]            <1> 	mov di, config_bounce_hma_lba
  3747 00001ADD B80004              <1> 	mov ax, F_LBA
  3748 00001AE0 E8C203              <1> 	call detect_bounce
  3749                              <1>  assume ds:nothing, es:nothing, ss:nothing
  3750                              <1> .no_bounce_test:
  3751                              <1> 
  3752 00001AE3 BAFFFF              <1> 	mov dx, -1
  3753 00001AE6 8EC2                <1> 	mov es, dx
  3754                              <1>  assume es:nothing
  3755 00001AE8 BF1000              <1> 	mov di, 10h
  3756 00001AEB 0E                  <1> 	push cs
  3757 00001AEC 1F                  <1> 	pop ds
  3758                              <1>  assume ds:SYSINITGROUP
  3759 00001AED BE[D019]            <1> 	mov si, init2_hma_vdisk_header
  3760 00001AF0 B91000              <1> 	mov cx, init2_hma_vdisk_header_size_w
  3761 00001AF3 F3A5                <1> 	rep movsw
  3762                              <1> %if init2_hma_vdisk_header_size != 32
  3763                              <1>  %error Expected HMA VDISK header to be 32 bytes long
  3764                              <1> %endif
  3765 00001AF5 B90800              <1> 	mov cx, 10h >> 1
  3766 00001AF8 31C0                <1> 	xor ax, ax
  3767 00001AFA F3AB                <1> 	rep stosw
  3768 00001AFC 83EF10              <1> 	sub di, 10h
  3769                              <1> 
  3770                              <1> %if 0
  3771                              <1> 	mov cx, (doscode_end - doscode_start)
  3772                              <1> %else
  3773                              <1> extern afterdoscodelabel
  3774 00001AFF B9[0000]            <1> 	mov cx, afterdoscodelabel wrt DOSCODEGROUP
  3775 00001B02 83E950              <1> 	sub cx, DOSCODE_HMA_OFFSET
  3776                              <1> %endif
  3777                              <1> 
  3778 00001B05 BAFEFF              <1> 	mov dx, DOSCODE_HMA_SEGMENT
  3779 00001B08 26C7054D53          <1> 	mov word [es:di + hmcbSignature], "MS"
  3780 00001B0D 26895502            <1> 	mov word [es:di + hmcbOwner], dx
  3781 00001B11 26894D04            <1> 	mov word [es:di + hmcbSize], cx
  3782 00001B15 89FB                <1> 	mov bx, di
  3783 00001B17 83C310              <1> 	add bx, HMCB_size
  3784 00001B1A 01CB                <1> 	add bx, cx
  3785 00001B1C 26895D06            <1> 	mov word [es:di + hmcbNext], bx
  3786 00001B20 26C74508444F        <1> 	mov word [es:di + hmcbName], "DO"
  3787 00001B26 26C7450A5343        <1> 	mov word [es:di + hmcbName + 2], "SC"
  3788 00001B2C 26C7450C4F44        <1> 	mov word [es:di + hmcbName + 4], "OD"
  3789 00001B32 26C6450E45          <1> 	mov byte [es:di + hmcbName + 6], "E"
  3790                              <1> 
  3791 00001B37 89DF                <1> 	mov di, bx
  3792 00001B39 31C0                <1> 	xor ax, ax
  3793 00001B3B 51                  <1> 	 push cx
  3794 00001B3C B90800              <1> 	mov cx, 16 >> 1
  3795 00001B3F F3AB                <1> 	rep stosw
  3796 00001B41 59                  <1> 	 pop cx
  3797 00001B42 89DF                <1> 	mov di, bx
  3798 00001B44 26C7054D53          <1> 	mov word [es:di + hmcbSignature], "MS"
  3799                              <1> 	; word [es:di + hmcbOwner] already == 0
  3800 00001B49 89DE                <1> 	mov si, bx
  3801 00001B4B 83C610              <1> 	add si, 10h
  3802 00001B4E F7DE                <1> 	neg si
  3803 00001B50 26897504            <1> 	mov word [es:di + hmcbSize], si
  3804                              <1> 	; word [es:di + hmcbNext] already == 0
  3805                              <1> 
  3806 00001B54 8EC2                <1> 	mov es, dx
  3807                              <1>  assume es:nothing
  3808 00001B56 BF5000              <1> 	mov di, DOSCODE_HMA_OFFSET
  3809 00001B59 89FE                <1> 	mov si, di
  3810                              <1> %if 0
  3811                              <1> 	mov dx, 70h
  3812                              <1> 	mov ds, dx
  3813                              <1> 	mov ds, word [dosentry_to_dosdata_segment]
  3814                              <1> %else
  3815 00001B5B 31D2                <1> 	xor dx, dx
  3816 00001B5D 8EDA                <1> 	mov ds, dx
  3817                              <1>  assume ds:IVT
  3818 00001B5F 8E1EC600            <1> 	mov ds, word [31h * 4 + 2]
  3819                              <1>  assume ds:DOSGROUP
  3820                              <1> %endif
  3821 00001B63 8B1E[0000]          <1> 	mov bx, word [dosdata_to_doscode_segment]
  3822 00001B67 8EDB                <1> 	mov ds, bx
  3823                              <1>  assume ds:DOSCODEGROUP
  3824 00001B69 D1E9                <1> 	shr cx, 1
  3825 00001B6B F3A5                <1> 	rep movsw
  3826                              <1> 
  3827 00001B6D 8EDA                <1> 	mov ds, dx
  3828                              <1>  assume ds:IVT
  3829                              <1> %if 0
  3830                              <1> 	mov ds, word [dosentry_to_dosdata_segment]
  3831                              <1> %else
  3832 00001B6F 8E1EC600            <1> 	mov ds, word [31h * 4 + 2]
  3833                              <1>  assume ds:DOSGROUP
  3834                              <1> %endif
  3835                              <1> extern doslocation3306
  3836 00001B73 800E[0000]10        <1> 	or byte [doslocation3306], 10h
  3837                              <1> 
  3838 00001B78 8C06[0000]          <1> 	mov word [dosdata_to_doscode_segment], es
  3839 00001B7C B8[ssss]            <1> 	mov ax, DOSENTRY
  3840 00001B7F 8ED8                <1> 	mov ds, ax
  3841                              <1>  assume ds:DOSENTRYGROUP
  3842                              <1>  extern ..@dosentry_doscode_segment
  3843 00001B81 8C06[0000]          <1> 	mov word [..@dosentry_doscode_segment], es
  3844 00001B85 2EF616[1408]        <1> 	not byte [cs:doscode_relocated_to_final_position]
  3845                              <1>  assume es:DOSCODEGROUP
  3846                              <1> 
  3847 00001B8A 8CD0                <1> 	mov ax, ss
  3848 00001B8C 39D8                <1> 	cmp ax, bx
  3849 00001B8E 7502                <1> 	jne @F
  3850 00001B90 06                  <1> 	push es
  3851 00001B91 17                  <1> 	pop ss
  3852                              <1>  assume ss:DOSCODEGROUP
  3853                              <1> @@:
  3854                              <1>  assume ss:nothing
  3855                              <1> 
  3856 00001B92 83C305              <1> 	add bx, DOSCODE_HMA_OFFSET / 16
  3857 00001B95 8EC3                <1> 	mov es, bx			; => DOSCODE source
  3858                              <1>  assume es:nothing
  3859 00001B97 B449                <1> 	mov ah, 49h
  3860 00001B99 CD21                <1> 	int 21h				; free it
  3861                              <1> 
  3862                              <1> extern first_hmcb
  3863 00001B9B 8EDA                <1> 	mov ds, dx
  3864                              <1>  assume ds:IVT
  3865                              <1> %if 0
  3866                              <1> 	mov ds, word [dosentry_to_dosdata_segment]
  3867                              <1> %else
  3868 00001B9D 8E1EC600            <1> 	mov ds, word [31h * 4 + 2]
  3869                              <1>  assume ds:DOSGROUP
  3870                              <1> %endif
  3871 00001BA1 C706[0000]3000      <1> 	mov word [first_hmcb], 30h
  3872                              <1> 
  3873 00001BA7 2EF606[FC07]02      <1> 	testopt [cs:verbose_mode], verbose_xms
  3874 00001BAD 7406                <1> 	jz @F
  3875 00001BAF BA[DF20]            <1> 	mov dx, init2_msg.relocated_to_hma
  3876 00001BB2 E8C905              <1> 	call init2_disp_msg_asciz_cs_dx
  3877                              <1> @@:
  3878 00001BB5 EB08                <1> 	jmp .not_doscode_to_hma
  3879                              <1> 
  3880                              <1> 
  3881                              <1> .not_doscode_free:
  3882                              <1>  assume ds:nothing, es:nothing, ss:nothing
  3883 00001BB7 E8C405              <1> 	call init2_disp_msg_asciz_cs_dx
  3884                              <1> 
  3885 00001BBA B402                <1> 	mov ah, 02h
  3886 00001BBC E86202              <1> 	call .call_xms		; free HMA
  3887                              <1> 
  3888                              <1> .not_doscode_to_hma:
  3889                              <1> .no_doscode_reloc:
  3890                              <1>  assume ds:nothing, es:nothing, ss:nothing
  3891                              <1> %endif
  3892                              <1> 
  3893 00001BBF 56                  <1> 	push si			; loop detection counter word
  3894 00001BC0 BE4000              <1> 	mov si, 40h		; "UMA only" (+ first fit)
  3895 00001BC3 56                  <1> 	push si
  3896 00001BC4 89E6                <1> 	mov si, sp		; ss:si -> area flags and strategy word
  3897                              <1> 
  3898 00001BC6 F746F80800          <1> 	test word [bp + ?flags], DOSFLAGS_LINK_UMB
  3899 00001BCB 7503E93E02          <1> 	jz .not_link_umb
  3900                              <1> 
  3901 00001BD0 B80043              <1> 	mov ax, 4300h
  3902 00001BD3 CD2F                <1> 	int 2Fh			; XMS present ?
  3903 00001BD5 3C80                <1> 	cmp al, 80h
  3904 00001BD7 7403E93202          <1> 	jne .not_link_umb	; no -->
  3905                              <1> 
  3906 00001BDC B81043              <1> 	mov ax, 4310h
  3907 00001BDF CD2F                <1> 	int 2Fh			; get XMS entrypoint
  3908 00001BE1 2E891E[C419]        <1> 	mov word [cs:init2_xmsentry], bx
  3909 00001BE6 2E8C06[C619]        <1> 	mov word [cs:init2_xmsentry + 2], es		; store
  3910                              <1> 
  3911                              <1> .link_next_umb:
  3912 00001BEB B410                <1> 	mov ah, 10h
  3913 00001BED BAFFFF              <1> 	mov dx, -1		; size
  3914 00001BF0 E82E02              <1> 	call .call_xms		; request UMB
  3915 00001BF3 7203E91002          <1> 	jnc .not_link_umb_error_succeeded_unexpectedly
  3916 00001BF8 80FBB0              <1> 	cmp bl, 0B0h		; "only smaller UMB available" ?
  3917 00001BFB 7403E90E02          <1> 	jne .not_link_umb	; no, done -->
  3918                              <1> 
  3919 00001C00 52                  <1> 	push dx
  3920 00001C01 B410                <1> 	mov ah, 10h		; (size initialised by prior call)
  3921 00001C03 E81B02              <1> 	call .call_xms		; request UMB
  3922 00001C06 58                  <1> 	pop ax
  3923 00001C07 7325                <1> 	jnc .link_umb
  3924                              <1> 
  3925 00001C09 BA[9A1F]            <1> 	mov dx, init2_msg.umb_unavailable_1
  3926 00001C0C E86F05              <1> 	call init2_disp_msg_asciz_cs_dx
  3927                              <1> 
  3928 00001C0F E89805              <1> 	call init2_disp_ax_hex
  3929 00001C12 BA[AD1F]            <1> 	mov dx, init2_msg.umb_unavailable_2
  3930 00001C15 E86605              <1> 	call init2_disp_msg_asciz_cs_dx
  3931                              <1> 
  3932 00001C18 53                  <1> 	push bx
  3933 00001C19 31D2                <1> 	xor dx, dx
  3934 00001C1B B91000              <1> 	mov cx, 16
  3935 00001C1E BB0800              <1> 	mov bx, 4+4
  3936 00001C21 E85EFC              <1> 	call init2_disp_dxax_times_cx_width_bx_size
  3937 00001C24 5B                  <1> 	pop bx
  3938 00001C25 BA[B11F]            <1> 	mov dx, init2_msg.umb_unavailable_3
  3939 00001C28 E85305              <1> 	call init2_disp_msg_asciz_cs_dx
  3940                              <1> 
  3941 00001C2B E9E001              <1> 	jmp .not_link_umb
  3942                              <1> 
  3943                              <1> .link_umb:
  3944                              <1> 		; dx = allocated UMB size
  3945                              <1> 		; bx = allocated UMB segment
  3946 00001C2E 3683640200          <1> 	and word [ss:si + 2], 0	; initialise loop detection counter to zero
  3947                              <1> 
  3948 00001C33 52                  <1> 	push dx
  3949 00001C34 89D0                <1> 	mov ax, dx
  3950 00001C36 2EF606[FC07]02      <1> 	testopt [cs:verbose_mode], verbose_xms
  3951 00001C3C 742D                <1> 	jz @F
  3952 00001C3E BA[9A1F]            <1> 	mov dx, init2_msg.umb_allocated_1
  3953 00001C41 E83A05              <1> 	call init2_disp_msg_asciz_cs_dx
  3954                              <1> 
  3955 00001C44 E86305              <1> 	call init2_disp_ax_hex
  3956 00001C47 BA[AD1F]            <1> 	mov dx, init2_msg.umb_allocated_2
  3957 00001C4A E83105              <1> 	call init2_disp_msg_asciz_cs_dx
  3958                              <1> 
  3959 00001C4D 53                  <1> 	push bx
  3960 00001C4E 31D2                <1> 	xor dx, dx
  3961 00001C50 B91000              <1> 	mov cx, 16
  3962 00001C53 BB0800              <1> 	mov bx, 4+4
  3963 00001C56 E829FC              <1> 	call init2_disp_dxax_times_cx_width_bx_size
  3964 00001C59 5B                  <1> 	pop bx
  3965 00001C5A BA[DB1F]            <1> 	mov dx, init2_msg.umb_allocated_3
  3966 00001C5D E81E05              <1> 	call init2_disp_msg_asciz_cs_dx
  3967                              <1> 
  3968 00001C60 89D8                <1> 	mov ax, bx
  3969 00001C62 E84505              <1> 	call init2_disp_ax_hex
  3970 00001C65 BA[E11F]            <1> 	mov dx, init2_msg.umb_allocated_4
  3971 00001C68 E81305              <1> 	call init2_disp_msg_asciz_cs_dx
  3972                              <1> @@:
  3973 00001C6B 5A                  <1> 	pop dx
  3974                              <1> 
  3975                              <1> 		; dx = size, bx = segment
  3976 00001C6C 31C9                <1> 	xor cx, cx		; step = 0
  3977                              <1> 
  3978 00001C6E 51                  <1> 	push cx
  3979 00001C6F 53                  <1> 	push bx
  3980 00001C70 52                  <1> 	push dx
  3981 00001C71 31C9                <1> 	xor cx, cx		; free
  3982 00001C73 93                  <1> 	xchg ax, bx		; ax => MCB
  3983 00001C74 89D3                <1> 	mov bx, dx		; size = size of UMB
  3984 00001C76 83EB02              <1> 	sub bx, 2		; -1 for initial MCB, -1 for end MCB
  3985 00001C79 721B                <1> 	jc @F			; too small!
  3986 00001C7B BA4D00              <1> 	mov dx, "M"		; "M"
  3987 00001C7E 8946FE              <1> 	mov word [bp + ?umb_first_umcb], ax
  3988                              <1> 		; INP:	ax => MCB to initialise
  3989                              <1> 		;	cx = owner to set (8 if S MCB)
  3990                              <1> 		;	bx = size to set
  3991                              <1> 		;	dl = MCB signature, "M" or "Z"
  3992                              <1> 		;	dh = S MCB type
  3993                              <1> 		; OUT:	-
  3994                              <1> 		; CHG:	-
  3995 00001C81 E811FD              <1> 	call init2_init_an_mcb
  3996                              <1> 
  3997 00001C84 01D8                <1> 	add ax, bx
  3998 00001C86 40                  <1> 	inc ax			; => end MCB
  3999 00001C87 31DB                <1> 	xor bx, bx		; size zero (may be changed to link next UMB)
  4000 00001C89 BA5A30              <1> 	mov dx, (S_EXCLDUMA << 8) | "Z"	; type, and signature
  4001 00001C8C B90800              <1> 	mov cx, 8		; allocate S MCB
  4002 00001C8F 8946FC              <1> 	mov word [bp + ?umb_last_umcb], ax
  4003 00001C92 E800FD              <1> 	call init2_init_an_mcb
  4004                              <1> 
  4005 00001C95 A8                  <1> 	db __TEST_IMM8		; (NC) skip stc
  4006                              <1> @@:
  4007 00001C96 F9                  <1> 	stc
  4008 00001C97 5A                  <1> 	pop dx
  4009 00001C98 5B                  <1> 	pop bx
  4010 00001C99 59                  <1> 	pop cx
  4011 00001C9A 7303E94A01          <1> 	jc .not_link_umb_error_mcb_chain
  4012                              <1> 
  4013 00001C9F 31C0                <1> 	xor ax, ax		; = 0 = get first UMCB
  4014                              <1> .search_umb:
  4015 00001CA1 B101                <1> 	mov cl, 1		; step = 1
  4016 00001CA3 8946FA              <1> 	mov word [bp + ?last_mcb], ax
  4017                              <1> %if 0
  4018                              <1> 	call init2_to_doscode
  4019                              <1> 	dw SNextMCB		; get next (U)MCB
  4020                              <1> %else
  4021 00001CA6 E88401              <1> 	call init2_SNextMCB
  4022                              <1> %endif
  4023 00001CA9 7303E93B01          <1> 	jc .not_link_umb_error_mcb_chain	; chain corrupted
  4024 00001CAE 7403E90901          <1> 	jnz .umb_case_3		; end of chain, word [bp + ?last_mcb] has last
  4025 00001CB3 41                  <1> 	inc cx			; step = 2
  4026 00001CB4 39C3                <1> 	cmp bx, ax		; area to add is below ?
  4027 00001CB6 7703E92E01          <1> 	jbe .not_link_umb_error_mcb_chain	; if so, error out -->
  4028 00001CBB 8ED8                <1> 	mov ds, ax
  4029                              <1>  assume ds:MCB
  4030 00001CBD 89C7                <1> 	mov di, ax		; => MCB
  4031 00001CBF 033E0300            <1> 	add di, word [mcbSize]
  4032 00001CC3 47                  <1> 	inc di			; => next MCB (if any)
  4033 00001CC4 39FB                <1> 	cmp bx, di
  4034 00001CC6 77D9                <1> 	ja .search_umb		; next -->
  4035 00001CC8 7403E99F00          <1> 	jne .umb_case_2		; UMB is below where next points to
  4036                              <1> 
  4037                              <1> .umb_case_1:
  4038                              <1> %if 0
  4039                              <1> case 1: S_EXCLDUMA MCB ends at where our UMB starts
  4040                              <1> 	0123456789
  4041                              <1> 	S2 E
  4042                              <1> 	   U3  L
  4043                              <1> 
  4044                              <1> %endif
  4045 00001CCD B108                <1> 	mov cl, 8		; step = 8
  4046                              <1> 
  4047 00001CCF 833E010008          <1> 	cmp word [mcbOwner], 8
  4048 00001CD4 7403E91001          <1> 	jne .not_link_umb_error_mcb_chain
  4049 00001CD9 41                  <1> 	inc cx			; step = 9
  4050 00001CDA 833E080053          <1> 	cmp word [smcbName], "S"
  4051 00001CDF 7403E90501          <1> 	jne .not_link_umb_error_mcb_chain
  4052 00001CE4 41                  <1> 	inc cx			; step = A
  4053 00001CE5 803E0A0030          <1> 	cmp byte [smcbType], S_EXCLDUMA
  4054 00001CEA 7403E9FA00          <1> 	jne .not_link_umb_error_mcb_chain
  4055 00001CEF 41                  <1> 	inc cx			; step = B
  4056                              <1> 
  4057 00001CF0 803E00005A          <1> 	cmp byte [mcbSignature], "Z"
  4058 00001CF5 7403E9EF00          <1> 	jne .not_link_umb_error_mcb_chain
  4059 00001CFA C60600004D          <1> 	mov byte [mcbSignature], "M"
  4060                              <1> 
  4061                              <1> .check_empty_umcb:
  4062 00001CFF 833E030000          <1> 	cmp word [mcbSize], 0	; empty area ?
  4063 00001D04 750A                <1> 	jne @F			; no, no question as to whether to free -->
  4064                              <1> 
  4065 00001D06 3B46F4              <1> 	cmp ax, [bp + ?first_umcb]	; is ds => first UMCB ?
  4066 00001D09 7408                <1> 	je .check_enlarge_lma	; yes, either protect UMCB or enlarge LMA -->
  4067                              <1> 				; no, unconditionally delete the hole
  4068                              <1> .free_umcb_link_next_umb:
  4069 00001D0B 8326010000          <1> 	and word [mcbOwner], 0	; empty area found, clear owner
  4070                              <1> 				;  (affects first UMCB only if enlarging LMA)
  4071                              <1> @@:
  4072 00001D10 E9D8FE              <1> 	jmp .link_next_umb
  4073                              <1> 
  4074                              <1> .check_enlarge_lma:
  4075                              <1>  extern enlargelma_option
  4076 00001D13 2ED006[0000]        <1> 	rol byte [cs:enlargelma_option], 1
  4077                              <1> 				; enlarge ?
  4078 00001D18 73F6                <1> 	jnc @B			; no, protect it -->
  4079                              <1> 
  4080                              <1> @@:			; loop to find next UMA hole (or end of UMCB chain)
  4081                              <1> %if 0
  4082                              <1> 	call init2_to_doscode
  4083                              <1> 	dw SNextMCB		; get next (U)MCB
  4084                              <1> %else
  4085 00001D1A E81001              <1> 	call init2_SNextMCB
  4086                              <1> %endif
  4087 00001D1D B120                <1> 	mov cl, 20h		; step = 20
  4088 00001D1F 7303E9C500          <1> 	jc .not_link_umb_error_mcb_chain	; chain corrupted
  4089 00001D24 B121                <1> 	mov cl, 21h		; step = 21
  4090 00001D26 7403E9BE00          <1> 	jnz .not_link_umb_error_mcb_chain
  4091 00001D2B 8ED8                <1> 	mov ds, ax
  4092                              <1>  assume ds:MCB
  4093 00001D2D 833E010008          <1> 	cmp word [mcbOwner], 8
  4094 00001D32 75E6                <1> 	jne @B
  4095 00001D34 833E080053          <1> 	cmp word [smcbName], "S"
  4096 00001D39 75DF                <1> 	jne @B
  4097 00001D3B 803E0A0030          <1> 	cmp byte [smcbType], S_EXCLDUMA
  4098 00001D40 75D8                <1> 	jne @B
  4099                              <1>  extern first_umcb
  4100 00001D42 E8(0000)            <1> 	call sysinit_get_ds_dosbiodata
  4101                              <1>  assume ds:DOSGROUP
  4102 00001D45 92                  <1> 	xchg dx, ax			; new first UMCB to dx
  4103                              <1> 
  4104                              <1> 		; natch, we need to link UMBs before changing things !
  4105 00001D46 B80258              <1> 	mov ax, 5802h
  4106 00001D49 CD21                <1> 	int 21h
  4107 00001D4B 50                  <1> 	push ax
  4108 00001D4C B80358              <1> 	mov ax, 5803h
  4109 00001D4F BB0100              <1> 	mov bx, 1			; link in UMBs before modification
  4110 00001D52 CD21                <1> 	int 21h
  4111                              <1> 
  4112 00001D54 8916[0000]          <1> 	mov word [first_umcb], dx	; update DOSDATA's reference
  4113 00001D58 8756F4              <1> 	xchg word [bp + ?first_umcb], dx; update our stack frame's reference,
  4114                              <1> 					;  and dx = old first UMCB
  4115 00001D5B 5B                  <1> 	pop bx
  4116 00001D5C B80358              <1> 	mov ax, 5803h
  4117 00001D5F CD21                <1> 	int 21h				; restore old UMB link state
  4118                              <1> 
  4119 00001D61 92                  <1> 	xchg ax, dx			; old first UMCB to ax
  4120                              <1> 
  4121                              <1>  extern configmsg.enlargelma_message
  4122 00001D62 BA[0000]            <1> 	mov dx, configmsg.enlargelma_message
  4123 00001D65 E81604              <1> 	call init2_disp_msg_asciz_cs_dx
  4124                              <1> 
  4125 00001D68 8ED8                <1> 	mov ds, ax			; => old first UMCB
  4126                              <1>  assume ds:MCB
  4127 00001D6A EB9F                <1> 	jmp .free_umcb_link_next_umb	; free the old first UMCB
  4128                              <1> 
  4129                              <1> 
  4130                              <1> .umb_case_2:
  4131                              <1>  assume ds:nothing, es:nothing, ss:nothing
  4132                              <1> %if 0
  4133                              <1> case 2: S_EXCLDUMA MCB around entire area
  4134                              <1> 	0123456789
  4135                              <1> 	S8       E
  4136                              <1> 	   U3  L
  4137                              <1> 	S2 U3  L1E
  4138                              <1> S=0
  4139                              <1> S size=8
  4140                              <1> di=9
  4141                              <1> L=7
  4142                              <1> E=9
  4143                              <1> L want size=1
  4144                              <1> L want size=E-L-1
  4145                              <1> S want size=2
  4146                              <1> S want size=U-S-1
  4147                              <1> %endif
  4148                              <1> 
  4149 00001D6C 833E010008          <1> 	cmp word [mcbOwner], 8
  4150 00001D71 7576                <1> 	jne .not_link_umb_error_mcb_chain
  4151 00001D73 41                  <1> 	inc cx			; step = 3
  4152 00001D74 833E080053          <1> 	cmp word [smcbName], "S"
  4153 00001D79 756E                <1> 	jne .not_link_umb_error_mcb_chain
  4154 00001D7B 41                  <1> 	inc cx			; step = 4
  4155 00001D7C 803E0A0030          <1> 	cmp byte [smcbType], S_EXCLDUMA
  4156 00001D81 7566                <1> 	jne .not_link_umb_error_mcb_chain
  4157 00001D83 41                  <1> 	inc cx			; step = 5
  4158                              <1> 
  4159 00001D84 8E46FC              <1> 	mov es, word [bp + ?umb_last_umcb]
  4160                              <1>  assume es:nothing
  4161 00001D87 8A2E0000            <1> 	mov ch, byte [mcbSignature]
  4162 00001D8B 26882E0000          <1> 	mov byte [es:mcbSignature], ch
  4163 00001D90 2B7EFC              <1> 	sub di, word [bp + ?umb_last_umcb]
  4164                              <1> 				; (E-L) size of UMB's last UMCB
  4165 00001D93 4F                  <1> 	dec di			; (E-L-1) minus last UMCB itself
  4166 00001D94 26893E0300          <1> 	mov word [es:mcbSize], di
  4167 00001D99 26803E00005A        <1> 	cmp byte [es:mcbSignature], "Z"	; last ?
  4168 00001D9F 740A                <1> 	je @F			; yes, do not clear owner (even if empty) -->
  4169 00001DA1 85FF                <1> 	test di, di		; empty area ?
  4170 00001DA3 7506                <1> 	jnz @F
  4171 00001DA5 268326010000        <1> 	and word [es:mcbOwner], 0	; yes, clear owner
  4172                              <1> @@:
  4173                              <1> .umb_case_2_3_common:
  4174                              <1>  assume ds:nothing, es:nothing, ss:nothing
  4175 00001DAB 89DF                <1> 	mov di, bx		; (U)
  4176 00001DAD 29C7                <1> 	sub di, ax		; (U-S)
  4177 00001DAF 4F                  <1> 	dec di			; (U-S-1)
  4178 00001DB0 893E0300            <1> 	mov word [mcbSize], di
  4179 00001DB4 C60600004D          <1> 	mov byte [mcbSignature], "M"	; link to UMB's first UMCB
  4180 00001DB9 E943FF              <1> 	jmp .check_empty_umcb
  4181                              <1> 
  4182                              <1> 
  4183                              <1> .umb_case_3:
  4184                              <1>  assume ds:nothing, es:nothing, ss:nothing
  4185                              <1> %if 0
  4186                              <1> case 1: S_EXCLDUMA MCB ends somewhere below our UMB
  4187                              <1> 	0123456789
  4188                              <1> 	S1E
  4189                              <1> 	   U3  L
  4190                              <1> S want size=2
  4191                              <1> S want size=U-S-1
  4192                              <1> %endif
  4193 00001DBC B110                <1> 	mov cl, 10h		; step = 10
  4194                              <1> 
  4195 00001DBE 8B46FA              <1> 	mov ax, word [bp + ?last_mcb]
  4196 00001DC1 85C0                <1> 	test ax, ax
  4197 00001DC3 7424                <1> 	jz .not_link_umb_error_mcb_chain
  4198 00001DC5 41                  <1> 	inc cx			; step = 11
  4199 00001DC6 8ED8                <1> 	mov ds, ax
  4200                              <1>  assume ds:MCB
  4201 00001DC8 833E010008          <1> 	cmp word [mcbOwner], 8
  4202 00001DCD 751A                <1> 	jne .not_link_umb_error_mcb_chain
  4203 00001DCF 41                  <1> 	inc cx			; step = 12
  4204 00001DD0 833E080053          <1> 	cmp word [smcbName], "S"
  4205 00001DD5 7512                <1> 	jne .not_link_umb_error_mcb_chain
  4206 00001DD7 41                  <1> 	inc cx			; step = 13
  4207 00001DD8 803E0A0030          <1> 	cmp byte [smcbType], S_EXCLDUMA
  4208 00001DDD 750A                <1> 	jne .not_link_umb_error_mcb_chain
  4209 00001DDF 41                  <1> 	inc cx			; step = 14
  4210                              <1> 
  4211 00001DE0 803E00005A          <1> 	cmp byte [mcbSignature], "Z"
  4212 00001DE5 7502                <1> 	jne .not_link_umb_error_mcb_chain
  4213                              <1> 
  4214 00001DE7 EBC2                <1> 	jmp .umb_case_2_3_common
  4215                              <1> 
  4216                              <1> 
  4217                              <1> .not_link_umb_error_mcb_chain:
  4218                              <1>  assume ds:nothing, es:nothing, ss:nothing
  4219 00001DE9 50                  <1> 	push ax
  4220 00001DEA BA[F01F]            <1> 	mov dx, init2_msg.umb_mcb_chain_corrupted_1
  4221 00001DED E88E03              <1> 	call init2_disp_msg_asciz_cs_dx
  4222                              <1> 
  4223 00001DF0 88C8                <1> 	mov al, cl
  4224 00001DF2 E8BC03              <1> 	call init2_disp_al_hex
  4225 00001DF5 BA[1220]            <1> 	mov dx, init2_msg.umb_mcb_chain_corrupted_2
  4226 00001DF8 E88303              <1> 	call init2_disp_msg_asciz_cs_dx
  4227                              <1> 
  4228 00001DFB 58                  <1> 	pop ax
  4229 00001DFC E8AB03              <1> 	call init2_disp_ax_hex
  4230 00001DFF BA[1220]            <1> 	mov dx, init2_msg.umb_mcb_chain_corrupted_2
  4231 00001E02 E87903              <1> 	call init2_disp_msg_asciz_cs_dx
  4232                              <1> 
  4233                              <1> 		; Note that we do not free the UMB here! In case the user
  4234                              <1> 		;  wants to do that, the address has already been displayed.
  4235 00001E05 E9E3FD              <1> 	jmp .link_next_umb
  4236                              <1> 
  4237                              <1> 
  4238                              <1> .not_link_umb_error_succeeded_unexpectedly:
  4239 00001E08 BA[1E20]            <1> 	mov dx, init2_msg.umb_succeeded_unexpectedly
  4240 00001E0B E87003              <1> 	call init2_disp_msg_asciz_cs_dx
  4241                              <1> 
  4242                              <1> .not_link_umb:
  4243                              <1>  assume ds:nothing, es:nothing, ss:nothing
  4244 00001E0E 5E                  <1> 	pop si			; (discard area flags and strategy word)
  4245 00001E0F 5E                  <1> 	pop si			; (discard loop detection counter)
  4246                              <1> 
  4247 00001E10 2ED006[1308]        <1> 	rol byte [cs:dosdata_relocate_early], 1
  4248 00001E15 7306                <1> 	jnc @F
  4249 00001E17 BAFFFF              <1> 	mov dx, -1		; != 0 = relocate only if UMA
  4250 00001E1A E8AF03              <1> 	call relocate_dosdata
  4251                              <1> @@:
  4252                              <1> 
  4253 00001E1D 89EC5D              <1> 	lleave code
  4254 00001E20 C3                  <1> 	retn
  4255                              <1> 
  4256                              <1> %if 1 || (_RELOCATEDOSCODE && _DOSCODEHMA)
  4257                              <1> .call_xms:
  4258 00001E21 2EFF1E[C419]        <1> 	call far [cs:init2_xmsentry]
  4259 00001E26 83F801              <1> 	cmp ax, 1
  4260 00001E29 7401                <1> 	je @F			; (NC) -->
  4261 00001E2B F9                  <1> 	stc
  4262                              <1> @@:
  4263 00001E2C C3                  <1> 	retn
  4264                              <1> %endif
  4265                              <1> 
  4266                              <1> 		; Get next MCB, insuring the chain doesn't loop
  4267                              <1> 		;
  4268                              <1> 		; INP:	word [ss:si] = area flags and allocation strategy
  4269                              <1> 		;	word [ss:si + 2] = loop detection counter, init to 0
  4270                              <1> 		;	ax = former MCB (0000h to get first)
  4271                              <1> 		; OUT:	CY if MCB chain corrupted or loops,
  4272                              <1> 		;	 ax = error code
  4273                              <1> 		;	NC if MCB chain intact,
  4274                              <1> 		;	 NZ if no next MCB,
  4275                              <1> 		;	  ax = error code (0008h)
  4276                              <1> 		;	 ZR if next MCB available,
  4277                              <1> 		;	  ax = next MCB
  4278                              <1> 		;	di = 0
  4279                              <1> 		; CHG:	-
  4280                              <1> 		; STK:	8 word
  4281                              <1> ;	doscode_insure_low_byte_not_0CCh
  4282                              <1> init2_SNextMCB:
  4283                              <1>  assume ds:nothing, es:nothing, ss:nothing
  4284 00001E2D 31FF                <1> 	xor di, di
  4285 00001E2F 36FF4C02            <1> 	dec word [ss:si + 2]
  4286 00001E33 7505                <1> 	jnz @F
  4287                              <1> 		; This doesn't branch if ZR, meaning if the 1_0000h iterations
  4288                              <1> 		;  have run out (if counter was 1 prior to the dec).
  4289 00001E35 F9                  <1> 	stc
  4290 00001E36 B8FE00              <1> 	mov ax, errorMCBLoops
  4291 00001E39 C3                  <1> 	retn
  4292                              <1> 
  4293                              <1> @@:
  4294                              <1> 		; (fall through to NextMCB)
  4295                              <1> 
  4296                              <1> 
  4297                              <1> 		; Get next MCB
  4298                              <1> 		;
  4299                              <1> 		; INP:	word [ss:si] = area flags and allocation strategy
  4300                              <1> 		;	word [ss:si + 2] = loop detection counter
  4301                              <1> 		;	ax = former MCB (0000h to get first)
  4302                              <1> 		; OUT:	CY if MCB chain corrupted,
  4303                              <1> 		;	 ax = error code
  4304                              <1> 		;	NC if MCB chain intact,
  4305                              <1> 		;	 NZ if no next MCB,
  4306                              <1> 		;	  ax = error code 0008h (Not enough memory)
  4307                              <1> 		;	 ZR if next MCB available,
  4308                              <1> 		;	  ax = next MCB
  4309                              <1> 		;	di = 0
  4310                              <1> 		; CHG:	-
  4311                              <1> 		; STK:	3 word
  4312                              <1> 		;
  4313                              <1> 		; An interesting effect of how this code handles the first UMCB
  4314                              <1> 		; is that it doesn't care whether the previous MCB contains an
  4315                              <1> 		; 'M' (normal MCB chain extended into UMA) or 'Z' (normal MCB
  4316                              <1> 		; chain limited to LMA). Also, the parsed area flags allow to
  4317                              <1> 		; ignore the actual requested UMB link: If it was zero, all
  4318                              <1> 		; area flags are cleared and forced to 10h (LMA only) instead.
  4319                              <1> %ifn _UMA
  4320                              <1> init2_NextMCB:
  4321                              <1>  assume ds:nothing, es:nothing, ss:nothing
  4322                              <1> 	push ds
  4323                              <1> 	test ax, ax				; request for first ?
  4324                              <1> 	jz .first				; yes -->
  4325                              <1> 
  4326                              <1> 	call init2_VerifyMCB			; check input MCB first
  4327                              <1> 	jc .return
  4328                              <1>  assume ds:MCB
  4329                              <1> 	inc ax
  4330                              <1> 	add ax, word [di+mcbSize]		; get address of next (if any)
  4331                              <1> 	cmp byte [di+mcbSignature], 'M'		; current in-chain ?
  4332                              <1> 	je .verify				; yes, verify it -->
  4333                              <1> 		; If this was NZ and didn't jump, then the mcbSignature
  4334                              <1> 		;  contains the letter 'Z', which is above 'M'. Therefore,
  4335                              <1> 		;  it is always true that it is NC at this point.
  4336                              <1> 	mov ax, errorInsufficientMemory		; (NC, NZ)
  4337                              <1> 	pop ds
  4338                              <1>  assume ds:nothing
  4339                              <1> 	retn
  4340                              <1> .first:
  4341                              <1> 	mov ax, word [bp + ?first_mcb]
  4342                              <1> .verify:
  4343                              <1> 	call init2_VerifyMCB			; NC, ZR if valid - CY if invalid
  4344                              <1> .return:
  4345                              <1> 	pop ds
  4346                              <1> 	retn
  4347                              <1> %else
  4348                              <1> 		; The UMA build has to evaluate the (parsed) area flags
  4349                              <1> 		; here to show the caller a continuous chain of MCBs.
  4350                              <1> 		; This requires special handling in two cases: If the
  4351                              <1> 		; caller's input was 0000h (to get the first MCB) or if
  4352                              <1> 		; it was the MCB before the first UMCB. Area flags of
  4353                              <1> 		; 80h and 40h want to start their search with the first
  4354                              <1> 		; UMCB instead. Flags 20h want to proceed at the first
  4355                              <1> 		; UMCB, all other flags want to stop there. The first
  4356                              <1> 		; UMCB's handling ignores whether the preceeding MCB
  4357                              <1> 		; contained 'M' or 'Z'.
  4358                              <1> init2_NextMCB:
  4359                              <1>  assume ds:nothing, es:nothing, ss:nothing
  4360 00001E3A 1E                  <1> 	push ds
  4361 00001E3B 85C0                <1> 	test ax, ax				; request for first ?
  4362 00001E3D 742C                <1> 	jz .first				; yes -->
  4363                              <1> 
  4364 00001E3F E84900              <1> 	call init2_VerifyMCB			; check input MCB first
  4365 00001E42 723B                <1> 	jc .return
  4366                              <1>  assume ds:MCB
  4367 00001E44 40                  <1> 	inc ax
  4368 00001E45 034503              <1> 	add ax, word [di+mcbSize]		; get address of next (whether current is 'M' or 'Z')
  4369                              <1> 
  4370 00001E48 E83600              <1> 	call init2_IsFirstUMCB?			; is the one behind this the first UMCB ?
  4371 00001E4B 7508                <1> 	jne .notfirstumcb			; nope, check if last -->
  4372 00001E4D 36F604D0            <1> 	test byte [ss:si], ~2Fh			; "LMA then UMA" ?
  4373                              <1> 		; x = D0h --> x & ~20h != 00h if area other than LMA-then-UMA,
  4374                              <1> 		; x = 20h --> x & ~20h = 00h if area is LMA-then-UMA
  4375 00001E51 7429                <1> 	jz .verify				; yes, proceed here -->
  4376                              <1> 		; After test, it is always NC here.
  4377 00001E53 EB11                <1> 	jmp short .last				; (NC, NZ) else it's the last one (even if 'M') -->
  4378                              <1> .notfirstumcb:
  4379 00001E55 803D4D              <1> 	cmp byte [di+mcbSignature], 'M'		; current in-chain ?
  4380 00001E58 7422                <1> 	je .verify				; no -->
  4381 00001E5A 837EF4FE            <1> 	cmp word [bp + ?first_umcb], byte -2	; any UMA ?
  4382 00001E5E 7706                <1> 	ja .last				; (NC, NZ) no, really last -->
  4383 00001E60 36F60470            <1> 	test byte [ss:si], ~8Fh			; "UMA then LMA" ?
  4384                              <1> 		; x = 70h --> x & ~80h != 00h if area other than UMA-then-LMA,
  4385                              <1> 		; x = 80h --> x & ~80h = 00h if area is UMA-then-LMA
  4386 00001E64 7413                <1> 	jz .firstlma				; yes, start to search LMA instead -->
  4387                              <1> 		; After test, it is always NC here.
  4388                              <1> .last:
  4389 00001E66 B80800              <1> 	mov ax, errorInsufficientMemory		; (NC, NZ)
  4390 00001E69 1F                  <1> 	pop ds
  4391                              <1>  assume ds:nothing
  4392 00001E6A C3                  <1> 	retn
  4393                              <1> .first:
  4394 00001E6B 36F604C0            <1> 	test byte [ss:si], (80h|40h)		; "UMA then LMA" or "UMA only" ?
  4395 00001E6F 7408                <1> 	jz .firstlma				; no, start with LMA -->
  4396 00001E71 8B46F4              <1> 	mov ax, word [bp + ?first_umcb]		; yes, start with UMA
  4397 00001E74 83F8FF              <1> 	cmp ax, -1				; UMA valid ?
  4398 00001E77 7503                <1> 	jne .verify				; yes -->
  4399                              <1> .firstlma:
  4400 00001E79 8B46F6              <1> 	mov ax, word [bp + ?first_mcb]		; start with LMA
  4401                              <1> .verify:
  4402 00001E7C E80C00              <1> 	call init2_VerifyMCB			; NC, ZR if valid - CY if invalid
  4403                              <1> .return:
  4404 00001E7F 1F                  <1> 	pop ds
  4405                              <1>  assume ds:nothing
  4406 00001E80 C3                  <1> 	retn
  4407                              <1> 
  4408                              <1> 
  4409                              <1> 		; Compare ax to first UMCB
  4410                              <1> 		;
  4411                              <1> 		; INP:	ax = MCB
  4412                              <1> 		; OUT:	NZ if not first UMCB (or if there's no UMCB)
  4413                              <1> 		;	ZR if first UMCB
  4414                              <1> 		; CHG:	-
  4415                              <1> 		; STK:	1 word
  4416                              <1> init2_IsFirstUMCB?:
  4417                              <1>  assume ds:nothing, es:nothing, ss:nothing
  4418 00001E81 837EF4FE            <1> 	cmp word [bp + ?first_umcb], byte -2
  4419 00001E85 7703                <1> 	ja .return			; (NZ if it jumps) -->
  4420 00001E87 3B46F4              <1> 	cmp ax, word [bp + ?first_umcb]
  4421                              <1> .return:
  4422 00001E8A C3                  <1> 	retn
  4423                              <1> %endif
  4424                              <1> 
  4425                              <1> 
  4426                              <1> 		; Verify MCB
  4427                              <1> 		;
  4428                              <1> 		; INP:	ax = MCB
  4429                              <1> 		; OUT:	ds = MCB
  4430                              <1> 		;	di = 0
  4431                              <1> 		;	NZ, CY if invalid MCB,
  4432                              <1> 		;	 ax = error code 0007h (MCB chain corrupted)
  4433                              <1> 		;	ZR, NC if valid MCB
  4434                              <1> 		; CHG:	-
  4435                              <1> 		; STK:	1 word
  4436                              <1> init2_VerifyMCB:
  4437                              <1>  assume ds:nothing, es:nothing, ss:nothing
  4438 00001E8B 31FF                <1> 	xor di, di
  4439 00001E8D 8ED8                <1> 	mov ds, ax				; set up working registers
  4440                              <1>  assume ds:nothing
  4441 00001E8F 40                  <1> 	inc ax
  4442 00001E90 83F802              <1> 	cmp ax, byte 2				; passed value FFFFh or 0000h ?
  4443 00001E93 720B                <1> 	jb .invalid				; (NZ, CY) yes -->
  4444                              <1>  assume ds:MCB
  4445 00001E95 48                  <1> 	dec ax
  4446 00001E96 803D4D              <1> 	cmp byte [di+mcbSignature], 'M'		; valid 'M' signature ?
  4447 00001E99 7409                <1> 	je .return				; yes --> (ZR, NC)
  4448 00001E9B 803D5A              <1> 	cmp byte [di+mcbSignature], 'Z'		; valid 'Z' signature ?
  4449 00001E9E 7404                <1> 	je .return				; yes --> (ZR, NC)
  4450                              <1> .invalid:
  4451                              <1>  assume ds:nothing
  4452 00001EA0 F9                  <1> 	stc
  4453 00001EA1 B80700              <1> 	mov ax, errorMCBDestroyed		; (CY, NZ) else invalid
  4454                              <1> .return:
  4455 00001EA4 C3                  <1> 	retn
  4456                              <1> 
  4457                              <1> 	lleave ctx
  4458                              <1> 
  4459                              <1> 
  4460                              <1> %if _RELOCATEDOSCODE && _DOSCODEHMA
  4461                              <1> detect_bounce:
  4462                              <1>  assume ds:nothing, es:nothing, ss:nothing
  4463 00001EA5 2ED007              <1> 	rol byte [cs:bx], 1
  4464 00001EA8 7203E9B900          <1> 	jnc .retn
  4465 00001EAD 57                  <1> 	push di
  4466 00001EAE 50                  <1> 	push ax
  4467 00001EAF E8(0000)            <1> 	call sysinit_get_ds_dosbiodata
  4468                              <1>  assume ds:DOSGROUP
  4469 00001EB2 C60500              <1> 	mov byte [di], 0
  4470 00001EB5 C436[0000]          <1> 	les si, [DPBHEAD]
  4471                              <1> .loop_dpb:
  4472 00001EB9 83FEFF              <1> 	cmp si, -1
  4473 00001EBC 7503E9A300          <1> 	je .done
  4474                              <1>  assume es:DPB
  4475 00001EC1 26817C15[ssss]      <1> 	cmp word [es:si + dpb_driver_addr + 2], DOSENTRY + DOSENTRYDEVICEBASE
  4476 00001EC7 7403E99100          <1> 	jne .next_dpb
  4477 00001ECC 26817C13[00FF]      <1> 	cmp word [es:si + dpb_driver_addr], DSKDEV - DOSENTRYDEVICEBASE * 16
  4478 00001ED2 7403E98600          <1> 	jne .next_dpb
  4479 00001ED7 268B14              <1> 	mov dx, [es:si + dpb_drive]	; dh = device driver unit
  4480 00001EDA B80308              <1> 	mov ax, 0803h
  4481 00001EDD CD2F                <1> 	int 2Fh
  4482                              <1>  assume ds:UPB
  4483                              <1> .loop_upb:
  4484 00001EDF 83FFFF              <1> 	cmp di, -1
  4485 00001EE2 7479                <1> 	je .done_upb
  4486 00001EE4 387505              <1> 	cmp byte [di + DRIVELET], dh
  4487 00001EE7 7570                <1> 	jne .next_upb
  4488 00001EE9 F6452301            <1> 	testopt [di + FLAGS], FNON_REMOVABLE
  4489 00001EED 746A                <1> 	jz .next_upb
  4490 00001EEF 58                  <1> 	pop ax
  4491 00001EF0 50                  <1> 	push ax
  4492 00001EF1 334523              <1> 	xor ax, [di + FLAGS]
  4493 00001EF4 250004              <1> 	and ax, F_LBA			; differs ?
  4494 00001EF7 7560                <1> 	jnz .next_upb			; yes -->
  4495                              <1> 
  4496 00001EF9 52                  <1> 	push dx
  4497 00001EFA 1E                  <1> 	push ds
  4498 00001EFB 06                  <1> 	push es
  4499 00001EFC 57                  <1> 	push di
  4500 00001EFD 56                  <1> 	push si
  4501                              <1> 
  4502 00001EFE BF[ssss]            <1> 	mov di, DOSENTRY
  4503 00001F01 8EC7                <1> 	mov es, di
  4504                              <1>  assume es:DOSENTRYGROUP
  4505 00001F03 BF[0000]            <1> 	mov di, DISKSECTOR	; access with es
  4506 00001F06 B89090              <1> 	mov ax, 9090h
  4507 00001F09 B90001              <1> 	mov cx, words(512)
  4508 00001F0C F3AB                <1> 	rep stosw
  4509                              <1> 
  4510 00001F0E B9FFFF              <1> 	mov cx, -1
  4511 00001F11 88D0                <1> 	mov al, dl
  4512 00001F13 0E                  <1> 	 push cs
  4513 00001F14 1F                  <1> 	 pop ds
  4514                              <1>  assume ds:SYSINITGROUP
  4515 00001F15 BB[681F]            <1> 	mov bx, int25packet	; access with ds
  4516 00001F18 CD25                <1> 	int 25h
  4517 00001F1A 7237                <1> 	jc .next_upb_pop_2
  4518 00001F1C 9D                  <1> 	popf
  4519                              <1> 
  4520 00001F1D BF[ssss]            <1> 	mov di, DOSENTRY
  4521 00001F20 8EC7                <1> 	mov es, di
  4522                              <1>  assume es:DOSENTRYGROUP
  4523 00001F22 BF[0000]            <1> 	mov di, DISKSECTOR	; access with es
  4524 00001F25 B89090              <1> 	mov ax, 9090h
  4525 00001F28 B90001              <1> 	mov cx, words(512)
  4526 00001F2B F3AF                <1> 	repe scasw
  4527 00001F2D 7425                <1> 	je .next_upb_pop_1
  4528 00001F2F 5E                  <1> 	pop si
  4529 00001F30 5F                  <1> 	pop di
  4530 00001F31 07                  <1> 	pop es
  4531                              <1>  assume es:DPB
  4532 00001F32 1F                  <1> 	pop ds
  4533                              <1>  assume ds:UPB
  4534 00001F33 58                  <1> 	pop ax			; al = drive number (0 = A:)
  4535                              <1> 
  4536 00001F34 BA[1421]            <1> 	mov dx, init2_msg.auto_bounce_hma_chs
  4537 00001F37 59                  <1> 	pop cx			; cx = flag, NZ if LBA
  4538 00001F38 E303                <1> 	jcxz @F
  4539 00001F3A BA[4721]            <1> 	mov dx, init2_msg.auto_bounce_hma_lba
  4540                              <1> @@:
  4541 00001F3D E83E02              <1> 	call init2_disp_msg_asciz_cs_dx
  4542 00001F40 0441                <1> 	add al, 'A'
  4543 00001F42 E85202              <1> 	call init2_disp_al
  4544 00001F45 BA[7A21]            <1> 	mov dx, init2_msg.auto_bounce_trail
  4545 00001F48 E83302              <1> 	call init2_disp_msg_asciz_cs_dx
  4546 00001F4B 5F                  <1> 	pop di			; DOSDATA:di -> the resident choice
  4547 00001F4C E8(0000)            <1> 	call sysinit_get_ds_dosbiodata
  4548                              <1>  assume ds:DOSGROUP
  4549 00001F4F C605FF              <1> 	mov byte [di], 0FFh
  4550 00001F52 C3                  <1> 	retn
  4551                              <1> 
  4552                              <1> .next_upb_pop_2:
  4553 00001F53 9D                  <1> 	popf
  4554                              <1> .next_upb_pop_1:
  4555 00001F54 5E                  <1> 	pop si
  4556 00001F55 5F                  <1> 	pop di
  4557 00001F56 07                  <1> 	pop es
  4558                              <1>  assume es:DPB
  4559 00001F57 1F                  <1> 	pop ds
  4560                              <1>  assume ds:UPB
  4561 00001F58 5A                  <1> 	pop dx
  4562                              <1> .next_upb:
  4563 00001F59 C53D                <1> 	lds di, [di + LINK]
  4564 00001F5B EB82                <1> 	jmp .loop_upb
  4565                              <1> 
  4566                              <1> .done_upb:
  4567                              <1> .next_dpb:
  4568 00001F5D 26C47419            <1> 	les si, [es:si + dpb_next_dpb]
  4569 00001F61 E955FF              <1> 	jmp .loop_dpb
  4570                              <1> 
  4571                              <1> .done:
  4572 00001F64 58                  <1> 	pop ax
  4573 00001F65 5F                  <1> 	pop di
  4574                              <1> .retn:
  4575 00001F66 C3                  <1> 	retn
  4576                              <1> 
  4577 00001F67 00                  <1> 	align 2, db 0
  4578                              <1> int25packet:
  4579 00001F68 00000000            <1> 	dd 0
  4580 00001F6C 0100                <1> 	dw 1
  4581                              <1> .offset:
  4582 00001F6E [1000]FFFF          <1> 	dw DISKSECTOR + 10h, 0FFFFh
  4583                              <1> %endif
  4584                              <1> 
  4585                              <1> 
  4586                              <1> init2_msg:
  4587                              <1> 
  4588                              <1> %if 0
  4589                              <1> .internal_error_handles: db "init: Internal error during "
  4590                              <1> 			asciz "handle allocation.",13,10
  4591                              <1> .con:			asciz "CON"
  4592                              <1> .aux:			asciz "AUX"
  4593                              <1> .prn:			asciz "PRN"
  4594                              <1> .rxconfigsys:		asciz "RxCONFIG.SYS"
  4595                              <1> .configsys:		asciz "CONFIG.SYS"
  4596                              <1> .config_error_reading_1:asciz "init: Error "
  4597                              <1> .config_error_reading_2:asciz "h while reading configuration.",13,10
  4598                              <1> .config_too_long_line_1:asciz "init: Line "
  4599                              <1> .config_too_long_line_2:asciz " is too long. Ignoring!",13,10
  4600                              <1> .config_too_long_file_1: db "init: Configuration file too long, "
  4601                              <1> 			asciz "ignoring remainder starting at line "
  4602                              <1> .config_too_long_file_2:asciz ".",13,10
  4603                              <1> .internal_error_config:	asciz "init: Internal error in CONFIG processing.",13,10
  4604                              <1> %endif
  4605                              <1> 
  4606 00001F72 48616C7465642E2050- <1> .reboot_prompt:		asciz "Halted. Press Ctrl+Alt+Del to reboot.",13,10
  4606 00001F7B 72657373204374726C- <1>
  4606 00001F84 2B416C742B44656C20- <1>
  4606 00001F8D 746F207265626F6F74- <1>
  4606 00001F96 2E0D0A00            <1>
  4607                              <1> 
  4608                              <1> .umb_unavailable_1:
  4609                              <1> .umb_allocated_1:
  4610 00001F9A 696E69743A20554D42- <1> 	asciz "init: UMB of size "
  4610 00001FA3 206F662073697A6520- <1>
  4610 00001FAC 00                  <1>
  4611                              <1> .umb_unavailable_2:
  4612                              <1> .umb_allocated_2:
  4613 00001FAD 68202800            <1> 	asciz "h ("
  4614                              <1> .umb_unavailable_3:
  4615 00001FB1 29207265706F727465- <1> 	asciz ") reported free but failed to allocate.",13,10
  4615 00001FBA 642066726565206275- <1>
  4615 00001FC3 74206661696C656420- <1>
  4615 00001FCC 746F20616C6C6F6361- <1>
  4615 00001FD5 74652E0D0A00        <1>
  4616                              <1> .umb_allocated_3:
  4617 00001FDB 292061742000        <1> 	asciz ") at "
  4618                              <1> .umb_allocated_4:
  4619 00001FE1 6820616C6C6F636174- <1> 	asciz "h allocated.",13,10
  4619 00001FEA 65642E0D0A00        <1>
  4620                              <1> .umb_mcb_chain_corrupted_1:
  4621 00001FF0 696E69743A20554D43- <1> 	asciz "init: UMCB chain corrupted, step="
  4621 00001FF9 4220636861696E2063- <1>
  4621 00002002 6F727275707465642C- <1>
  4621 0000200B 20737465703D00      <1>
  4622                              <1> .umb_mcb_chain_corrupted_2:
  4623 00002012 682C2061783D00      <1> 	asciz "h, ax="
  4624                              <1> .umb_mcb_chain_corrupted_3:
  4625 00002019 682E0D0A00          <1> 	asciz "h.",13,10
  4626                              <1> .umb_succeeded_unexpectedly:
  4627 0000201E 696E69743A20526571- <1> 	db "init: Requested UMB allocation of size 0FFFFh"
  4627 00002027 75657374656420554D- <1>
  4627 00002030 4220616C6C6F636174- <1>
  4627 00002039 696F6E206F66207369- <1>
  4627 00002042 7A6520304646464668  <1>
  4628 0000204B 20756E657870656374- <1> 	asciz " unexpectedly succeeded.",13,10
  4628 00002054 65646C792073756363- <1>
  4628 0000205D 65656465642E0D0A00  <1>
  4629                              <1> 
  4630                              <1> %if _RELOCATEDOSCODE && _DOSCODEHMA
  4631                              <1> .error_enabling_a20_xms:
  4632 00002066 696E69743A20457272- <1> 	asciz "init: Error enabling A20, XMS call failed.",13,10
  4632 0000206F 6F7220656E61626C69- <1>
  4632 00002078 6E67204132302C2058- <1>
  4632 00002081 4D532063616C6C2066- <1>
  4632 0000208A 61696C65642E0D0A00  <1>
  4633                              <1> .error_enabling_a20_actual:
  4634 00002093 696E69743A20457272- <1> 	asciz "init: Error enabling A20, XMS call reported success but A20 is still off.", 13,10
  4634 0000209C 6F7220656E61626C69- <1>
  4634 000020A5 6E67204132302C2058- <1>
  4634 000020AE 4D532063616C6C2072- <1>
  4634 000020B7 65706F727465642073- <1>
  4634 000020C0 756363657373206275- <1>
  4634 000020C9 742041323020697320- <1>
  4634 000020D2 7374696C6C206F6666- <1>
  4634 000020DB 2E0D0A00            <1>
  4637                              <1> .relocated_to_hma:
  4638 000020DF 696E69743A20537563- <1> 	asciz "init: Successfully relocated DOSCODE into the HMA.",13,10
  4638 000020E8 6365737366756C6C79- <1>
  4638 000020F1 2072656C6F63617465- <1>
  4638 000020FA 6420444F53434F4445- <1>
  4638 00002103 20696E746F20746865- <1>
  4638 0000210C 20484D412E0D0A00    <1>
  4639                              <1> .auto_bounce_hma_chs:
  4640 00002114 696E69743A20426F75- <1> 	asciz "init: Bounce HMA CHS detected as needed for drive "
  4640 0000211D 6E636520484D412043- <1>
  4640 00002126 485320646574656374- <1>
  4640 0000212F 6564206173206E6565- <1>
  4640 00002138 64656420666F722064- <1>
  4640 00002141 726976652000        <1>
  4641                              <1> .auto_bounce_hma_lba:
  4642 00002147 696E69743A20426F75- <1> 	asciz "init: Bounce HMA LBA detected as needed for drive "
  4642 00002150 6E636520484D41204C- <1>
  4642 00002159 424120646574656374- <1>
  4642 00002162 6564206173206E6565- <1>
  4642 0000216B 64656420666F722064- <1>
  4642 00002174 726976652000        <1>
  4643                              <1> .auto_bounce_trail:
  4644 0000217A 3A0D0A00            <1> 	asciz ":",13,10
  4645                              <1> %endif
  4646                              <1> 
  4647                              <1> %if 1 || (_RELOCATEDOSCODE && _DOSCODEHMA)
  4648                              <1>  global init2_disp_msg_asciz_cs_dx
  4649                              <1> init2_disp_msg_asciz_cs_dx:
  4650                              <1>  assume ds:nothing, es:nothing, ss:nothing
  4651 0000217E 1E                  <1> 	push ds
  4652 0000217F 56                  <1> 	push si
  4653 00002180 50                  <1> 	push ax
  4654 00002181 0E                  <1> 	 push cs
  4655 00002182 1F                  <1> 	 pop ds
  4656                              <1>  assume ds:SYSINITGROUP
  4657 00002183 89D6                <1> 	mov si, dx
  4658 00002185 E80400              <1> 	call init2_disp_msg
  4659 00002188 58                  <1> 	pop ax
  4660 00002189 5E                  <1> 	pop si
  4661 0000218A 1F                  <1> 	pop ds
  4662                              <1>  assume ds:nothing
  4663 0000218B C3                  <1> 	retn
  4664                              <1> 
  4665                              <1> init2_disp_msg:
  4666                              <1>  assume ds:nothing, es:nothing, ss:nothing
  4667 0000218C 50                  <1> 	push ax
  4668                              <1> @@:
  4669 0000218D AC                  <1> 	lodsb
  4670 0000218E 84C0                <1> 	test al, al
  4671 00002190 7411                <1> 	jz @F
  4672 00002192 E80200              <1> 	call init2_disp_al
  4673 00002195 EBF6                <1> 	jmp short @B
  4674                              <1> 
  4675                              <1>  global init2_disp_al
  4676                              <1> init2_disp_al:
  4677                              <1>  assume ds:nothing, es:nothing, ss:nothing
  4678 00002197 50                  <1> 	push ax
  4679 00002198 53                  <1> 	push bx
  4680 00002199 55                  <1> 	push bp
  4681 0000219A B40E                <1> 	mov ah, 0Eh
  4682 0000219C BB0700              <1> 	mov bx, 7
  4683 0000219F CD10                <1> 	int 10h
  4684 000021A1 5D                  <1> 	pop bp
  4685 000021A2 5B                  <1> 	pop bx
  4686                              <1> @@:
  4687 000021A3 58                  <1> 	pop ax
  4688 000021A4 C3                  <1> 	retn
  4689                              <1> 
  4690                              <1>  global init2_disp_dxax_hex
  4691                              <1> init2_disp_dxax_hex:		; dx:ax
  4692                              <1>  assume ds:nothing, es:nothing, ss:nothing
  4693 000021A5 92                  <1> 		xchg ax, dx
  4694 000021A6 E80100              <1> 		call init2_disp_ax_hex
  4695 000021A9 92                  <1> 		xchg ax, dx
  4696                              <1>  global init2_disp_ax_hex
  4697                              <1> init1_disp_ax_hex:		; ax
  4698                              <1> init2_disp_ax_hex:		; ax
  4699                              <1>  assume ds:nothing, es:nothing, ss:nothing
  4700 000021AA 86C4                <1> 		xchg al,ah
  4701 000021AC E80200              <1> 		call init2_disp_al_hex		; display former ah
  4702 000021AF 86C4                <1> 		xchg al,ah			;  and fall trough for al
  4703                              <1>  global init2_disp_al_hex
  4704                              <1> init2_disp_al_hex:		; al
  4705                              <1>  assume ds:nothing, es:nothing, ss:nothing
  4706 000021B1 51                  <1> 		push cx
  4707 000021B2 B104                <1> 		mov cl,4
  4708 000021B4 D2C8                <1> 		ror al,cl
  4709 000021B6 E80300              <1> 		call init2_disp_al_lownibble_hex; display former high-nibble
  4710 000021B9 D2C0                <1> 		rol al,cl
  4711 000021BB 59                  <1> 		pop cx
  4712                              <1> 						;  and fall trough for low-nibble
  4713                              <1> init2_disp_al_lownibble_hex:
  4714                              <1>  assume ds:nothing, es:nothing, ss:nothing
  4715 000021BC 50                  <1> 		push ax			 ; save ax for call return
  4716 000021BD 240F                <1> 		and al,00001111b		; high nibble must be zero
  4717 000021BF 0430                <1> 		add al,'0'			; if number is 0-9, now it's the correct character
  4718 000021C1 3C39                <1> 		cmp al,'9'
  4719 000021C3 7602                <1> 		jna .decimalnum		 ; if we get decimal number with this, ok -->
  4720 000021C5 0407                <1> 		add al,7			;  otherwise, add 7 and we are inside our alphabet
  4721                              <1>  .decimalnum:
  4722 000021C7 E8CDFF              <1> 		call init2_disp_al
  4723 000021CA 58                  <1> 		pop ax
  4724 000021CB C3                  <1> 		retn
  4725                              <1> %endif
  4726                              <1> 
  4727                              <1> 
  4728                              <1> 		; INP:	cx = flags
  4729                              <1> 		;	dx = indicator if to use UMA only
  4730                              <1> 		; CHG:	all except bp
  4731                              <1> relocate_dosdata:
  4732                              <1>  assume ds:nothing, es:nothing, ss:nothing
  4733 000021CC 2ED006[1108]        <1> 	rol byte [cs:dosdata_relocated_to_final_position], 1
  4734 000021D1 7221                <1> 	jc .ret
  4735                              <1> 
  4736                              <1> %if 0
  4737                              <1> 	mov ax, (dosdata_end - dosdata_start)
  4738                              <1> %else
  4739 000021D3 31C0                <1> 	xor ax, ax
  4740 000021D5 8ED8                <1> 	mov ds, ax
  4741                              <1>  assume ds:IVT
  4742 000021D7 A1C600              <1> 	mov ax, [31h * 4 + 2]
  4743 000021DA 48                  <1> 	dec ax
  4744 000021DB 8ED8                <1> 	mov ds, ax
  4745                              <1>  assume ds:MCB
  4746 000021DD A10300              <1> 	mov ax, [mcbSize]
  4747 000021E0 B104                <1> 	mov cl, 4
  4748 000021E2 D3E0                <1> 	shl ax, cl
  4749                              <1> %endif
  4750 000021E4 BE[6823]            <1> 	mov si, alloc_dosdata
  4751                              <1> 
  4752 000021E7 50                  <1> 	push ax
  4753 000021E8 85D2                <1> 	test dx, dx
  4754 000021EA 7409                <1> 	jz @F
  4755 000021EC 31D2                <1> 	xor dx, dx
  4756 000021EE E89001              <1> 	call allocate_relocate_block.large_upper_only
  4757 000021F1 7305                <1> 	jnc .allocated
  4758 000021F3 59                  <1> 	pop cx
  4759                              <1> .ret:
  4760 000021F4 C3                  <1> 	retn
  4761                              <1> 
  4762                              <1> @@:
  4763 000021F5 E88601              <1> 	call allocate_relocate_block
  4764                              <1> .allocated:			; es:di -> DOSDATA destination
  4765                              <1>  assume es:nothing
  4766 000021F8 59                  <1> 	pop cx
  4767                              <1> 
  4768                              <1> %if 0
  4769                              <1> 	mov ax, 70h
  4770                              <1> 	mov ds, ax			; => DOSENTRY
  4771                              <1> 	mov bx, word [dosentry_to_dosdata_segment]
  4772                              <1> 					; get DOSDATA segment
  4773                              <1> %else
  4774 000021F9 31C0                <1> 	xor ax, ax
  4775 000021FB 8ED8                <1> 	mov ds, ax
  4776                              <1>  assume ds:IVT
  4777 000021FD 8B1EC600            <1> 	mov bx, [31h * 4 + 2]
  4778                              <1> %endif
  4779 00002201 8EDB                <1> 	mov ds, bx
  4780                              <1>  assume ds:DOSGROUP
  4781 00002203 31F6                <1> 	xor si, si			; ds:si -> DOSDATA source
  4782 00002205 D1E9                <1> 	shr cx, 1			; get number of words
  4783 00002207 F3A5                <1> 	rep movsw			; move
  4784                              <1> 
  4785                              <1> %if 0		; done by DOSREINIT
  4786                              <1> 	mov ds, ax
  4787                              <1> 	mov word [dosentry_to_dosdata_segment], es
  4788                              <1> 					; DOSDATA reference in DOSENTRY
  4789                              <1> %if _COMBINED_DOSDATA_DOSCODE
  4790                              <1> 	push es
  4791                              <1> 	pop ds
  4792                              <1> 	mov word [dosdata_to_doscode_segment], es
  4793                              <1> %endif
  4794                              <1> 	xor ax, ax
  4795                              <1> 	mov ds, ax
  4796                              <1> 	mov word [30h * 4 + 6], es	; DR-DOS compatible DOSDATA reference
  4797                              <1> %endif
  4798                              <1> 
  4799 00002209 8CD0                <1> 	mov ax, ss
  4800 0000220B 39D8                <1> 	cmp ax, bx
  4801 0000220D 7502                <1> 	jne @F
  4802 0000220F 06                  <1> 	push es
  4803 00002210 17                  <1> 	pop ss
  4804                              <1>  assume ss:nothing
  4805                              <1> @@:
  4806                              <1> 
  4807 00002211 89DA                <1> 	mov dx, bx			; => old DOSDATA
  4808 00002213 8CC0                <1> 	mov ax, es			; => new DOSDATA
  4809 00002215 E8(0000)            <1> 	invoke DOSREINIT
  4810                              <1>  assume ds:nothing, es:DOSGROUP
  4811                              <1> 
  4812 00002218 2EF616[1108]        <1> 	not byte [cs:dosdata_relocated_to_final_position]
  4813                              <1> 
  4814 0000221D 8EC2                <1> 	mov es, dx			; => DOSDATA source
  4815                              <1>  assume es:nothing
  4816 0000221F B449                <1> 	mov ah, 49h
  4817 00002221 CD21                <1> 	int 21h				; free it
  4818 00002223 C3                  <1> 	retn
  4819                              <1> 
  4820                              <1> 
  4821                              <1> 		; This is to be called after all device drivers are installed.
  4822                              <1> 		;  It relocates DOSCODE and DOSDATA.
  4823                              <1> 		; May be extended to relocate more things later.
  4824                              <1> 		;
  4825                              <1> 		; INP:	ax = flags
  4826                              <1> 		; CHG:	ds, es, si, di, ax, bx, cx, dx
  4827                              <1> init2_relocate_end:
  4828                              <1>  assume ds:nothing, es:nothing, ss:nothing
  4829                              <1> 	lframe 0
  4830                              <1> 	lvar word, count
  4831                              <1> 	lvar dword, prior
  4832 00002224 5589E58D66FA        <1> 	lenter
  4833                              <1> 	lvar word, flags
  4834 0000222A 50                  <1> 	 push ax
  4835 0000222B 91                  <1> 	xchg cx, ax			; cx = flags
  4836                              <1> 
  4837 0000222C B80058              <1> 	mov ax, 5800h
  4838 0000222F CD21                <1> 	int 21h
  4839 00002231 50                  <1> 	push ax
  4840                              <1> 
  4841 00002232 31D2                <1> 	xor dx, dx			; 0 = relocate in any case, LMA if needed
  4842 00002234 E895FF              <1> 	call relocate_dosdata
  4843                              <1> 
  4844                              <1> %if !_COMBINED_DOSDATA_DOSCODE && _RELOCATEDOSCODE
  4845                              <1> 
  4846 00002237 2ED006[1408]        <1> 	rol byte [cs:doscode_relocated_to_final_position], 1
  4847 0000223C 7278                <1> 	jc .no_doscode_reloc
  4848                              <1> 
  4849 0000223E B80158              <1> 	mov ax, 5801h
  4850 00002241 BB1001              <1> 	mov bx, 0110h		; ignore UMB link
  4851 00002244 CD21                <1> 	int 21h			; alloc strategy: first fit, LMA only
  4852                              <1> 
  4853 00002246 F746F80100          <1> 	test word [bp + ?flags], DOSFLAGS_RELOCATE_DOSCODE_UMA
  4854 0000224B 7408                <1> 	jz .got_doscode_strat
  4855                              <1> 
  4856 0000224D B80158              <1> 	mov ax, 5801h
  4857 00002250 BB8001              <1> 	mov bx, 0180h		; ignore UMB link
  4858 00002253 CD21                <1> 	int 21h			; alloc strategy: first fit, try UMA then LMA
  4859                              <1> .got_doscode_strat:
  4860                              <1> 
  4861                              <1> %if 0
  4862                              <1> 	mov ax, 70h
  4863                              <1> 	mov ds, ax
  4864                              <1> 	mov ds, word [dosentry_to_dosdata_segment]
  4865                              <1> %else
  4866 00002255 31C0                <1> 	xor ax, ax
  4867 00002257 8ED8                <1> 	mov ds, ax
  4868                              <1>  assume ds:IVT
  4869 00002259 8E1EC600            <1> 	mov ds, word [31h * 4 + 2]	; => DOSDATA
  4870                              <1>  assume ds:DOSGROUP
  4871                              <1> %endif
  4872 0000225D 833E[0000]FE        <1> 	cmp word [dosdata_to_doscode_segment], DOSCODE_HMA_SEGMENT
  4873 00002262 7352                <1> 	jae .skip_doscode
  4874                              <1> 
  4875                              <1> %if 0
  4876                              <1> 	mov ax, (doscode_end - doscode_start)
  4877                              <1> %else
  4878                              <1> extern afterdoscodelabel
  4879 00002264 B8[0000]            <1> 	mov ax, afterdoscodelabel wrt DOSCODEGROUP
  4880 00002267 83E850              <1> 	sub ax, DOSCODE_HMA_OFFSET
  4881                              <1> %endif
  4882 0000226A B102                <1> 	mov cl, S_DOSCODE
  4883 0000226C E87AF5              <1> 	call init2_alloc_s_mcb
  4884                              <1>  assume es:nothing
  4885                              <1> 
  4886                              <1> %if 0
  4887                              <1> 	mov ax, 70h
  4888                              <1> 	mov ds, ax			; => DOSENTRY
  4889                              <1> 	mov ds, word [dosentry_to_dosdata_segment]	; => DOSDATA
  4890                              <1> %else
  4891 0000226F 31C0                <1> 	xor ax, ax
  4892 00002271 8ED8                <1> 	mov ds, ax
  4893                              <1>  assume ds:IVT
  4894 00002273 8E1EC600            <1> 	mov ds, word [31h * 4 + 2]	; => DOSDATA
  4895                              <1>  assume ds:DOSGROUP
  4896                              <1> %endif
  4897 00002277 8CC3                <1> 	mov bx, es
  4898 00002279 83EB05              <1> 	sub bx, DOSCODE_HMA_OFFSET / 16	; start offset
  4899 0000227C 8EC3                <1> 	mov es, bx
  4900                              <1>  assume es:nothing
  4901 0000227E BF5000              <1> 	mov di, DOSCODE_HMA_OFFSET	; es:di -> DOSCODE destination
  4902 00002281 8B1E[0000]          <1> 	mov bx, word [dosdata_to_doscode_segment]
  4903 00002285 8EDB                <1> 	mov ds, bx
  4904                              <1>  assume ds:DOSCODEGROUP
  4905 00002287 89FE                <1> 	mov si, di			; ds:si -> DOSCODE source
  4906 00002289 D1E9                <1> 	shr cx, 1			; = number of words
  4907 0000228B F3A5                <1> 	rep movsw			; move
  4908                              <1> 
  4909                              <1> %if 0
  4910                              <1> 	mov ds, ax
  4911                              <1> 	mov ds, word [dosentry_to_dosdata_segment]
  4912                              <1> %else
  4913 0000228D 8ED8                <1> 	mov ds, ax
  4914                              <1>  assume ds:IVT
  4915 0000228F 8E1EC600            <1> 	mov ds, word [31h * 4 + 2]	; => DOSDATA
  4916                              <1>  assume ds:DOSGROUP
  4917                              <1> %endif
  4918 00002293 8C06[0000]          <1> 	mov word [dosdata_to_doscode_segment], es
  4919 00002297 B8[ssss]            <1> 	mov ax, DOSENTRY
  4920 0000229A 8ED8                <1> 	mov ds, ax
  4921                              <1>  assume ds:DOSENTRYGROUP
  4922                              <1>  extern ..@dosentry_doscode_segment
  4923 0000229C 8C06[0000]          <1> 	mov word [..@dosentry_doscode_segment], es
  4924 000022A0 2EF616[1408]        <1> 	not byte [cs:doscode_relocated_to_final_position]
  4925                              <1>  assume es:DOSCODEGROUP
  4926                              <1> 
  4927 000022A5 8CD0                <1> 	mov ax, ss
  4928 000022A7 39D8                <1> 	cmp ax, bx
  4929 000022A9 7502                <1> 	jne @F
  4930 000022AB 06                  <1> 	push es
  4931 000022AC 17                  <1> 	pop ss
  4932                              <1>  assume ss:DOSCODEGROUP
  4933                              <1> @@:
  4934                              <1>  assume ss:nothing
  4935                              <1> 
  4936 000022AD 83C305              <1> 	add bx, DOSCODE_HMA_OFFSET / 16	; start offset
  4937 000022B0 8EC3                <1> 	mov es, bx			; => DOSCODE source
  4938                              <1>  assume es:nothing
  4939 000022B2 B449                <1> 	mov ah, 49h
  4940 000022B4 CD21                <1> 	int 21h				; free it
  4941                              <1> 
  4942                              <1> .skip_doscode:
  4943                              <1> .no_doscode_reloc:
  4944                              <1> %endif
  4945                              <1>  assume ds:nothing, es:nothing, ss:nothing
  4946                              <1> 
  4947 000022B6 5B                  <1> 	pop bx
  4948 000022B7 B80158              <1> 	mov ax, 5801h
  4949 000022BA CD21                <1> 	int 21h			; alloc strategy: restore
  4950                              <1> 
  4951 000022BC 89EC5D              <1> 	lleave
  4952 000022BF C3                  <1> 	retn
  4953                              <1> 
  4954                              <1> 
  4955                              <1> init2_internal_error_reboot_prompt:
  4956 000022C0 E8C9FE              <1> 	call init2_disp_msg
  4957                              <1> 
  4958                              <1> init2_reboot_prompt:
  4959 000022C3 0E                  <1> 	push cs
  4960 000022C4 1F                  <1> 	pop ds
  4961                              <1>  assume ds:SYSINITGROUP
  4962 000022C5 BE[721F]            <1> 	mov si, init2_msg.reboot_prompt	; access with ds
  4963 000022C8 E8C1FE              <1> 	call init2_disp_msg
  4964                              <1> .loop:
  4965 000022CB CC                  <1> 	int3
  4966 000022CC 31C0                <1> 	xor ax, ax
  4967 000022CE CD16                <1> 	int 16h
  4968 000022D0 EBF9                <1> 	jmp .loop
  4969                              <1> 
  4970                              <1> 
  4971                              <1> %if 0
  4972                              <1> 	align 4
  4973                              <1> %include "RxDOSINI.ASM"
  4974                              <1> 
  4975                              <1> 	align 16
  4976                              <1> init2_end:
  4977                              <1> 	istruc MCB
  4978                              <1> at mcbSignature,	db "M"
  4979                              <1> at mcbOwner,		dw 8
  4980                              <1> at mcbSize,		dw (init3_end - init3_start) >> 4
  4981                              <1> at smcbName,		dw "S"
  4982                              <1> at smcbType,		db S_INITPSP
  4983                              <1> 	iend
  4984                              <1> 
  4985                              <1> 	; section INIT3 align=16 follows=INIT2 vstart=0
  4986                              <1> init3_start:
  4987                              <1> 	istruc PSP
  4988                              <1> at pspCall0,		int 20h
  4989                              <1> at pspCall5,		call 0:(30h * 4)
  4990                              <1> at pspInt22,		dw init3_terminated, 0		; +2 segment here
  4991                              <1> at pspInt23,		dw i23, 70h
  4992                              <1> at pspInt24,		dw i24, 70h
  4993                              <1> at pspParent,		dw 0				; +0 segment here
  4994                              <1> at pspPHT,		times pspPHT_size db -1
  4995                              <1> at pspEnvironment,	dw 0				; +0 env segment here
  4996                              <1> at pspStack,		dw init3_stack.end - 32, 0	; +2 segment here
  4997                              <1> at pspPHTEntries,	dw pspPHT_size
  4998                              <1> at pspPHTAddress,	dw pspPHT, 0			; +2 segment here
  4999                              <1> at pspShareNext,	dd -1
  5000                              <1> at pspVersion,		dw RXDOS_MS_VERSION
  5001                              <1> at pspInt21Far,		int 21h
  5002                              <1> 			retf
  5003                              <1> at pspCommandLine
  5004                              <1> 	; iend
  5005                              <1> 	%pop		; (pop off the istruc context)
  5006                              <1> 
  5007                              <1> init3_msg:
  5008                              <1> .internal_error_terminated:	db "init: Internal error, init PSP "
  5009                              <1> 				asciz "has been terminated.",13,10
  5010                              <1> .reboot_prompt:		asciz "Halted. Press Ctrl+Alt+Del to reboot.",13,10
  5011                              <1> 
  5012                              <1> init3_terminated:
  5013                              <1> 	cli
  5014                              <1> 	cld
  5015                              <1> 	mov ax, cs
  5016                              <1> 	mov ss, ax
  5017                              <1> 	mov sp, init3_stack.end
  5018                              <1> 	sti
  5019                              <1> 
  5020                              <1> 	push cs
  5021                              <1> 	pop ds
  5022                              <1> 	mov si, init3_msg.internal_error_terminated
  5023                              <1> init3_internal_error_reboot_prompt:
  5024                              <1> 	call init3_disp_msg
  5025                              <1> 
  5026                              <1> init3_reboot_prompt:
  5027                              <1> 	push cs
  5028                              <1> 	pop ds
  5029                              <1> 	mov si, init3_msg.reboot_prompt
  5030                              <1> 	call init3_disp_msg
  5031                              <1> .loop:
  5032                              <1> 	int3
  5033                              <1> 	xor ax, ax
  5034                              <1> 	int 16h
  5035                              <1> 	jmp .loop
  5036                              <1> 
  5037                              <1> init3_disp_msg_asciz:
  5038                              <1> 	push ds
  5039                              <1> 	push si
  5040                              <1> 	push ax
  5041                              <1> 	 push cs
  5042                              <1> 	 pop ds
  5043                              <1> 	mov si, dx
  5044                              <1> 	call init3_disp_msg
  5045                              <1> 	pop ax
  5046                              <1> 	pop si
  5047                              <1> 	pop ds
  5048                              <1> 	retn
  5049                              <1> 
  5050                              <1> init3_disp_msg:
  5051                              <1> 	push ax
  5052                              <1> @@:
  5053                              <1> 	lodsb
  5054                              <1> 	test al, al
  5055                              <1> 	jz @F
  5056                              <1> 	call init3_disp_al
  5057                              <1> 	jmp short @B
  5058                              <1> 
  5059                              <1> init3_disp_al:
  5060                              <1> 	push ax
  5061                              <1> 	push bx
  5062                              <1> 	push bp
  5063                              <1> 	mov ah, 0Eh
  5064                              <1> 	mov bx, 7
  5065                              <1> 	int 10h
  5066                              <1> 	pop bp
  5067                              <1> 	pop bx
  5068                              <1> @@:
  5069                              <1> 	pop ax
  5070                              <1> 	retn
  5071                              <1> 
  5072                              <1> 
  5073                              <1> 	align 16
  5074                              <1> init3_stack:
  5075                              <1> 	times 512 db 0
  5076                              <1> .end:
  5077                              <1> 
  5078                              <1> 	align 16
  5079                              <1> init3_end:
  5080                              <1> 	istruc MCB
  5081                              <1> at mcbSignature,	db "Z"
  5082                              <1> at mcbOwner,		dw 0
  5083                              <1> at mcbSize,		dw 0
  5084                              <1> 	iend
  5085                              <1> 
  5086                              <1> %include "comload.asm"
  5087                              <1> %endif
  5088                              <1> 
  5089                              <1> 	struc ALLOCDATA
  5090 00000000 ??                  <1> adSMCBType:	resb 1
  5091 00000001 ??                  <1> adSDSign:	resb 1
  5092 00000002 ????????????????    <1> adHMCBName:	resb 8
  5093                              <1> 	endstruc
  5094                              <1> 
  5095                              <1> %imacro allocdata 4.nolist
  5096                              <1> %1:
  5097                              <1> 	istruc ALLOCDATA
  5098                              <1> at adSMCBType,	db %2
  5099                              <1> at adSDSign,	db %3
  5100                              <1> at adHMCBName,	db %4
  5101                              <1> 	iend
  5102                              <1> %endmacro
  5103                              <1> 
  5104                              <1> 	align 2, db 0
  5105 000022D2 0A4653465400-       <1> allocdata alloc_sft, S_SFT, DEVMARK_FILES, "SFT"
  5105 000022D2 <rep 5h>            <1>
  5106 000022DC 0B5846434253465400- <1> allocdata alloc_fcb, S_FCBSFT, DEVMARK_FCBS, "FCBSFT"
  5106 000022DC <rep 2h>            <1>
  5107 000022E6 1658FF00<rep 7h>    <1> allocdata alloc_initfcb, S_INITFCBSFT, DEVMARK_FCBS, -1
  5108 000022F0 0C4242756666657273- <1> allocdata alloc_buffers, S_CCB, DEVMARK_BUF, "Buffers"
  5108 000022F9 00                  <1>
  5109 000022FA 064C43445300-       <1> allocdata alloc_cds, S_CDS, DEVMARK_CDS, "CDS"
  5109 000022FA <rep 5h>            <1>
  5110 00002304 0453FF00<rep 7h>    <1> allocdata alloc_stack, S_IRQSCODE, DEVMARK_STK, -1	; not for HMA
  5111 0000230E 1F00FF00<rep 7h>    <1> allocdata alloc_init, S_INIT, 0, -1
  5112 00002318 1800FF00<rep 7h>    <1> allocdata alloc_initcds, S_INITCDS, 0, -1
  5113 00002322 1900FF00<rep 7h>    <1> allocdata alloc_initconfig, S_INITCONFIG, 0, -1
  5114 0000232C 1D00FF00<rep 7h>    <1> allocdata alloc_initpsp, S_INITPSP, 0, -1
  5115 00002336 0900FF00<rep 7h>    <1> allocdata alloc_upb_temporary, S_UPB, 0, -1
  5116 00002340 090055504200-       <1> allocdata alloc_upb, S_UPB, 0, "UPB"
  5116 00002340 <rep 5h>            <1>
  5117                              <1> alloc_dpb_temporary:
  5118 0000234A 0800FF00<rep 7h>    <1> allocdata alloc_dpb_no_hma, S_DPB, 0, -1
  5119 00002354 080044504200-       <1> allocdata alloc_dpb, S_DPB, 0, "DPB"
  5119 00002354 <rep 5h>            <1>
  5120 0000235E 1700496E6953746163- <1> allocdata alloc_initstack, S_INITSTACK, 0, "IniStack"
  5120 00002367 6B                  <1>
  5121 00002368 0300FF00<rep 7h>    <1> allocdata alloc_dosdata, S_DOSDATA, 0, -1
  5122                              <1> 
  5123                              <1> global alloc_init, alloc_initcds, alloc_initconfig, alloc_dpb_no_hma
  5124                              <1> global alloc_upb_temporary, alloc_upb
  5125                              <1> global alloc_dpb_temporary, alloc_dpb
  5126                              <1> global allocate_relocate_block
  5127                              <1> global allocate_temporary_block
  5128                              <1> global allocate_temporary_block.large_allow_error
  5129                              <1> 
  5130                              <1> 	align 2, db 0
  5131 00002372 00                  <1> 	db 0			; pad so start is odd
  5132                              <1> smcb_template:
  5133 00002373 000000              <1> .:	db 0, 0, 0
  5134 00002376 5300                <1> 	db "S", 0
  5135 00002378 00<rep 6h>          <1> 	times 6 db 0
  5136                              <1> .end:
  5137                              <1> .size equ .end - .
  5138                              <1> 
  5139                              <1> 		; INP:	cs:si -> data
  5140                              <1> 		;	(dx:)ax = bytes needed
  5141                              <1> 		; OUT:	es:di -> memory allocated, zeroed
  5142                              <1> 		;	di = 0 if not in HMA
  5143                              <1> allocate_relocate_block:
  5144                              <1>  assume ds:nothing, es:nothing, ss:nothing
  5145 0000237E 31D2                <1> 	xor dx, dx
  5146                              <1> .large:
  5147                              <1>  assume ds:nothing, es:nothing, ss:nothing
  5148 00002380 A8                  <1> 	db __TEST_IMM8		; skip stc, NC
  5149                              <1> .large_upper_only:
  5150 00002381 F9                  <1> 	stc
  5151                              <1>  assume ds:nothing, es:nothing, ss:nothing
  5152                              <1> 	lframe
  5153                              <1> 	lvar word, parasize
  5154 00002382 5589E550            <1> 	lenter
  5155                              <1> 	lvar word, bit0_upper_only
  5156 00002386 9C                  <1> 	 pushf
  5157                              <1> 	lvar word, data
  5158 00002387 56                  <1> 	 push si
  5159                              <1> 	lvar dword, size
  5160 00002388 52                  <1> 	 push dx
  5161 00002389 50                  <1> 	 push ax
  5162                              <1> 
  5163 0000238A 2E807C02FF          <1> 	cmp byte [cs:si + adHMCBName], -1
  5164 0000238F 7446                <1> 	je .nothma		; if cannot relocate to HMA -->
  5165 00002391 85D2                <1> 	test dx, dx		; >= 64 KiB ?
  5166 00002393 7542                <1> 	jnz .nothma		; cannot fit in the HMA -->
  5167 00002395 93                  <1> 	xchg bx, ax		; bx = how many bytes needed
  5168 00002396 BFFFFF              <1> 	mov di, -1		; harden
  5169 00002399 B92600              <1> 	mov cx, 26h		; owner
  5170 0000239C B200                <1> 	mov dl, 0		; allocate low in the largest free block
  5171 0000239E B8034A              <1> 	mov ax, 4A03h
  5172 000023A1 CD2F                <1> 	int 2Fh			; allocate HMA memory block
  5173                              <1>  assume es:nothing
  5174 000023A3 83FFFF              <1> 	cmp di, -1
  5175 000023A6 742F                <1> 	je .nothma
  5176 000023A8 83C7F8              <1> 	add di, - HMCB_size + hmcbName
  5177                              <1> 				; -> HMCB name field
  5178 000023AB 0E                  <1> 	push cs
  5179 000023AC 1F                  <1> 	pop ds
  5180                              <1>  assume ds:SYSINITGROUP
  5181 000023AD 83C602              <1> 	add si, adHMCBName	; -> our data's name field
  5182 000023B0 B90400              <1> 	mov cx, words(8)	; length of name
  5183 000023B3 F3A5                <1> 	rep movsw		; es:di -> at data again
  5184 000023B5 57                  <1> 	push di
  5185 000023B6 31C0                <1> 	xor ax, ax
  5186 000023B8 89D9                <1> 	mov cx, bx
  5187 000023BA D1E9                <1> 	shr cx, 1		; amount words actually allocated
  5188 000023BC F3AB                <1> 	rep stosw
  5189 000023BE 85FF                <1> 	test di, di
  5190 000023C0 740F                <1> 	jz @F
  5191 000023C2 83FFF0              <1> 	cmp di, 0FFF0h		; near end ?
  5192 000023C5 730A                <1> 	jae @F			; yes -->
  5193 000023C7 BFFEFF              <1> 	mov di, 0FFFEh		; no, address with segment 0FFFEh instead
  5194 000023CA 8EC7                <1> 	mov es, di		; es => HMA
  5195                              <1>  assume es:nothing
  5196 000023CC 5F                  <1> 	pop di
  5197 000023CD 83C710              <1> 	add di, 10h		; -> allocation in segment 0FFFEh
  5198 000023D0 A8                  <1> 	db __TEST_IMM8		; (skip pop)
  5199                              <1> @@:
  5200 000023D1 5F                  <1> 	pop di			; es:di -> allocated memory block
  5201                              <1> .ret_NC:
  5202 000023D2 F8                  <1> 	clc
  5203                              <1> .ret:
  5204 000023D3 89EC5D              <1> 	lleave code
  5205 000023D6 C3                  <1> 	retn
  5206                              <1> 
  5207                              <1> .nothma:
  5208 000023D7 B80058              <1> 	mov ax, 5800h
  5209 000023DA CD21                <1> 	int 21h			; get strategy
  5210 000023DC 50                  <1> 	push ax
  5211 000023DD B80158              <1> 	mov ax, 5801h
  5212 000023E0 BB4101              <1> 	mov bx, 0141h		; UMA only, best fit, ignore UMB link status
  5213 000023E3 CD21                <1> 	int 21h			; set strategy
  5214                              <1> 
  5215 000023E5 8B56F8              <1> 	mov dx, word [bp + ?size + 2]
  5216 000023E8 8B46F6              <1> 	mov ax, word [bp + ?size]
  5217 000023EB 83C00F              <1> 	add ax, 15		; round up
  5218 000023EE 83D200              <1> 	adc dx, 0
  5219                              <1> .err_CY:
  5220 000023F1 7303E9(0000)        <1> 	jc MEM_ERR
  5221                              <1> 
  5222 000023F6 B90400              <1> 	mov cx, 4
  5223                              <1> @@:
  5224 000023F9 D1EA                <1> 	shr dx, 1
  5225 000023FB D1D8                <1> 	rcr ax, 1
  5226 000023FD E2FA                <1> 	loop @B
  5227 000023FF 85D2                <1> 	test dx, dx		; >= 1 MiB ?
  5228 00002401 F9                  <1> 	stc
  5229 00002402 75ED                <1> 	jnz .err_CY		; error -->
  5230                              <1> 
  5231 00002404 8946FE              <1> 	mov word [bp + ?parasize], ax
  5232 00002407 93                  <1> 	xchg bx, ax
  5233 00002408 B448                <1> 	mov ah, 48h
  5234 0000240A CD21                <1> 	int 21h
  5235 0000240C 7322                <1> 	jnc .success
  5236                              <1> 
  5237 0000240E F646FC01            <1> 	testopt [bp + ?bit0_upper_only], 1
  5238 00002412 740B                <1> 	jz .trylma
  5239 00002414 5B                  <1> 	pop bx
  5240 00002415 B80158              <1> 	mov ax, 5801h
  5241 00002418 CD21                <1> 	int 21h			; restore strategy
  5242                              <1> 
  5243 0000241A 0E                  <1> 	push cs
  5244 0000241B 1F                  <1> 	pop ds
  5245                              <1>  assume ds:SYSINITGROUP
  5246 0000241C F9                  <1> 	stc
  5247 0000241D EBB4                <1> 	jmp .ret
  5248                              <1> 
  5249                              <1> .trylma:
  5250                              <1>  assume ds:nothing
  5251 0000241F B80158              <1> 	mov ax, 5801h
  5252 00002422 BB8001              <1> 	mov bx, 0180h		; UMA then LMA, first fit, ignore UMB link status
  5253 00002425 CD21                <1> 	int 21h			; set strategy
  5254                              <1> 
  5255 00002427 8B5EFE              <1> 	mov bx, word [bp + ?parasize]
  5256 0000242A B448                <1> 	mov ah, 48h
  5257 0000242C CD21                <1> 	int 21h
  5258 0000242E 7257                <1> 	jc .fail
  5259                              <1> 
  5260                              <1> .success:
  5261 00002430 50                  <1> 	push ax			; => UMA memory block
  5262 00002431 48                  <1> 	dec ax
  5263 00002432 8EC0                <1> 	mov es, ax		; => UMCB
  5264                              <1>  assume es:MCB
  5265 00002434 BF0500              <1> 	mov di, mcbReserved	; -> UMCB reserved field
  5266 00002437 0E                  <1> 	push cs
  5267 00002438 1F                  <1> 	pop ds
  5268                              <1>  assume ds:SYSINITGROUP
  5269 00002439 8A04                <1> 	mov al, byte [si + adSMCBType]
  5270                              <1> 				; al = S MCB type
  5271 0000243B BE[7323]            <1> 	mov si, smcb_template	; -> our template
  5272 0000243E B90B00              <1> 	mov cx, smcb_template.size
  5273 00002441 26C70601000800      <1> 	mov word [es:mcbOwner], 8
  5274                              <1> 				; MCB owner = 8 (system)
  5275 00002448 F3A4                <1> 	rep movsb
  5276 0000244A 26A20A00            <1> 	mov byte [es:smcbType], al
  5277                              <1> 				; set the type
  5278                              <1> 
  5279 0000244E 07                  <1> 	pop es			; => UMA memory block
  5280                              <1>  assume es:nothing
  5281 0000244F 31FF                <1> 	xor di, di		; -> start of allocation
  5282 00002451 89D9                <1> 	mov cx, bx		; size in paras
  5283                              <1> 
  5284 00002453 5B                  <1> 	pop bx
  5285 00002454 B80158              <1> 	mov ax, 5801h
  5286 00002457 CD21                <1> 	int 21h			; restore strategy
  5287                              <1> 
  5288 00002459 89CB                <1> 	mov bx, cx		; = amount paragraphs
  5289                              <1> 
  5290                              <1> .ret_init_bx:
  5291 0000245B 06                  <1> 	push es
  5292 0000245C 57                  <1> 	push di
  5293                              <1> 
  5294                              <1> @@:
  5295 0000245D B90080              <1> 	mov cx, 8000h		; words in 64 KiB
  5296 00002460 81EB0010            <1> 	sub bx, 1000h		; another 64 KiB ?
  5297 00002464 730D                <1> 	jae @F			; yes -->
  5298 00002466 80C710              <1> 	add bh, 10h		; restore bx
  5299 00002469 31C9                <1> 	xor cx, cx		; cx = 0
  5300 0000246B 87D9                <1> 	xchg bx, cx		; bx = 0, cx = amount paragraphs
  5301 0000246D D1E1                <1> 	shl cx, 1
  5302 0000246F D1E1                <1> 	shl cx, 1
  5303 00002471 D1E1                <1> 	shl cx, 1		; cx = amount words
  5304                              <1> @@:
  5305 00002473 31C0                <1> 	xor ax, ax
  5306 00002475 F3AB                <1> 	rep stosw		; zero the memory
  5307 00002477 8CC0                <1> 	mov ax, es
  5308 00002479 050010              <1> 	add ax, 1000h
  5309 0000247C 8EC0                <1> 	mov es, ax		; => next segment (skip 64 KiB)
  5310                              <1>  assume es:nothing
  5311 0000247E 85DB                <1> 	test bx, bx		; any remaining ?
  5312 00002480 75DB                <1> 	jnz @BB			; yes -->
  5313                              <1> 
  5314 00002482 5F                  <1> 	pop di
  5315 00002483 07                  <1> 	pop es			; -> back at start
  5316                              <1>  assume es:nothing
  5317 00002484 E94BFF              <1> 	jmp .ret_NC
  5318                              <1> 
  5319                              <1> .fail:
  5320 00002487 5B                  <1> 	pop bx
  5321 00002488 B80158              <1> 	mov ax, 5801h
  5322 0000248B CD21                <1> 	int 21h			; restore strategy
  5323                              <1> 
  5324 0000248D 0E                  <1> 	push cs
  5325 0000248E 1F                  <1> 	pop ds
  5326                              <1>  assume ds:SYSINITGROUP
  5327                              <1> %if 0
  5328                              <1> 	INVOKE	ROUND
  5329                              <1> 	mov al, [si + adSDSign]
  5330                              <1> 	; cmp al, 1
  5331                              <1> 	; jb .err_CY
  5332                              <1> 	call SetDevMark
  5333                              <1> 	mov bx, [bp + ?parasize]
  5334                              <1> 	les di, [ss:MEMLO]	; es:di -> allocated data block
  5335                              <1> 	add word [ss:MEMHI], bx	; size in paragraphs
  5336                              <1> 	or byte [ss:SetDevMarkFlag], FOR_DEVMARK
  5337                              <1> 	INVOKE	ROUND		; allocate, will error out if not enough
  5338                              <1> 	jmp .ret_init_bx
  5339                              <1> %else
  5340                              <1>  assume ds:nothing, es:nothing, ss:nothing
  5341 0000248F E9(0000)            <1> 	jmp MEM_ERR
  5342                              <1> %endif
  5343                              <1> 
  5344                              <1> 	lleave ctx
  5345                              <1> 
  5346                              <1> 
  5347                              <1> 		; INP:	cs:si -> data
  5348                              <1> 		;	(dx:)ax = bytes needed
  5349                              <1> 		; OUT:	es:di -> memory allocated, zeroed
  5350                              <1> 		;	di = 0
  5351                              <1> 		;	ds = cs
  5352                              <1> allocate_temporary_block:
  5353                              <1>  assume ds:nothing, es:nothing, ss:nothing
  5354 00002492 31D2                <1> 	xor dx, dx
  5355                              <1> .large:
  5356                              <1>  assume ds:nothing, es:nothing, ss:nothing
  5357 00002494 A8                  <1> 	db __TEST_IMM8		; skip stc, NC
  5358                              <1> .large_allow_error:
  5359 00002495 F9                  <1> 	stc
  5360                              <1>  assume ds:nothing, es:nothing, ss:nothing
  5361                              <1> 	lframe
  5362                              <1> 	lvar word, parasize
  5363 00002496 5589E550            <1> 	lenter
  5364                              <1> 	lvar word, bit0_allow_error
  5365 0000249A 9C                  <1> 	 pushf
  5366                              <1> 	lvar word, data
  5367 0000249B 56                  <1> 	 push si
  5368                              <1> 	lvar dword, size
  5369 0000249C 52                  <1> 	 push dx
  5370 0000249D 50                  <1> 	 push ax
  5371                              <1> 
  5372 0000249E B80058              <1> 	mov ax, 5800h
  5373 000024A1 CD21                <1> 	int 21h			; get strategy
  5374 000024A3 50                  <1> 	push ax
  5375 000024A4 B80158              <1> 	mov ax, 5801h
  5376 000024A7 BB2205              <1> 	mov bx, 0522h		; LMA then UMA as two areas,
  5377                              <1> 				;  last fit, ignore UMB link status
  5378 000024AA CD21                <1> 	int 21h			; set strategy
  5379                              <1> 
  5380 000024AC 8B56F8              <1> 	mov dx, word [bp + ?size + 2]
  5381 000024AF 8B46F6              <1> 	mov ax, word [bp + ?size]
  5382 000024B2 83C00F              <1> 	add ax, 15		; round up
  5383 000024B5 83D200              <1> 	adc dx, 0
  5384                              <1> .err_CY:
  5385 000024B8 7303E9(0000)        <1> 	jc MEM_ERR
  5386                              <1> 
  5387 000024BD B90400              <1> 	mov cx, 4
  5388                              <1> @@:
  5389 000024C0 D1EA                <1> 	shr dx, 1
  5390 000024C2 D1D8                <1> 	rcr ax, 1
  5391 000024C4 E2FA                <1> 	loop @B
  5392 000024C6 85D2                <1> 	test dx, dx		; >= 1 MiB ?
  5393 000024C8 F9                  <1> 	stc
  5394 000024C9 75ED                <1> 	jnz .err_CY		; error -->
  5395                              <1> 
  5396 000024CB 8946FE              <1> 	mov word [bp + ?parasize], ax
  5397 000024CE 93                  <1> 	xchg bx, ax
  5398 000024CF B448                <1> 	mov ah, 48h
  5399 000024D1 CD21                <1> 	int 21h
  5400 000024D3 7312                <1> 	jnc .success
  5401 000024D5 F646FC01            <1> 	test byte [bp + ?bit0_allow_error], 1
  5402 000024D9 F9                  <1> 	stc
  5403 000024DA 74DC                <1> 	jz .err_CY
  5404                              <1> 
  5405 000024DC 5B                  <1> 	pop bx
  5406 000024DD B80158              <1> 	mov ax, 5801h
  5407 000024E0 CD21                <1> 	int 21h			; restore strategy
  5408                              <1> 
  5409 000024E2 0E                  <1> 	push cs
  5410 000024E3 1F                  <1> 	pop ds
  5411                              <1>  assume ds:SYSINITGROUP
  5412 000024E4 F9                  <1> 	stc
  5413 000024E5 EB54                <1> 	jmp .ret
  5414                              <1> 
  5415                              <1> .success:
  5416                              <1>  assume ds:nothing, es:nothing, ss:nothing
  5417 000024E7 50                  <1> 	push ax			; => LMA memory block
  5418 000024E8 48                  <1> 	dec ax
  5419 000024E9 8EC0                <1> 	mov es, ax		; => LMCB
  5420                              <1>  assume es:MCB
  5421 000024EB BF0500              <1> 	mov di, mcbReserved	; -> LMCB reserved field
  5422 000024EE 0E                  <1> 	push cs
  5423 000024EF 1F                  <1> 	pop ds			; ! ds = cs
  5424                              <1>  assume ds:SYSINITGROUP
  5425 000024F0 8A04                <1> 	mov al, byte [si + adSMCBType]
  5426                              <1> 				; al = S MCB type
  5427 000024F2 BE[7323]            <1> 	mov si, smcb_template	; -> our template
  5428 000024F5 B90B00              <1> 	mov cx, smcb_template.size
  5429 000024F8 26C70601000800      <1> 	mov word [es:mcbOwner], 8
  5430                              <1> 				; MCB owner = 8 (system)
  5431 000024FF F3A4                <1> 	rep movsb
  5432 00002501 26A20A00            <1> 	mov byte [es:smcbType], al
  5433                              <1> 				; set the type
  5434                              <1> 
  5435 00002505 07                  <1> 	pop es			; => LMA memory block
  5436                              <1>  assume es:nothing
  5437 00002506 31FF                <1> 	xor di, di		; -> start of allocation
  5438 00002508 89D9                <1> 	mov cx, bx		; size in paras
  5439                              <1> 
  5440 0000250A 5B                  <1> 	pop bx
  5441 0000250B B80158              <1> 	mov ax, 5801h
  5442 0000250E CD21                <1> 	int 21h			; restore strategy
  5443                              <1> 
  5444 00002510 89CB                <1> 	mov bx, cx		; = amount paragraphs
  5445                              <1> 
  5446 00002512 06                  <1> 	push es
  5447 00002513 57                  <1> 	push di
  5448                              <1> 
  5449                              <1> @@:
  5450 00002514 B90080              <1> 	mov cx, 8000h		; words in 64 KiB
  5451 00002517 81EB0010            <1> 	sub bx, 1000h		; another 64 KiB ?
  5452 0000251B 730D                <1> 	jae @F			; yes -->
  5453 0000251D 80C710              <1> 	add bh, 10h		; restore bx
  5454 00002520 31C9                <1> 	xor cx, cx		; cx = 0
  5455 00002522 87D9                <1> 	xchg bx, cx		; bx = 0, cx = amount paragraphs
  5456 00002524 D1E1                <1> 	shl cx, 1
  5457 00002526 D1E1                <1> 	shl cx, 1
  5458 00002528 D1E1                <1> 	shl cx, 1		; cx = amount words
  5459                              <1> @@:
  5460 0000252A 31C0                <1> 	xor ax, ax
  5461 0000252C F3AB                <1> 	rep stosw		; zero the memory
  5462 0000252E 8CC0                <1> 	mov ax, es
  5463 00002530 050010              <1> 	add ax, 1000h
  5464 00002533 8EC0                <1> 	mov es, ax		; => next segment (skip 64 KiB)
  5465                              <1>  assume es:nothing
  5466 00002535 85DB                <1> 	test bx, bx		; any remaining ? (NC)
  5467 00002537 75DB                <1> 	jnz @BB			; yes -->
  5468                              <1> 
  5469 00002539 5F                  <1> 	pop di
  5470 0000253A 07                  <1> 	pop es			; -> back at start
  5471                              <1>  assume es:nothing
  5472                              <1> .ret:
  5473 0000253B 89EC5D              <1> 	lleave
  5474 0000253E C3                  <1> 	retn
  5030                                  
  5031                                  sysinit_msg:
  5032 0000253F 5761726E696E673A20-     .warn_upb:		db "Warning: init unable to relocate UPBs!",13,10
  5032 00002548 696E697420756E6162-
  5032 00002551 6C6520746F2072656C-
  5032 0000255A 6F6361746520555042-
  5032 00002563 73210D0A           
  5033                                  .warn_upb.size: equ $ - .warn_upb
  5034 00002567 5761726E696E673A20-     .warn_dpb:		db "Warning: init unable to relocate DPBs!",13,10
  5034 00002570 696E697420756E6162-
  5034 00002579 6C6520746F2072656C-
  5034 00002582 6F6361746520445042-
  5034 0000258B 73210D0A           
  5035                                  .warn_dpb.size: equ $ - .warn_dpb
  5036 0000258F 00                      .nullbyte:		db 0
  5037                                  
  5038                                  	   END
