     1                                  
     2                                  ; Public Domain
     3                                  
     4                                  ; test install command: install; chstool walk 80; chstool uninstall
     5                                  ; test run command: walk 80; .; .
     6                                  
     7                                  %include "lmacros3.mac"
     1                              <1> [list -]
    14                              <2> [list -]
    14                              <1> [list -]
     8                                  
     9                                  %include "eld.mac"
     1                              <1> %if 0
     2                              <1> 
     3                              <1> Extensions for lDebug macros
     4                              <1> 
     5                              <1> Copyright (C) 2008-2025 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> %ifndef ELD_MAC
    16                              <1> %define ELD_MAC 1
    17                              <1> 
    18                              <1> %include "lmacros3.mac"
     1                              <2> [list -]
    19                              <1> 
    20                              <1> 		; ELD executable header
    21                              <1> 	struc ELD_HEADER
    22 00000000 ????????            <1> eldhSignature:		resb 4	; "ELD1"
    23 00000004 ??????              <1> 			resb 3	; reserved
    24 00000007 ??                  <1> 			resb 1	; 26 (Ctrl-Z)
    25 00000008 ????????            <1> eldhCodeOffset:		resd 1	; position displacement from eldhSignature
    26 0000000C ????                <1> eldhCodeImageLength:	resw 1	; amount bytes, at least 32
    27 0000000E ????                <1> eldhCodeAllocLength:	resw 1	; amount bytes, added to prior. sum < 64 KiB
    28 00000010 ????????            <1> eldhDataOffset:		resd 1
    29 00000014 ????                <1> eldhDataImageLength:	resw 1	; (zero allowed)
    30 00000016 ????                <1> eldhDataAllocLength:	resw 1	; (zero allowed)
    31 00000018 ????                <1> eldhCodeEntrypoint:	resw 1	; within code section, used as displacement
    32 0000001A ????????            <1> eldhReserved:		resb 4	; reserved
    33 0000001E ????                <1> eldhExtensionSize:	resw 1	; from eldhSignature, -> past eldhx fields in use
    34                              <1> 	endstruc
    35                              <1> 	endarea ELD_HEADER, 1
    36                              <1> 
    37                              <1> 	struc ELD_HEADERX
    38 00000000 <res 20h>           <1> eldhxHeader:		resb ELD_HEADER_size
    39 00000020 ????????            <1> eldhxDescriptionOffset:	resd 1	; zero if none, from eldhxHeader. <= 128 Bytes
    40 00000024 ????????            <1> eldhxHelpOffset:	resd 1	; zero if none, from eldhxHeader
    41 00000028 ????????            <1> eldhxLibTable:		resd 1	; zero if none, from eldhxHeader
    42 0000002C ????????            <1> eldhxDateTimeOffset:	resd 1	; zero if none, from eldhxHeader
    43                              <1> 	alignb 16
    44                              <1> 	endstruc
    45                              <1> 
    46                              <1> 	struc ELD_TRAILER_HEADER
    47 00000000 ????????????????    <1> eldthSignature:		resb 8	; "ELD1TAIL"
    48 00000008 ????????            <1> eldthHeaderOffset:	resd 1	; negative displacement from eldthSignature,
    49                              <1> 				;  add this dword to the seek offset
    50 0000000C ????                <1> eldthReserved:		resw 1	; reserved, must be initialised to zero
    51 0000000E ????                <1> eldthChecksum:		resw 1	; sum of all words in trailer header = 0
    52                              <1> 	endstruc
    53                              <1> 	endarea ELD_TRAILER_HEADER, 1
    54                              <1> 
    55                              <1> 	struc ELD_LIBTABLE
    56 00000000 ????                <1> eldltFormat:		resw 1
    57                              <1> 	; 0 = uncompressed
    58                              <1> 	; 2 = heatshrink compressed
    59                              <1> 	; 3 = lzexedat -4 compressed
    60                              <1> 	; 4 = lzexedat -4 -l compressed
    61 00000002 ????                <1> eldltAmount:		resw 1
    62 00000004 ????????            <1> eldltOffset:		resd 1	; from eldhxHeader
    63                              <1> eldltCompressedLength:		; (dword, only present if format 2, 3, or 4)
    64                              <1> 	endstruc
    65                              <1> 	endarea ELD_LIBTABLE, 1
    66                              <1> 
    67                              <1> 		; ELD instance header
    68                              <1> 	struc ELD_INSTANCE
    69 00000000 ????                <1> eldiStartCode:		resw 1	; -> this structure itself (para aligned)
    70 00000002 ????                <1> eldiEndCode:		resw 1	; -> behind memory used by instance (para aligned)
    71 00000004 ????                <1> eldiStartData:		resw 1	; -> data in data entry section (para aligned), or 0
    72 00000006 ????                <1> eldiEndData:		resw 1	; -> behind data (para aligned), or 0
    73 00000008 ????????????????    <1> eldiIdentifier:		resb 8	; blank-filled text
    74 00000010 ????                <1> eldiFlags:		resw 1	; flags
    75                              <1> eldiListing_size equ 14
    76 00000012 <res Eh>            <1> eldiListing:		resb eldiListing_size
    77                              <1> 				; ASCIZ listing file name
    78                              <1> 	endstruc
    79                              <1> 		; flags for eldiFlags:
    80                              <1> eldifResident:		equ 1
    81                              <1> 
    82                              <1> 		; ELD link info header
    83                              <1> 	struc ELD_LINKINFO
    84 00000000 ????                <1> eldlSignature:		resw 1	; 0E1D1h
    85 00000002 ????????            <1> eldlReserved:		resw 2
    86 00000006 ????                <1> eldlUseLinkHash:	resw 1
    87 00000008 ????                <1> eldlDataAmount:		resw 1
    88 0000000A ????                <1> eldlDataPrefixes:	resw 1
    89 0000000C ????                <1> eldlDataEntries:	resw 1
    90 0000000E ????                <1> eldlDataAddresses:	resw 1
    91 00000010 ????                <1> eldlCodeAmount:		resw 1
    92 00000012 ????                <1> eldlCodePrefixes:	resw 1
    93 00000014 ????                <1> eldlCodeEntries:	resw 1
    94 00000016 ????                <1> eldlCodeAddresses:	resw 1
    95                              <1> 	endstruc
    96                              <1> 
    97                              <1> 	numdef ELD_CODE_VSTART, 9001h
    98                              <1> 	numdef ELD_DATA_VSTART, 8000h
    99                              <1> 	numdef ELD_RELOC_VSTART, 8000h
   100                              <1> 
   101                              <1> 	numdef ELD_RECLAIM_HINT, 0
   102                              <1> 	strdef ELD_LISTING, ""
   103                              <1> 	numdef ELD_DATETIME, 0
   104                              <1> 
   105                              <1> %if _ELD_DATETIME
   106                              <1>  %define PUT_ELDHX_DATETIME_OFFSET at eldhxDateTimeOffset, dd DATAOFFSET + datetime - datastart
   107                              <1>  %macro PUT_ELD_DATETIME 0.nolist
   108                              <1> datetime:	asciz __UTC_DATE__,'T',__UTC_TIME__,'Z'
   109                              <1> 		asciz		; for future extension
   110                              <1>  %endmacro
   111                              <1> %else
   112                              <1>  %define PUT_ELDHX_DATETIME_OFFSET
   113                              <1>  %define PUT_ELD_DATETIME
   114                              <1> %endif
   115                              <1> 
   116                              <1> %endif
    10                                  %include "eldcall.mac"
     1                              <1> %if 0
     2                              <1> 
     3                              <1> Extensions for lDebug call macros
     4                              <1> 
     5                              <1> Copyright (C) 2008-2024 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> %ifndef ELDCALL_MAC
    16                              <1> %define ELDCALL_MAC 1
    17                              <1> 
    18                              <1> %include "lmacros3.mac"
     1                              <2> [list -]
    19                              <1> %include "nasmhash.mac"
     1                              <2> 
     2                              <2> %if 0
     3                              <2> 
     4                              <2> Hashing macros
     5                              <2>  by E. C. Masloch, 2019
     6                              <2> 
     7                              <2> Usage of the works is permitted provided that this
     8                              <2> instrument is retained with the works, so that any entity
     9                              <2> that uses the works is notified of this instrument.
    10                              <2> 
    11                              <2> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    12                              <2> 
    13                              <2> %endif
    14                              <2> 
    15                              <2> %ifndef __NASMHASH_MAC__
    16                              <2> %assign __NASMHASH_MAC__ 1
    17                              <2> 
    18                              <2> 
    19                              <2> 	%macro hashdef 2+.nolist
    20                              <2> %ifempty %2
    21                              <2>  %assign _%1 1
    22                              <2> %else
    23                              <2> %ifstr %2
    24                              <2>  %define %%string %2
    25                              <2> %elifid %2
    26                              <2>  %defstr %%string %2
    27                              <2> %elifnum %2
    28                              <2>  %defstr %%string %2
    29                              <2> %eliftok %2
    30                              <2>  %defstr %%string %2
    31                              <2> %else
    32                              <2>  %error Unknown input
    33                              <2> %endif
    34                              <2> %strlen %%length %%string
    35                              <2> %assign %%hash 1
    36                              <2> %assign %%index 1
    37                              <2> %rep %%length
    38                              <2>  %substr %%char %%string %%index
    39                              <2>  %assign %%hash (%%hash * 31 + %%char) & 0FFFFh
    40                              <2>  %assign %%index %%index + 1
    41                              <2> %endrep
    42                              <2> %assign _%1 %%hash
    43                              <2> %endif
    44                              <2> 	%endmacro
    45                              <2> 
    46                              <2> 
    47                              <2> %endif
    20                              <1> %include "elddata.mac"
     1                              <2> %if 0
     2                              <2> 
     3                              <2> Extensions for lDebug data relocation macros
     4                              <2> 
     5                              <2> Copyright (C) 2008-2024 E. C. Masloch
     6                              <2> 
     7                              <2> Usage of the works is permitted provided that this
     8                              <2> instrument is retained with the works, so that any entity
     9                              <2> that uses the works is notified of this instrument.
    10                              <2> 
    11                              <2> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    12                              <2> 
    13                              <2> %endif
    14                              <2> 
    15                              <2> %ifndef ELDDATA_MAC
    16                              <2> %define ELDDATA_MAC 1
    17                              <2> 
    18                              <2> %include "lmacros3.mac"
     1                              <3> [list -]
    19                              <2> %include "nasmhash.mac"
     1                              <3> 
     2                              <3> %if 0
     3                              <3> 
     4                              <3> Hashing macros
     5                              <3>  by E. C. Masloch, 2019
     6                              <3> 
     7                              <3> Usage of the works is permitted provided that this
     8                              <3> instrument is retained with the works, so that any entity
     9                              <3> that uses the works is notified of this instrument.
    10                              <3> 
    11                              <3> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    12                              <3> 
    13                              <3> %endif
    14                              <3> 
    15                              <3> %ifndef __NASMHASH_MAC__
    16                              <3> %assign __NASMHASH_MAC__ 1
    17                              <3> 
    18                              <3> 
    19                              <3> 	%macro hashdef 2+.nolist
    20                              <3> %ifempty %2
    21                              <3>  %assign _%1 1
    22                              <3> %else
    23                              <3> %ifstr %2
    24                              <3>  %define %%string %2
    25                              <3> %elifid %2
    26                              <3>  %defstr %%string %2
    27                              <3> %elifnum %2
    28                              <3>  %defstr %%string %2
    29                              <3> %eliftok %2
    30                              <3>  %defstr %%string %2
    31                              <3> %else
    32                              <3>  %error Unknown input
    33                              <3> %endif
    34                              <3> %strlen %%length %%string
    35                              <3> %assign %%hash 1
    36                              <3> %assign %%index 1
    37                              <3> %rep %%length
    38                              <3>  %substr %%char %%string %%index
    39                              <3>  %assign %%hash (%%hash * 31 + %%char) & 0FFFFh
    40                              <3>  %assign %%index %%index + 1
    41                              <3> %endrep
    42                              <3> %assign _%1 %%hash
    43                              <3> %endif
    44                              <3> 	%endmacro
    45                              <3> 
    46                              <3> 
    47                              <3> %endif
    20                              <2> %include "eldcheck.mac"
     1                              <3> %if 0
     2                              <3> 
     3                              <3> Extensions for lDebug relocation check macros
     4                              <3> 
     5                              <3> Copyright (C) 2008-2023 E. C. Masloch
     6                              <3> 
     7                              <3> Usage of the works is permitted provided that this
     8                              <3> instrument is retained with the works, so that any entity
     9                              <3> that uses the works is notified of this instrument.
    10                              <3> 
    11                              <3> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    12                              <3> 
    13                              <3> %endif
    14                              <3> 
    15                              <3> %ifndef ELDCHECK_MAC
    16                              <3> %define ELDCHECK_MAC 1
    17                              <3> 
    18                              <3> %assign ELDSTRICT 0
    19                              <3> %assign ELDSTRICTCOUNTER 0
    20                              <3> 
    21                              <3> 	%imacro eldstrict 1.nolist
    22                              <3> %ifidni %1, on
    23                              <3>  %assign ELDSTRICT 1
    24                              <3>  [warning +error=reloc-abs]
    25                              <3>  [warning +reloc-abs]
    26                              <3> %elifidni %1, off
    27                              <3>  %assign ELDSTRICT 0
    28                              <3>  [warning -reloc-abs]
    29                              <3> %else
    30                              <3>  %error Unknown keyword
    31                              <3> %endif
    32                              <3> 	%endmacro
    33                              <3> 
    34                              <3> 	%imacro reloc 1+.nolist
    35                              <3> %if ELDSTRICT
    36                              <3>  %if ELDSTRICTCOUNTER
    37                              <3>   %error Missing relocation
    38                              <3>  %endif
    39                              <3>  [warning -reloc-abs]
    40                              <3>  %assign ELDSTRICTCOUNTER 1
    41                              <3> %endif
    42                              <3> %1
    43                              <3> 	%endmacro
    44                              <3> 
    45                              <3> 	%imacro reloc2 1+.nolist
    46                              <3> %if ELDSTRICT
    47                              <3>  %if ELDSTRICTCOUNTER
    48                              <3>   %error Missing relocation
    49                              <3>  %endif
    50                              <3>  [warning -reloc-abs]
    51                              <3>  %assign ELDSTRICTCOUNTER 2
    52                              <3> %endif
    53                              <3> %1
    54                              <3> 	%endmacro
    55                              <3> 
    56                              <3> 	%imacro eldstrictcheck 0.nolist
    57                              <3> %if ELDSTRICT
    58                              <3>  %ifn ELDSTRICTCOUNTER
    59                              <3>   %error Unexpected relocation
    60                              <3>  %else
    61                              <3>   %assign ELDSTRICTCOUNTER ELDSTRICTCOUNTER - 1
    62                              <3>   %ifn ELDSTRICTCOUNTER
    63                              <3>    [warning +reloc-abs]
    64                              <3>   %endif
    65                              <3>  %endif
    66                              <3> %endif
    67                              <3> 	%endmacro
    68                              <3> 
    69                              <3> %endif
    70                              <3> 
    21                              <2> 
    22                              <2> 
    23                              <2> %assign ELDLINKER 0
    24                              <2> 
    25                              <2> %define INTERNAL_CODE_TO_CODE_RELOCATIONS ""
    26                              <2> %define INTERNAL_CODE_TO_DATA_RELOCATIONS ""
    27                              <2> %define INTERNAL_DATA_TO_CODE_RELOCATIONS ""
    28                              <2> %define INTERNAL_DATA_TO_DATA_RELOCATIONS ""
    29                              <2> %define INTERNAL_LINKER_CODE_TO_CODE_RELOCATIONS ""
    30                              <2> %define INTERNAL_LINKER_CODE_TO_DATA_RELOCATIONS ""
    31                              <2> %define INTERNAL_LINKER_DATA_TO_CODE_RELOCATIONS ""
    32                              <2> %define INTERNAL_LINKER_DATA_TO_DATA_RELOCATIONS ""
    33                              <2> %assign ELDDATA_OPTIONAL_STATUS 0		; not any seen yet
    34                              <2> %assign ELDDATA_PMREQUIRED_STATUS 0		; not any seen yet
    35                              <2> %assign ELDDATA_NEXT_STATUS 0			; not any seen yet
    36                              <2> %assign ELDDATA_NEXT_ENTRY -1
    37                              <2> %assign ELDDATA_NEXT_SECTION -1
    38                              <2> %assign ELDDATA_NEXT_OTHER -1
    39                              <2> 
    40                              <2> 	%imacro internalcoderelocation 0-1.nolist -2
    41                              <2> %assign %%entry $ + _CURRENT_SECTION %+ FIXUP + %1
    42                              <2> %if ELDLINKER
    43                              <2>  %ifidni _CURRENT_SECTION_TYPE, DATA
    44                              <2>   %xdefine INTERNAL_LINKER_DATA_TO_CODE_RELOCATIONS INTERNAL_LINKER_DATA_TO_CODE_RELOCATIONS, %%entry
    45                              <2>  %else
    46                              <2>   %xdefine INTERNAL_LINKER_CODE_TO_CODE_RELOCATIONS INTERNAL_LINKER_CODE_TO_CODE_RELOCATIONS, %%entry
    47                              <2>  %endif
    48                              <2> %else
    49                              <2>  %ifidni _CURRENT_SECTION_TYPE, DATA
    50                              <2>   %xdefine INTERNAL_DATA_TO_CODE_RELOCATIONS INTERNAL_DATA_TO_CODE_RELOCATIONS, %%entry
    51                              <2>  %else
    52                              <2>   %xdefine INTERNAL_CODE_TO_CODE_RELOCATIONS INTERNAL_CODE_TO_CODE_RELOCATIONS, %%entry
    53                              <2>  %endif
    54                              <2> %endif
    55                              <2> 	eldstrictcheck
    56                              <2> 	%endmacro
    57                              <2> 
    58                              <2> 	%imacro internaldatarelocation 0-1.nolist -2
    59                              <2> %assign %%entry $ + _CURRENT_SECTION %+ FIXUP + %1
    60                              <2> %if ELDLINKER
    61                              <2>  %ifidni _CURRENT_SECTION_TYPE, DATA
    62                              <2>   %xdefine INTERNAL_LINKER_DATA_TO_DATA_RELOCATIONS INTERNAL_LINKER_DATA_TO_DATA_RELOCATIONS, %%entry
    63                              <2>  %else
    64                              <2>   %xdefine INTERNAL_LINKER_CODE_TO_DATA_RELOCATIONS INTERNAL_LINKER_CODE_TO_DATA_RELOCATIONS, %%entry
    65                              <2>  %endif
    66                              <2> %else
    67                              <2>  %ifidni _CURRENT_SECTION_TYPE, DATA
    68                              <2>   %xdefine INTERNAL_DATA_TO_DATA_RELOCATIONS INTERNAL_DATA_TO_DATA_RELOCATIONS, %%entry
    69                              <2>  %else
    70                              <2>   %xdefine INTERNAL_CODE_TO_DATA_RELOCATIONS INTERNAL_CODE_TO_DATA_RELOCATIONS, %%entry
    71                              <2>  %endif
    72                              <2> %endif
    73                              <2> 	eldstrictcheck
    74                              <2> 	%endmacro
    75                              <2> 
    76                              <2> ; dw INTERNAL_LINKER_CODE_TO_CODE_RELOCATIONS, 0
    77                              <2> ; dw INTERNAL_LINKER_CODE_TO_DATA_RELOCATIONS, 0
    78                              <2> ; dw INTERNAL_LINKER_DATA_TO_CODE_RELOCATIONS, -1
    79                              <2> ; dw INTERNAL_LINKER_DATA_TO_DATA_RELOCATIONS, -1
    80                              <2> ; dw INTERNAL_CODE_TO_CODE_RELOCATIONS, 0
    81                              <2> ; dw INTERNAL_CODE_TO_DATA_RELOCATIONS, 0
    82                              <2> ; dw INTERNAL_DATA_TO_CODE_RELOCATIONS, -1
    83                              <2> ; dw INTERNAL_DATA_TO_DATA_RELOCATIONS, -1
    84                              <2> 
    85                              <2> 
    86                              <2> %define LINK_DATA_RELOCATIONS ""
    87                              <2> %define LINK_LINKER_DATA_RELOCATIONS ""
    88                              <2> %define LINK_DATA_NAMES db ""
    89                              <2> %define LINK_DATA_DETECTION none, none
    90                              <2> 
    91                              <2> %define LINK_OTHER_DATA_RELOCATIONS ""
    92                              <2> %define LINK_OTHER_LINKER_DATA_RELOCATIONS ""
    93                              <2> %define LINK_OTHER_DATA_NAMES db ""
    94                              <2> %define LINK_OTHER_DATA_DETECTION none, none
    95                              <2> 
    96                              <2> %ifndef ELDOTHER
    97                              <2>  %assign ELDOTHER 0
    98                              <2> %endif
    99                              <2> %assign ELDOTHERLINK 0
   100                              <2> 
   101                              <2> 	%imacro otherlinkdatarelocation 1-3.nolist -2, required
   102                              <2> %if ELDOTHER
   103                              <2>  %assign ELDOTHERLINK 1
   104                              <2> %endif
   105                              <2> 	linkdatarelocation %1, %2, %3
   106                              <2> %assign ELDOTHERLINK 0
   107                              <2> 	%endmacro
   108                              <2> 
   109                              <2> 	%imacro linkdatarelocation 1-4.nolist -2, required, single
   110                              <2> %assign %%entry $ + _CURRENT_SECTION %+ FIXUP + %2
   111                              <2> %ifidni %3, required
   112                              <2>  %assign %%optional 0
   113                              <2> %elifidni %3, optional
   114                              <2>  %assign %%optional 100h
   115                              <2>  %if ELDDATA_OPTIONAL_STATUS == 0
   116                              <2>   %assign ELDDATA_OPTIONAL_STATUS 1
   117                              <2>  %elif ELDDATA_OPTIONAL_STATUS == 1
   118                              <2>  %else
   119                              <2>   %error Optional data link not allowed here
   120                              <2>  %endif
   121                              <2> %elifidni %3, PM required
   122                              <2>  %assign %%optional 300h
   123                              <2>  %assign ELDDATA_PMREQUIRED_STATUS 1
   124                              <2>  %if ELDDATA_OPTIONAL_STATUS == 0
   125                              <2>   %assign ELDDATA_OPTIONAL_STATUS 1
   126                              <2>  %elif ELDDATA_OPTIONAL_STATUS == 1
   127                              <2>  %else
   128                              <2>   %error Optional data link not allowed here
   129                              <2>  %endif
   130                              <2> %else
   131                              <2>  %fatal Unknown optional keyword
   132                              <2> %endif
   133                              <2> %ifidni _CURRENT_SECTION_TYPE, DATA
   134                              <2>  %assign %%DATASECTION 1
   135                              <2> %else
   136                              <2>  %assign %%DATASECTION 0
   137                              <2> %endif
   138                              <2> %ifidni %4, single
   139                              <2>  %if ELDDATA_NEXT_STATUS == 1		; after next ?
   140                              <2>   %error Unexpected single data link after next data link
   141                              <2>  %elif ELDDATA_NEXT_STATUS == 2		; after last ?
   142                              <2>   %assign ELDDATA_NEXT_STATUS 3		; note single with next/last present
   143                              <2>  %endif
   144                              <2>  %assign %%next 0
   145                              <2> %elifidni %4, next
   146                              <2>  %if ELDDATA_NEXT_STATUS == 0		; no next/last yet ?
   147                              <2>   %assign ELDDATA_NEXT_STATUS 1		; in next
   148                              <2>  %elif ELDDATA_NEXT_STATUS == 2		; after last ?
   149                              <2>   %assign ELDDATA_NEXT_STATUS 1		; in next
   150                              <2>  %elif ELDDATA_NEXT_STATUS == 3		; after single ?
   151                              <2>   %assign ELDDATA_NEXT_STATUS 1		; in next
   152                              <2>  %elif ELDDATA_NEXT_STATUS == 1		; repeated next ?
   153                              <2>   %if ELDDATA_NEXT_ENTRY != %%entry 	|| ELDDATA_NEXT_SECTION != %%DATASECTION 	|| ELDDATA_NEXT_OTHER != ELDOTHERLINK
   156                              <2>    %error Unexpected next data link
   157                              <2>   %endif
   158                              <2>  %else
   159                              <2>   %error Next data link not allowed here
   160                              <2>  %endif
   161                              <2>  %ifn %%optional
   162                              <2>   %error Next data link only valid as optional or PM required
   163                              <2>  %endif
   164                              <2>  %assign %%next 400h
   165                              <2>  %assign ELDDATA_NEXT_ENTRY %%entry
   166                              <2>  %assign ELDDATA_NEXT_SECTION %%DATASECTION
   167                              <2>  %assign ELDDATA_NEXT_OTHER ELDOTHERLINK
   168                              <2> %elifidni %4, last
   169                              <2>  %if ELDDATA_NEXT_STATUS == 0		; no next/last yet ?
   170                              <2>   %error Next last data link not allowed here
   171                              <2>  %elif ELDDATA_NEXT_STATUS == 2		; after last ?
   172                              <2>   %error Next last data link not allowed here
   173                              <2>  %elif ELDDATA_NEXT_STATUS == 3		; after single ?
   174                              <2>   %error Next last data link not allowed here
   175                              <2>  %elif ELDDATA_NEXT_STATUS == 1		; after next ?
   176                              <2>   %if ELDDATA_NEXT_ENTRY != %%entry 	|| ELDDATA_NEXT_SECTION != %%DATASECTION 	|| ELDDATA_NEXT_OTHER != ELDOTHERLINK
   179                              <2>    %error Unexpected next data link
   180                              <2>   %endif
   181                              <2>   %assign ELDDATA_NEXT_STATUS 2		; note now after last
   182                              <2>  %else
   183                              <2>   %error Next data link not allowed here
   184                              <2>  %endif
   185                              <2>  %assign %%next 800h
   186                              <2>  %assign ELDDATA_NEXT_ENTRY -1
   187                              <2>  %assign ELDDATA_NEXT_SECTION -1
   188                              <2> %else
   189                              <2>  %fatal Unknown next keyword
   190                              <2> %endif
   191                              <2> 	%if ELDOTHERLINK
   192                              <2> %if ELDLINKER
   193                              <2>  %xdefine LINK_OTHER_LINKER_DATA_RELOCATIONS LINK_OTHER_LINKER_DATA_RELOCATIONS, 1 + %%DATASECTION + %%optional + %%next, %%entry, %%name
   194                              <2> %else
   195                              <2>  %xdefine LINK_OTHER_DATA_RELOCATIONS LINK_OTHER_DATA_RELOCATIONS, 1 + %%DATASECTION + %%optional + %%next, %%entry, %%name
   196                              <2> %endif
   197                              <2> 	%else
   198                              <2> %if ELDLINKER
   199                              <2>  %xdefine LINK_LINKER_DATA_RELOCATIONS LINK_LINKER_DATA_RELOCATIONS, 1 + %%DATASECTION + %%optional + %%next, %%entry, %%name
   200                              <2> %else
   201                              <2>  %xdefine LINK_DATA_RELOCATIONS LINK_DATA_RELOCATIONS, 1 + %%DATASECTION + %%optional + %%next, %%entry, %%name
   202                              <2> %endif
   203                              <2> 	%endif
   204                              <2> %defstr %%string %1
   205                              <2> %strlen %%length %%string
   206                              <2> %if %%length > 64
   207                              <2> 	; Could be increased, but mustn't exceed 127 bytes
   208                              <2> 	;  because flag 80h is used to mark optional links
   209                              <2> 	;  that failed to be matched.
   210                              <2>  %error Too long link name: %1
   211                              <2> %endif
   212                              <2> %define LINK_DATA_CHECK %1
   213                              <2> 	%if ELDOTHERLINK
   214                              <2> 	linkdata_detect LINK_OTHER_DATA_DETECTION
   215                              <2> %if LINK_DATA_NEW
   216                              <2>  %xdefine LINK_OTHER_DATA_DETECTION LINK_OTHER_DATA_DETECTION, %1, %%name
   217                              <2> 	hashdef HASH, %%string
   218                              <2>  %xdefine LINK_OTHER_DATA_NAMES 	LINK_OTHER_DATA_NAMES, %%name:, dw _HASH, {counted %%string}
   220                              <2> %else
   221                              <2>  %%name equ LINK_DATA_DUPLICATE
   222                              <2> %endif
   223                              <2> 	%else
   224                              <2> 	linkdata_detect LINK_DATA_DETECTION
   225                              <2> %if LINK_DATA_NEW
   226                              <2>  %xdefine LINK_DATA_DETECTION LINK_DATA_DETECTION, %1, %%name
   227                              <2> 	hashdef HASH, %%string
   228                              <2>  %xdefine LINK_DATA_NAMES 	LINK_DATA_NAMES, %%name:, dw _HASH, {counted %%string}
   230                              <2> %else
   231                              <2>  %%name equ LINK_DATA_DUPLICATE
   232                              <2> %endif
   233                              <2> 	%endif
   234                              <2> 	eldstrictcheck
   235                              <2> 	%endmacro
   236                              <2> 
   237                              <2> 	%imacro linkdata_detect 2-*.nolist
   238                              <2> %assign LINK_DATA_NEW 1
   239                              <2> %rep (%0 - 2) / 2
   240                              <2>  %rotate 2
   241                              <2>  %ifidni %1, LINK_DATA_CHECK
   242                              <2>   %assign LINK_DATA_NEW 0
   243                              <2>   %xdefine LINK_DATA_DUPLICATE %2
   244                              <2>   %exitrep
   245                              <2>  %endif
   246                              <2> %endrep
   247                              <2> 	%endmacro
   248                              <2> 
   249                              <2> 	%imacro link_data_dump_names 1-*.nolist
   250                              <2> %rep %0
   251                              <2> 	%1
   252                              <2>  %rotate 1
   253                              <2> %endrep
   254                              <2> 	%endmacro
   255                              <2> 
   256                              <2> ; dw LINK_LINKER_DATA_RELOCATIONS, 0, 0
   257                              <2> ; dw LINK_DATA_RELOCATIONS, 0, 0
   258                              <2> ; link_data_dump_names ELDCALL_CODE_NAMES
   259                              <2> 
   260                              <2> %endif
    21                              <1> 
    22                              <1> %assign ELDLINKER 0
    23                              <1> 
    24                              <1> [section relocatedzero nobits vstart=0]
    25                              <1> relocatedzero:
    26                              <1> __SECT__
    27                              <1> 
    28                              <1> 	numdef HOUDINI, 1
    29                              <1> 	numdef HOUDINI_CONDITIONAL, 1
    30                              <1> 
    31                              <1> %imacro houdini 0.nolist
    32                              <1> %if _HOUDINI
    33                              <1>  %if _HOUDINI_CONDITIONAL
    34                              <1> reloc	testopt [ss:relocateddata], 100h
    35                              <1> linkdatarelocation options7, -3
    36                              <1> 	jz %%skip
    37                              <1>  %endif
    38                              <1> reloc	testopt [ss:relocateddata], 100h
    39                              <1> linkdatarelocation internalflags6, -3
    40                              <1> 	jz %%skip
    41                              <1> 	int3
    42                              <1> %%skip:
    43                              <1> %endif
    44                              <1> %endmacro
    45                              <1> 
    46                              <1> %define ELDCALL_CODE_RELOCATIONS ""
    47                              <1> %define ELDCALL_LINKER_CODE_RELOCATIONS ""
    48                              <1> %define ELDCALL_CODE_RELOCATIONS_OPTIONAL ""
    49                              <1> %define ELDCALL_LINKER_CODE_RELOCATIONS_OPTIONAL ""
    50                              <1> %define ELDCALL_CODE_NAMES db ""
    51                              <1> %define ELDCALL_CODE_DETECTION none, none
    52                              <1> %assign ELDCALL_OPTIONAL_STATUS 0		; not any seen yet
    53                              <1> %assign ELDCALL_PMREQUIRED_STATUS 0		; not any seen yet
    54                              <1> %assign ELDCALL_NEXT_STATUS 0			; not any seen yet
    55                              <1> %assign ELDCALL_NEXT_ENTRY -1
    56                              <1> 
    57                              <1> 	%imacro extcall 1-3.nolist required, single
    58                              <1> %ifidni _CURRENT_SECTION_TYPE, DATA
    59                              <1>  %error "ELD call cannot be used in ELD data block"
    60                              <1> %endif
    61                              <1> %assign %%entry $ + _CURRENT_SECTION %+ FIXUP
    62                              <1> %ifidni %2, required
    63                              <1>  %assign %%optional 0
    64                              <1> %elifidni %2, optional
    65                              <1>  %assign %%optional 100h
    66                              <1>  %if ELDCALL_OPTIONAL_STATUS == 0
    67                              <1>   %assign ELDCALL_OPTIONAL_STATUS 1
    68                              <1>  %elif ELDCALL_OPTIONAL_STATUS == 1
    69                              <1>  %else
    70                              <1>   %error Optional code link not allowed here
    71                              <1>  %endif
    72                              <1> %elifidni %2, PM required
    73                              <1>  %assign %%optional 300h
    74                              <1>  %assign ELDCALL_PMREQUIRED_STATUS 1
    75                              <1>  %if ELDCALL_OPTIONAL_STATUS == 0
    76                              <1>   %assign ELDCALL_OPTIONAL_STATUS 1
    77                              <1>  %elif ELDCALL_OPTIONAL_STATUS == 1
    78                              <1>  %else
    79                              <1>   %error Optional code link not allowed here
    80                              <1>  %endif
    81                              <1> %else
    82                              <1>  %fatal Unknown optional keyword
    83                              <1> %endif
    84                              <1> %ifidni %3, single
    85                              <1>  %if ELDCALL_NEXT_STATUS == 1		; after next ?
    86                              <1>   %error Unexpected single code link after next code link
    87                              <1>  %elif ELDCALL_NEXT_STATUS == 2		; after last ?
    88                              <1>   %assign ELDCALL_NEXT_STATUS 3		; note single with next/last present
    89                              <1>  %endif
    90                              <1>  %assign %%next 0
    91                              <1> %elifidni %3, next
    92                              <1>  %if ELDCALL_NEXT_STATUS == 0		; no next/last yet ?
    93                              <1>   %assign ELDCALL_NEXT_STATUS 1		; in next
    94                              <1>  %elif ELDCALL_NEXT_STATUS == 2		; after last ?
    95                              <1>   %assign ELDCALL_NEXT_STATUS 1		; in next
    96                              <1>  %elif ELDCALL_NEXT_STATUS == 3		; after single ?
    97                              <1>   %assign ELDCALL_NEXT_STATUS 1		; in next
    98                              <1>  %elif ELDCALL_NEXT_STATUS == 1		; repeated next ?
    99                              <1>   %if ELDCALL_NEXT_ENTRY != %%entry
   100                              <1>    %error Unexpected next code link
   101                              <1>   %endif
   102                              <1>  %else
   103                              <1>   %error Next code link not allowed here
   104                              <1>  %endif
   105                              <1>  %ifn %%optional
   106                              <1>   %error Next code link only valid as optional or PM required
   107                              <1>  %endif
   108                              <1>  %assign %%next 400h
   109                              <1>  %assign ELDCALL_NEXT_ENTRY %%entry
   110                              <1> %elifidni %3, last
   111                              <1>  %if ELDCALL_NEXT_STATUS == 0		; no next/last yet ?
   112                              <1>   %error Next last code link not allowed here
   113                              <1>  %elif ELDCALL_NEXT_STATUS == 2		; after last ?
   114                              <1>   %error Next last code link not allowed here
   115                              <1>  %elif ELDCALL_NEXT_STATUS == 3		; after single ?
   116                              <1>   %error Next last code link not allowed here
   117                              <1>  %elif ELDCALL_NEXT_STATUS == 1		; after next ?
   118                              <1>   %if ELDCALL_NEXT_ENTRY != %%entry
   119                              <1>    %error Unexpected next code link
   120                              <1>   %endif
   121                              <1>   %assign ELDCALL_NEXT_STATUS 2		; note now after last
   122                              <1>  %else
   123                              <1>   %error Next code link not allowed here
   124                              <1>  %endif
   125                              <1>  %assign %%next 800h
   126                              <1>  %assign ELDCALL_NEXT_ENTRY -1
   127                              <1>  %assign ELDCALL_NEXT_SECTION -1
   128                              <1> %else
   129                              <1>  %fatal Unknown next keyword
   130                              <1> %endif
   131                              <1> %if %%next != 400h
   132                              <1> %if 0
   133                              <1> [warning -reloc-rel-word]
   134                              <1> 	call near relocatedzero
   135                              <1> [warning +reloc-rel-word]
   136                              <1> %else
   137                              <1> 	db 0E8h
   138                              <1> reloc	dw relocatedzero
   139                              <1> 	eldstrictcheck
   140                              <1> %endif
   141                              <1> 	jmp strict short %%skipparameter
   142                              <1> 	dw 0
   143                              <1> %%skipparameter:
   144                              <1> %endif
   145                              <1> %if ELDLINKER
   146                              <1>  %xdefine ELDCALL_LINKER_CODE_RELOCATIONS ELDCALL_LINKER_CODE_RELOCATIONS, %%entry, %%name
   147                              <1>  %xdefine ELDCALL_LINKER_CODE_RELOCATIONS_OPTIONAL ELDCALL_LINKER_CODE_RELOCATIONS_OPTIONAL, 1 + %%optional + %%next, %%entry, %%name
   148                              <1> %else
   149                              <1>  %xdefine ELDCALL_CODE_RELOCATIONS ELDCALL_CODE_RELOCATIONS, %%entry, %%name
   150                              <1>  %xdefine ELDCALL_CODE_RELOCATIONS_OPTIONAL ELDCALL_CODE_RELOCATIONS_OPTIONAL, 1 + %%optional + %%next, %%entry, %%name
   151                              <1> %endif
   152                              <1> %defstr %%string %1
   153                              <1> %strlen %%length %%string
   154                              <1> %if %%length > 64
   155                              <1> 	; Could be increased, but mustn't exceed 127 bytes
   156                              <1> 	;  because flag 80h is used to mark optional links
   157                              <1> 	;  that failed to be matched.
   158                              <1>  %error Too long link name: %1
   159                              <1> %endif
   160                              <1> %define ELDCALL_CODE_CHECK %1
   161                              <1> 	linkcode_detect ELDCALL_CODE_DETECTION
   162                              <1> %if ELDCALL_CODE_NEW
   163                              <1>  %xdefine ELDCALL_CODE_DETECTION ELDCALL_CODE_DETECTION, %1, %%name
   164                              <1> 	hashdef HASH, %%string
   165                              <1> %xdefine ELDCALL_CODE_NAMES 	ELDCALL_CODE_NAMES, %%name:, dw _HASH, {counted %%string}
   167                              <1> %else
   168                              <1>  %%name equ ELDCALL_CODE_DUPLICATE
   169                              <1> %endif
   170                              <1> 	%endmacro
   171                              <1> 
   172                              <1> 	%imacro linkcode_detect 2-*.nolist
   173                              <1> %assign ELDCALL_CODE_NEW 1
   174                              <1> %rep (%0 - 2) / 2
   175                              <1>  %rotate 2
   176                              <1>  %ifidni %1, ELDCALL_CODE_CHECK
   177                              <1>   %assign ELDCALL_CODE_NEW 0
   178                              <1>   %xdefine ELDCALL_CODE_DUPLICATE %2
   179                              <1>   %exitrep
   180                              <1>  %endif
   181                              <1> %endrep
   182                              <1> 	%endmacro
   183                              <1> 
   184                              <1> 
   185                              <1> %define ELDCALL_CALLCALL_LIST none
   186                              <1> %define ELDCALL_CALLCALL_PROCESSED_PRIOR ""
   187                              <1> 
   188                              <1> 	%imacro extcallcall 1.nolist
   189                              <1> 	call %1
   190                              <1> %xdefine ELDCALL_CALLCALL_LIST ELDCALL_CALLCALL_LIST, %1
   191                              <1> 	%endmacro
   192                              <1> 
   193                              <1> %assign ELDCALLCALL_DUMPED 0
   194                              <1> 
   195                              <1> 	%imacro eldcall_dump_callcall 1-*.nolist
   196                              <1> %xdefine ELDCALL_CALLCALL_PROCESSED ELDCALL_CALLCALL_PROCESSED_PRIOR
   197                              <1>  %rep %0 - 1
   198                              <1>   %rotate 1
   199                              <1>   %define ELDCALL_CHECK %1
   200                              <1> 	eldcall_callcall_detect ELDCALL_CALLCALL_PROCESSED
   201                              <1>   %if ELDCALL_NEW
   202                              <1>    %xdefine ELDCALL_CALLCALL_PROCESSED ELDCALL_CALLCALL_PROCESSED, %1
   203                              <1> 	align 8, nop
   204                              <1> %1:
   205                              <1> 	extcall %1
   206                              <1> 	retn
   207                              <1>   %endif
   208                              <1>  %endrep
   209                              <1> %assign ELDCALLCALL_DUMPED 1
   210                              <1> %define ELDCALL_CALLCALL_LIST none
   211                              <1> 	%endmacro
   212                              <1> 
   213                              <1> 	%imacro eldcall_new_callcall 0.nolist
   214                              <1> %if ELDCALLCALL_DUMPED
   215                              <1>  %xdefine ELDCALL_CALLCALL_PROCESSED_PRIOR   ELDCALL_CALLCALL_PROCESSED_PRIOR, ELDCALL_CALLCALL_PROCESSED
   217                              <1>  %assign ELDCALLCALL_DUMPED 0
   218                              <1>  %define ELDCALL_CALLCALL_LIST none
   219                              <1> %endif
   220                              <1> 	%endmacro
   221                              <1> 
   222                              <1> 	%imacro eldcall_callcall_detect 1-*.nolist
   223                              <1> %assign ELDCALL_NEW 1
   224                              <1> %rep %0
   225                              <1>  %ifidni %1, ELDCALL_CHECK
   226                              <1>   %assign ELDCALL_NEW 0
   227                              <1>   %exitrep
   228                              <1>  %endif
   229                              <1>  %rotate 1
   230                              <1> %endrep
   231                              <1> 	%endmacro
   232                              <1> 
   233                              <1> 	%imacro eldcall_dump_names 1-*.nolist
   234                              <1> %rep %0
   235                              <1> 	%1
   236                              <1>  %rotate 1
   237                              <1> %endrep
   238                              <1> 	%endmacro
   239                              <1> 
   240                              <1> ; eldcall_dump_callcall ELDCALL_CALLCALL_LIST
   241                              <1> ; if using optional code links:
   242                              <1> ;  dw ELDCALL_LINKER_CODE_RELOCATIONS_OPTIONAL, 0
   243                              <1> ;  dw ELDCALL_CODE_RELOCATIONS_OPTIONAL, 0
   244                              <1> ; if not using optional code links:
   245                              <1> ;  dw ELDCALL_LINKER_CODE_RELOCATIONS, 0, 0
   246                              <1> ;  dw ELDCALL_CODE_RELOCATIONS, 0, 0
   247                              <1> ; eldcall_dump_names ELDCALL_CODE_NAMES
   248                              <1> 
   249                              <1> %endif
    11                                  %include "elddata.mac"
     1                              <1> %if 0
     2                              <1> 
     3                              <1> Extensions for lDebug data relocation macros
     4                              <1> 
     5                              <1> Copyright (C) 2008-2024 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> %ifndef ELDDATA_MAC
    16                              <1> %define ELDDATA_MAC 1
    17                              <1> 
    18                              <1> %include "lmacros3.mac"
    19                              <1> %include "nasmhash.mac"
    20                              <1> %include "eldcheck.mac"
    21                              <1> 
    22                              <1> 
    23                              <1> %assign ELDLINKER 0
    24                              <1> 
    25                              <1> %define INTERNAL_CODE_TO_CODE_RELOCATIONS ""
    26                              <1> %define INTERNAL_CODE_TO_DATA_RELOCATIONS ""
    27                              <1> %define INTERNAL_DATA_TO_CODE_RELOCATIONS ""
    28                              <1> %define INTERNAL_DATA_TO_DATA_RELOCATIONS ""
    29                              <1> %define INTERNAL_LINKER_CODE_TO_CODE_RELOCATIONS ""
    30                              <1> %define INTERNAL_LINKER_CODE_TO_DATA_RELOCATIONS ""
    31                              <1> %define INTERNAL_LINKER_DATA_TO_CODE_RELOCATIONS ""
    32                              <1> %define INTERNAL_LINKER_DATA_TO_DATA_RELOCATIONS ""
    33                              <1> %assign ELDDATA_OPTIONAL_STATUS 0		; not any seen yet
    34                              <1> %assign ELDDATA_PMREQUIRED_STATUS 0		; not any seen yet
    35                              <1> %assign ELDDATA_NEXT_STATUS 0			; not any seen yet
    36                              <1> %assign ELDDATA_NEXT_ENTRY -1
    37                              <1> %assign ELDDATA_NEXT_SECTION -1
    38                              <1> %assign ELDDATA_NEXT_OTHER -1
    39                              <1> 
    40                              <1> 	%imacro internalcoderelocation 0-1.nolist -2
    41                              <1> %assign %%entry $ + _CURRENT_SECTION %+ FIXUP + %1
    42                              <1> %if ELDLINKER
    43                              <1>  %ifidni _CURRENT_SECTION_TYPE, DATA
    44                              <1>   %xdefine INTERNAL_LINKER_DATA_TO_CODE_RELOCATIONS INTERNAL_LINKER_DATA_TO_CODE_RELOCATIONS, %%entry
    45                              <1>  %else
    46                              <1>   %xdefine INTERNAL_LINKER_CODE_TO_CODE_RELOCATIONS INTERNAL_LINKER_CODE_TO_CODE_RELOCATIONS, %%entry
    47                              <1>  %endif
    48                              <1> %else
    49                              <1>  %ifidni _CURRENT_SECTION_TYPE, DATA
    50                              <1>   %xdefine INTERNAL_DATA_TO_CODE_RELOCATIONS INTERNAL_DATA_TO_CODE_RELOCATIONS, %%entry
    51                              <1>  %else
    52                              <1>   %xdefine INTERNAL_CODE_TO_CODE_RELOCATIONS INTERNAL_CODE_TO_CODE_RELOCATIONS, %%entry
    53                              <1>  %endif
    54                              <1> %endif
    55                              <1> 	eldstrictcheck
    56                              <1> 	%endmacro
    57                              <1> 
    58                              <1> 	%imacro internaldatarelocation 0-1.nolist -2
    59                              <1> %assign %%entry $ + _CURRENT_SECTION %+ FIXUP + %1
    60                              <1> %if ELDLINKER
    61                              <1>  %ifidni _CURRENT_SECTION_TYPE, DATA
    62                              <1>   %xdefine INTERNAL_LINKER_DATA_TO_DATA_RELOCATIONS INTERNAL_LINKER_DATA_TO_DATA_RELOCATIONS, %%entry
    63                              <1>  %else
    64                              <1>   %xdefine INTERNAL_LINKER_CODE_TO_DATA_RELOCATIONS INTERNAL_LINKER_CODE_TO_DATA_RELOCATIONS, %%entry
    65                              <1>  %endif
    66                              <1> %else
    67                              <1>  %ifidni _CURRENT_SECTION_TYPE, DATA
    68                              <1>   %xdefine INTERNAL_DATA_TO_DATA_RELOCATIONS INTERNAL_DATA_TO_DATA_RELOCATIONS, %%entry
    69                              <1>  %else
    70                              <1>   %xdefine INTERNAL_CODE_TO_DATA_RELOCATIONS INTERNAL_CODE_TO_DATA_RELOCATIONS, %%entry
    71                              <1>  %endif
    72                              <1> %endif
    73                              <1> 	eldstrictcheck
    74                              <1> 	%endmacro
    75                              <1> 
    76                              <1> ; dw INTERNAL_LINKER_CODE_TO_CODE_RELOCATIONS, 0
    77                              <1> ; dw INTERNAL_LINKER_CODE_TO_DATA_RELOCATIONS, 0
    78                              <1> ; dw INTERNAL_LINKER_DATA_TO_CODE_RELOCATIONS, -1
    79                              <1> ; dw INTERNAL_LINKER_DATA_TO_DATA_RELOCATIONS, -1
    80                              <1> ; dw INTERNAL_CODE_TO_CODE_RELOCATIONS, 0
    81                              <1> ; dw INTERNAL_CODE_TO_DATA_RELOCATIONS, 0
    82                              <1> ; dw INTERNAL_DATA_TO_CODE_RELOCATIONS, -1
    83                              <1> ; dw INTERNAL_DATA_TO_DATA_RELOCATIONS, -1
    84                              <1> 
    85                              <1> 
    86                              <1> %define LINK_DATA_RELOCATIONS ""
    87                              <1> %define LINK_LINKER_DATA_RELOCATIONS ""
    88                              <1> %define LINK_DATA_NAMES db ""
    89                              <1> %define LINK_DATA_DETECTION none, none
    90                              <1> 
    91                              <1> %define LINK_OTHER_DATA_RELOCATIONS ""
    92                              <1> %define LINK_OTHER_LINKER_DATA_RELOCATIONS ""
    93                              <1> %define LINK_OTHER_DATA_NAMES db ""
    94                              <1> %define LINK_OTHER_DATA_DETECTION none, none
    95                              <1> 
    96                              <1> %ifndef ELDOTHER
    97                              <1>  %assign ELDOTHER 0
    98                              <1> %endif
    99                              <1> %assign ELDOTHERLINK 0
   100                              <1> 
   101                              <1> 	%imacro otherlinkdatarelocation 1-3.nolist -2, required
   102                              <1> %if ELDOTHER
   103                              <1>  %assign ELDOTHERLINK 1
   104                              <1> %endif
   105                              <1> 	linkdatarelocation %1, %2, %3
   106                              <1> %assign ELDOTHERLINK 0
   107                              <1> 	%endmacro
   108                              <1> 
   109                              <1> 	%imacro linkdatarelocation 1-4.nolist -2, required, single
   110                              <1> %assign %%entry $ + _CURRENT_SECTION %+ FIXUP + %2
   111                              <1> %ifidni %3, required
   112                              <1>  %assign %%optional 0
   113                              <1> %elifidni %3, optional
   114                              <1>  %assign %%optional 100h
   115                              <1>  %if ELDDATA_OPTIONAL_STATUS == 0
   116                              <1>   %assign ELDDATA_OPTIONAL_STATUS 1
   117                              <1>  %elif ELDDATA_OPTIONAL_STATUS == 1
   118                              <1>  %else
   119                              <1>   %error Optional data link not allowed here
   120                              <1>  %endif
   121                              <1> %elifidni %3, PM required
   122                              <1>  %assign %%optional 300h
   123                              <1>  %assign ELDDATA_PMREQUIRED_STATUS 1
   124                              <1>  %if ELDDATA_OPTIONAL_STATUS == 0
   125                              <1>   %assign ELDDATA_OPTIONAL_STATUS 1
   126                              <1>  %elif ELDDATA_OPTIONAL_STATUS == 1
   127                              <1>  %else
   128                              <1>   %error Optional data link not allowed here
   129                              <1>  %endif
   130                              <1> %else
   131                              <1>  %fatal Unknown optional keyword
   132                              <1> %endif
   133                              <1> %ifidni _CURRENT_SECTION_TYPE, DATA
   134                              <1>  %assign %%DATASECTION 1
   135                              <1> %else
   136                              <1>  %assign %%DATASECTION 0
   137                              <1> %endif
   138                              <1> %ifidni %4, single
   139                              <1>  %if ELDDATA_NEXT_STATUS == 1		; after next ?
   140                              <1>   %error Unexpected single data link after next data link
   141                              <1>  %elif ELDDATA_NEXT_STATUS == 2		; after last ?
   142                              <1>   %assign ELDDATA_NEXT_STATUS 3		; note single with next/last present
   143                              <1>  %endif
   144                              <1>  %assign %%next 0
   145                              <1> %elifidni %4, next
   146                              <1>  %if ELDDATA_NEXT_STATUS == 0		; no next/last yet ?
   147                              <1>   %assign ELDDATA_NEXT_STATUS 1		; in next
   148                              <1>  %elif ELDDATA_NEXT_STATUS == 2		; after last ?
   149                              <1>   %assign ELDDATA_NEXT_STATUS 1		; in next
   150                              <1>  %elif ELDDATA_NEXT_STATUS == 3		; after single ?
   151                              <1>   %assign ELDDATA_NEXT_STATUS 1		; in next
   152                              <1>  %elif ELDDATA_NEXT_STATUS == 1		; repeated next ?
   153                              <1>   %if ELDDATA_NEXT_ENTRY != %%entry 	|| ELDDATA_NEXT_SECTION != %%DATASECTION 	|| ELDDATA_NEXT_OTHER != ELDOTHERLINK
   156                              <1>    %error Unexpected next data link
   157                              <1>   %endif
   158                              <1>  %else
   159                              <1>   %error Next data link not allowed here
   160                              <1>  %endif
   161                              <1>  %ifn %%optional
   162                              <1>   %error Next data link only valid as optional or PM required
   163                              <1>  %endif
   164                              <1>  %assign %%next 400h
   165                              <1>  %assign ELDDATA_NEXT_ENTRY %%entry
   166                              <1>  %assign ELDDATA_NEXT_SECTION %%DATASECTION
   167                              <1>  %assign ELDDATA_NEXT_OTHER ELDOTHERLINK
   168                              <1> %elifidni %4, last
   169                              <1>  %if ELDDATA_NEXT_STATUS == 0		; no next/last yet ?
   170                              <1>   %error Next last data link not allowed here
   171                              <1>  %elif ELDDATA_NEXT_STATUS == 2		; after last ?
   172                              <1>   %error Next last data link not allowed here
   173                              <1>  %elif ELDDATA_NEXT_STATUS == 3		; after single ?
   174                              <1>   %error Next last data link not allowed here
   175                              <1>  %elif ELDDATA_NEXT_STATUS == 1		; after next ?
   176                              <1>   %if ELDDATA_NEXT_ENTRY != %%entry 	|| ELDDATA_NEXT_SECTION != %%DATASECTION 	|| ELDDATA_NEXT_OTHER != ELDOTHERLINK
   179                              <1>    %error Unexpected next data link
   180                              <1>   %endif
   181                              <1>   %assign ELDDATA_NEXT_STATUS 2		; note now after last
   182                              <1>  %else
   183                              <1>   %error Next data link not allowed here
   184                              <1>  %endif
   185                              <1>  %assign %%next 800h
   186                              <1>  %assign ELDDATA_NEXT_ENTRY -1
   187                              <1>  %assign ELDDATA_NEXT_SECTION -1
   188                              <1> %else
   189                              <1>  %fatal Unknown next keyword
   190                              <1> %endif
   191                              <1> 	%if ELDOTHERLINK
   192                              <1> %if ELDLINKER
   193                              <1>  %xdefine LINK_OTHER_LINKER_DATA_RELOCATIONS LINK_OTHER_LINKER_DATA_RELOCATIONS, 1 + %%DATASECTION + %%optional + %%next, %%entry, %%name
   194                              <1> %else
   195                              <1>  %xdefine LINK_OTHER_DATA_RELOCATIONS LINK_OTHER_DATA_RELOCATIONS, 1 + %%DATASECTION + %%optional + %%next, %%entry, %%name
   196                              <1> %endif
   197                              <1> 	%else
   198                              <1> %if ELDLINKER
   199                              <1>  %xdefine LINK_LINKER_DATA_RELOCATIONS LINK_LINKER_DATA_RELOCATIONS, 1 + %%DATASECTION + %%optional + %%next, %%entry, %%name
   200                              <1> %else
   201                              <1>  %xdefine LINK_DATA_RELOCATIONS LINK_DATA_RELOCATIONS, 1 + %%DATASECTION + %%optional + %%next, %%entry, %%name
   202                              <1> %endif
   203                              <1> 	%endif
   204                              <1> %defstr %%string %1
   205                              <1> %strlen %%length %%string
   206                              <1> %if %%length > 64
   207                              <1> 	; Could be increased, but mustn't exceed 127 bytes
   208                              <1> 	;  because flag 80h is used to mark optional links
   209                              <1> 	;  that failed to be matched.
   210                              <1>  %error Too long link name: %1
   211                              <1> %endif
   212                              <1> %define LINK_DATA_CHECK %1
   213                              <1> 	%if ELDOTHERLINK
   214                              <1> 	linkdata_detect LINK_OTHER_DATA_DETECTION
   215                              <1> %if LINK_DATA_NEW
   216                              <1>  %xdefine LINK_OTHER_DATA_DETECTION LINK_OTHER_DATA_DETECTION, %1, %%name
   217                              <1> 	hashdef HASH, %%string
   218                              <1>  %xdefine LINK_OTHER_DATA_NAMES 	LINK_OTHER_DATA_NAMES, %%name:, dw _HASH, {counted %%string}
   220                              <1> %else
   221                              <1>  %%name equ LINK_DATA_DUPLICATE
   222                              <1> %endif
   223                              <1> 	%else
   224                              <1> 	linkdata_detect LINK_DATA_DETECTION
   225                              <1> %if LINK_DATA_NEW
   226                              <1>  %xdefine LINK_DATA_DETECTION LINK_DATA_DETECTION, %1, %%name
   227                              <1> 	hashdef HASH, %%string
   228                              <1>  %xdefine LINK_DATA_NAMES 	LINK_DATA_NAMES, %%name:, dw _HASH, {counted %%string}
   230                              <1> %else
   231                              <1>  %%name equ LINK_DATA_DUPLICATE
   232                              <1> %endif
   233                              <1> 	%endif
   234                              <1> 	eldstrictcheck
   235                              <1> 	%endmacro
   236                              <1> 
   237                              <1> 	%imacro linkdata_detect 2-*.nolist
   238                              <1> %assign LINK_DATA_NEW 1
   239                              <1> %rep (%0 - 2) / 2
   240                              <1>  %rotate 2
   241                              <1>  %ifidni %1, LINK_DATA_CHECK
   242                              <1>   %assign LINK_DATA_NEW 0
   243                              <1>   %xdefine LINK_DATA_DUPLICATE %2
   244                              <1>   %exitrep
   245                              <1>  %endif
   246                              <1> %endrep
   247                              <1> 	%endmacro
   248                              <1> 
   249                              <1> 	%imacro link_data_dump_names 1-*.nolist
   250                              <1> %rep %0
   251                              <1> 	%1
   252                              <1>  %rotate 1
   253                              <1> %endrep
   254                              <1> 	%endmacro
   255                              <1> 
   256                              <1> ; dw LINK_LINKER_DATA_RELOCATIONS, 0, 0
   257                              <1> ; dw LINK_DATA_RELOCATIONS, 0, 0
   258                              <1> ; link_data_dump_names ELDCALL_CODE_NAMES
   259                              <1> 
   260                              <1> %endif
    12                                  %include "iniload.mac"
     1                              <1> %if 0
     2                              <1> 
     3                              <1> lDebug iniload/boot interfacing structs and macros
     4                              <1> 
     5                              <1> Copyright (C) 2008-2025 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> 
    16                              <1> 	struc BS
    17 00000000 ??????              <1> bsJump:	resb 3
    18 00000003 ????????????????    <1> bsOEM:	resb 8
    19                              <1> bsBPB:
    20                              <1> 	endstruc
    21                              <1> 
    22                              <1> 	struc EBPB		;        BPB sec
    23 00000000 ????                <1> bpbBytesPerSector:	resw 1	; offset 00h 0Bh
    24 00000002 ??                  <1> bpbSectorsPerCluster:	resb 1	; offset 02h 0Dh
    25 00000003 ????                <1> bpbReservedSectors:	resw 1	; offset 03h 0Eh
    26 00000005 ??                  <1> bpbNumFATs:		resb 1	; offset 05h 10h
    27 00000006 ????                <1> bpbNumRootDirEnts:	resw 1	; offset 06h 11h -- 0 for FAT32
    28 00000008 ????                <1> bpbTotalSectors:	resw 1	; offset 08h 13h
    29 0000000A ??                  <1> bpbMediaID:		resb 1	; offset 0Ah 15h
    30 0000000B ????                <1> bpbSectorsPerFAT:	resw 1	; offset 0Bh 16h -- 0 for FAT32
    31 0000000D ????                <1> bpbCHSSectors:		resw 1	; offset 0Dh 18h
    32 0000000F ????                <1> bpbCHSHeads:		resw 1	; offset 0Fh 1Ah
    33 00000011 ????????            <1> bpbHiddenSectors:	resd 1	; offset 11h 1Ch
    34 00000015 ????????            <1> bpbTotalSectorsLarge:	resd 1	; offset 15h 20h
    35                              <1> bpbNew:				; offset 19h 24h
    36                              <1> 
    37 00000019 ????????            <1> ebpbSectorsPerFATLarge:	resd 1	; offset 19h 24h
    38 0000001D ????                <1> ebpbFSFlags:		resw 1	; offset 1Dh 28h
    39 0000001F ????                <1> ebpbFSVersion:		resw 1	; offset 1Fh 2Ah
    40 00000021 ????????            <1> ebpbRootCluster:	resd 1	; offset 21h 2Ch
    41 00000025 ????                <1> ebpbFSINFOSector:	resw 1	; offset 25h 30h
    42 00000027 ????                <1> ebpbBackupSector:	resw 1	; offset 27h 32h
    43 00000029 <res Ch>            <1> ebpbReserved:		resb 12	; offset 29h 34h
    44                              <1> ebpbNew:			; offset 35h 40h
    45                              <1> 	endstruc
    46                              <1> 
    47                              <1> 	struc BPBN		; ofs B16 S16 B32 S32
    48 00000000 ??                  <1> bpbnBootUnit:		resb 1	; 00h 19h 24h 35h 40h
    49 00000001 ??                  <1> 			resb 1	; 01h 1Ah 25h 36h 41h
    50 00000002 ??                  <1> bpbnExtBPBSignature:	resb 1	; 02h 1Bh 26h 37h 42h -- 29h for valid BPBN
    51 00000003 ????????            <1> bpbnSerialNumber:	resd 1	; 03h 1Ch 27h 38h 43h
    52 00000007 <res Bh>            <1> bpbnVolumeLabel:	resb 11	; 07h 20h 2Bh 3Ch 47h
    53 00000012 ????????????????    <1> bpbnFilesystemID:	resb 8	; 12h 2Bh 36h 47h 52h
    54                              <1> 	endstruc		; 1Ah 33h 3Eh 4Fh 5Ah
    55                              <1> 
    56                              <1> 	struc DIRENTRY
    57 00000000 ????????????????    <1> deName:		resb 8
    58 00000008 ??????              <1> deExt:		resb 3
    59 0000000B ??                  <1> deAttrib:	resb 1
    60 0000000C ??                  <1> dePlusSize:	resb 1
    61 0000000D ??????????????      <1> 		resb 7
    62 00000014 ????                <1> deClusterHigh:	resw 1
    63 00000016 ????                <1> deTime:		resw 1
    64 00000018 ????                <1> deDate:		resw 1
    65 0000001A ????                <1> deClusterLow:	resw 1
    66 0000001C ????????            <1> deSize:		resd 1
    67                              <1> 	endstruc
    68                              <1> 
    69                              <1> ATTR_READONLY	equ 1
    70                              <1> ATTR_HIDDEN	equ 2
    71                              <1> ATTR_SYSTEM	equ 4
    72                              <1> ATTR_VOLLABEL	equ 8
    73                              <1> ATTR_DIRECTORY	equ 10h
    74                              <1> ATTR_ARCHIVE	equ 20h
    75                              <1> 
    76                              <1> lsvclSignature		equ "CL"
    77                              <1> lsvclBufferLength	equ 256
    78                              <1> 
    79                              <1> 	struc LOADSTACKVARS, -10h
    80 FFFFFFF0 ????????            <1> lsvFirstCluster:	resd 1
    81 FFFFFFF4 ????????            <1> lsvFATSector:		resd 1
    82 FFFFFFF8 ????                <1> lsvFATSeg:		resw 1
    83 FFFFFFFA ????                <1> lsvLoadSeg:		resw 1
    84 FFFFFFFC ????????            <1> lsvDataStart:		resd 1
    85                              <1> 	endstruc
    86                              <1> 
    87                              <1> 	struc LOADDATA, LOADSTACKVARS - 10h
    88 FFFFFFE0 ????                <1> ldMemoryTop:	resw 1
    89 FFFFFFE2 ????                <1> ldLoadTop:	resw 1
    90 FFFFFFE4 ????                <1> ldSectorSeg:	resw 1
    91 FFFFFFE6 ??                  <1> ldFATType:	resb 1
    92                              <1> ldFlags:
    93 FFFFFFE7 ??                  <1> ldHasLBA:	resb 1
    94 FFFFFFE8 ????                <1> ldClusterSize:	resw 1
    95 FFFFFFEA ????                <1> ldParaPerSector:resw 1
    96                              <1> ldDirCluster:			; dword
    97                              <1> ldLoadingSeg:		; word
    98                              <1> ldQueryPatchValue:	; word
    99                              <1> lsvCommandLine:		; word
   100                              <1> .start:		equ $ - lsvclBufferLength
   101 FFFFFFEC ????                <1> .signature:	resw 1
   102                              <1> ldLoadUntilSeg:		; word
   103                              <1> lsvExtra:		; word
   104 FFFFFFEE ??                  <1> .partition:	resb 1	; byte
   105 FFFFFFEF ??                  <1> .flags:		resb 1	; byte
   106                              <1> 	endstruc
   107                              <1> 
   108                              <1> ldhlfPreserveLoader	equ 4
   109                              <1> 
   110                              <1> lsvefNoDataStart	equ 1
   111                              <1> lsvefPartitionNumber	equ 2
   112                              <1> lsvefPreserveLoader	equ 4
   113                              <1> 
   114                              <1> %if lsvefPreserveLoader != ldhlfPreserveLoader
   115                              <1>  %error Unexpected flag values
   116                              <1> %endif
   117                              <1> 
   118                              <1> 	struc LOADCMDLINE, LOADDATA - lsvclBufferLength
   119                              <1> ldCommandLine:
   120 FFFFFEE0 <res 100h>          <1> .start:		resb lsvclBufferLength
   121                              <1> 	endstruc
   122                              <1> 
   123                              <1> ldfHasLBA:	equ 1
   124                              <1> ldfFATInvalid:	equ 2
   125                              <1> ldfFATBuffered:	equ 4
   126                              <1> ldfDataBuffered: equ 8
   127                              <1> 
   128                              <1> 	struc LOADDATA2, LOADDATA - 10h
   129 FFFFFFD0 ????????            <1> ldRootSector:		resd 1
   130 FFFFFFD4 ????                <1> ldEntriesPerSector:	resw 1
   131                              <1> ldDataSegment:		; word
   132 FFFFFFD6 ????                <1> ldLastAvailableSector:	resw 1
   133                              <1> ldDataSector:		; dword
   134 FFFFFFD8 ????                <1> ldParasLeft:		resw 1
   135 FFFFFFDA ????                <1> ldParasDone:		resw 1
   136                              <1> 	endstruc
   137                              <1> 
   138                              <1> 	struc LOADDATA3, LOADDATA2 - 10h
   139 FFFFFFC0 ????????            <1> ldMaxCluster:		resd 1
   140 FFFFFFC4 ????????            <1> ldFileSize:		resd 1
   141 FFFFFFC8 ????????            <1> ldCurrentCluster:	resd 1
   142 FFFFFFCC ????????            <1> ldCurrentSeek:		resd 1
   143                              <1> 	endstruc
   144                              <1> 
   145                              <1> 	struc LOADERIMAGEIDENT
   146 00000000 ????????            <1> liiSignature:		resb 4		; "NLDR"
   147 00000004 ????                <1> liiVersion:		resb 2		; "00"
   148 00000006 ????                <1> liiChecksum:		resw 1		; word sum of first 8 words = 0
   149 00000008 ????                <1> liiAmountParagraphs:	resw 1
   150 0000000A ????????????        <1> liiReserved:		resw 3
   151 00000010 ????                <1> liiEntryQuerySize:	resw 1		; 0 if not supported
   152                              <1> 		; INP:	cs => NLDR image ident
   153                              <1> 		;	ip = this word field content
   154                              <1> 		;	ax = 60h
   155                              <1> 		; OUT:	ax => behind memory requested (should be >= 60h)
   156                              <1> 		; CHG:	es, ds, di, si, bx, cx, dx
   157                              <1> 		; STT:	far called, UP, EI
   158 00000012 ????                <1> liiEntryRelocate:	resw 1		; 0 if not supported
   159                              <1> 		; INP:	cs => NLDR image ident
   160                              <1> 		;	ip = this word field content
   161                              <1> 		;	ax = 60h
   162                              <1> 		; OUT:	ax => relocated NLDR segment (usually 60h)
   163                              <1> 		; CHG:	es, ds, di, si, bx, cx, dx
   164                              <1> 		; STT:	far called, UP, EI
   165 00000014 ????                <1> liiEntryDebug:		resw 1		; 0 if not supported
   166                              <1> 		; INP:	es = ds = cs = ss => relocated NLDR
   167                              <1> 		;	ip = this word field content
   168                              <1> 		;	sp = next word field content
   169                              <1> 		; STT:	running as debuggee, UP, EI
   170 00000016 ????                <1> liiStackPointer:	resw 1
   171                              <1> 	endstruc
   172                              <1> 
   173                              <1> 	struc LBAPACKET
   174 00000000 ????                <1> lpSize:		resw 1
   175 00000002 ????                <1> lpCount:	resw 1
   176 00000004 ????????            <1> lpBuffer:	resd 1
   177 00000008 ????????????????    <1> lpSector:	resq 1
   178                              <1> 	endstruc
   179                              <1> 
   180                              <1> 	struc PARTINFO
   181 00000000 ??                  <1> piBoot:		resb 1
   182 00000001 ??????              <1> piStartCHS:	resb 3
   183 00000004 ??                  <1> piType:		resb 1
   184 00000005 ??????              <1> piEndCHS:	resb 3
   185 00000008 ????????            <1> piStart:	resd 1
   186 0000000C ????????            <1> piLength:	resd 1
   187                              <1> 	endstruc
   188                              <1> 
   189                              <1> ptEmpty:		equ 0
   190                              <1> ptFAT12:		equ 1
   191                              <1> ptFAT16_16BIT_CHS:	equ 4
   192                              <1> ptExtendedCHS:		equ 5
   193                              <1> ptFAT16_CHS:		equ 6
   194                              <1> ptFAT32_CHS:		equ 0Bh
   195                              <1> ptFAT32:		equ 0Ch
   196                              <1> ptFAT16:		equ 0Eh
   197                              <1> ptExtended:		equ 0Fh
   198                              <1> ptLinux:		equ 83h
   199                              <1> ptExtendedLinux:	equ 85h
   200                              <1> 
   201                              <1> 
   202                              <1> 		; Flags of load_unit_flags
   203                              <1> lufForceCHS:		equ 1
   204                              <1> lufForceLBA:		equ 2
   205                              <1> lufForceGeometry:	equ 4
   206                              <1> luf_mask_writable equ lufForceCHS | lufForceLBA | lufForceGeometry
    13                                  
    14                                  	numdef SPT_MULTIPASS, 1
    15                                  
    16                                  
    17                                  	cpu 8086
    18                                  
    19                                  	addsection RELOCATEDDATA, nobits vstart=_ELD_RELOC_VSTART
    20                                  relocateddata:
    21                                  
    22                                  	addsection HEADER, start=0
    23                                  
    24                                  	istruc ELD_HEADERX
    25                                  at eldhxHeader
    26                                  		; ELD executable header
    27                                  	istruc ELD_HEADER
    28 00000000 454C4431                at eldhSignature,	db "ELD1"
    29 00000004 000000                  			db 0,0,0
    30 00000007 1A                      			db 26
    31 00000008 50000000                at eldhCodeOffset,	dd CODEOFFSET
    32 0000000C F016                    at eldhCodeImageLength,	dw code_size
    33 0000000E 0000                    at eldhCodeAllocLength,	dw 0
    34 00000010 40170000                at eldhDataOffset,	dd DATAOFFSET
    35 00000014 1003                    at eldhDataImageLength,	dw data_size
    36 00000016 0022                    at eldhDataAllocLength,	dw total_data_size - data_size
    37 00000018 CF0D                    at eldhCodeEntrypoint,	dw linker - code
    38                                  at eldhReserved
    39 0000001A 00<rep 4h>2800          at eldhExtensionSize,	dw header_extension_end - $$
    40                                  	iend
    41 00000020 [30000000]              at eldhxDescriptionOffset,	dd description
    42 00000024 091A0000                at eldhxHelpOffset,		dd DATAOFFSET + msg.help - datastart
    43                                  PUT_ELDHX_DATETIME_OFFSET
    44                                  header_extension_end:
    45 00000028 00<rep 8h>              	iend
    46                                  
    47 00000030 4348532063616C6375-     description:		asciz "CHS calculation tool."
    47 00000039 6C6174696F6E20746F-
    47 00000042 6F6C2E00           
    48                                  
    49                                  
    50 00000046 00<rep Ah>              	align 16, db 0
    51                                  
    52                                  	eldstrict on
    53                                  
    54                                  CODEOFFSET equ $ - $$
    55                                  	addsection CODE, follows=HEADER vstart=_ELD_CODE_VSTART
    56                                  %define CODEFIXUP - code + 0
    57                                  code:
    58                                  		; ELD instance header
    59                                  	istruc ELD_INSTANCE
    60                                  at eldiStartCode
    61 00000000 00<rep 2h>              at eldiEndCode
    62 00000002 00<rep 2h>              at eldiStartData
    63 00000004 00<rep 2h>              at eldiEndData
    64 00000006 00<rep 2h>43485354-     at eldiIdentifier,	fill 8, 32, db "CHSTOOL"
    64 0000000C 4F4F4C20           
    65 00000010 00<rep 2h>63687374-     at eldiListing,		asciz _ELD_LISTING
    65 00000016 6F6F6C2E6C737400   
    66 0000001E 00<rep 2h>              	iend
    67                                  
    68                                  
    69                                  command:
    70 00000020 EB08                    	jmp strict short .entry
    71                                  .chain:
    72 00000022 E8[0000]EB020000        	extcall cmd3_not_ext, required	; must NOT be extcallcall
    73 00000029 90                      	times 10 - ($ - command) nop
    74                                  .entry:
    75 0000002A 56                      	push si
    76 0000002B 3C2D                    	cmp al, '-'
    77 0000002D 7503                    	jne @F
    78 0000002F E8760C                  	extcallcall skipcomma
    79                                  @@:
    80 00000032 4E                      	dec si
    81                                  
    82 00000033 BA[7102]                reloc	mov dx, msg.chstool
    83                                  internaldatarelocation
    84 00000036 E8770C                  	extcallcall isstring?
    85 00000039 7405                    	je .ours
    86 0000003B 5E                      	pop si
    87 0000003C 4E                      	dec si
    88 0000003D AC                      	lodsb
    89 0000003E EBE2                    	jmp .chain
    90                                  
    91                                  .ours:
    92 00000040 58                      	pop ax
    93 00000041 E8640C                  	extcallcall skipcomma
    94 00000044 4E                      	dec si
    95 00000045 C706[0000][0000]        reloc2	mov word [relocateddata], relocateddata
    96                                  linkdatarelocation lastcmd, -4
    97                                  linkdatarelocation dmycmd
    98 0000004B BA[0000]                reloc	mov dx, relocateddata
    99                                  linkdatarelocation msg.uninstall
   100 0000004E E85F0C                  	extcallcall isstring?
   101 00000051 7406                    	je uninstall
   102                                  
   103 00000053 E8A704                  	call run
   104 00000056 E85F0C                  	extcallcall cmd3
   105                                  
   106                                  uninstall:
   107 00000059 AC                      	lodsb
   108 0000005A E8630C                  	extcallcall chkeol
   109                                  
   110 0000005D E86B00                  	call get_es_ext
   111                                  
   112 00000060 06                      	push es
   113 00000061 1F                      	pop ds
   114 00000062 31DB                    	xor bx, bx		; = 0 (no prior, modify ext_command_handler)
   115 00000064 BF[2000]                reloc	mov di, command		; di -> us
   116                                  internalcoderelocation
   117 00000067 368B36[0000]            reloc	mov si, word [ss:relocateddata]
   118                                  linkdatarelocation ext_command_handler
   119                                  				; si -> first
   120 0000006C 85F6                    	test si, si		; none installed ?
   121 0000006E 7450                    	jz .error		; error -->
   122                                  
   123                                  .loop:
   124 00000070 39F7                    	cmp di, si		; found ?
   125 00000072 740D                    	je .bx			; yes, use bx -->
   126 00000074 89F3                    	mov bx, si		; bx -> prior handler
   127 00000076 AD                      	lodsw			; skip entrypoint jmp strict short
   128 00000077 AC                      	lodsb			; get first byte of chainer
   129 00000078 3CE9                    	cmp al, 0E9h		; expecting jmp near ?
   130 0000007A 7544                    	jne .error		; no, error -->
   131 0000007C AD                      	lodsw			; get rel16 displacement
   132 0000007D 01C6                    	add si, ax		; -> next handler
   133 0000007F EBEF                    	jmp .loop
   134                                  
   135                                  .bx:
   136 00000081 85DB                    	test bx, bx		; any prior ?
   137 00000083 751A                    	jnz .bxnz		; yes -->
   138 00000085 AF                      	scasw			; skip entrypoint jmp strict short
   139 00000086 803DE8                  	cmp byte [di], 0E8h	; is it a call to cmd3_not_ext ?
   140 00000089 7507                    	jne @F			; no -->
   141                                  				; yes, reset ext_command_handler to zero
   142                                  .setbx:
   143 0000008B 36891E[0000]            reloc	mov word [ss:relocateddata], bx
   144                                  linkdatarelocation ext_command_handler
   145 00000090 EB1E                    	jmp .done
   146                                  
   147                                  @@:
   148 00000092 803DE9                  	cmp byte [di], 0E9h	; validate
   149 00000095 7529                    	jne .error		; failure -->
   150 00000097 47                      	inc di			; -> rel16 displacement
   151 00000098 8B1D                    	mov bx, word [di]	; get displacement
   152 0000009A AF                      	scasw			; -> after jmp near
   153 0000009B 01FB                    	add bx, di		; -> next handler
   154 0000009D EBEC                    	jmp .setbx		; set ext_command_handler to next
   155                                  
   156                                  .bxnz:
   157 0000009F 89DE                    	mov si, bx		; -> prior handler with us as downlink
   158 000000A1 87FE                    	xchg di, si		; si -> ours, di -> prior
   159 000000A3 A7                      	cmpsw			; skip entrypoint jmp strict short
   160 000000A4 A4                      	movsb			; copy 0E8h/0E9h
   161 000000A5 AD                      	lodsw			; ax = near rel16 displacement
   162 000000A6 01F0                    	add ax, si		; add in our base (= absolute offset)
   163 000000A8 29F8                    	sub ax, di
   164 000000AA 48                      	dec ax
   165 000000AB 48                      	dec ax			; subtract new base (= relative displacement)
   166 000000AC AB                      	stosw			; store new rel16 displacement
   167 000000AD A5                      	movsw			; jmp strict short
   168 000000AE A5                      	movsw			; linkcall target
   169 000000AF A4                      	movsb			; trailer
   170                                  .done:
   171 000000B0 8026[1000]FE            reloc	clropt [code + eldiFlags], eldifResident
   172                                  internalcoderelocation -3	; mark block as free
   173 000000B5 BA[7902]                reloc	mov dx, msg.uninstall_done
   174                                  internaldatarelocation
   175                                  @@:
   176 000000B8 16                      	push ss
   177 000000B9 1F                      	pop ds
   178 000000BA E80B0C                  	extcallcall putsz
   179 000000BD E8F80B                  	extcallcall cmd3	; return
   180                                  
   181                                  .error:
   182 000000C0 B8010E                  	mov ax, 0E01h
   183 000000C3 E80A0C                  	extcallcall setrc
   184 000000C6 BA[9002]                reloc	mov dx, msg.uninstall_error
   185                                  internaldatarelocation
   186 000000C9 EBED                    	jmp @B
   187                                  
   188                                  
   189                                  get_es_ext:
   190 000000CB 8E06[0000]              reloc	mov es, word [relocateddata]
   191                                  linkdatarelocation extdssel
   192 000000CF E8060C                  	extcallcall ispm
   193 000000D2 7404                    	jz @F
   194 000000D4 8E06[0000]              reloc	mov es, word [relocateddata]
   195                                  linkdatarelocation extseg
   196                                  @@:
   197 000000D8 C3                      	retn
   198                                  
   199                                  
   200                                  overridedef DEBUG4, 0
   201                                  partition_table equ load_partition_table
   202                                  partition_table.end equ load_partition_table.end
   203                                  %define _SCANPTAB_PREFIX
   204                                  %define _SCANPTAB_DEBUG4_PREFIX
   205                                  %assign _PARTITION_TABLE_IN_CS 0
   206                                  %define _BASE bp
   207                                  %assign _SPT_ELD 1
   208                                  %include "scanptab.asm"
     1                              <1> 
     2                              <1> %if 0
     3                              <1> 
     4                              <1> scanptab - Scan partition table
     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> 	; _SCANPTAB_PREFIX = prefix for our variables and functions
    16                              <1> 	; _SCANPTAB_DEBUG4_PREFIX = prefix for d4 function calls
    17                              <1> 	numdef PARTITION_TABLE_IN_CS, 1
    18                              <1> 	numdef BOOTCMD_FAIL_ERROR, 1
    19                              <1> 	numdef SPT_ELD, 0
    20                              <1> 	numdef SPT_MULTIPASS, 0
    21                              <1> %if _SPT_ELD
    22                              <1>  %define sptrel reloc
    23                              <1>  %define sptinternal internaldatarelocation
    24                              <1>  %define sptexternal linkdatarelocation
    25                              <1> 	numdef MODE, 1
    26                              <1> %else
    27                              <1>  %define sptrel
    28                              <1>  %define sptinternal comment
    29                              <1>  %define sptexternal comment
    30                              <1> 	numdef MODE, 0
    31                              <1> %endif
    32                              <1> 	gendef BASE, ss:bx
    33                              <1> %ifidn _BASE, ss:bx
    34                              <1> %elifidn _BASE, bp
    35                              <1> %else
    36                              <1>  %error Invalid base
    37                              <1> %endif
    38                              <1> 
    39                              <1> %if _MODE
    40                              <1>  %include "scanptab.mac"
     1                              <2> 
     2                              <2> %if 0
     3                              <2> 
     4                              <2> scanptab - Scan partition table (macros)
     5                              <2>  2019, 2025 by E. C. Masloch
     6                              <2> 
     7                              <2> Usage of the works is permitted provided that this
     8                              <2> instrument is retained with the works, so that any entity
     9                              <2> that uses the works is notified of this instrument.
    10                              <2> 
    11                              <2> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    12                              <2> 
    13                              <2> %endif
    14                              <2> 
    15                              <2> mode_all_ext5			equ 00b
    16                              <2> mode_ignore_ext5		equ 01b
    17                              <2> mode_first_ext5			equ 10b
    18                              <2> mode_first_type_ext5		equ 11b
    19                              <2> 
    20                              <2> mode_all_ext15			equ 00b << 2
    21                              <2> mode_ignore_ext15		equ 01b << 2
    22                              <2> mode_first_ext15		equ 10b << 2
    23                              <2> mode_first_type_ext15		equ 11b << 2
    24                              <2> 
    25                              <2> mode_all_ext85			equ 00b << 4
    26                              <2> mode_ignore_ext85		equ 01b << 4
    27                              <2> mode_first_ext85		equ 10b << 4
    28                              <2> mode_first_type_ext85		equ 11b << 4
    29                              <2> 
    30                              <2> mode_ignore_subsequent_nested	equ            1_00_00_00b
    31                              <2> mode_ignore_subsequent_logical	equ           10_00_00_00b
    32                              <2> mode_ignore_subsequent_primary	equ          100_00_00_00b
    33                              <2> mode_traditional_order_logical	equ         1000_00_00_00b
    34                              <2> mode_active_priority		equ       1_0000_00_00_00b
    35                              <2> mode_subsequent_primary_after	equ      10_0000_00_00_00b
    36                              <2> mode_disable_fat32		equ 00_1000_0000_00_00_00b
    37                              <2> mode_disable_lba		equ 01_0000_0000_00_00_00b
    38                              <2> mode_dlasort_zero		equ 10_0000_0000_00_00_00b
    41                              <1> %endif
    42                              <1> 
    43                              <1> 
    44                              <1> 		; INP:	byte [%load_unit] = unit to scan
    45                              <1> 		;	cx = function to call for each partition
    46                              <1> 		; OUT:	function called for each partition
    47                              <1> 		; CHG:	di, si, ax, bx, (cx), dx, es
    48                              <1> 		; STT:	ds => data segment (used for %load_* variables, unless bp-based)
    49                              <1> 		;
    50                              <1> 		; Note:	Calls %read_partition_table (in this module),
    51                              <1> 		;	 which calls %read_ae_512_bytes, which calls
    52                              <1> 		;	 read_sector. The read_sector base must be
    53                              <1> 		;	 zero and the geometry must be initialised.
    54                              <1> 
    55                              <1> 		; Function in cx is called with:
    56                              <1> 		; INP:	es:si -> partition table entry,
    57                              <1> 		;	 si = %partition_table .. %partition_table+48,
    58                              <1> 		;	 es = ss (if not _PARTITION_TABLE_IN_CS)
    59                              <1> 		;	 es = cs (if _PARTITION_TABLE_IN_CS)
    60                              <1> 		;	byte [%load_current_partition] = partition number,
    61                              <1> 		;	 0 for diskette (unpartitioned),
    62                              <1> 		;	 1 to 4 for primary partitions,
    63                              <1> 		;	 5+ for logical partitions
    64                              <1> 		;	_BASE + di -> above part table metadata,
    65                              <1> 		;	 dword [_BASE + di - 4] = root (outermost extended position)
    66                              <1> 		;	 dword [_BASE + di - 8] = base (current table position)
    67                              <1> 		;	 dword [es:si + piStart] = local partition start
    68                              <1> 		;	 base + local start = absolute partition start
    69                              <1> 		;	_BASE -> bp value (dummy if _BASE is not bp),
    70                              <1> 		;		near return address of scan_partitions
    71                              <1> 		; CHG:	ax, (cx), dx, bx (unless part of _BASE)
    72                              <1> 		; STT:	ds => data segment (used for load_* variables, unless bp-based)
    73                              <1> 		; Note:	preserves (cx), si, di, ds, es, (bp), _BASE
    74                              <1> 		;
    75                              <1> 		; Note:	If the function returns to scan_partitions,
    76                              <1> 		;	 cx must be left as the function to call for
    77                              <1> 		;	 subsequent partitions afterwards.
    78                              <1> 		; Note:	May load sp from _BASE then pop bp then return
    79                              <1> 		;	 near if the scan should stop after the call.
    80                              <1> %if _SPT_MULTIPASS
    81                              <1> %[_SCANPTAB_PREFIX]scan_priority_primary:
    82                              <1> %else
    83                              <1> %[_SCANPTAB_PREFIX]scan_partitions:
    84                              <1> %endif
    85 000000D9 8326[F624]00        <1> sptrel	and word [ %[_SCANPTAB_PREFIX]load_partition_cycle], 0
    86                              <1> sptinternal -3
    87                              <1> d4	call %[_SCANPTAB_DEBUG4_PREFIX]d4message
    88                              <1> d4	asciz "In scan_partitions",13,10
    89                              <1> 
    90 000000DE 55                  <1> 	push bp
    91                              <1> %ifidn _BASE, ss:bx
    92                              <1> 	mov bx, sp
    93                              <1> %elifidn _BASE, bp
    94 000000DF 89E5                <1> 	mov bp, sp
    95                              <1> %endif
    96 000000E1 31FF                <1> 	xor di, di
    97 000000E3 57                  <1> 	push di		; [_BASE+di-2]
    98 000000E4 57                  <1> 	push di		; [_BASE+di-4]
    99 000000E5 57                  <1> 	push di		; [_BASE+di-6]
   100 000000E6 57                  <1> 	push di		; [_BASE+di-8]
   101                              <1> %if _MODE
   102 000000E7 893E[0425]          <1> sptrel	mov word [ %[_SCANPTAB_PREFIX]load_scan_flags ], di
   103                              <1> sptinternal
   104                              <1> %endif
   105                              <1> 
   106 000000EB 803E[FC24]80        <1> sptrel	cmp byte [ %[_SCANPTAB_PREFIX]load_unit], 80h
   107                              <1> sptinternal -3
   108 000000F0 7326                <1> 	jae @F
   109                              <1> 
   110 000000F2 57                  <1> 	push di
   111 000000F3 51                  <1> 	push cx
   112                              <1> %if _PARTITION_TABLE_IN_CS
   113                              <1> 	 push cs
   114                              <1> %else
   115 000000F4 16                  <1> 	 push ss
   116                              <1> %endif
   117 000000F5 07                  <1> 	 pop es
   118 000000F6 BF[B024]            <1> sptrel	mov di, %[_SCANPTAB_PREFIX]partition_table
   119                              <1> sptinternal
   120 000000F9 31C0                <1> 	xor ax, ax
   121 000000FB B92000              <1> 	mov cx, (4 * 16) >> 1
   122 000000FE F3AB                <1> 	rep stosw			; initialise fake partition table
   123 00000100 59                  <1> 	pop cx
   124 00000101 5F                  <1> 	pop di
   125 00000102 BE[B024]            <1> sptrel	mov si, %[_SCANPTAB_PREFIX]partition_table
   126                              <1> sptinternal
   127                              <1> 					; -> fake PARTINFO
   128 00000105 26C60480            <1> 	mov byte [es:si + piBoot], 80h	; fake primary active
   129 00000109 26C64404FF          <1> 	mov byte [es:si + piType], 0FFh	; fake a type
   130 0000010E C606[0025]00        <1> sptrel	mov byte [ %[_SCANPTAB_PREFIX]load_current_partition], 0	; special: 0 = diskette
   131                              <1> sptinternal -3				; piLength is 0, too
   132 00000113 FFD1                <1> 	call cx
   133                              <1> 
   134 00000115 E91202              <1> 	jmp %[_SCANPTAB_PREFIX]scan_logical.end
   135                              <1> 
   136                              <1> 
   137                              <1> @@:
   138                              <1>  %if _SPT_MULTIPASS
   139 00000118 F606[0325]04        <1> sptrel	testopt [ %[_SCANPTAB_PREFIX]load_mode ], mode_active_priority
   140                              <1> sptinternal -3			; active primary first ?
   141 0000011D 7438                <1> 	jz .end
   142                              <1>  %endif
   143                              <1> 
   144 0000011F 31C0                <1> 	xor ax, ax
   145 00000121 31D2                <1> 	xor dx, dx
   146                              <1> d4	call %[_SCANPTAB_DEBUG4_PREFIX]d4message
   147                              <1> d4	asciz "In scan_partitions (before first call to read_partition_table)",13,10
   148 00000123 E8A503              <1> 	call %[_SCANPTAB_PREFIX]read_partition_table.first
   149                              <1> d4	call %[_SCANPTAB_DEBUG4_PREFIX]d4message
   150                              <1> d4	asciz "In scan_partitions (after first call to read_partition_table)",13,10
   151 00000126 BE[B024]            <1> sptrel	mov si, %[_SCANPTAB_PREFIX]partition_table
   152                              <1> sptinternal
   153 00000129 8816[0025]          <1> sptrel	mov byte [ %[_SCANPTAB_PREFIX]load_current_partition], dl	; = 0
   154                              <1> sptinternal
   155                              <1> %if _SPT_ELD
   156 0000012D 8916[0C25]          <1> sptrel	mov word [ %[_SCANPTAB_PREFIX]load_current_extended_and_is], dx	; = 0
   157                              <1> sptinternal
   158                              <1> %endif
   159                              <1> 
   160                              <1> %if _MODE
   161                              <1>  %ifn _SPT_MULTIPASS
   162                              <1> sptrel	testopt [ %[_SCANPTAB_PREFIX]load_mode ], mode_active_priority
   163                              <1> sptinternal -3			; active primary first ?
   164                              <1> 	jz .active_ignored
   165                              <1>  %endif
   166                              <1> 
   167                              <1> .loop_active_primary:
   168                              <1> 
   169 00000131 FE06[0025]          <1> sptrel	inc byte [ %[_SCANPTAB_PREFIX]load_current_partition]
   170                              <1> sptinternal
   171 00000135 268A4404            <1> 	mov al, byte [es:si + piType]
   172 00000139 3C00                <1> 	cmp al, 0
   173 0000013B 7411                <1> 	je .loop_active_primary_skip
   174 0000013D 26803C00            <1> 	cmp byte [es:si + piBoot], 0
   175 00000141 740B                <1> 	je .loop_active_primary_skip
   176                              <1> 
   177                              <1> 		; INP:	al = partition type
   178                              <1> 		; OUT:	CY if an LBA or FAT32 type that's disabled
   179                              <1> 		;	NC, ZR if known type we can access
   180                              <1> 		;	NC, NZ if unknown type
   181 00000143 E8CC07              <1> 	call %[_SCANPTAB_PREFIX]load_is_known
   182 00000146 7206                <1> 	jc .loop_active_primary_skip
   183 00000148 7504                <1> 	jnz .loop_active_primary_skip
   184                              <1> 
   185 0000014A FFD1                <1> 	call cx			; es:si -> partition table entry
   186                              <1> 				; byte [load_current_partition] = which
   187 0000014C EB09                <1> 	jmp .active_done
   188                              <1> 
   189                              <1> .loop_active_primary_skip:
   190 0000014E 83C610              <1> 	add si, 16
   191 00000151 81FE[F024]          <1> sptrel	cmp si, strict word %[_SCANPTAB_PREFIX]partition_table.end
   192                              <1> sptinternal
   193 00000155 72DA                <1> 	jb .loop_active_primary
   194                              <1> 
   195                              <1> .active_done:
   196                              <1> %if _SPT_MULTIPASS
   197                              <1> .end:
   198                              <1> %ifidn _BASE, bp
   199 00000157 89EC                <1> 	mov sp, bp		; restore sp
   200 00000159 5D                  <1> 	pop bp
   201                              <1> %else
   202                              <1> 	mov sp, bx		; restore sp
   203                              <1> 	pop ax			; (discard dummy bp value)
   204                              <1> %endif
   205 0000015A C3                  <1> 	retn			; and bye
   206                              <1> 
   207                              <1> 
   208                              <1> %[_SCANPTAB_PREFIX]scan_early_primary:
   209 0000015B 8326[F624]00        <1> sptrel	and word [ %[_SCANPTAB_PREFIX]load_partition_cycle], 0
   210                              <1> sptinternal -3
   211                              <1> 
   212 00000160 55                  <1> 	push bp
   213                              <1> %ifidn _BASE, ss:bx
   214                              <1> 	mov bx, sp
   215                              <1> %elifidn _BASE, bp
   216 00000161 89E5                <1> 	mov bp, sp
   217                              <1> %endif
   218 00000163 31FF                <1> 	xor di, di
   219 00000165 57                  <1> 	push di		; [_BASE+di-2]
   220 00000166 57                  <1> 	push di		; [_BASE+di-4]
   221 00000167 57                  <1> 	push di		; [_BASE+di-6]
   222 00000168 57                  <1> 	push di		; [_BASE+di-8]
   223 00000169 31C0                <1> 	xor ax, ax
   224 0000016B 31D2                <1> 	xor dx, dx
   225                              <1> 
   226                              <1> %if _MODE
   227 0000016D A3[0425]            <1> sptrel	mov word [ %[_SCANPTAB_PREFIX]load_scan_flags ], ax
   228                              <1> sptinternal
   229                              <1> %endif
   230                              <1> 
   231 00000170 E85803              <1> 	call %[_SCANPTAB_PREFIX]read_partition_table.first
   232 00000173 8816[0025]          <1> sptrel	mov byte [ %[_SCANPTAB_PREFIX]load_current_partition], dl	; = 0
   233                              <1> sptinternal
   234                              <1> %if _SPT_ELD
   235 00000177 8916[0C25]          <1> sptrel	mov word [ %[_SCANPTAB_PREFIX]load_current_extended_and_is], dx	; = 0
   236                              <1> sptinternal
   237                              <1> %endif
   238                              <1> %else
   239                              <1> sptrel	mov byte [ %[_SCANPTAB_PREFIX]load_current_partition], 0
   240                              <1> sptinternal -3
   241                              <1> %endif
   242 0000017B BE[B024]            <1> sptrel	mov si, %[_SCANPTAB_PREFIX]partition_table
   243                              <1> sptinternal
   244                              <1> 
   245                              <1> 
   246 0000017E F606[0325]04        <1> sptrel	testopt [ %[_SCANPTAB_PREFIX]load_mode ], mode_active_priority
   247                              <1> sptinternal -3			; active primary first ?
   248 00000183 7437                <1> 	jz .active_ignored
   249                              <1> 
   250                              <1> .loop_active_skip:
   251                              <1> 
   252 00000185 FE06[0025]          <1> sptrel	inc byte [ %[_SCANPTAB_PREFIX]load_current_partition]
   253                              <1> sptinternal
   254 00000189 268A4404            <1> 	mov al, byte [es:si + piType]
   255 0000018D 3C00                <1> 	cmp al, 0
   256 0000018F 741A                <1> 	je .loop_active_skip_skip
   257 00000191 26803C00            <1> 	cmp byte [es:si + piBoot], 0
   258 00000195 7414                <1> 	je .loop_active_skip_skip
   259                              <1> 
   260                              <1> 		; INP:	al = partition type
   261                              <1> 		; OUT:	CY if an LBA or FAT32 type that's disabled
   262                              <1> 		;	NC, ZR if known type we can access
   263                              <1> 		;	NC, NZ if unknown type
   264 00000197 E87807              <1> 	call %[_SCANPTAB_PREFIX]load_is_known
   265 0000019A 720F                <1> 	jc .loop_active_skip_skip
   266 0000019C 750D                <1> 	jnz .loop_active_skip_skip
   267 0000019E A0[0025]            <1> sptrel	mov al, byte [ %[_SCANPTAB_PREFIX]load_current_partition]
   268                              <1> sptinternal
   269 000001A1 A2[0525]            <1> sptrel	mov byte [ %[_SCANPTAB_PREFIX]load_scan_flags + 1], al
   270                              <1> sptinternal
   271 000001A4 800E[0425]20        <1> sptrel	setopt [ %[_SCANPTAB_PREFIX]load_scan_flags ], 32
   272                              <1> sptinternal -3			; mark as had a primary partition yet
   273 000001A9 EB09                <1> 	jmp .active_skip_done
   274                              <1> 
   275                              <1> .loop_active_skip_skip:
   276 000001AB 83C610              <1> 	add si, 16
   277 000001AE 81FE[F024]          <1> sptrel	cmp si, strict word %[_SCANPTAB_PREFIX]partition_table.end
   278                              <1> sptinternal
   279 000001B2 72D1                <1> 	jb .loop_active_skip
   280                              <1> 
   281                              <1> .active_skip_done:
   282 000001B4 BE[B024]            <1> sptrel	mov si, %[_SCANPTAB_PREFIX]partition_table
   283                              <1> sptinternal
   284 000001B7 C606[0025]00        <1> sptrel	mov byte [ %[_SCANPTAB_PREFIX]load_current_partition], 0
   285                              <1> sptinternal -3
   286                              <1> 
   287                              <1> %endif
   288                              <1> 
   289                              <1> .active_ignored:
   290                              <1> .loop_primary_parts:
   291 000001BC FE06[0025]          <1> sptrel	inc byte [ %[_SCANPTAB_PREFIX]load_current_partition]
   292                              <1> sptinternal
   293 000001C0 26807C0400          <1> 	cmp byte [es:si + piType], 0
   294 000001C5 7427                <1> 	je .loop_primary_skip
   295                              <1> 
   296                              <1> %if _MODE
   297 000001C7 F606[0325]04        <1> sptrel	testopt [ %[_SCANPTAB_PREFIX]load_mode ], mode_active_priority
   298                              <1> sptinternal -3			; active primary first ?
   299 000001CC 7409                <1> 	jz @F			; no -->
   300 000001CE A0[0025]            <1> sptrel	mov al, byte [ %[_SCANPTAB_PREFIX]load_current_partition]
   301                              <1> sptinternal
   302 000001D1 3806[0525]          <1> sptrel	cmp byte [ %[_SCANPTAB_PREFIX]load_scan_flags + 1], al
   303                              <1> sptinternal
   304 000001D5 7417                <1> 	je .ignoreprimary
   305                              <1> @@:
   306                              <1> 
   307 000001D7 F606[0425]20        <1> sptrel	testopt [ %[_SCANPTAB_PREFIX]load_scan_flags ], 32
   308                              <1> sptinternal -3			; had a primary partition yet ?
   309 000001DC 740E                <1> 	jz .callprimary		; no, accept it -->
   310 000001DE F606[0325]01        <1> sptrel	testopt [ %[_SCANPTAB_PREFIX]load_mode ], mode_ignore_subsequent_primary
   311                              <1> sptinternal -3			; ignore subsequent primary ?
   312 000001E3 7509                <1> 	jnz .ignoreprimary	; yes, ignore it -->
   313 000001E5 F606[0325]08        <1> sptrel	testopt [ %[_SCANPTAB_PREFIX]load_mode ], mode_subsequent_primary_after
   314                              <1> sptinternal -3			; subsequent after ?
   315 000001EA 7502                <1> 	jnz .ignoreprimary
   316                              <1> .callprimary:
   317                              <1> %endif
   318 000001EC FFD1                <1> 	call cx			; es:si -> partition table entry
   319                              <1> 				; byte [load_current_partition] = which
   320                              <1> .ignoreprimary:
   321                              <1> .loop_primary_skip:
   322 000001EE 83C610              <1> 	add si, 16
   323 000001F1 81FE[F024]          <1> sptrel	cmp si, strict word %[_SCANPTAB_PREFIX]partition_table.end
   324                              <1> sptinternal
   325 000001F5 72C5                <1> 	jb .loop_primary_parts
   326                              <1> 
   327                              <1> %if _SPT_MULTIPASS
   328                              <1> .end:
   329                              <1> %ifidn _BASE, bp
   330 000001F7 89EC                <1> 	mov sp, bp		; restore sp
   331 000001F9 5D                  <1> 	pop bp
   332                              <1> %else
   333                              <1> 	mov sp, bx		; restore sp
   334                              <1> 	pop ax			; (discard dummy bp value)
   335                              <1> %endif
   336 000001FA C3                  <1> 	retn			; and bye
   337                              <1> 
   338                              <1> 
   339                              <1> %[_SCANPTAB_PREFIX]scan_logical:
   340 000001FB 55                  <1> 	push bp
   341                              <1> %ifidn _BASE, ss:bx
   342                              <1> 	mov bx, sp
   343                              <1> %elifidn _BASE, bp
   344 000001FC 89E5                <1> 	mov bp, sp
   345                              <1> %endif
   346 000001FE 31FF                <1> 	xor di, di
   347 00000200 57                  <1> 	push di		; [_BASE+di-2]
   348 00000201 57                  <1> 	push di		; [_BASE+di-4]
   349 00000202 57                  <1> 	push di		; [_BASE+di-6]
   350 00000203 57                  <1> 	push di		; [_BASE+di-8]
   351                              <1> 
   352 00000204 31C0                <1> 	xor ax, ax
   353 00000206 31D2                <1> 	xor dx, dx
   354                              <1> %if _MODE
   355 00000208 A3[0425]            <1> sptrel	mov word [ %[_SCANPTAB_PREFIX]load_scan_flags ], ax
   356                              <1> sptinternal
   357                              <1> %endif
   358 0000020B A3[F624]            <1> sptrel	mov word [ %[_SCANPTAB_PREFIX]load_partition_cycle], ax
   359                              <1> sptinternal
   360 0000020E E8BA02              <1> 	call %[_SCANPTAB_PREFIX]read_partition_table.first
   361 00000211 C606[0025]04        <1> sptrel	mov byte [ %[_SCANPTAB_PREFIX]load_current_partition], 4
   362                              <1> sptinternal -3
   363                              <1> %if _SPT_ELD
   364 00000216 8916[0C25]          <1> sptrel	mov word [ %[_SCANPTAB_PREFIX]load_current_extended_and_is], dx	; = 0
   365                              <1> sptinternal
   366                              <1> %endif
   367                              <1> %else
   368                              <1> 
   369                              <1> %[_SCANPTAB_PREFIX]scan_logical:
   370                              <1> %endif
   371                              <1> .:
   372                              <1> d4	call %[_SCANPTAB_DEBUG4_PREFIX]d4message
   373                              <1> d4	asciz "In scan_logical.",13,10
   374                              <1> 
   375                              <1> %if _MODE
   376 0000021A F606[0325]02        <1> sptrel	testopt [ %[_SCANPTAB_PREFIX]load_mode ], mode_traditional_order_logical
   377                              <1> sptinternal -3
   378 0000021F 7451                <1> 	jz .nottraditional
   379                              <1> 
   380 00000221 BE[B024]            <1> sptrel	mov si, %[_SCANPTAB_PREFIX]partition_table
   381                              <1> sptinternal
   382                              <1> .loop_traditional:
   383 00000224 FF06[F624]          <1> sptrel	inc word [ %[_SCANPTAB_PREFIX]load_partition_cycle]
   384                              <1> sptinternal
   385 00000228 7503E9DB01          <1> 	jz .got_partition_cycle
   386                              <1> 
   387 0000022D 268A4404            <1> 	mov al, [es:si + piType]
   388                              <1> 
   389                              <1> %ifidn _BASE, bp
   390 00000231 31DB                <1> 	xor bx, bx
   391                              <1> %endif
   392 00000233 84C0                <1> 	test al, al
   393 00000235 742D                <1> 	jz .next_traditional
   394 00000237 3C0F                <1> 	cmp al, 0Fh		; extended partition (LBA aware) ?
   395 00000239 7429                <1> 	je .next_traditional	; yes -->
   396 0000023B 247F                <1> 	and al, ~80h		; extended partition Linux (85h) ?
   397 0000023D 3C05                <1> 	cmp al, 05h		;  or extended partition DOS (05h) ?
   398 0000023F 7423                <1> 	je .next_traditional	; yes -->
   399                              <1> 
   400                              <1> %ifidn _BASE, bp
   401 00000241 395BFE              <1> 	cmp word [_BASE+di-2], bx
   402 00000244 7505                <1> 	jne .logical_traditional
   403 00000246 395BFC              <1> 	cmp word [_BASE+di-4], bx
   404                              <1> %else
   405                              <1> 	cmp word [_BASE+di-2], 0
   406                              <1> 	jne .logical_traditional
   407                              <1> 	cmp word [_BASE+di-4], 0
   408                              <1> %endif
   409 00000249 7419                <1> 	je .next_traditional
   410                              <1> .logical_traditional:
   411                              <1> 
   412                              <1> %if _MODE
   413 0000024B F606[0425]20        <1> sptrel	testopt [ %[_SCANPTAB_PREFIX]load_scan_flags ], 32
   414                              <1> sptinternal -3			; had a logical partition yet ?
   415 00000250 7407                <1> 	jz .calllogicaltrad	; no, accept it -->
   416 00000252 F606[0225]80        <1> sptrel	testopt [ %[_SCANPTAB_PREFIX]load_mode ], mode_ignore_subsequent_logical
   417                              <1> sptinternal -3			; ignore subsequent logical ?
   418 00000257 750B                <1> 	jnz .ignorelogicaltrad	; yes, ignore it -->
   419                              <1> .calllogicaltrad:
   420                              <1> %endif
   421                              <1> 
   422 00000259 FE06[0025]          <1> sptrel	inc byte [ %[_SCANPTAB_PREFIX]load_current_partition]
   423                              <1> sptinternal
   424 0000025D 7503E9AC01          <1> 	jz .error_too_many_partitions
   425 00000262 FFD1                <1> 	call cx			; (sets load_scan_flags & 32 if recognised)
   426                              <1> 		; CHG: ax, (cx), dx, bx if _BASE = bp
   427                              <1> 		; preserve: (cx), si, di, ds, es, bx if _BASE = ss:bx
   428                              <1> .ignorelogicaltrad:
   429                              <1> .next_traditional:
   430 00000264 83C610              <1> 	add si, 16		; -> next partition table entry
   431 00000267 81FE[F024]          <1> sptrel	cmp si, strict word %[_SCANPTAB_PREFIX]partition_table.end
   432                              <1> sptinternal			; was last?
   433 0000026B 72B7                <1> 	jb .loop_traditional	; no, loop -->
   434                              <1> 
   435 0000026D 800E[0425]20        <1> sptrel	setopt [ %[_SCANPTAB_PREFIX]load_scan_flags ], 32
   436                              <1> sptinternal -3			; mark as had logical
   437                              <1> 
   438                              <1> .nottraditional:
   439                              <1> %endif
   440                              <1> 
   441 00000272 BE[B024]            <1> sptrel	mov si, %[_SCANPTAB_PREFIX]partition_table
   442                              <1> sptinternal
   443                              <1> .loop:
   444 00000275 FF06[F624]          <1> sptrel	inc word [ %[_SCANPTAB_PREFIX]load_partition_cycle]
   445                              <1> sptinternal
   446 00000279 7503E98A01          <1> 	jz .got_partition_cycle
   447                              <1> 
   448 0000027E 268A4404            <1> 	mov al, [es:si + piType]
   449                              <1> 
   450                              <1> %ifidn _BASE, bp
   451 00000282 31DB                <1> 	xor bx, bx
   452                              <1> %endif
   453 00000284 84C0                <1> 	test al, al
   454 00000286 7503E98C00          <1> 	jz .next
   455                              <1> %if _MODE
   456                              <1> %ifidn _BASE, bp
   457 0000028B 395BFE              <1> 	cmp word [_BASE+di-2], bx
   458 0000028E 754B                <1> 	jne .allextended
   459 00000290 395BFC              <1> 	cmp word [_BASE+di-4], bx
   460                              <1> %else
   461                              <1> 	cmp word [_BASE+di-2], 0
   462                              <1> 	jne .allextended
   463                              <1> 	cmp word [_BASE+di-4], 0
   464                              <1> %endif
   465 00000293 7546                <1> 	jne .allextended
   466                              <1> 
   467 00000295 8A26[0225]          <1> sptrel	mov ah, [ %[_SCANPTAB_PREFIX]load_mode ]
   468                              <1> sptinternal
   469 00000299 3C05                <1> 	cmp al, 5
   470 0000029B 7410                <1> 	je .check
   471 0000029D D0EC                <1> 	shr ah, 1
   472 0000029F D0EC                <1> 	shr ah, 1
   473 000002A1 3C0F                <1> 	cmp al, 15
   474 000002A3 7408                <1> 	je .check
   475 000002A5 D0EC                <1> 	shr ah, 1
   476 000002A7 D0EC                <1> 	shr ah, 1
   477 000002A9 3C85                <1> 	cmp al, 85h
   478 000002AB 7546                <1> 	jne .notextended
   479                              <1> .check:
   480 000002AD 8026[0425]EF        <1> sptrel	clropt [ %[_SCANPTAB_PREFIX]load_scan_flags ], 16
   481                              <1> sptinternal -3			; new outermost extended
   482                              <1> 
   483 000002B2 F6C403              <1> 	test ah, 11b
   484 000002B5 7477                <1> 	jz .push		; if it is 00b = all, always accept -->
   485 000002B7 F6C402              <1> 	test ah, 10b		; if prior is NZ but this is zero
   486 000002BA 745B                <1> 	jz .ignoreextended	;  then we have 01b, always ignore -->
   487 000002BC F6C401              <1> 	test ah, 01b		; if prior is NZ and this is NZ,
   488                              <1> 	; jnz .firsttype	;  then we have 11b, accept first of type
   489 000002BF B401                <1> 	mov ah, 1		; flag 1 for 10b
   490 000002C1 740C                <1> 	jz @F			; if ZR, we have 10b, accept first of all types with 10b
   491                              <1> .firsttype:
   492 000002C3 B402                <1> 	mov ah, 2		; flag 2 for 11b type 5
   493 000002C5 3C0F                <1> 	cmp al, 15
   494 000002C7 7206                <1> 	jb @F
   495 000002C9 B404                <1> 	mov ah, 4		; flag 4 for 11b type 15
   496 000002CB 7402                <1> 	je @F
   497 000002CD B408                <1> 	mov ah, 8		; flag 8 for 11b type 85h
   498                              <1> @@:
   499 000002CF 8426[0425]          <1> sptrel	test byte [ %[_SCANPTAB_PREFIX]load_scan_flags ], ah
   500                              <1> sptinternal			; seen one of those before ?
   501 000002D3 7542                <1> 	jnz .ignoreextended	; yes, ignore -->
   502 000002D5 0826[0425]          <1> sptrel	or byte [ %[_SCANPTAB_PREFIX]load_scan_flags ], ah
   503                              <1> sptinternal			; no, note seen it now
   504 000002D9 EB53                <1> 	jmp .push		; and process extended partition -->
   505                              <1> %endif
   506                              <1> 
   507                              <1> .allextended:
   508                              <1> %if _MODE
   509 000002DB F606[0225]40        <1> sptrel	testopt [ %[_SCANPTAB_PREFIX]load_mode ], mode_ignore_subsequent_nested
   510                              <1> sptinternal -3
   511 000002E0 7407                <1> 	jz @F
   512 000002E2 F606[0425]10        <1> sptrel	testopt [ %[_SCANPTAB_PREFIX]load_scan_flags ], 16
   513                              <1> sptinternal -3
   514 000002E7 752E                <1> 	jnz .ignoreextended
   515                              <1> @@:
   516                              <1> %endif
   517 000002E9 3C0F                <1> 	cmp al, 0Fh		; extended partition (LBA aware) ?
   518 000002EB 7441                <1> 	je .push		; yes -->
   519 000002ED 247F                <1> 	and al, ~80h		; extended partition Linux (85h) ?
   520 000002EF 3C05                <1> 	cmp al, 05h		;  or extended partition DOS (05h) ?
   521 000002F1 743B                <1> 	je .push		; yes -->
   522                              <1> .notextended:
   523                              <1> 
   524                              <1> %ifidn _BASE, bp
   525 000002F3 395BFE              <1> 	cmp word [_BASE+di-2], bx
   526 000002F6 7505                <1> 	jne .logical
   527 000002F8 395BFC              <1> 	cmp word [_BASE+di-4], bx
   528                              <1> %else
   529                              <1> 	cmp word [_BASE+di-2], 0
   530                              <1> 	jne .logical
   531                              <1> 	cmp word [_BASE+di-4], 0
   532                              <1> %endif
   533 000002FB 741A                <1> 	je .next
   534                              <1> .logical:
   535                              <1> 
   536                              <1> %if _MODE
   537 000002FD F606[0425]20        <1> sptrel	testopt [ %[_SCANPTAB_PREFIX]load_scan_flags ], 32
   538                              <1> sptinternal -3			; had a logical partition yet ?
   539 00000302 7408                <1> 	jz .calllogical		; no, accept it -->
   540 00000304 F706[0225]8002      <1> sptrel	test word [ %[_SCANPTAB_PREFIX]load_mode ], strict word 		mode_ignore_subsequent_logical | mode_traditional_order_logical
   542                              <1> sptinternal -4			; ignore subsequent logical or post-trad run ?
   543 0000030A 750B                <1> 	jnz .ignorelogical	; yes, ignore it -->
   544                              <1> .calllogical:
   545                              <1> %endif
   546                              <1> 
   547 0000030C FE06[0025]          <1> sptrel	inc byte [ %[_SCANPTAB_PREFIX]load_current_partition]
   548                              <1> sptinternal
   549 00000310 7503E9F900          <1> 	jz .error_too_many_partitions
   550 00000315 FFD1                <1> 	call cx			; (sets load_scan_flags & 32 if recognised)
   551                              <1> 		; CHG: ax, (cx), dx, bx if _BASE = bp
   552                              <1> 		; preserve: (cx), si, di, ds, es, bx if _BASE = ss:bx
   553                              <1> .ignorelogical:
   554                              <1> .ignoreextended:
   555                              <1> .next:
   556 00000317 83C610              <1> 	add si, 16		; -> next partition table entry
   557 0000031A 81FE[F024]          <1> sptrel	cmp si, strict word %[_SCANPTAB_PREFIX]partition_table.end
   558                              <1> sptinternal			; was last?
   559 0000031E 7303E952FF          <1> 	jb .loop		; no, loop -->
   560 00000323 85FF                <1> 	test di, di		; still some on stack?
   561 00000325 7403E99700          <1> 	jnz .pop		; yes, pop
   562                              <1> .end:
   563                              <1> %ifidn _BASE, bp
   564 0000032A 89EC                <1> 	mov sp, bp		; restore sp
   565 0000032C 5D                  <1> 	pop bp
   566                              <1> %else
   567                              <1> 	mov sp, bx		; restore sp
   568                              <1> 	pop ax			; (discard dummy bp value)
   569                              <1> %endif
   570                              <1> %if _MODE && ! _SPT_MULTIPASS
   571                              <1> 	jmp scan_subsequent_primary
   572                              <1> %else
   573 0000032D C3                  <1> 	retn			; and bye
   574                              <1> %endif
   575                              <1> 
   576                              <1> 
   577                              <1> .push:
   578                              <1> d4	call %[_SCANPTAB_DEBUG4_PREFIX]d4message
   579                              <1> d4	asciz "In scan_logical.push",13,10
   580                              <1> 
   581                              <1> %if _SPT_ELD
   582 0000032E D006[0625]          <1> sptrel	rol byte [ %[_SCANPTAB_PREFIX]extended], 1
   583                              <1> sptinternal
   584 00000332 7327                <1> 	jnc @F
   585 00000334 F616[0D25]          <1> sptrel	not byte [ %[_SCANPTAB_PREFIX]load_is_extended]
   586                              <1> sptinternal
   587                              <1> 
   588 00000338 56                  <1> 	push si
   589 00000339 83EF0A              <1> 	sub di, 10			; address temporary root and base
   590 0000033C FF7308              <1> 	push word [_BASE+di+10-2]
   591 0000033F FF7306              <1> 	push word [_BASE+di+10-4]	; copy root as root
   592 00000342 FF7308              <1> 	push word [_BASE+di+10-2]
   593 00000345 FF7306              <1> 	push word [_BASE+di+10-4]	; copy root as base
   594                              <1> 		; Extended partitions always have LBA start values
   595                              <1> 		;  relative to the outermost extended partition.
   596                              <1> 		;  Therefore the "root" must be used as base for
   597                              <1> 		;  this call to always get the expected address
   598                              <1> 		;  from dword [bp - di - 8] + dword [es:si + 8].
   599                              <1> 
   600 00000348 FFD1                <1> 	call cx
   601                              <1> 
   602 0000034A 83C408              <1> 	add sp, 8			; discard temporary root and base
   603 0000034D 83C70A              <1> 	add di, 10			; point back to prior root and base
   604 00000350 5E                  <1> 	pop si				; undo last part of the stack frame
   605                              <1> 
   606 00000351 F616[0D25]          <1> sptrel	not byte [ %[_SCANPTAB_PREFIX]load_is_extended]
   607                              <1> sptinternal
   608 00000355 FE06[0C25]          <1> sptrel	inc byte [ %[_SCANPTAB_PREFIX]load_current_extended]
   609                              <1> sptinternal
   610                              <1> %ifidn _BASE, bp
   611 00000359 31DB                <1> 	xor bx, bx
   612                              <1> %endif
   613                              <1> @@:
   614                              <1> %endif
   615                              <1> 
   616 0000035B 56                  <1> 	push si
   617                              <1> .push_check_empty_next:
   618 0000035C 83C610              <1> 	add si, 16		; -> next
   619 0000035F 81FE[F024]          <1> sptrel	cmp si, strict word %[_SCANPTAB_PREFIX]partition_table.end
   620                              <1> sptinternal			; at end?
   621 00000363 7203E98400          <1> 	jae .replace		; yes, no other partitions found, replace -->
   622 00000368 26807C0400          <1> 	cmp byte [es:si + piType], 0	; is this a partition?
   623 0000036D 74ED                <1> 	je .push_check_empty_next	; no, check next -->
   624                              <1> 				; found a partition after this, do push
   625                              <1> 				; (possibly logical or another extended)
   626                              <1> .push_check_is_not_empty:
   627                              <1> d4	call %[_SCANPTAB_DEBUG4_PREFIX]d4message
   628                              <1> d4	asciz "In scan_logical.push_check_is_not_empty",13,10
   629                              <1> 
   630                              <1> %if _MODE
   631 0000036F 31C0                <1> 	xor ax, ax		; sentinel 0 = accept more logicals
   632                              <1> 
   633 00000371 F606[0325]02        <1> sptrel	testopt [ %[_SCANPTAB_PREFIX]load_mode ], mode_traditional_order_logical
   634                              <1> sptinternal -3
   635 00000376 750E                <1> 	jnz .traditionalsentinel
   636 00000378 F606[0425]20        <1> sptrel	testopt [ %[_SCANPTAB_PREFIX]load_scan_flags ], 32
   637                              <1> sptinternal -3			; had a logical partition in this table ?
   638 0000037D 7409                <1> 	jz @F			; no, no need to reset -->
   639 0000037F F606[0225]80        <1> sptrel	testopt [ %[_SCANPTAB_PREFIX]load_mode ], mode_ignore_subsequent_logical
   640                              <1> sptinternal -3			; ignore subsequent logical ?
   641 00000384 7402                <1> 	jz @F			; no -->
   642                              <1> .traditionalsentinel:
   643 00000386 B040                <1> 	mov al, 64		; sentinel 64 = no more logicals
   644                              <1> @@:
   645 00000388 8026[0425]DF        <1> sptrel	clropt [ %[_SCANPTAB_PREFIX]load_scan_flags ], 32
   646                              <1> sptinternal -3			; accept a logical partition in next table
   647                              <1> %endif
   648                              <1> 
   649 0000038D 5E                  <1> 	pop si			; restore -> partition table entry
   650                              <1> %if _MODE
   651 0000038E 26FF7408            <1> 	push word [es:si + piStart]
   652 00000392 268B540A            <1> 	mov dx, word [es:si + piStart + 2]	; get extended partition offset
   653 00000396 01C6                <1> 	add si, ax		; now -> behind partition_table if sentinel set
   654 00000398 58                  <1> 	pop ax
   655                              <1> %endif
   656 00000399 56                  <1> 	push si			; stored at word [_BASE+di-10]
   657 0000039A 83EF0A              <1> 	sub di, 10
   658 0000039D FF7308              <1> 	push word [_BASE+di+10-2]
   659 000003A0 FF7306              <1> 	push word [_BASE+di+10-4]	; copy root
   660                              <1> %ifn _MODE
   661                              <1> 	mov ax, word [es:si + piStart]
   662                              <1> 	mov dx, word [es:si + piStart + 2]	; get extended partition offset
   663                              <1> %endif
   664 000003A3 0343FC              <1> 	add ax, word [_BASE+di-4]
   665 000003A6 1353FE              <1> 	adc dx, word [_BASE+di-2]	; add in root to get absolute sector number
   666                              <1> 
   667 000003A9 52                  <1> 	push dx
   668 000003AA 50                  <1> 	push ax			; new base
   669                              <1> 
   670                              <1> .replace_common:
   671                              <1> %ifidn _BASE, bp
   672 000003AB 395BFE              <1> 	cmp word [_BASE+di-2], bx	; have a (nonzero) root?
   673 000003AE 750B                <1> 	jne .have_root
   674 000003B0 395BFC              <1> 	cmp word [_BASE+di-4], bx
   675                              <1> %else
   676                              <1> 	cmp word [_BASE+di-2], 0	; have a (nonzero) root?
   677                              <1> 	jne .have_root
   678                              <1> 	cmp word [_BASE+di-4], 0
   679                              <1> %endif
   680 000003B3 7506                <1> 	jne .have_root		; yes -->
   681                              <1> 
   682 000003B5 8953FE              <1> 	mov word [_BASE+di-2], dx
   683 000003B8 8943FC              <1> 	mov word [_BASE+di-4], ax	; set root
   684                              <1> .have_root:
   685                              <1> 
   686 000003BB E80D01              <1> 	call %[_SCANPTAB_PREFIX]read_partition_table.first
   687 000003BE E959FE              <1> 	jmp .
   688                              <1> 
   689                              <1> .pop:
   690                              <1> d4	call %[_SCANPTAB_DEBUG4_PREFIX]d4message
   691                              <1> d4	asciz "In scan_logical.pop",13,10
   692                              <1> 
   693                              <1> %if _MODE
   694 000003C1 800E[0425]10        <1> sptrel	setopt [ %[_SCANPTAB_PREFIX]load_scan_flags ], 16
   695                              <1> sptinternal -3			; remember we found a nested extended partition
   696                              <1> 				;  so we can ignore others in the same outermost
   697                              <1> %endif
   698                              <1> 
   699 000003C6 83C70A              <1> 	add di, 10
   700 000003C9 83C408              <1> 	add sp, 8
   701 000003CC 5E                  <1> 	pop si
   702                              <1> 
   703                              <1> %if _MODE
   704 000003CD 8026[0425]DF        <1> sptrel	clropt [ %[_SCANPTAB_PREFIX]load_scan_flags ], 32
   705                              <1> sptinternal -3			; accept a logical partition in this table
   706 000003D2 81FE[F024]          <1> sptrel	cmp si, 64 + %[_SCANPTAB_PREFIX]partition_table
   707                              <1> sptinternal			; sentinel set ?
   708 000003D6 7208                <1> 	jb @F			; no -->
   709 000003D8 800E[0425]20        <1> sptrel	setopt [ %[_SCANPTAB_PREFIX]load_scan_flags ], 32
   710                              <1> sptinternal -3			; do not accept a logical partition in this table
   711 000003DD 83EE40              <1> 	sub si, 64		; undo sentinel addition
   712                              <1> @@:
   713                              <1> %endif
   714 000003E0 8B43F8              <1> 	mov ax, word [_BASE+di-8]
   715 000003E3 8B53FA              <1> 	mov dx, word [_BASE+di-6]
   716 000003E6 E8E300              <1> 	call %[_SCANPTAB_PREFIX]read_partition_table.reload
   717 000003E9 E92BFF              <1> 	jmp .next
   718                              <1> 
   719                              <1> .replace:
   720                              <1> d4	call %[_SCANPTAB_DEBUG4_PREFIX]d4message
   721                              <1> d4	asciz "In scan_logical.replace",13,10
   722                              <1> %if _MODE
   723 000003EC 8026[0425]DF        <1> sptrel	clropt [ %[_SCANPTAB_PREFIX]load_scan_flags ], 32
   724                              <1> sptinternal -3			; accept a logical partition in next table
   725                              <1> %endif
   726                              <1> 
   727 000003F1 5E                  <1> 	pop si				; (discard)
   728                              <1> .replace_no_pop:
   729 000003F2 268B4408            <1> 	mov ax, word [es:si + piStart]
   730 000003F6 268B540A            <1> 	mov dx, word [es:si + piStart + 2]	; get extended partition offset
   731 000003FA 0343FC              <1> 	add ax, word [_BASE+di - 4]
   732 000003FD 1353FE              <1> 	adc dx, word [_BASE+di - 2]	; add in root
   733 00000400 8943F8              <1> 	mov word [_BASE+di - 8], ax
   734 00000403 8953FA              <1> 	mov word [_BASE+di - 6], dx	; set base
   735                              <1> 
   736 00000406 EBA3                <1> 	jmp .replace_common
   737                              <1> 
   738                              <1> 
   739                              <1> %if _BOOTCMD_FAIL_ERROR
   740                              <1> .got_partition_cycle:
   741 00000408 BA[4F02]            <1> sptrel	mov dx, msg.boot_partition_cycle_error
   742                              <1> sptinternal
   743 0000040B E9A105              <1> 	jmp bootcmd.fail
   744                              <1> 
   745                              <1> .error_too_many_partitions:
   746 0000040E BA[2C02]            <1> sptrel	mov dx, msg.boot_too_many_partitions_error
   747                              <1> sptinternal
   748 00000411 E99B05              <1> 	jmp bootcmd.fail
   749                              <1> %endif
   750                              <1> 
   751                              <1> 
   752                              <1> %if _MODE
   753                              <1> @@:
   754 00000414 C3                  <1> 	retn
   755                              <1> 
   756                              <1> scan_subsequent_primary:
   757 00000415 F606[0325]01        <1> sptrel	testopt [ %[_SCANPTAB_PREFIX]load_mode ], mode_ignore_subsequent_primary
   758                              <1> sptinternal -3			; ignore subsequent primary ?
   759 0000041A 75F8                <1> 	jnz @B			; yes -->
   760 0000041C F606[0325]08        <1> sptrel	testopt [ %[_SCANPTAB_PREFIX]load_mode ], mode_subsequent_primary_after
   761                              <1> sptinternal -3			; subsequent after ?
   762 00000421 74F1                <1> 	jz @B			; no -->
   763                              <1> 
   764 00000423 55                  <1> 	push bp
   765                              <1> %ifidn _BASE, ss:bx
   766                              <1> 	mov bx, sp
   767                              <1> %elifidn _BASE, bp
   768 00000424 89E5                <1> 	mov bp, sp
   769                              <1> %endif
   770 00000426 31FF                <1> 	xor di, di
   771 00000428 57                  <1> 	push di		; [_BASE+di-2]
   772 00000429 57                  <1> 	push di		; [_BASE+di-4]
   773 0000042A 57                  <1> 	push di		; [_BASE+di-6]
   774 0000042B 57                  <1> 	push di		; [_BASE+di-8]
   775                              <1> 
   776                              <1> %if ! _SPT_MULTIPASS
   777                              <1> sptrel	mov word [ %[_SCANPTAB_PREFIX]load_scan_flags ], di
   778                              <1> sptinternal
   779                              <1> %endif
   780                              <1> 
   781 0000042C 31C0                <1> 	xor ax, ax
   782 0000042E 31D2                <1> 	xor dx, dx
   783                              <1> 
   784                              <1> %if _SPT_MULTIPASS
   785 00000430 A3[0425]            <1> sptrel	mov word [ %[_SCANPTAB_PREFIX]load_scan_flags ], ax
   786                              <1> sptinternal
   787                              <1> %endif
   788                              <1> 
   789 00000433 E89600              <1> 	call %[_SCANPTAB_PREFIX]read_partition_table.reload
   790                              <1> 				; (re)read MBR
   791 00000436 BE[B024]            <1> sptrel	mov si, %[_SCANPTAB_PREFIX]partition_table
   792                              <1> sptinternal
   793 00000439 8816[0025]          <1> sptrel	mov byte [ %[_SCANPTAB_PREFIX]load_current_partition], dl	; = 0
   794                              <1> sptinternal
   795                              <1> %if _SPT_ELD
   796 0000043D 8916[0C25]          <1> sptrel	mov word [ %[_SCANPTAB_PREFIX]load_current_extended_and_is], dx	; = 0
   797                              <1> sptinternal
   798                              <1> %endif
   799                              <1> 
   800 00000441 F606[0325]04        <1> sptrel	testopt [ %[_SCANPTAB_PREFIX]load_mode ], mode_active_priority
   801                              <1> sptinternal -3			; active primary first ?
   802 00000446 742A                <1> 	jz .detect_lowest
   803                              <1> 
   804                              <1> .loop_active_skip:
   805                              <1> 
   806 00000448 FE06[0025]          <1> sptrel	inc byte [ %[_SCANPTAB_PREFIX]load_current_partition]
   807                              <1> sptinternal
   808 0000044C 268A4404            <1> 	mov al, byte [es:si + piType]
   809 00000450 3C00                <1> 	cmp al, 0
   810 00000452 7415                <1> 	je .loop_active_skip_skip
   811 00000454 26803C00            <1> 	cmp byte [es:si + piBoot], 0
   812 00000458 740F                <1> 	je .loop_active_skip_skip
   813                              <1> 
   814                              <1> 		; INP:	al = partition type
   815                              <1> 		; OUT:	CY if an LBA or FAT32 type that's disabled
   816                              <1> 		;	NC, ZR if known type we can access
   817                              <1> 		;	NC, NZ if unknown type
   818 0000045A E8B504              <1> 	call %[_SCANPTAB_PREFIX]load_is_known
   819 0000045D 720A                <1> 	jc .loop_active_skip_skip
   820 0000045F 7508                <1> 	jnz .loop_active_skip_skip
   821 00000461 A0[0025]            <1> sptrel	mov al, byte [ %[_SCANPTAB_PREFIX]load_current_partition]
   822                              <1> sptinternal
   823 00000464 A2[0525]            <1> sptrel	mov byte [ %[_SCANPTAB_PREFIX]load_scan_flags + 1], al
   824                              <1> sptinternal
   825 00000467 EB37                <1> 	jmp .active_skip_done
   826                              <1> 
   827                              <1> .loop_active_skip_skip:
   828 00000469 83C610              <1> 	add si, 16
   829 0000046C 81FE[F024]          <1> sptrel	cmp si, strict word %[_SCANPTAB_PREFIX]partition_table.end
   830                              <1> sptinternal
   831 00000470 72D6                <1> 	jb .loop_active_skip
   832                              <1> 
   833                              <1> .detect_lowest:
   834 00000472 BE[B024]            <1> sptrel	mov si, %[_SCANPTAB_PREFIX]partition_table
   835                              <1> sptinternal
   836 00000475 C606[0025]00        <1> sptrel	mov byte [ %[_SCANPTAB_PREFIX]load_current_partition], 0
   837                              <1> sptinternal -3
   838                              <1> 
   839                              <1> .loop_lowest:
   840 0000047A FE06[0025]          <1> sptrel	inc byte [ %[_SCANPTAB_PREFIX]load_current_partition]
   841                              <1> sptinternal
   842 0000047E 268A4404            <1> 	mov al, byte [es:si + piType]
   843 00000482 3C00                <1> 	cmp al, 0
   844 00000484 740F                <1> 	je .loop_lowest_skip_skip
   845                              <1> 
   846                              <1> 		; INP:	al = partition type
   847                              <1> 		; OUT:	CY if an LBA or FAT32 type that's disabled
   848                              <1> 		;	NC, ZR if known type we can access
   849                              <1> 		;	NC, NZ if unknown type
   850 00000486 E88904              <1> 	call %[_SCANPTAB_PREFIX]load_is_known
   851 00000489 720A                <1> 	jc .loop_lowest_skip_skip
   852 0000048B 7508                <1> 	jnz .loop_lowest_skip_skip
   853 0000048D A0[0025]            <1> sptrel	mov al, byte [ %[_SCANPTAB_PREFIX]load_current_partition]
   854                              <1> sptinternal
   855 00000490 A2[0525]            <1> sptrel	mov byte [ %[_SCANPTAB_PREFIX]load_scan_flags + 1], al
   856                              <1> sptinternal
   857 00000493 EB0B                <1> 	jmp .lowest_skip_done
   858                              <1> 
   859                              <1> .loop_lowest_skip_skip:
   860 00000495 83C610              <1> 	add si, 16
   861 00000498 81FE[F024]          <1> sptrel	cmp si, strict word %[_SCANPTAB_PREFIX]partition_table.end
   862                              <1> sptinternal
   863 0000049C 72DC                <1> 	jb .loop_lowest
   864 0000049E EB27                <1> 	jmp .end		; none found
   865                              <1> 
   866                              <1> .lowest_skip_done:
   867                              <1> .active_skip_done:
   868 000004A0 BE[B024]            <1> sptrel	mov si, %[_SCANPTAB_PREFIX]partition_table
   869                              <1> sptinternal
   870 000004A3 C606[0025]00        <1> sptrel	mov byte [ %[_SCANPTAB_PREFIX]load_current_partition], 0
   871                              <1> sptinternal -3
   872                              <1> 
   873                              <1> .loop_primary_parts:
   874 000004A8 FE06[0025]          <1> sptrel	inc byte [ %[_SCANPTAB_PREFIX]load_current_partition]
   875                              <1> sptinternal
   876 000004AC 26807C0400          <1> 	cmp byte [es:si + piType], 0
   877 000004B1 740B                <1> 	je .loop_primary_skip
   878                              <1> 
   879                              <1> %if _MODE
   880 000004B3 A0[0025]            <1> sptrel	mov al, byte [ %[_SCANPTAB_PREFIX]load_current_partition]
   881                              <1> sptinternal
   882 000004B6 3806[0525]          <1> sptrel	cmp byte [ %[_SCANPTAB_PREFIX]load_scan_flags + 1], al
   883                              <1> sptinternal
   884 000004BA 7402                <1> 	je .ignoreprimary
   885                              <1> %endif
   886 000004BC FFD1                <1> 	call cx			; es:si -> partition table entry
   887                              <1> 				; byte [load_current_partition] = which
   888                              <1> .ignoreprimary:
   889                              <1> .loop_primary_skip:
   890 000004BE 83C610              <1> 	add si, 16
   891 000004C1 81FE[F024]          <1> sptrel	cmp si, strict word %[_SCANPTAB_PREFIX]partition_table.end
   892                              <1> sptinternal
   893 000004C5 72E1                <1> 	jb .loop_primary_parts
   894                              <1> 
   895                              <1> .end:
   896                              <1> %ifidn _BASE, bp
   897 000004C7 89EC                <1> 	mov sp, bp		; restore sp
   898 000004C9 5D                  <1> 	pop bp
   899                              <1> %else
   900                              <1> 	mov sp, bx		; restore sp
   901                              <1> 	pop ax			; (discard dummy bp value)
   902                              <1> %endif
   903 000004CA C3                  <1> 	retn
   904                              <1> %endif
   905                              <1> 
   906                              <1> 
   907                              <1> 		; if _PARTITION_TABLE_IN_CS:
   908                              <1> 		; INP:  dx:ax = partition table sector to read
   909                              <1> 		; CHG:	ax, dx
   910                              <1> 		; OUT:  es = cs
   911                              <1> 		;       64 bytes [es:partition_table] = partition table
   912                              <1> 		;       does not return if error
   913                              <1> 
   914                              <1> 		; else:
   915                              <1> 		; INP:  dx:ax = partition table sector to read
   916                              <1> 		; CHG:	ax, dx
   917                              <1> 		; OUT:  es = ss
   918                              <1> 		;       64 bytes [es:partition_table] = partition table
   919                              <1> 		;       does not return if error
   920                              <1> %[_SCANPTAB_PREFIX]read_partition_table:
   921                              <1> %if _SPT_ELD
   922                              <1> .first:
   923 000004CB A8                  <1> 	db __TEST_IMM8			; NC, skip stc
   924                              <1> .reload:
   925 000004CC F9                  <1> 	stc
   926                              <1> %else
   927                              <1> .first:
   928                              <1> .reload:
   929                              <1> %endif
   930                              <1> 
   931 000004CD 53                  <1> 	push bx
   932                              <1> %if _SPT_ELD
   933 000004CE 8B1E[F424]          <1> sptrel	mov bx, word [buffersegment]
   934                              <1> sptinternal
   935                              <1> %elifidn _BASE, bp
   936                              <1> 	mov bx, word [auxbuff_segorsel]	; bx => auxbuff
   937                              <1> %else
   938                              <1> 	mov bx, word [bp + ldSectorSeg]
   939                              <1> %endif
   940 000004D2 E87F06              <1> 	call %[_SCANPTAB_PREFIX]read_ae_512_bytes
   941 000004D5 5B                  <1> 	pop bx
   942 000004D6 26813EFE0155AA      <1> 	cmp word [es:510], 0AA55h
   943 000004DD 7518                <1> 	jne .signature_fail
   944 000004DF 1E                  <1> 	 push ds
   945 000004E0 57                  <1> 	 push di
   946 000004E1 56                  <1> 	 push si
   947 000004E2 51                  <1> 	 push cx
   948 000004E3 06                  <1> 	push es
   949 000004E4 1F                  <1> 	pop ds
   950 000004E5 BEBE01              <1> 	mov si, 510 - 4*16		; ds:si -> partition table in sectorseg
   951                              <1> %if _PARTITION_TABLE_IN_CS
   952                              <1> 	push cs
   953                              <1> %else
   954 000004E8 16                  <1> 	push ss
   955                              <1> %endif
   956 000004E9 07                  <1> 	pop es
   957 000004EA BF[B024]            <1> sptrel	mov di, %[_SCANPTAB_PREFIX]partition_table
   958                              <1> sptinternal				; es:di -> cs:%[_SCANPTAB_PREFIX]partition_table
   959 000004ED B92000              <1> 	mov cx, 4*16 / 2
   960 000004F0 F3A5                <1> 	rep movsw
   961 000004F2 59                  <1> 	 pop cx
   962 000004F3 5E                  <1> 	 pop si
   963 000004F4 5F                  <1> 	 pop di
   964 000004F5 1F                  <1> 	 pop ds
   965 000004F6 C3                  <1> 	retn
   966                              <1> 
   967                              <1> 
   968                              <1> %if _BOOTCMD_FAIL_ERROR
   969                              <1> .signature_fail:
   970 000004F7 BA[F801]            <1> sptrel	mov dx, msg.bootfail_sig_parttable
   971                              <1> sptinternal
   972 000004FA E9B204              <1> 	jmp bootcmd.fail
   973                              <1> %endif
   209                                  resetdef DEBUG4
   210                                  
   211                                  
   212                                  run:
   213 000004FD 16                      	push ss
   214 000004FE 07                      	pop es
   215                                  
   216 000004FF E8D607                  	extcallcall ispm
   217 00000502 7503                    	jnz @F
   218 00000504 E8D907                  	extcallcall error
   219                                  @@:
   220                                  
   221 00000507 31C0                    	xor ax, ax
   222 00000509 A3[F024]                reloc	mov word [heads], ax
   223                                  internaldatarelocation
   224 0000050C A3[F224]                reloc	mov word [sectors], ax
   225                                  internaldatarelocation
   226                                  
   227 0000050F BA[3800]                reloc	mov dx, msg.walk
   228                                  internaldatarelocation
   229 00000512 E89B07                  	extcallcall isstring?
   230 00000515 7503E96A01              	je walk
   231                                  
   232 0000051A BA[A400]                reloc	mov dx, msg.geometry
   233                                  internaldatarelocation
   234 0000051D E89007                  	extcallcall isstring?
   235 00000520 7503E92104              	je geometry
   236                                  
   237 00000525 B180                    	mov cl, 80h
   238                                  .loop:
   239                                  .heads:
   240 00000527 BA[B200]                reloc	mov dx, msg.heads
   241                                  internaldatarelocation
   242 0000052A E88307                  	extcallcall isstring?
   243 0000052D 7524                    	jne .sectors
   244                                  @@:
   245 0000052F E87607                  	extcallcall skipcomma
   246 00000532 3C3D                    	cmp al, '='
   247 00000534 74F9                    	je @B
   248 00000536 E8AF07                  	extcallcall getword
   249 00000539 E8B407                  	extcallcall skipcomm0
   250                                  
   251 0000053C 81FA0001                	cmp dx, 256
   252 00000540 7603E93201              	ja .invalid
   253 00000545 85D2                    	test dx, dx
   254 00000547 7503E92B01              	jz .invalid
   255                                  
   256 0000054C 8916[F024]              reloc	mov word [heads], dx
   257                                  internaldatarelocation
   258 00000550 4E                      	dec si
   259 00000551 EBD4                    	jmp .loop
   260                                  
   261                                  .sectors:
   262 00000553 BA[B800]                reloc	mov dx, msg.sectors
   263                                  internaldatarelocation
   264 00000556 E85707                  	extcallcall isstring?
   265 00000559 7525                    	jne .unit
   266                                  @@:
   267 0000055B E84A07                  	extcallcall skipcomma
   268 0000055E 3C3D                    	cmp al, '='
   269 00000560 74F9                    	je @B
   270 00000562 E89307                  	extcallcall getbyte
   271 00000565 E88807                  	extcallcall skipcomm0
   272                                  
   273 00000568 B600                    	mov dh, 0
   274 0000056A 83FA3F                  	cmp dx, 63
   275 0000056D 7603E90501              	ja .invalid
   276 00000572 85D2                    	test dx, dx
   277 00000574 7503E9FE00              	jz .invalid
   278                                  
   279 00000579 8916[F224]              reloc	mov word [sectors], dx
   280                                  internaldatarelocation
   281 0000057D 4E                      	dec si
   282 0000057E EBA7                    	jmp .loop
   283                                  
   284                                  .unit:
   285 00000580 BA[AD00]                reloc	mov dx, msg.unit
   286                                  internaldatarelocation
   287 00000583 E82A07                  	extcallcall isstring?
   288 00000586 7512                    	jne @FF
   289                                  @@:
   290 00000588 E81D07                  	extcallcall skipcomma
   291 0000058B 3C3D                    	cmp al, '='
   292 0000058D 74F9                    	je @B
   293 0000058F E86607                  	extcallcall getbyte
   294 00000592 E85B07                  	extcallcall skipcomm0
   295 00000595 88D1                    	mov cl, dl
   296 00000597 4E                      	dec si
   297 00000598 EB8D                    	jmp .loop
   298                                  
   299                                  @@:
   300 0000059A AC                      	lodsb
   301 0000059B E86207                  	extcallcall getdword
   302 0000059E E81F07                  	extcallcall chkeol
   303                                  
   304                                  .entry_bxdx_cl:
   305 000005A1 53                      	push bx
   306 000005A2 52                      	push dx
   307                                  
   308 000005A3 31C0                    	xor ax, ax
   309 000005A5 3906[F024]              reloc	cmp word [heads], ax
   310                                  internaldatarelocation
   311 000005A9 7406                    	je @F
   312 000005AB 3906[F224]              reloc	cmp word [sectors], ax
   313                                  internaldatarelocation
   314 000005AF 752F                    	jne .no_query
   315                                  
   316                                  @@:
   317 000005B1 B408                    	mov ah, 08h
   318 000005B3 88CA                    	mov dl, cl
   319 000005B5 F9                      	stc
   320 000005B6 CD13                    	int 13h
   321 000005B8 16                      	push ss
   322 000005B9 07                      	pop es
   323 000005BA 7303E9B600              	jc .invalid_pop_2
   324 000005BF 83E13F                  	and cx, 3Fh
   325 000005C2 7503E9AE00              	jz .invalid_pop_2
   326                                  
   327 000005C7 833E[F224]00            reloc	cmp word [sectors], strict byte 0
   328                                  internaldatarelocation -3
   329 000005CC 7504                    	jne @F
   330 000005CE 890E[F224]              reloc	mov word [sectors], cx
   331                                  internaldatarelocation
   332                                  @@:
   333 000005D2 88F1                    	mov cl, dh
   334 000005D4 41                      	inc cx
   335 000005D5 833E[F024]00            reloc	cmp word [heads], strict byte 0
   336                                  internaldatarelocation -3
   337 000005DA 7504                    	jne @F
   338 000005DC 890E[F024]              reloc	mov word [heads], cx
   339                                  internaldatarelocation
   340                                  @@:
   341                                  
   342                                  .no_query:
   343 000005E0 5D                      	pop bp
   344 000005E1 5E                      	pop si			; si:bp = tuple
   345                                  				; (sil67:sih = C, bph = H, sil05 = S)
   346                                  
   347 000005E2 BF[0000]                reloc	mov di, relocateddata
   348                                  linkdatarelocation line_out
   349                                  
   350 000005E5 B84348                  	mov ax, "CH"
   351 000005E8 AB                      	stosw
   352 000005E9 B85320                  	mov ax, "S "
   353 000005EC AB                      	stosw
   354                                  
   355 000005ED 89F0                    	mov ax, si		; al67:ah = C
   356 000005EF 86C4                    	xchg al, ah		; ah67:al = C
   357 000005F1 B106                    	mov cl, 6
   358 000005F3 D2EC                    	shr ah, cl		; ax = C
   359                                  
   360 000005F5 E81007                  	extcallcall hexword
   361 000005F8 C6053A                  	mov byte [di], ':'
   362 000005FB 47                      	inc di
   363                                  
   364 000005FC F726[F024]              reloc	mul word [heads]
   365                                  internaldatarelocation
   366 00000600 89E9                    	mov cx, bp		; ch = H
   367 00000602 86CD                    	xchg cl, ch
   368 00000604 B500                    	mov ch, 0		; cx = H
   369 00000606 91                      	xchg ax, cx		; ax = H
   370                                  
   371 00000607 E80607                  	extcallcall hexbyte
   372 0000060A C6053A                  	mov byte [di], ':'
   373 0000060D 47                      	inc di
   374                                  
   375 0000060E 01C8                    	add ax, cx
   376 00000610 83D200                  	adc dx, 0
   377                                  
   378 00000613 93                      	xchg ax, bx		; bx = low word
   379 00000614 92                      	xchg ax, dx		; ax = high word
   380 00000615 F726[F224]              reloc	mul word [sectors]	; dx:ax = ax = high word result
   381                                  internaldatarelocation
   382 00000619 93                      	xchg ax, bx		; ax = low word, bx = high word result
   383 0000061A F726[F224]              reloc	mul word [sectors]	; dx:ax = low word result plus overflow
   384                                  internaldatarelocation
   385 0000061E 01DA                    	add dx, bx		; dx:ax = result
   386                                  
   387 00000620 89F1                    	mov cx, si		; cl05 = S
   388 00000622 83E13F                  	and cx, 3Fh		; cx = S
   389 00000625 49                      	dec cx			; 1-based
   390 00000626 784F                    	js .invalid
   391                                  
   392 00000628 91                      	xchg ax, cx		; ax = S
   393                                  
   394 00000629 E8E406                  	extcallcall hexbyte
   395 0000062C C705203D                	mov word [di], " ="
   396 00000630 C74502204C              	mov word [di + 2], " L"
   397 00000635 C745044241              	mov word [di + 4], "BA"
   398 0000063A C6450620                	mov byte [di + 6], " "
   399 0000063E 83C707                  	add di, 7
   400                                  
   401 00000641 01C8                    	add ax, cx
   402 00000643 83D200                  	adc dx, 0
   403                                  
   404 00000646 E80400                  	call store_lba
   405 00000649 E8CC06                  	extcallcall putsline_crlf
   406 0000064C C3                      	retn
   407                                  
   408                                  
   409                                  store_lba: equ $
   410 0000064D 92                      	xchg ax, dx
   411 0000064E E8B706                  	extcallcall hexword
   412 00000651 C6055F                  	mov byte [di], '_'
   413 00000654 47                      	inc di
   414 00000655 92                      	xchg dx, ax
   415 00000656 E8AF06                  	extcallcall hexword
   416                                  
   417 00000659 C705203D                	mov word [di], " ="
   418 0000065D AF                      	scasw			; di += 2
   419 0000065E B90002                  	mov cx, 512
   420 00000661 BB0900                  	mov bx, 9
   421 00000664 E8B906                  	extcallcall disp_dxax_times_cx_width_bx_size.store
   422 00000667 8036[0100]10            reloc	xor byte [relocateddata + 1], 10h
   423                                  linkdatarelocation options, -3
   424 0000066C E8B106                  	extcallcall disp_dxax_times_cx_width_bx_size.store
   425 0000066F 8036[0100]10            reloc	xor byte [relocateddata + 1], 10h
   426                                  linkdatarelocation options, -3
   427 00000674 C3                      	retn
   428                                  
   429                                  
   430                                  .invalid_pop_2:
   431 00000675 58                      	pop ax
   432 00000676 58                      	pop ax
   433                                  .invalid:
   434 00000677 BA[EB00]                reloc	mov dx, msg.invalid
   435                                  internaldatarelocation
   436 0000067A E84B06                  	extcallcall putsz
   437 0000067D B8650E                  	mov ax, 0E65h
   438 00000680 E84D06                  	extcallcall setrc
   439 00000683 C3                      	retn
   440                                  
   441                                  walk:
   442 00000684 AC                      	lodsb
   443 00000685 E87006                  	extcallcall getbyte
   444 00000688 8816[FC24]              reloc	mov byte [load_unit], dl
   445                                  internaldatarelocation
   446 0000068C 8816[FF24]              reloc	mov byte [upto], dl
   447                                  internaldatarelocation
   448                                  
   449 00000690 BF[0225]                reloc	mov di, zeroing
   450                                  internaldatarelocation
   451 00000693 31C0                    	xor ax, ax
   452 00000695 B90500                  	mov cx, words(zeroing_end - zeroing)	; may overflow one byte
   453 00000698 F3AB                    	rep stosw
   454 0000069A 4E                      	dec si
   455                                  .parse:
   456 0000069B E80A06                  	extcallcall skipcomma
   457 0000069E 4E                      	dec si
   458 0000069F BB[0400]                reloc	mov bx, keywordtable
   459                                  internaldatarelocation
   460                                  .parse_loop:
   461 000006A2 8B17                    	mov dx, [bx]
   462 000006A4 E80906                  	extcallcall isstring?
   463 000006A7 7508                    	jne @F
   464 000006A9 8B5F02                  	mov bx, [bx + 2]
   465 000006AC C607FF                  	mov byte [bx], -1
   466 000006AF EBEA                    	jmp .parse
   467                                  
   468                                  @@:
   469 000006B1 83C304                  	add bx, 4
   470 000006B4 81FB[1C00]              reloc	cmp bx, strict word keywordtable.end
   471                                  internaldatarelocation
   472 000006B8 72E8                    	jb .parse_loop
   473                                  
   474 000006BA BA[6600]                reloc	mov dx, msg.mode
   475                                  internaldatarelocation
   476 000006BD E8F005                  	extcallcall isstring?
   477 000006C0 7555                    	jne .notmode
   478                                  @@:
   479 000006C2 E8E305                  	extcallcall skipcomma
   480 000006C5 3C3D                    	cmp al, '='
   481 000006C7 74F9                    	je @B
   482 000006C9 4E                      	dec si
   483 000006CA BB[1C00]                reloc	mov bx, modetable
   484                                  internaldatarelocation
   485                                  .mode_loop:
   486 000006CD 8B17                    	mov dx, [bx]
   487 000006CF E8DE05                  	extcallcall isstring?
   488 000006D2 7509                    	jne @F
   489 000006D4 8B5F02                  	mov bx, [bx + 2]
   490 000006D7 891E[0225]              reloc	mov word [mode], bx
   491                                  internaldatarelocation
   492 000006DB EBBE                    	jmp .parse
   493                                  
   494                                  @@:
   495 000006DD 83C304                  	add bx, 4
   496 000006E0 81FB[3800]              reloc	cmp bx, strict word modetable.end
   497                                  internaldatarelocation
   498 000006E4 72E7                    	jb .mode_loop
   499                                  
   500 000006E6 AC                      	lodsb
   501 000006E7 88C3                    	mov bl, al
   502 000006E9 3C2B                    	cmp al, '+'
   503 000006EB 7407                    	je @F
   504 000006ED 3C2D                    	cmp al, '-'
   505 000006EF 7403                    	je @F
   506 000006F1 B300                    	mov bl, 0
   507 000006F3 4E                      	dec si
   508                                  @@:
   509 000006F4 AC                      	lodsb
   510 000006F5 E8F005                  	call getword
   511 000006F8 4E                      	dec si
   512 000006F9 80FB2D                  	cmp bl, '-'
   513 000006FC 7411                    	je .modeclear
   514 000006FE 80FB2B                  	cmp bl, '+'
   515 00000701 7406                    	je .modeset
   516                                  .modereplace:
   517 00000703 8916[0225]              reloc	mov word [mode], dx
   518                                  internaldatarelocation
   519 00000707 EB92                    	jmp .parse
   520                                  
   521                                  .modeset:
   522 00000709 0916[0225]              reloc	or word [mode], dx
   523                                  internaldatarelocation
   524 0000070D EB8C                    	jmp .parse
   525                                  
   526                                  .modeclear:
   527 0000070F F7D2                    	not dx
   528 00000711 2116[0225]              reloc	and word [mode], dx
   529                                  internaldatarelocation
   530 00000715 EB84                    	jmp .parse
   531                                  
   532                                  .notmode:
   533 00000717 BA[6100]                reloc	mov dx, msg.upto
   534                                  internaldatarelocation
   535 0000071A E89305                  	extcallcall isstring?
   536 0000071D 7512                    	jne .notupto
   537                                  @@:
   538 0000071F E88605                  	extcallcall skipcomma
   539 00000722 3C3D                    	cmp al, '='
   540 00000724 74F9                    	je @B
   541 00000726 E8CF05                  	call getbyte
   542 00000729 8816[FF24]              reloc	mov byte [upto], dl
   543                                  internaldatarelocation
   544 0000072D 4E                      	dec si
   545 0000072E E96AFF                  	jmp .parse
   546                                  
   547                                  .notupto:
   548 00000731 AC                      	lodsb
   549 00000732 E88B05                  	extcallcall chkeol
   550                                  
   551 00000735 8CD0                    	mov ax, ss
   552 00000737 BB[A004]                reloc	mov bx, buffer + 512 - 16
   553                                  internaldatarelocation
   554 0000073A B104                    	mov cl, 4
   555 0000073C D3EB                    	shr bx, cl
   556 0000073E 01D8                    	add ax, bx
   557 00000740 83E0E0                  	and ax, ~ (paras(512) - 1)
   558 00000743 A3[F424]                reloc	mov word [buffersegment], ax
   559                                  internaldatarelocation
   560                                  
   561                                  %if _SPT_MULTIPASS
   562 00000746 F606[0325]80            reloc	testopt [load_mode], mode_dlasort_zero
   563                                  internaldatarelocation -3
   564 0000074B 7442                    	jz .once
   565                                  
   566 0000074D BB[D900]                reloc	mov bx, scan_priority_primary
   567                                  internalcoderelocation
   568 00000750 E81300                  	call .pass
   569 00000753 BB[5B01]                reloc	mov bx, scan_early_primary
   570                                  internalcoderelocation
   571 00000756 E80D00                  	call .pass
   572 00000759 BB[FB01]                reloc	mov bx, scan_logical
   573                                  internalcoderelocation
   574 0000075C E80700                  	call .pass
   575 0000075F BB[1504]                reloc	mov bx, scan_subsequent_primary
   576                                  internalcoderelocation
   577 00000762 E80100                  	call .pass
   578 00000765 C3                      	retn
   579                                  
   580                                  
   581                                  .pass:
   582 00000766 FF36[FC24]              reloc	push word [load_unit]
   583                                  internaldatarelocation
   584                                  .passloop:
   585 0000076A 31C0                    	xor ax, ax
   586 0000076C A3[F624]                reloc	mov word [load_partition_cycle], ax
   587                                  internaldatarelocation
   588 0000076F 53                      	push bx
   589 00000770 E85202                  	call query_geometry
   590 00000773 5B                      	pop bx
   591                                  
   592 00000774 53                      	push bx
   593 00000775 B9[BF07]                reloc	mov cx, .each
   594                                  internalcoderelocation
   595 00000778 FFD3                    	call bx
   596 0000077A 5B                      	pop bx
   597                                  
   598 0000077B A0[FF24]                reloc	mov al, [upto]
   599                                  internaldatarelocation
   600 0000077E 3A06[FC24]              reloc	cmp al, [load_unit]
   601                                  internaldatarelocation
   602 00000782 7606                    	jbe .passdone
   603 00000784 FE06[FC24]              reloc	inc byte [load_unit]
   604                                  internaldatarelocation
   605 00000788 EBE0                    	jmp .passloop
   606                                  
   607                                  .passdone:
   608 0000078A 8F06[FC24]              reloc	pop word [load_unit]
   609                                  internaldatarelocation
   610 0000078E C3                      	retn
   611                                  
   612                                  
   613                                  .once:
   614                                  .loop:
   615 0000078F 31C0                    	xor ax, ax
   616 00000791 A3[F624]                reloc	mov word [load_partition_cycle], ax
   617                                  internaldatarelocation
   618                                  
   619 00000794 E82E02                  	call query_geometry
   620                                  
   621 00000797 B9[BF07]                reloc	mov cx, .each
   622                                  internalcoderelocation
   623 0000079A E83CF9                  	call scan_priority_primary
   624 0000079D B9[BF07]                reloc	mov cx, .each
   625                                  internalcoderelocation
   626 000007A0 E8B8F9                  	call scan_early_primary
   627 000007A3 B9[BF07]                reloc	mov cx, .each
   628                                  internalcoderelocation
   629 000007A6 E852FA                  	call scan_logical
   630 000007A9 B9[BF07]                reloc	mov cx, .each
   631                                  internalcoderelocation
   632 000007AC E866FC                  	call scan_subsequent_primary
   633                                  %else
   634                                  .loop:
   635                                  	xor ax, ax
   636                                  reloc	mov word [load_partition_cycle], ax
   637                                  internaldatarelocation
   638                                  
   639                                  	call query_geometry
   640                                  
   641                                  reloc	mov cx, .each
   642                                  internalcoderelocation
   643                                  	call scan_partitions
   644                                  %endif
   645                                  
   646 000007AF A0[FF24]                reloc	mov al, [upto]
   647                                  internaldatarelocation
   648 000007B2 3A06[FC24]              reloc	cmp al, [load_unit]
   649                                  internaldatarelocation
   650 000007B6 7606                    	jbe .ret
   651 000007B8 FE06[FC24]              reloc	inc byte [load_unit]
   652                                  internaldatarelocation
   653 000007BC EBD1                    	jmp .loop
   654                                  
   655                                  .ret:
   656 000007BE C3                      	retn
   657                                  
   658                                  
   659                                  		; INP:	es:si -> partition table entry,
   660                                  		;	 si = load_partition_table .. load_partition_table+48,
   661                                  		;	 es = ss
   662                                  		;	bp + di -> above part table metadata,
   663                                  		;	 dwo [bp + di - 4] = root (outermost extended position)
   664                                  		;	 dwo [bp + di - 8] = base (current table position)
   665                                  		; CHG:	ax, bx, (cx), dx
   666                                  .each:
   667                                  	houdini
   668                                  
   669 000007BF 8B43F8                  	mov ax, [bp + di - 8]
   670 000007C2 8B53FA                  	mov dx, [bp + di - 6]		; base (current table position)
   671                                  
   672 000007C5 26034408                	add ax, [es:si + 8]
   673 000007C9 2613540A                	adc dx, [es:si + 8 + 2]		; add offset to logical partition
   674                                  
   675 000007CD 51                      	push cx
   676 000007CE 57                      	push di
   677 000007CF 55                      	push bp
   678                                  
   679 000007D0 52                      	push dx
   680 000007D1 50                      	push ax
   681                                  
   682 000007D2 56                      	push si
   683                                  
   684 000007D3 26FF740E                	push word [es:si + 12 + 2]
   685 000007D7 26FF740C                	push word [es:si + 12]
   686                                  
   687 000007DB 50                      	push ax
   688                                  
   689 000007DC BF[0000]                reloc	mov di, relocateddata
   690                                  linkdatarelocation line_out
   691                                  
   692 000007DF B054                    	mov al, 'T'
   693 000007E1 AA                      	stosb
   694                                  
   695 000007E2 268A4404                	mov al, byte [es:si + piType]
   696                                  
   697 000007E6 D006[0B25]              reloc	rol byte [skipext], 1
   698                                  internaldatarelocation
   699 000007EA 730C                    	jnc .nocheckext
   700                                  .skipext:
   701 000007EC 3C05                    	cmp al, 5
   702 000007EE 740D                    	je .discard
   703 000007F0 3C0F                    	cmp al, 15
   704 000007F2 7409                    	je .discard
   705 000007F4 3C85                    	cmp al, 85h
   706 000007F6 7405                    	je .discard
   707                                  .nocheckext:
   708                                  
   709                                  %if _MODE
   710 000007F8 E81701                  	call load_is_known
   711 000007FB 730A                    	jnc @F
   712                                  %else
   713                                  	jmp @F
   714                                  %endif
   715                                  
   716                                  .discard:
   717 000007FD 83C406                  	add sp, 6
   718 00000800 5E                      	pop si
   719 00000801 58                      	pop ax
   720 00000802 5A                      	pop dx
   721 00000803 5D                      	pop bp
   722 00000804 5F                      	pop di
   723 00000805 59                      	pop cx
   724 00000806 C3                      	retn
   725                                  
   726                                  @@:
   727                                  %if _MODE
   728 00000807 7505                    	jnz @F
   729 00000809 800E[0425]20            sptrel	setopt [ %[_SCANPTAB_PREFIX]load_scan_flags ], 32
   730                                  sptinternal -3			; a logical or primary partition found
   731                                  
   732                                  @@:
   733                                  %endif
   734                                  
   735 0000080E E8FF04                  	extcallcall hexbyte
   736 00000811 58                      	pop ax
   737                                  
   738 00000812 BE[C900]                reloc	mov si, msg.startlba
   739                                  internaldatarelocation
   740 00000815 E81005                  	extcallcall copy_single_counted_string
   741 00000818 E832FE                  	call store_lba
   742                                  
   743 0000081B 58                      	pop ax
   744 0000081C 5A                      	pop dx
   745                                  
   746 0000081D BE[D500]                reloc	mov si, msg.sizelba
   747                                  internaldatarelocation
   748 00000820 E80505                  	extcallcall copy_single_counted_string
   749 00000823 E827FE                  	call store_lba
   750                                  
   751 00000826 E8EF04                  	extcallcall putsline_crlf
   752                                  
   753 00000829 D006[0A25]              reloc	rol byte [quiet], 1
   754                                  internaldatarelocation
   755 0000082D 722F                    	jc .quiet
   756                                  
   757 0000082F BA[DD00]                reloc	mov dx, msg.startchs
   758                                  internaldatarelocation
   759 00000832 E89304                  	extcallcall putsz
   760                                  
   761 00000835 5E                      	pop si
   762 00000836 56                      	push si
   763 00000837 268B5C02                	mov bx, word [es:si + 2]
   764 0000083B 268B14                  	mov dx, word [es:si]
   765 0000083E 8A0E[FC24]              reloc	mov cl, byte [load_unit]
   766                                  internaldatarelocation
   767 00000842 E85CFD                  	call run.entry_bxdx_cl
   768                                  
   769 00000845 BA[E400]                reloc	mov dx, msg.endchs
   770                                  internaldatarelocation
   771 00000848 E87D04                  	extcallcall putsz
   772                                  
   773 0000084B 5E                      	pop si
   774 0000084C 56                      	push si
   775 0000084D 268B5C06                	mov bx, word [es:si + 6]
   776 00000851 268B5404                	mov dx, word [es:si + 4]
   777 00000855 06                      	 push es
   778 00000856 8A0E[FC24]              reloc	mov cl, byte [load_unit]
   779                                  internaldatarelocation
   780 0000085A E844FD                  	call run.entry_bxdx_cl
   781 0000085D 07                      	 pop es
   782                                  
   783                                  .quiet:
   784 0000085E 5E                      	pop si
   785 0000085F 58                      	 pop ax
   786 00000860 5A                      	 pop dx
   787 00000861 56                      	push si
   788                                  
   789 00000862 D006[0925]              reloc	rol byte [label], 1
   790                                  internaldatarelocation
   791 00000866 7203E99600              	jnc .nolabel
   792                                  
   793 0000086B BF[0000]                reloc	mov di, relocateddata
   794                                  linkdatarelocation line_out	; reset di
   795                                  
   796 0000086E 268A5C04                	mov bl, byte [es:si + piType]
   797 00000872 80FB01                  	cmp bl, ptFAT12
   798 00000875 7419                    	je .isfat
   799 00000877 80FB04                  	cmp bl, ptFAT16_16BIT_CHS
   800 0000087A 7414                    	je .isfat
   801 0000087C 80FB06                  	cmp bl, ptFAT16_CHS
   802 0000087F 740F                    	je .isfat
   803 00000881 80FB0B                  	cmp bl, ptFAT32_CHS
   804 00000884 740A                    	je .isfat
   805 00000886 80FB0C                  	cmp bl, ptFAT32
   806 00000889 7405                    	je .isfat
   807 0000088B 80FB0E                  	cmp bl, ptFAT16
   808 0000088E 7571                    	jne .notfat
   809                                  .isfat:
   810                                  
   811 00000890 8B1E[F424]              reloc	mov bx, word [buffersegment]
   812                                  internaldatarelocation
   813 00000894 E8AC02                  	call read_ae_512_bytes_no_dump
   814                                  
   815 00000897 26813EFE0155AA          	cmp word [es:510], 0AA55h
   816 0000089E 7561                    	jne .nolabel
   817 000008A0 26833E0B0000            	cmp word [es:bsBPB + bpbBytesPerSector], 0
   818 000008A6 7459                    	je .nolabel
   819 000008A8 BE2B00                  	mov si, bsBPB + bpbNew + bpbnVolumeLabel
   820 000008AB 26833E160000            	cmp word [es:bsBPB + bpbSectorsPerFAT], 0
   821 000008B1 7503                    	jne @F
   822 000008B3 BE4700                  	mov si, bsBPB + ebpbNew + bpbnVolumeLabel
   823                                  @@:
   824 000008B6 26807CFB29              	cmp byte [es:si - bpbnVolumeLabel + bpbnExtBPBSignature], 29h
   825 000008BB 7544                    	jne .nolabel
   826 000008BD B90B00                  	mov cx, 11
   827                                  
   828 000008C0 06                      	push es
   829 000008C1 1F                      	pop ds
   830 000008C2 16                      	push ss
   831 000008C3 07                      	pop es
   832                                  
   833 000008C4 B020                    	mov al, 32
   834 000008C6 AA                      	stosb
   835                                  @@:
   836 000008C7 AC                      	lodsb
   837 000008C8 84C0                    	test al, al
   838 000008CA 7407                    	jz @F
   839 000008CC E83900                  	call dotreplace
   840 000008CF AA                      	stosb
   841 000008D0 E2F5                    	loop @B
   842 000008D2 41                      	inc cx			; = 1
   843                                  @@:
   844 000008D3 49                      	dec cx			; = how many bytes remain
   845 000008D4 01CE                    	add si, cx		; -> behind label
   846                                  
   847 000008D6 B108                    	mov cl, 8
   848 000008D8 B020                    	mov al, 32
   849 000008DA AA                      	stosb
   850                                  @@:
   851 000008DB AC                      	lodsb
   852 000008DC 84C0                    	test al, al
   853 000008DE 7406                    	jz @F
   854 000008E0 E82500                  	call dotreplace
   855 000008E3 AA                      	stosb
   856 000008E4 E2F5                    	loop @B
   857                                  @@:
   858                                  
   859 000008E6 16                      	push ss
   860 000008E7 1F                      	pop ds
   861 000008E8 16                      	push ss
   862 000008E9 07                      	pop es
   863                                  
   864 000008EA B82055                  	mov ax, " U"
   865 000008ED AB                      	stosw
   866                                  
   867 000008EE A0[FC24]                reloc	mov al, byte [load_unit]
   868                                  internaldatarelocation
   869 000008F1 E81C04                  	extcallcall hexbyte
   870                                  
   871 000008F4 B82050                  	mov ax, " P"
   872 000008F7 AB                      	stosw
   873                                  
   874 000008F8 A0[0025]                reloc	mov al, byte [load_current_partition]
   875                                  internaldatarelocation
   876 000008FB E81204                  	extcallcall hexbyte
   877                                  
   878 000008FE E81704                  	call putsline_crlf
   879                                  .notfat:
   880                                  .nolabel:
   881                                  
   882 00000901 16                      	push ss
   883 00000902 07                      	pop es
   884                                  
   885 00000903 5E                      	pop si
   886 00000904 5D                      	pop bp
   887 00000905 5F                      	pop di
   888 00000906 59                      	pop cx
   889 00000907 C3                      	retn
   890                                  
   891                                  
   892                                  dotreplace:
   893 00000908 FEC0                    	inc al			; change 7Fh to 80h, 32 to 33
   894 0000090A 3C20                    	cmp al, 32		; printable ?
   895 0000090C 7F02                    	jg .keep		; yes -->
   896 0000090E B02F                    	mov al, '.' + 1		; was 7Fh to FFh or 00h to 1Fh
   897                                  .keep:
   898 00000910 48                      	dec ax			; cannot underflow into ah
   899 00000911 C3                      	retn
   900                                  
   901                                  
   902                                  %if _MODE
   903                                  		; INP:	al = partition type
   904                                  		; OUT:	CY if an LBA or FAT32 type that's disabled
   905                                  		;	NC, ZR if known type we can access
   906                                  		;	NC, NZ if unknown type
   907                                  load_is_known:
   908 00000912 3C01                    	cmp al, ptFAT12
   909 00000914 741D                    	je .isknown
   910 00000916 3C04                    	cmp al, ptFAT16_16BIT_CHS
   911 00000918 7419                    	je .isknown
   912 0000091A 3C06                    	cmp al, ptFAT16_CHS
   913 0000091C 7415                    	je .isknown
   914 0000091E 3C0B                    	cmp al, ptFAT32_CHS
   915 00000920 7411                    	je .isknown
   916 00000922 3C0C                    	cmp al, ptFAT32
   917 00000924 7404                    	je .isknown_lba
   918 00000926 3C0E                    	cmp al, ptFAT16
   919 00000928 751A                    	jne .notknown
   920                                  .isknown_lba:
   921 0000092A F606[0325]40            sptrel	testopt [ %[_SCANPTAB_PREFIX]load_mode ], mode_disable_lba
   922                                  sptinternal -3
   923 0000092F 7402                    	jz .isknown
   924                                  .discard:
   925 00000931 F9                      	stc
   926 00000932 C3                      	retn
   927                                  
   928                                  .isknown:
   929 00000933 3C0C                    	cmp al, ptFAT32
   930 00000935 7402                    	je @F
   931 00000937 3C0B                    	cmp al, ptFAT32_CHS
   932                                  @@:
   933 00000939 7507                    	jne @F
   934 0000093B F606[0325]20            sptrel	testopt [ %[_SCANPTAB_PREFIX]load_mode ], mode_disable_fat32
   935                                  sptinternal -3
   936 00000940 75EF                    	jnz .discard
   937                                  @@:
   938 00000942 38C0                    	cmp al, al		; ZR
   939                                  .notknown:
   940 00000944 F8                      	clc
   941 00000945 C3                      	retn
   942                                  %endif
   943                                  
   944                                  
   945                                  geometry:
   946 00000946 AC                      	lodsb
   947 00000947 E8AE03                  	extcallcall getbyte
   948 0000094A 8816[FC24]              reloc	mov byte [load_unit], dl
   949                                  internaldatarelocation
   950 0000094E E86F03                  	extcallcall chkeol
   951                                  
   952 00000951 8CD0                    	mov ax, ss
   953 00000953 BB[A004]                reloc	mov bx, buffer + 512 - 16
   954                                  internaldatarelocation
   955 00000956 B104                    	mov cl, 4
   956 00000958 D3EB                    	shr bx, cl
   957 0000095A 01D8                    	add ax, bx
   958 0000095C 83E0E0                  	and ax, ~ (paras(512) - 1)
   959 0000095F A3[F424]                reloc	mov word [buffersegment], ax
   960                                  internaldatarelocation
   961                                  
   962                                  	houdini
   963                                  
   964 00000962 E86000                  	call query_geometry
   965                                  
   966 00000965 16                      	push ss
   967 00000966 07                      	pop es
   968                                  
   969 00000967 BF[0000]                reloc	mov di, relocateddata
   970                                  linkdatarelocation line_out
   971                                  
   972 0000096A A1[F024]                reloc	mov ax, [load_heads]
   973                                  internaldatarelocation
   974 0000096D E89803                  	extcallcall hexword
   975 00000970 C705203D                	mov word [di], " ="
   976 00000974 AF                      	scasw
   977 00000975 C60520                  	mov byte [di], " "
   978 00000978 47                      	inc di
   979 00000979 E8B403                  	extcallcall decword
   980                                  
   981 0000097C B82048                  	mov ax, " H"
   982 0000097F AB                      	stosw
   983 00000980 88C4                    	mov ah, al
   984 00000982 AB                      	stosw
   985                                  
   986 00000983 A1[F224]                reloc	mov ax, [load_sectors]
   987                                  internaldatarelocation
   988 00000986 E87F03                  	extcallcall hexword
   989 00000989 C705203D                	mov word [di], " ="
   990 0000098D AF                      	scasw
   991 0000098E C60520                  	mov byte [di], " "
   992 00000991 47                      	inc di
   993 00000992 E89B03                  	extcallcall decword
   994                                  
   995 00000995 B82053                  	mov ax, " S"
   996 00000998 AB                      	stosw
   997 00000999 E87C03                  	extcallcall putsline_crlf
   998 0000099C C3                      	retn
   999                                  
  1000                                  
  1001                                  bootcmd:
  1002                                  .fail_read:
  1003 0000099D 16                      	 push ss
  1004 0000099E 07                      	 pop es
  1005 0000099F BF[2B01]                reloc	mov di, msg.bootfail_read_errorcode
  1006                                  internaldatarelocation
  1007 000009A2 88E0                    	mov al, ah
  1008 000009A4 B404                    	mov ah, 04h
  1009 000009A6 E82703                  	extcallcall setrc
  1010 000009A9 E86403                  	extcallcall hexbyte
  1011 000009AC BA[0E01]                reloc	mov dx, msg.bootfail_read
  1012                                  internaldatarelocation
  1013                                  
  1014                                  .fail:
  1015 000009AF 16                      	 push ss
  1016 000009B0 07                      	 pop es
  1017 000009B1 52                      	push dx
  1018 000009B2 BA[FF00]                reloc	mov dx, msg.bootfail
  1019                                  internaldatarelocation
  1020 000009B5 E81003                  	extcallcall putsz
  1021 000009B8 5A                      	pop dx
  1022 000009B9 E80C03                  	extcallcall putsz
  1023 000009BC B8FF02                  	mov ax, 02FFh
  1024 000009BF E80E03                  	extcallcall setrc
  1025                                  
  1026 000009C2 E8F302                  	extcallcall cmd3
  1027                                  
  1028                                  
  1029                                  %idefine d5 comment
  1030                                  %idefine d4 comment
  1031                                  
  1032                                  query_geometry:
  1033 000009C5 8A16[FC24]              reloc	mov dl, [load_unit]
  1034                                  internaldatarelocation
  1035                                  ;	test dl, dl		; floppy?
  1036                                  ;	jns @F			; don't attempt query, might fail -->
  1037                                  	; Note that while the original PC BIOS doesn't support this function
  1038                                  	;  (for its diskettes), it does properly return the error code 01h.
  1039                                  	; https://sites.google.com/site/pcdosretro/ibmpcbios (IBM PC version 1)
  1040 000009C9 B408                    	mov ah, 08h
  1041 000009CB 31C9                    	xor cx, cx		; initialise cl to 0
  1042 000009CD 890E[F024]              reloc	mov [load_heads], cx
  1043                                  internaldatarelocation
  1044 000009D1 890E[F224]              reloc	mov [load_sectors], cx
  1045                                  internaldatarelocation
  1046 000009D5 31DB                    	xor bx, bx
  1047 000009D7 88D3                    	mov bl, dl
  1048                                  %if 1
  1049 000009D9 F687[0000]04            reloc	testopt [word relocateddata + bx], lufForceGeometry
  1050                                  linkdatarelocation load_unit_flags, -3
  1051 000009DE 7512                    	jnz .try_bootsector
  1052                                  %endif
  1053                                  		; Note:	The int 13h function 08h call may change or
  1054                                  		;	 set ax, bx, cx, dx, es, di. es is left as
  1055                                  		;	 indeterminate afterwards, until the code at
  1056                                  		;	 .try_bootsector runs, or bootcmd.fail, or
  1057                                  		;	 the "mov es" in .got_sectors_heads.
  1058 000009E0 F9                      	stc			; initialise to CY
  1059 000009E1 E81201                  	call .int13_retry	; query drive geometry
  1060 000009E4 720C                    	jc .try_bootsector	; apparently failed -->
  1061 000009E6 88F2                    	mov dl, dh
  1062 000009E8 B600                    	mov dh, 0		; dx = maximum head number
  1063 000009EA 42                      	inc dx			; dx = number of heads (H is 0-based)
  1064 000009EB 89C8                    	mov ax, cx		; ax & 3Fh = maximum sector number
  1065 000009ED 83E03F                  	and ax, 3Fh		; get sectors (number of sectors, S is 1-based)
  1066 000009F0 7523                    	jnz .got_sectors_heads	; valid (S is 1-based), use these -->
  1067                                  				; zero = invalid
  1068                                  .try_bootsector:
  1069 000009F2 8E06[F424]              reloc	mov es, word [buffersegment]	; es => buffer
  1070                                  internaldatarelocation
  1071 000009F6 31DB                    	xor bx, bx			; es:bx -> buffer
  1072 000009F8 B80102                  	mov ax, 0201h			; read sector, 1 sector
  1073 000009FB B90100                  	mov cx, 1			; sector 1 (1-based!), cylinder 0 (0-based)
  1074 000009FE B600                    	mov dh, 0			; head 0 (0-based)
  1075 00000A00 8A16[FC24]              reloc	mov dl, [load_unit]
  1076                                  internaldatarelocation
  1077 00000A04 F9                      	stc
  1078 00000A05 E8EE00                  	call .int13_retry
  1079 00000A08 7303E90601              	jc .access_error
  1080                                  
  1081                                  		; note: the smallest supported sector size, 32 bytes,
  1082                                  		;  does contain these entries (offset 18h and 1Ah in sector)
  1083                                  		;  within the first BPB sector.
  1084 00000A0D 268B4718                	mov ax, word [es:bx + bsBPB + bpbCHSSectors]
  1085 00000A11 268B571A                	mov dx, word [es:bx + bsBPB + bpbCHSHeads]
  1086                                  
  1087                                  .got_sectors_heads:
  1088 00000A15 A3[F224]                reloc	mov word [load_sectors], ax
  1089                                  internaldatarelocation
  1090 00000A18 8916[F024]              reloc	mov word [load_heads], dx
  1091                                  internaldatarelocation
  1092                                  
  1093 00000A1C 85C0                    	test ax, ax
  1094 00000A1E 7503E90C01              	jz .invalid_sectors
  1095 00000A23 83F83F                  	cmp ax, 63
  1096 00000A26 7603E90401              	ja .invalid_sectors
  1097 00000A2B 85D2                    	test dx, dx
  1098 00000A2D 7503E90401              	jz .invalid_heads
  1099 00000A32 81FA0001                	cmp dx, 100h
  1100 00000A36 7603E9FB00              	ja .invalid_heads
  1101                                  
  1102 00000A3B 8E06[F424]              reloc	mov es, word [buffersegment]	; es => buffer
  1103                                  internaldatarelocation
  1104 00000A3F 31DB                    	xor bx, bx			; es:bx -> buffer
  1105 00000A41 31C0                    	xor ax, ax
  1106                                  
  1107                                  d5	call d5dumpregs
  1108                                  d5	call d5message
  1109                                  d5	asciz 13,10,"In query_geometry 0",13,10
  1110                                  
  1111 00000A43 89DF                    	mov di, bx
  1112 00000A45 B90110                  	mov cx, (8192 + 2) >> 1
  1113                                  					; es:bx -> buffer, es:di = same
  1114 00000A48 F3AB                    	rep stosw			; fill buffer, di -> behind (buffer+8192+2)
  1115 00000A4A B80102                  	mov ax, 0201h			; read sector, 1 sector
  1116 00000A4D 41                      	inc cx				; sector 1 (1-based!), cylinder 0 (0-based)
  1117 00000A4E B600                    	mov dh, 0			; head 0 (0-based)
  1118 00000A50 8A16[FC24]              reloc	mov dl, [load_unit]
  1119                                  internaldatarelocation
  1120 00000A54 F9                      	stc
  1121 00000A55 E89E00                  	call .int13_retry
  1122 00000A58 7303E9B600              	jc .access_error
  1123                                  
  1124 00000A5D FD                      	std				; _AMD_ERRATUM_109_WORKAROUND does not apply
  1125 00000A5E AF                      	scasw				; -> buffer+8192 (at last word to sca)
  1126                                  d5	call d5dumpregs
  1127                                  d5	call d5message
  1128                                  d5	asciz 13,10,"In query_geometry 1",13,10
  1129 00000A5F B90110                  	mov cx, (8192 + 2) >> 1
  1130 00000A62 31C0                    	xor ax, ax
  1131 00000A64 F3AF                    	repe scasw
  1132 00000A66 83C704                  	add di, 4			; di -> first differing byte (from top)
  1133 00000A69 FC                      	cld
  1134 00000A6A 57                      	push di
  1135                                  
  1136 00000A6B 89DF                    	mov di, bx
  1137 00000A6D B90110                  	mov cx, (8192 + 2) >> 1
  1138 00000A70 48                      	dec ax				; = FFFFh
  1139 00000A71 F3AB                    	rep stosw
  1140                                  
  1141 00000A73 B80102                  	mov ax, 0201h
  1142 00000A76 41                      	inc cx
  1143 00000A77 B600                    	mov dh, 0
  1144 00000A79 8A16[FC24]              reloc	mov dl, [load_unit]
  1145                                  internaldatarelocation
  1146 00000A7D F9                      	stc
  1147 00000A7E E87500                  	call .int13_retry
  1148 00000A81 7303E98D00              	jc .access_error
  1149                                  
  1150 00000A86 FD                      	std				; _AMD_ERRATUM_109_WORKAROUND does not apply
  1151 00000A87 AF                      	scasw				; di -> buffer+8192 (last word to sca)
  1152                                  d5	call d5dumpregs
  1153                                  d5	call d5message
  1154                                  d5	asciz 13,10,"In query_geometry 2",13,10
  1155 00000A88 5A                      	pop dx
  1156 00000A89 B8FFFF                  	mov ax, -1
  1157 00000A8C B90110                  	mov cx, (8192 + 2) >> 1
  1158 00000A8F F3AF                    	repe scasw
  1159                                  %if 0
  1160                                  AAAB
  1161                                     ^
  1162                                  	sca B, match
  1163                                    ^
  1164                                  	sca B, mismatch
  1165                                   ^
  1166                                  	stop
  1167                                  %endif
  1168 00000A91 83C704                  	add di, 4			; di -> first differing byte (from top)
  1169 00000A94 FC                      	cld
  1170                                  
  1171                                  %if 0
  1172                                  0000000000000
  1173                                  AAAAAAAA00000
  1174                                  	^
  1175                                  FFFFFFFFFFFFF
  1176                                  AAAAAAAA00FFF
  1177                                  	  ^
  1178                                  %endif
  1179 00000A95 39FA                    	cmp dx, di			; choose the higher one
  1180 00000A97 7302                    	jae @F
  1181 00000A99 89FA                    	mov dx, di
  1182                                  @@:
  1183 00000A9B 29DA                    	sub dx, bx			; dx = sector size
  1184                                  
  1185                                  d5	call d5dumpregs
  1186                                  d5	call d5message
  1187                                  d5	asciz 13,10,"In query_geometry 3",13,10
  1188                                  
  1189 00000A9D 81FA0220                	cmp dx, 8192 + 2
  1190 00000AA1 7377                    	jae .sector_too_large
  1191 00000AA3 B82000                  	mov ax, 32
  1192 00000AA6 39C2                    	cmp dx, ax
  1193 00000AA8 7277                    	jb .sector_too_small
  1194                                  @@:
  1195 00000AAA 39C2                    	cmp dx, ax
  1196 00000AAC 7409                    	je .got_match
  1197 00000AAE 3D0020                  	cmp ax, 8192
  1198 00000AB1 7375                    	jae .sector_not_power
  1199 00000AB3 D1E0                    	shl ax, 1
  1200 00000AB5 EBF3                    	jmp @B
  1201                                  
  1202                                  .got_match:
  1203 00000AB7 A3[F824]                reloc	mov word [load_sectorsize], ax
  1204                                  internaldatarelocation
  1205 00000ABA B104                    	mov cl, 4
  1206 00000ABC D3E8                    	shr ax, cl
  1207 00000ABE A3[FA24]                reloc	mov word [load_sectorsizepara], ax
  1208                                  internaldatarelocation
  1209                                  
  1210 00000AC1 C606[FE24]00            reloc	mov byte [load_flags], 0
  1211                                  internaldatarelocation -3
  1212 00000AC6 8A16[FC24]              reloc	mov dl, [load_unit]
  1213                                  internaldatarelocation
  1214 00000ACA 31DB                    	xor bx, bx
  1215 00000ACC 88D3                    	mov bl, dl
  1216                                  %if 1
  1217 00000ACE F687[0000]01            reloc	testopt [word relocateddata + bx], lufForceCHS
  1218                                  linkdatarelocation load_unit_flags, -3
  1219 00000AD3 7520                    	jnz .no_lba
  1220 00000AD5 F687[0000]02            reloc	testopt [word relocateddata + bx], lufForceLBA
  1221                                  linkdatarelocation load_unit_flags, -3
  1222 00000ADA 7515                    	jnz .yes_lba
  1223                                  %endif
  1224 00000ADC B441                    	mov ah, 41h
  1225 00000ADE BBAA55                  	mov bx, 55AAh
  1226 00000AE1 F9                      	stc
  1227 00000AE2 CD13                    	int 13h		; 13.41.bx=55AA extensions installation check
  1228 00000AE4 720F                    	jc .no_lba
  1229 00000AE6 81FB55AA                	cmp bx, 0AA55h
  1230 00000AEA 7509                    	jne .no_lba
  1231 00000AEC F6C101                  	test cl, 1	; support bitmap bit 0
  1232 00000AEF 7404                    	jz .no_lba
  1233                                  
  1234                                  .yes_lba:
  1235                                  %if ldfHasLBA != 1
  1236                                   %error Assuming ldfHasLBA is 1
  1237                                  %endif
  1238 00000AF1 FE06[FE24]              reloc	inc byte [load_flags]
  1239                                  internaldatarelocation
  1240                                  .no_lba:
  1241                                  
  1242 00000AF5 C3                      	retn
  1243                                  
  1244                                  
  1245                                  .int13_retry:
  1246 00000AF6 9C                      	pushf
  1247 00000AF7 50                      	push ax
  1248 00000AF8 CD13                    	int 13h		; first try
  1249 00000AFA 730B                    	jnc @F		; NC, success on first attempt -->
  1250                                  
  1251                                  ; reset drive
  1252 00000AFC 31C0                    	xor ax, ax
  1253 00000AFE CD13                    	int 13h
  1254 00000B00 7205                    	jc @F		; CY, reset failed, error in ah -->
  1255                                  
  1256                                  ; try read again
  1257 00000B02 58                      	pop ax		; restore function number
  1258 00000B03 9D                      	popf		; CF
  1259 00000B04 CD13                    	int 13h		; retry, CF error status, ah error number
  1260 00000B06 C3                      	retn
  1261                                  
  1262                                  @@:			; NC or CY, stack has function number
  1263 00000B07 44                      	inc sp
  1264 00000B08 44                      	inc sp
  1265 00000B09 44                      	inc sp
  1266 00000B0A 44                      	inc sp		; discard two words on stack, preserve CF
  1267 00000B0B C3                      	retn
  1268                                  
  1269                                  
  1270                                  .out_of_memory_error:
  1271 00000B0C BA[3301]                reloc	mov dx, msg.boot_out_of_memory_error
  1272                                  internaldatarelocation
  1273 00000B0F B021                    	mov al, 21h
  1274 00000B11 EB28                    	jmp .error_common_j
  1275                                  .access_error:
  1276 00000B13 BA[4401]                reloc	mov dx, msg.boot_access_error
  1277                                  internaldatarelocation
  1278 00000B16 B022                    	mov al, 22h
  1279 00000B18 EB21                    	jmp .error_common_j
  1280                                  .sector_too_large:
  1281 00000B1A BA[5201]                reloc	mov dx, msg.boot_sector_too_large
  1282                                  internaldatarelocation
  1283 00000B1D B023                    	mov al, 23h
  1284 00000B1F EB1A                    	jmp .error_common_j
  1285                                  .sector_too_small:
  1286 00000B21 BA[7801]                reloc	mov dx, msg.boot_sector_too_small
  1287                                  internaldatarelocation
  1288 00000B24 B024                    	mov al, 24h
  1289 00000B26 EB13                    	jmp .error_common_j
  1290                                  .sector_not_power:
  1291 00000B28 BA[A001]                reloc	mov dx, msg.boot_sector_not_power
  1292                                  internaldatarelocation
  1293 00000B2B B025                    	mov al, 25h
  1294 00000B2D EB0C                    	jmp .error_common_j
  1295                                  .invalid_sectors:
  1296 00000B2F BA[C201]                reloc	mov dx, msg.boot_invalid_sectors
  1297                                  internaldatarelocation
  1298 00000B32 B026                    	mov al, 26h
  1299 00000B34 EB05                    	jmp .error_common_j
  1300                                  .invalid_heads:
  1301 00000B36 BA[DE01]                reloc	mov dx, msg.boot_invalid_heads
  1302                                  internaldatarelocation
  1303 00000B39 B027                    	mov al, 27h
  1304                                  .error_common_j:
  1305 00000B3B B402                    	mov ah, 02h
  1306 00000B3D E89001                  	extcallcall setrc
  1307 00000B40 E96CFE                  	jmp bootcmd.fail
  1308                                  
  1309                                  
  1310                                  read_ae_512_bytes_no_dump:
  1311 00000B43 51                      	push cx
  1312 00000B44 53                      	push bx
  1313 00000B45 B90002                  	mov cx, 512
  1314                                  @@:
  1315 00000B48 E89200                  	call read_sector
  1316 00000B4B 2B0E[F824]              reloc	sub cx, word [load_sectorsize]
  1317                                  internaldatarelocation
  1318 00000B4F 77F7                    	ja @B
  1319 00000B51 07                      	pop es
  1320 00000B52 59                      	pop cx
  1321 00000B53 C3                      	retn
  1322                                  
  1323                                  
  1324                                  		; INP:	dx:ax = first sector
  1325                                  		;	bx:0 -> buffer
  1326                                  		;	NC if loading table the first time
  1327                                  		;	CY if reloading table
  1328                                  		; OUT:	dx:ax = sector number after last read
  1329                                  		;	es = input bx
  1330                                  		;	bx:0 -> buffer after last written
  1331                                  		; CHG:	-
  1332                                  		; STT:	ds = ss
  1333                                  read_ae_512_bytes:
  1334 00000B54 51                      	push cx
  1335 00000B55 53                      	push bx
  1336 00000B56 9C                      	pushf
  1337 00000B57 B90002                  	mov cx, 512
  1338                                  @@:
  1339 00000B5A E88000                  	call read_sector
  1340 00000B5D 2B0E[F824]              reloc	sub cx, word [load_sectorsize]
  1341                                  internaldatarelocation
  1342 00000B61 77F7                    	ja @B
  1343 00000B63 9D                      	popf
  1344 00000B64 1F                      	pop ds
  1345 00000B65 16                      	 push ss
  1346 00000B66 07                      	 pop es
  1347 00000B67 56                      	push si
  1348 00000B68 57                      	push di
  1349 00000B69 52                      	push dx
  1350 00000B6A 53                      	push bx
  1351 00000B6B 50                      	push ax
  1352 00000B6C 1E                      	push ds
  1353                                  
  1354 00000B6D 7307                    	jnc @F				; first time -->
  1355 00000B6F 36D006[0825]            reloc	rol byte [ss:dumpreload], 1	; want to dump on reload ?
  1356                                  internaldatarelocation
  1357 00000B74 735D                    	jnc .skip			; no -->
  1358                                  @@:
  1359 00000B76 36D006[0725]            reloc	rol byte [ss:dump], 1		; want to dump at all ?
  1360                                  internaldatarelocation
  1361 00000B7B 7356                    	jnc .skip			; no -->
  1362                                  
  1363 00000B7D BEBE01                  	mov si, 512 - 2 - 16 * 4
  1364 00000B80 B90400                  	mov cx, 4
  1365                                  .loop:
  1366 00000B83 807C0400                	cmp byte [si + piType], ptEmpty
  1367 00000B87 7445                    	je .next
  1368 00000B89 BF[0000]                reloc	mov di, relocateddata
  1369                                  linkdatarelocation line_out
  1370 00000B8C 56                      	push si
  1371 00000B8D 89F0                    	mov ax, si
  1372 00000B8F E87601                  	extcallcall hexword
  1373 00000B92 B502                    	mov ch, 2
  1374                                  .innerloopchs:
  1375 00000B94 B82020                  	mov ax, "  "
  1376 00000B97 AB                      	stosw
  1377 00000B98 AC                      	lodsb
  1378 00000B99 E87401                  	extcallcall hexbyte	; piBoot or piType
  1379 00000B9C B020                    	mov al, " "
  1380 00000B9E AA                      	stosb
  1381 00000B9F AC                      	lodsb			; low byte tuple
  1382 00000BA0 50                      	push ax
  1383 00000BA1 AD                      	lodsw
  1384 00000BA2 E86301                  	extcallcall hexword	; high and middle byte
  1385 00000BA5 58                      	pop ax
  1386 00000BA6 E86701                  	extcallcall hexbyte	; low byte
  1387 00000BA9 FECD                    	dec ch
  1388 00000BAB 75E7                    	jnz .innerloopchs	; do twice, for start and end tuple
  1389 00000BAD B502                    	mov ch, 2
  1390                                  .innerlooplba:
  1391 00000BAF B82020                  	mov ax, "  "
  1392 00000BB2 AB                      	stosw
  1393 00000BB3 AD                      	lodsw			; low word
  1394 00000BB4 50                      	push ax
  1395 00000BB5 AD                      	lodsw			; high word
  1396 00000BB6 E84F01                  	extcallcall hexword	; high word
  1397 00000BB9 B05F                    	mov al, '_'		; separator
  1398 00000BBB AA                      	stosb
  1399 00000BBC 58                      	pop ax
  1400 00000BBD E84801                  	extcallcall hexword	; low word
  1401 00000BC0 FECD                    	dec ch
  1402 00000BC2 75EB                    	jnz .innerlooplba
  1403 00000BC4 1E                      	push ds
  1404 00000BC5 16                      	 push ss
  1405 00000BC6 1F                      	 pop ds
  1406 00000BC7 51                      	 push cx
  1407 00000BC8 E84D01                  	extcallcall putsline_crlf
  1408 00000BCB 59                      	 pop cx
  1409 00000BCC 1F                      	pop ds
  1410 00000BCD 5E                      	pop si
  1411                                  .next:
  1412 00000BCE 83C610                  	add si, 16		; skip
  1413 00000BD1 E2B0                    	loop .loop		; four times
  1414                                  
  1415                                  .skip:
  1416 00000BD3 07                      	pop es
  1417 00000BD4 58                      	pop ax
  1418 00000BD5 5B                      	pop bx
  1419 00000BD6 5A                      	pop dx
  1420 00000BD7 5F                      	pop di
  1421 00000BD8 5E                      	pop si
  1422 00000BD9 16                      	 push ss
  1423 00000BDA 1F                      	 pop ds
  1424 00000BDB 59                      	pop cx
  1425 00000BDC C3                      	retn
  1426                                  
  1427                                  
  1428                                  		; Read a sector using Int13.02 or Int13.42
  1429                                  		;
  1430                                  		; INP:	dx:ax = sector number (within partition)
  1431                                  		;	bx:0-> buffer
  1432                                  		;	(_LBA) ds = ss
  1433                                  		;	dword[load_data - LOADDATA2 + bsBPB + bpbHiddenSectors]
  1434                                  		;	 = base sector number (dx:ax is added to this to get
  1435                                  		;	    the absolute sector number in the selected unit.)
  1436                                  		; OUT:	If unable to read,
  1437                                  		;	 ! jumps to error instead of returning
  1438                                  		;	If sector has been read,
  1439                                  		;	 dx:ax = next sector number (has been incremented)
  1440                                  		;	 bx:0-> next buffer (bx = es+word[load_sectorsizepara])
  1441                                  		;	 es = input bx
  1442                                  		; CHG:	-
  1443                                  		;
  1444                                  		; Note:	If error 09h (data boundary error) is returned,
  1445                                  		;	 the read is done into the load_sectorseg buffer,
  1446                                  		;	 then copied into the user buffer.
  1447                                  read_sector:
  1448                                  	lframe near
  1449 00000BDD 5589E5                  	lenter
  1450                                  
  1451                                  .err: equ bootcmd.fail_read
  1452                                  d5	call d5dumpregs
  1453                                  d5	call d5message
  1454                                  d5	asciz 13,10,"In read_sector",13,10
  1455                                  
  1456 00000BE0 52                      	push dx
  1457 00000BE1 51                      	push cx
  1458 00000BE2 50                      	push ax
  1459 00000BE3 56                      	push si
  1460                                  
  1461 00000BE4 8EC3                    	mov es, bx
  1462                                  
  1463                                  ; DX:AX==LBA sector number
  1464                                  ; add partition start (= number of hidden sectors)
  1465 00000BE6 0306[0000]              reloc		add ax,[load_hidden_sectors + 0]
  1466                                  internaldatarelocation
  1467 00000BEA 1316[0200]              reloc		adc dx,[load_hidden_sectors + 2]
  1468                                  internaldatarelocation
  1469                                  
  1470 00000BEE 19F6                    	sbb si, si	; -1 if was CY, 0 else
  1471 00000BF0 F7DE                    	neg si		; 1 if was CY, 0 else
  1472 00000BF2 31C9                    	xor cx, cx
  1473 00000BF4 51                      	push cx
  1474 00000BF5 56                      	push si		; bit 32 = 1 if operating in 33-bit space
  1475 00000BF6 52                      	push dx
  1476 00000BF7 50                      	push ax		; qword sector number (lpSector)
  1477 00000BF8 53                      	push bx
  1478 00000BF9 51                      	push cx		; bx:0 -> buffer (lpBuffer)
  1479 00000BFA 41                      	inc cx
  1480 00000BFB 51                      	push cx		; word number of sectors to read (lpCount)
  1481 00000BFC B110                    	mov cl, 10h
  1482 00000BFE 51                      	push cx		; word size of disk address packet (lpSize)
  1483 00000BFF 89E6                    	mov si, sp	; ds:si -> disk address packet (on stack)
  1484                                  
  1485 00000C01 F606[FE24]01            reloc	test byte [load_flags], ldfHasLBA
  1486                                  internaldatarelocation -3
  1487 00000C06 7427                    	jz .no_lba
  1488                                  
  1489                                  d5	call d5message
  1490                                  d5	asciz "In read_sector.lba",13,10
  1491                                  
  1492 00000C08 8A16[FC24]              reloc	mov dl, byte [load_unit]
  1493                                  internaldatarelocation
  1494 00000C0C E88A00                  	call .set_ah_function_42_or_43
  1495 00000C0F CD13                    	int 13h		; 13.42 extensions read
  1496 00000C11 7317                    	jnc .lba_done
  1497                                  
  1498 00000C13 31C0                    	xor ax, ax
  1499 00000C15 CD13                    	int 13h
  1500 00000C17 7303E981FD              	jc .lba_error
  1501                                  
  1502                                  		; have to reset the LBAPACKET's lpCount, as the handler may
  1503                                  		;  set it to "the number of blocks successfully transferred".
  1504                                  		; (in any case, the high byte is still zero.)
  1505 00000C1C C6440201                	mov byte [si + lpCount], 1
  1506                                  
  1507 00000C20 E87600                  	call .set_ah_function_42_or_43
  1508 00000C23 CD13                    	int 13h
  1509 00000C25 7303                    	jnc .lba_done
  1510                                  
  1511 00000C27 E973FD                  	jmp .lba_error
  1512                                  
  1513                                  .lba_done:
  1514 00000C2A 83C410                  	add sp, 10h
  1515 00000C2D EB5A                    	jmp .done
  1516                                  
  1517                                  .lba_error: equ .err
  1518                                  
  1519                                  .no_lba:
  1520 00000C2F 83C408                  	add sp, 8
  1521 00000C32 58                      	pop ax
  1522 00000C33 5A                      	pop dx
  1523 00000C34 5E                      	pop si
  1524 00000C35 59                      	pop cx
  1525 00000C36 85F6                    	test si, si
  1526 00000C38 7532                    	jnz .err_4_NZ
  1527                                  
  1528                                  ; DX:AX=LBA sector number
  1529                                  ; divide by number of sectors per track to get sector number
  1530                                  ; Use 32:16 DIV instead of 64:32 DIV for 8088 compatability
  1531                                  ; Use two-step 32:16 divide to avoid overflow
  1532 00000C3A 89C1                    			mov cx,ax
  1533 00000C3C 89D0                    			mov ax,dx
  1534 00000C3E 31D2                    			xor dx,dx
  1535 00000C40 F736[F224]              reloc			div word [load_sectors]
  1536                                  internaldatarelocation
  1537 00000C44 91                      			xchg cx,ax
  1538 00000C45 F736[F224]              reloc			div word [load_sectors]
  1539                                  internaldatarelocation
  1540 00000C49 87CA                    			xchg cx,dx
  1541                                  
  1542                                  ; DX:AX=quotient, CX=remainder=sector (S) - 1
  1543                                  ; divide quotient by number of heads
  1544 00000C4B 89C3                    			mov bx, ax
  1545 00000C4D 92                      			xchg ax, dx
  1546 00000C4E 31D2                    			xor dx, dx
  1547 00000C50 F736[F024]              reloc			div word [load_heads]
  1548                                  internaldatarelocation
  1549 00000C54 93                      			xchg bx, ax
  1550 00000C55 F736[F024]              reloc			div word [load_heads]
  1551                                  internaldatarelocation
  1552                                  
  1553                                  ; bx:ax=quotient=cylinder (C), dx=remainder=head (H)
  1554                                  ; move variables into registers for INT 13h AH=02h
  1555 00000C59 88D6                    			mov dh, dl	; dh = head
  1556 00000C5B 41                      			inc cx		; cl5:0 = sector
  1557 00000C5C 86E8                    			xchg ch, al	; ch = cylinder 7:0, al = 0
  1558 00000C5E D1E8                    			shr ax, 1
  1559 00000C60 D1E8                    			shr ax, 1	; al7:6 = cylinder 9:8
  1560                                  	; bx has bits set iff it's > 0, indicating a cylinder >= 65536.
  1561 00000C62 08FB                    			 or bl, bh	; collect set bits from bh
  1562 00000C64 08C1                    			or cl, al	; cl7:6 = cylinder 9:8
  1563                                  	; ah has bits set iff it was >= 4, indicating a cylinder >= 1024.
  1564 00000C66 08E3                    			 or bl, ah	; collect set bits from ah
  1565 00000C68 8A16[FC24]              reloc			mov dl, [load_unit]
  1566                                  internaldatarelocation
  1567                                  					; dl = drive
  1568                                  .err_4_NZ:
  1569 00000C6C B404                    			mov ah, 04h	; error number: sector not found
  1570 00000C6E 7403E92AFD              			 jnz .err	; error if cylinder >= 1024 -->
  1571                                  					; ! bx = 0 (for 13.02 call)
  1572                                  
  1573                                  ; we call INT 13h AH=02h once for each sector. Multi-sector reads
  1574                                  ; may fail if we cross a track or 64K boundary
  1575 00000C73 BE1100                  			mov si, 16 + 1
  1576                                  .loop_chs_retry_repeat:
  1577 00000C76 E82300                  			call .set_ax_function_0201_or_0301
  1578 00000C79 CD13                    			int 13h		; read one sector
  1579 00000C7B 730C                    			jnc .done
  1580 00000C7D 50                      			push ax
  1581 00000C7E 31C0                    			xor ax, ax
  1582 00000C80 CD13                    			int 13h		; reset disk
  1583 00000C82 58                      			pop ax
  1584 00000C83 4E                      			dec si		; another attempt ?
  1585 00000C84 75F0                    			jnz .loop_chs_retry_repeat	; yes -->
  1586                                  
  1587 00000C86 E914FD                  	jmp .err
  1588                                  
  1589                                  .done:
  1590                                  ; increment segment
  1591 00000C89 8CC3                    	mov bx, es
  1592 00000C8B 031E[FA24]              reloc	add bx, word [load_sectorsizepara]
  1593                                  internaldatarelocation
  1594                                  
  1595 00000C8F 5E                      	pop si
  1596 00000C90 58                      	pop ax
  1597 00000C91 59                      	pop cx
  1598 00000C92 5A                      	pop dx
  1599                                  ; increment LBA sector number
  1600 00000C93 40                      	inc ax
  1601 00000C94 7501                    	jne @F
  1602 00000C96 42                      	inc dx
  1603                                  @@:
  1604 00000C97 5D                      	lleave code
  1605 00000C98 C3                      	retn
  1606                                  
  1607                                  .set_ah_function_42_or_43:
  1608 00000C99 B442                    	mov ah, 42h
  1609 00000C9B C3                      	retn
  1610                                  
  1611                                  .set_ax_function_0201_or_0301:
  1612 00000C9C B001                    	mov al, 1
  1613                                  .set_ah_function_02_or_03:
  1614 00000C9E B402                    	mov ah, 02h
  1615 00000CA0 C3                      	retn
  1616                                  
  1617                                  	lleave ctx
  1618                                  
  1619                                  
  1620 00000CA1 90<rep 7h>E8[0000]-     	eldcall_dump_callcall ELDCALL_CALLCALL_LIST
  1620 00000CAB EB020000C3E8[0000]-
  1620 00000CB3 EB020000C3E8[0000]-
  1620 00000CBB EB020000C3E8[0000]-
  1620 00000CC3 EB020000C3E8[0000]-
  1620 00000CCB EB020000C3E8[0000]-
  1620 00000CD3 EB020000C3E8[0000]-
  1620 00000CDB EB020000C3E8[0000]-
  1620 00000CE3 EB020000C3E8[0000]-
  1620 00000CEB EB020000C3E8[0000]-
  1620 00000CF3 EB020000C3E8[0000]-
  1620 00000CFB EB020000C3E8[0000]-
  1620 00000D03 EB020000C3E8[0000]-
  1620 00000D0B EB020000C3E8[0000]-
  1620 00000D13 EB020000C3E8[0000]-
  1620 00000D1B EB020000C3E8[0000]-
  1620 00000D23 EB020000C3E8[0000]-
  1620 00000D2B EB020000C3E8[0000]-
  1620 00000D33 EB020000C3         
  1621                                  
  1622                                  endinstalled equ ($ + CODEFIXUP + 15) & ~15
  1623                                  
  1624                                  
  1625                                  start:
  1626 00000D38 8CC3                    	mov bx, es
  1627 00000D3A 16                      	 push ss
  1628 00000D3B 07                      	 pop es
  1629 00000D3C E869FF                  	call skipcomma
  1630 00000D3F 4E                      	dec si
  1631 00000D40 BA[0000]                reloc	mov dx, relocateddata
  1632                                  linkdatarelocation msg.install
  1633 00000D43 E86AFF                  	call isstring?
  1634 00000D46 7440                    	je install
  1635 00000D48 BA[C402]                reloc	mov dx, msg.keyword_help
  1636                                  internaldatarelocation
  1637 00000D4B E862FF                  	call isstring?
  1638 00000D4E 7409                    	je help
  1639 00000D50 E8AAF7                  	call run
  1640                                  @@:
  1641 00000D53 E80F00                  	call uninstall_oneshot
  1642 00000D56 31C0                    	xor ax, ax
  1643 00000D58 CB                      	retf
  1644                                  
  1645                                  help:
  1646 00000D59 AC                      	lodsb
  1647 00000D5A E863FF                  	call chkeol
  1648 00000D5D BA[C902]                reloc	mov dx, msg.help
  1649                                  internaldatarelocation
  1650 00000D60 E865FF                  	call putsz
  1651 00000D63 EBEE                    	jmp @B
  1652                                  
  1653                                  
  1654                                  uninstall_oneshot:
  1655 00000D65 36F606[0000]01          reloc	testopt [ss:relocateddata], 1
  1656                                  linkdatarelocation options7, -3
  1657 00000D6B 751A                    	jnz @F
  1658                                  
  1659 00000D6D 2EA1[0200]              reloc	mov ax, word [cs:code + eldiEndCode]
  1660                                  internalcoderelocation
  1661 00000D71 2E2B06[0000]            reloc	sub ax, word [cs:code + eldiStartCode]
  1662                                  internalcoderelocation
  1663 00000D76 2906[0000]              reloc	sub word [relocateddata], ax
  1664                                  linkdatarelocation extseg_used
  1665                                  
  1666 00000D7A 2EA1[0600]              reloc	mov ax, word [cs:code + eldiEndData]
  1667                                  internalcoderelocation
  1668 00000D7E 2E2B06[0400]            reloc	sub ax, word [cs:code + eldiStartData]
  1669                                  internalcoderelocation
  1670 00000D83 2906[0000]              reloc	sub word [relocateddata], ax
  1671                                  linkdatarelocation extdata_used
  1672                                  @@:
  1673 00000D87 C3                      	retn
  1674                                  
  1675                                  
  1676                                  DATAOFFSET equ CODEOFFSET + code_size
  1677                                  	addsection DATA, follows=CODE vstart=_ELD_DATA_VSTART
  1678                                  %define DATAFIXUP - datastart + 0
  1679                                  datastart:
  1680                                  PUT_ELD_DATETIME
  1681                                  
  1682                                  	align 4, db 0
  1683 00000000 00000000                load_hidden_sectors:	dd 0
  1684                                  keywordtable:
  1685 00000004 [C000]                  reloc	dw msg.extended
  1686                                  internaldatarelocation
  1687 00000006 [0625]                  reloc	dw extended
  1688                                  internaldatarelocation
  1689                                  
  1690 00000008 [3D00]                  reloc	dw msg.dump
  1691                                  internaldatarelocation
  1692 0000000A [0725]                  reloc	dw dump
  1693                                  internaldatarelocation
  1694                                  
  1695 0000000C [4200]                  reloc	dw msg.dumpreload
  1696                                  internaldatarelocation
  1697 0000000E [0825]                  reloc	dw dumpreload
  1698                                  internaldatarelocation
  1699                                  
  1700 00000010 [4D00]                  reloc	dw msg.label
  1701                                  internaldatarelocation
  1702 00000012 [0925]                  reloc	dw label
  1703                                  internaldatarelocation
  1704                                  
  1705 00000014 [5300]                  reloc	dw msg.quiet
  1706                                  internaldatarelocation
  1707 00000016 [0A25]                  reloc	dw quiet
  1708                                  internaldatarelocation
  1709                                  
  1710 00000018 [5900]                  reloc	dw msg.skipext
  1711                                  internaldatarelocation
  1712 0000001A [0B25]                  reloc	dw skipext
  1713                                  internaldatarelocation
  1714                                  .end:
  1715                                  
  1716                                  modetable:
  1717 0000001C [6B00]                  reloc	dw msg.ldos2024
  1718                                  internaldatarelocation
  1719 0000001E 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
  1726 00000020 [7400]                  reloc	dw msg.ldosnew
  1727                                  internaldatarelocation
  1728 00000022 0020                    	dw mode_all_ext5 | mode_all_ext15 | mode_all_ext85 		| mode_disable_fat32
  1730 00000024 [7C00]                  reloc	dw msg.freedos
  1731                                  internaldatarelocation
  1732 00000026 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
  1738 00000028 [8400]                  reloc	dw msg.freedosdla
  1739                                  internaldatarelocation
  1740 0000002A 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
  1745 0000002C [8F00]                  reloc	dw msg.edrdos
  1746                                  internaldatarelocation
  1747 0000002E 5A82                    	dw mode_first_ext5 | mode_first_ext15 | mode_ignore_ext85 		| mode_ignore_subsequent_nested 		| mode_traditional_order_logical 		| mode_dlasort_zero
  1751 00000030 [9600]                  reloc	dw msg.msdos5
  1752                                  internaldatarelocation
  1753 00000032 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
  1762 00000034 [9D00]                  reloc	dw msg.msdos7
  1763                                  internaldatarelocation
  1764 00000036 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
  1771                                  .end:
  1772                                  
  1773                                  msg:
  1774 00000038 57414C4B00              .walk:			asciz "WALK"
  1775 0000003D 44554D5000              .dump:			asciz "DUMP"
  1776 00000042 44554D5052454C4F41-     .dumpreload:		asciz "DUMPRELOAD"
  1776 0000004B 4400               
  1777 0000004D 4C4142454C00            .label:			asciz "LABEL"
  1778 00000053 515549455400            .quiet:			asciz "QUIET"
  1779 00000059 534B495045585400        .skipext:		asciz "SKIPEXT"
  1780 00000061 5550544F00              .upto:			asciz "UPTO"
  1781 00000066 4D4F444500              .mode:			asciz "MODE"
  1782 0000006B 4C444F533230323400      .ldos2024:		asciz "LDOS2024"
  1783 00000074 4C444F534E455700        .ldosnew:		asciz "LDOSNEW"
  1784 0000007C 46524545444F5300        .freedos:		asciz "FREEDOS"
  1785 00000084 46524545444F53444C-     .freedosdla:		asciz "FREEDOSDLA"
  1785 0000008D 4100               
  1786 0000008F 454452444F5300          .edrdos:		asciz "EDRDOS"
  1787 00000096 4D53444F533500          .msdos5:		asciz "MSDOS5"
  1788 0000009D 4D53444F533700          .msdos7:		asciz "MSDOS7"
  1789 000000A4 47454F4D4554525900      .geometry:		asciz "GEOMETRY"
  1790 000000AD 554E495400              .unit:			asciz "UNIT"
  1791 000000B2 484541445300            .heads:			asciz "HEADS"
  1792 000000B8 534543544F525300        .sectors:		asciz "SECTORS"
  1793 000000C0 455854454E44454400      .extended:		asciz "EXTENDED"
  1794                                  
  1795 000000C9 0B205374617274204C-     .startlba:		counted " Start LBA "
  1795 000000D2 424120             
  1796 000000D5 072C2073697A6520        .sizelba:		counted ", size "
  1797 000000DD 53746172742000          .startchs:		asciz "Start "
  1798 000000E4 456E6420202000          .endchs:		asciz "End   "
  1799 000000EB 496E76616C69642067-     .invalid:		asciz "Invalid geometry!",13,10
  1799 000000F4 656F6D65747279210D-
  1799 000000FD 0A00               
  1800                                  
  1801 000000FF 426F6F74206661696C-     .bootfail:	asciz "Boot failure: "
  1801 00000108 7572653A2000       
  1802 0000010E 52656164696E672073-     .bootfail_read:	db "Reading sector failed (error "
  1802 00000117 6563746F7220666169-
  1802 00000120 6C656420286572726F-
  1802 00000129 7220               
  1803 0000012B 5F5F68292E0D0A00        .bootfail_read_errorcode:	asciz "__h).",13,10
  1804 00000133 4F7574206F66206D65-     .boot_out_of_memory_error:	asciz "Out of memory.", 13,10
  1804 0000013C 6D6F72792E0D0A00   
  1805 00000144 52656164206572726F-     .boot_access_error:	asciz "Read error.", 13,10
  1805 0000014D 722E0D0A00         
  1806 00000152 536563746F72207369-     .boot_sector_too_large:	asciz "Sector size too small (< 32 bytes).", 13,10
  1806 0000015B 7A6520746F6F20736D-
  1806 00000164 616C6C20283C203332-
  1806 0000016D 206279746573292E0D-
  1806 00000176 0A00               
  1807 00000178 536563746F72207369-     .boot_sector_too_small:	asciz "Sector size too large (> 8192 bytes).", 13,10
  1807 00000181 7A6520746F6F206C61-
  1807 0000018A 72676520283E203831-
  1807 00000193 393220627974657329-
  1807 0000019C 2E0D0A00           
  1808 000001A0 536563746F72207369-     .boot_sector_not_power:	asciz "Sector size not a power of two.", 13,10
  1808 000001A9 7A65206E6F74206120-
  1808 000001B2 706F776572206F6620-
  1808 000001BB 74776F2E0D0A00     
  1809 000001C2 496E76616C69642067-     .boot_invalid_sectors:	asciz "Invalid geometry sectors.", 13,10
  1809 000001CB 656F6D657472792073-
  1809 000001D4 6563746F72732E0D0A-
  1809 000001DD 00                 
  1810 000001DE 496E76616C69642067-     .boot_invalid_heads:	asciz "Invalid geometry heads.", 13,10
  1810 000001E7 656F6D657472792068-
  1810 000001F0 656164732E0D0A00   
  1811                                  
  1812 000001F8 506172746974696F6E-     .bootfail_sig_parttable:	ascii "Partition table signature missing"
  1812 00000201 207461626C65207369-
  1812 0000020A 676E6174757265206D-
  1812 00000213 697373696E67       
  1813 00000219 20286973206E6F7420-     				asciz " (is not AA55h).",13,10
  1813 00000222 4141353568292E0D0A-
  1813 0000022B 00                 
  1814 0000022C 546F6F206D616E7920-     .boot_too_many_partitions_error:asciz "Too many partitions (or a loop).",13,10
  1814 00000235 706172746974696F6E-
  1814 0000023E 7320286F722061206C-
  1814 00000247 6F6F70292E0D0A00   
  1815 0000024F 506172746974696F6E-     .boot_partition_cycle_error:	asciz "Partition table cycle detected.",13,10
  1815 00000258 207461626C65206379-
  1815 00000261 636C65206465746563-
  1815 0000026A 7465642E0D0A00     
  1816 00000271 434853544F4F4C00        .chstool:		asciz "CHSTOOL"
  1817 00000279 434853544F4F4C2075-     .uninstall_done:	db "CHSTOOL uninstalled."
  1817 00000282 6E696E7374616C6C65-
  1817 0000028B 642E               
  1818                                  %if _ELD_RECLAIM_HINT
  1819                                  			db " (Don't forget to use reclaim.eld)"
  1820                                  %endif
  1821 0000028D 0D0A00                  			asciz 13,10
  1822 00000290 434853544F4F4C2075-     .uninstall_error:	asciz "CHSTOOL unable to uninstall!",13,10
  1822 00000299 6E61626C6520746F20-
  1822 000002A2 756E696E7374616C6C-
  1822 000002AB 210D0A00           
  1823                                  
  1824                                  uinit_data: equ $
  1825 000002AF 434853544F4F4C2069-     .installed:		asciz "CHSTOOL installed.",13,10
  1825 000002B8 6E7374616C6C65642E-
  1825 000002C1 0D0A00             
  1826 000002C4 48454C5000              .keyword_help:		asciz "HELP"
  1827 000002C9 5468697320454C4420-     .help:		db "This ELD can be installed residently or used transiently.",13,10
  1827 000002D2 63616E20626520696E-
  1827 000002DB 7374616C6C65642072-
  1827 000002E4 65736964656E746C79-
  1827 000002ED 206F72207573656420-
  1827 000002F6 7472616E7369656E74-
  1827 000002FF 6C792E0D0A         
  1828 00000304 0D0A                    		db 13,10
  1829 00000306 00                      		asciz
  1830                                  
  1831 00000307 00<rep 9h>              	align 16, db 0
  1832                                  init_data_end:
  1833                                  data_size equ $ - datastart
  1834                                  transient_data_size equ data_size
  1835                                  
  1836                                  	absolute uinit_data
  1837                                  
  1838 000002AF ??                      	alignb 16
  1839                                  buffer:
  1840 000002B0 <res 2200h>             		resb 8192 + 512
  1841                                  
  1842                                  load_partition_table:
  1843 000024B0 <res 40h>               		resb 16 * 4
  1844                                  .end:
  1845                                  
  1846                                  	alignb 4
  1847                                  load_heads:
  1848 000024F0 ????                    heads:		resw 1
  1849                                  load_sectors:
  1850 000024F2 ????                    sectors:	resw 1
  1851                                  
  1852 000024F4 ????                    buffersegment:	resw 1
  1853                                  load_partition_cycle:
  1854 000024F6 ????                    		resw 1
  1855 000024F8 ????                    load_sectorsize:resw 1
  1856                                  load_sectorsizepara:
  1857 000024FA ????                    		resw 1
  1858                                  
  1859 000024FC ??                      load_unit:	resb 1
  1860 000024FD ??                      		resb 1	; placeholder to allow writing a word with pop
  1861 000024FE ??                      load_flags:	resb 1
  1862 000024FF ??                      upto:		resb 1
  1863                                  load_current_partition:
  1864 00002500 ??                      		resb 1
  1865 00002501 ??                      	alignb 2
  1866                                  zeroing:
  1867                                  load_mode:
  1868 00002502 ????                    mode:		resw 1
  1869 00002504 ????                    load_scan_flags:resw 1
  1870 00002506 ??                      extended:	resb 1
  1871 00002507 ??                      dump:		resb 1
  1872 00002508 ??                      dumpreload:	resb 1
  1873 00002509 ??                      label:		resb 1
  1874 0000250A ??                      quiet:		resb 1
  1875 0000250B ??                      skipext:	resb 1
  1876                                  zeroing_end:		; may overflow one byte
  1877                                  load_current_extended_and_is:
  1878                                  load_current_extended:
  1879 0000250C ??                      		resb 1
  1880                                  load_is_extended:
  1881 0000250D ??                      		resb 1
  1882                                  
  1883                                  
  1884 0000250E ????                    	alignb 16
  1885                                  uinit_data_end:
  1886                                  resident_data_end:
  1887                                  resident_data_size equ resident_data_end - datastart
  1888                                  
  1889                                  %if uinit_data_end >= init_data_end
  1890                                   total_data_size equ $ - datastart
  1891                                  %else
  1892                                   total_data_size equ init_data_end - datastart
  1893                                  %endif
  1894                                  %assign _DATA_SIZE total_data_size
  1895                                  
  1896                                  
  1897                                  	usesection CODE
  1898                                  
  1899                                  install:
  1900 00000D88 AC                      	lodsb
  1901 00000D89 E8[0000]EB020000        	extcall chkeol
  1902                                  
  1903                                  	houdini
  1904 00000D90 8EC3                    	mov es, bx		; => ext seg (writable)
  1905                                  
  1906 00000D92 B89000                  	mov ax, endresident - endinstalled
  1907 00000D95 262906[0200]            reloc	sub word [es:code + eldiEndCode], ax
  1908                                  internalcoderelocation		; adjust size
  1909 00000D9A 2906[0000]              reloc	sub word [relocateddata], ax
  1910                                  linkdatarelocation extseg_used	; adjust size
  1911                                  
  1912                                  %if (transient_data_size - resident_data_size) > 0
  1913                                  	mov ax, transient_data_size - resident_data_size
  1914                                  reloc	sub word [es:code + eldiEndData], ax
  1915                                  internalcoderelocation		; adjust size
  1916                                  reloc	sub word [relocateddata], ax
  1917                                  linkdatarelocation extdata_used	; adjust size
  1918                                  %endif
  1919                                  
  1920 00000D9E 8B1E[0000]              reloc	mov bx, word [relocateddata]
  1921                                  linkdatarelocation ext_command_handler
  1922                                  				; -> prior
  1923 00000DA2 BF[2000]                reloc	mov di, command		; -> our handler
  1924                                  internalcoderelocation
  1925 00000DA5 85DB                    	test bx, bx		; installing as first ?
  1926 00000DA7 740A                    	jz .only_first		; yes, simple --> (leave as extcall cmd3_not_ext)
  1927 00000DA9 AF                      	scasw			; skip entrypoint jmp strict short
  1928 00000DAA B0E9                    	mov al, 0E9h		; = jmp near opcode
  1929 00000DAC AA                      	stosb			; store
  1930 00000DAD 93                      	xchg ax, bx		; ax -> next handler
  1931 00000DAE 29F8                    	sub ax, di
  1932 00000DB0 48                      	dec ax
  1933 00000DB1 48                      	dec ax			; ax = ax - (di + 2)
  1934 00000DB2 AB                      	stosw			; store our downlink as rel16 displacement
  1935                                  
  1936                                  .only_first:
  1937 00000DB3 26800E[1000]01          reloc	setopt [es:code + eldiFlags], eldifResident
  1938                                  internalcoderelocation -3	; mark block as resident
  1939 00000DB9 C706[0000][2000]        reloc2	mov word [relocateddata], command
  1940                                  linkdatarelocation ext_command_handler, -4
  1941                                  internalcoderelocation		; -> our entrypoint
  1942                                  
  1943 00000DBF F606[0000]04            reloc	testopt [relocateddata], 4
  1944                                  linkdatarelocation options7, -3
  1945 00000DC4 7506                    	jnz @F
  1946 00000DC6 BA[AF02]                reloc	mov dx, msg.installed
  1947                                  internaldatarelocation
  1948 00000DC9 E8FCFE                  	call putsz
  1949                                  @@:
  1950 00000DCC 31C0                    	xor ax, ax
  1951 00000DCE CB                      	retf
  1952                                  
  1953                                  
  1954                                  %include "eldlink.asm"
     1                              <1> %if 0
     2                              <1> 
     3                              <1> Extensions for lDebug linker
     4                              <1> 
     5                              <1> Copyright (C) 2008-2025 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> %include "lmacros3.mac"
     1                              <2> [list -]
    16                              <1> %include "eld.mac"
     1                              <2> %if 0
     2                              <2> 
     3                              <2> Extensions for lDebug macros
     4                              <2> 
     5                              <2> Copyright (C) 2008-2025 E. C. Masloch
     6                              <2> 
     7                              <2> Usage of the works is permitted provided that this
     8                              <2> instrument is retained with the works, so that any entity
     9                              <2> that uses the works is notified of this instrument.
    10                              <2> 
    11                              <2> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    12                              <2> 
    13                              <2> %endif
    14                              <2> 
    15                              <2> %ifndef ELD_MAC
    16                              <2> %define ELD_MAC 1
    17                              <2> 
    18                              <2> %include "lmacros3.mac"
    19                              <2> 
    20                              <2> 		; ELD executable header
    21                              <2> 	struc ELD_HEADER
    22                              <2> eldhSignature:		resb 4	; "ELD1"
    23                              <2> 			resb 3	; reserved
    24                              <2> 			resb 1	; 26 (Ctrl-Z)
    25                              <2> eldhCodeOffset:		resd 1	; position displacement from eldhSignature
    26                              <2> eldhCodeImageLength:	resw 1	; amount bytes, at least 32
    27                              <2> eldhCodeAllocLength:	resw 1	; amount bytes, added to prior. sum < 64 KiB
    28                              <2> eldhDataOffset:		resd 1
    29                              <2> eldhDataImageLength:	resw 1	; (zero allowed)
    30                              <2> eldhDataAllocLength:	resw 1	; (zero allowed)
    31                              <2> eldhCodeEntrypoint:	resw 1	; within code section, used as displacement
    32                              <2> eldhReserved:		resb 4	; reserved
    33                              <2> eldhExtensionSize:	resw 1	; from eldhSignature, -> past eldhx fields in use
    34                              <2> 	endstruc
    35                              <2> 	endarea ELD_HEADER, 1
    36                              <2> 
    37                              <2> 	struc ELD_HEADERX
    38                              <2> eldhxHeader:		resb ELD_HEADER_size
    39                              <2> eldhxDescriptionOffset:	resd 1	; zero if none, from eldhxHeader. <= 128 Bytes
    40                              <2> eldhxHelpOffset:	resd 1	; zero if none, from eldhxHeader
    41                              <2> eldhxLibTable:		resd 1	; zero if none, from eldhxHeader
    42                              <2> eldhxDateTimeOffset:	resd 1	; zero if none, from eldhxHeader
    43                              <2> 	alignb 16
    44                              <2> 	endstruc
    45                              <2> 
    46                              <2> 	struc ELD_TRAILER_HEADER
    47                              <2> eldthSignature:		resb 8	; "ELD1TAIL"
    48                              <2> eldthHeaderOffset:	resd 1	; negative displacement from eldthSignature,
    49                              <2> 				;  add this dword to the seek offset
    50                              <2> eldthReserved:		resw 1	; reserved, must be initialised to zero
    51                              <2> eldthChecksum:		resw 1	; sum of all words in trailer header = 0
    52                              <2> 	endstruc
    53                              <2> 	endarea ELD_TRAILER_HEADER, 1
    54                              <2> 
    55                              <2> 	struc ELD_LIBTABLE
    56                              <2> eldltFormat:		resw 1
    57                              <2> 	; 0 = uncompressed
    58                              <2> 	; 2 = heatshrink compressed
    59                              <2> 	; 3 = lzexedat -4 compressed
    60                              <2> 	; 4 = lzexedat -4 -l compressed
    61                              <2> eldltAmount:		resw 1
    62                              <2> eldltOffset:		resd 1	; from eldhxHeader
    63                              <2> eldltCompressedLength:		; (dword, only present if format 2, 3, or 4)
    64                              <2> 	endstruc
    65                              <2> 	endarea ELD_LIBTABLE, 1
    66                              <2> 
    67                              <2> 		; ELD instance header
    68                              <2> 	struc ELD_INSTANCE
    69                              <2> eldiStartCode:		resw 1	; -> this structure itself (para aligned)
    70                              <2> eldiEndCode:		resw 1	; -> behind memory used by instance (para aligned)
    71                              <2> eldiStartData:		resw 1	; -> data in data entry section (para aligned), or 0
    72                              <2> eldiEndData:		resw 1	; -> behind data (para aligned), or 0
    73                              <2> eldiIdentifier:		resb 8	; blank-filled text
    74                              <2> eldiFlags:		resw 1	; flags
    75                              <2> eldiListing_size equ 14
    76                              <2> eldiListing:		resb eldiListing_size
    77                              <2> 				; ASCIZ listing file name
    78                              <2> 	endstruc
    79                              <2> 		; flags for eldiFlags:
    80                              <2> eldifResident:		equ 1
    81                              <2> 
    82                              <2> 		; ELD link info header
    83                              <2> 	struc ELD_LINKINFO
    84                              <2> eldlSignature:		resw 1	; 0E1D1h
    85                              <2> eldlReserved:		resw 2
    86                              <2> eldlUseLinkHash:	resw 1
    87                              <2> eldlDataAmount:		resw 1
    88                              <2> eldlDataPrefixes:	resw 1
    89                              <2> eldlDataEntries:	resw 1
    90                              <2> eldlDataAddresses:	resw 1
    91                              <2> eldlCodeAmount:		resw 1
    92                              <2> eldlCodePrefixes:	resw 1
    93                              <2> eldlCodeEntries:	resw 1
    94                              <2> eldlCodeAddresses:	resw 1
    95                              <2> 	endstruc
    96                              <2> 
    97                              <2> 	numdef ELD_CODE_VSTART, 9001h
    98                              <2> 	numdef ELD_DATA_VSTART, 8000h
    99                              <2> 	numdef ELD_RELOC_VSTART, 8000h
   100                              <2> 
   101                              <2> 	numdef ELD_RECLAIM_HINT, 0
   102                              <2> 	strdef ELD_LISTING, ""
   103                              <2> 	numdef ELD_DATETIME, 0
   104                              <2> 
   105                              <2> %if _ELD_DATETIME
   106                              <2>  %define PUT_ELDHX_DATETIME_OFFSET at eldhxDateTimeOffset, dd DATAOFFSET + datetime - datastart
   107                              <2>  %macro PUT_ELD_DATETIME 0.nolist
   108                              <2> datetime:	asciz __UTC_DATE__,'T',__UTC_TIME__,'Z'
   109                              <2> 		asciz		; for future extension
   110                              <2>  %endmacro
   111                              <2> %else
   112                              <2>  %define PUT_ELDHX_DATETIME_OFFSET
   113                              <2>  %define PUT_ELD_DATETIME
   114                              <2> %endif
   115                              <2> 
   116                              <2> %endif
    17                              <1> 
    18                              <1> 	cpu 8086
    19                              <1> 
    20                              <1> %if ELDSTRICT
    21                              <1>  %if ELDSTRICTCOUNTER
    22                              <1>   %error Missing relocation
    23                              <1>  %endif
    24                              <1> %endif
    25                              <1> 	eldstrict off		; linker does some relocations
    26                              <1> 
    27                              <1> %ifn ELDCALLCALL_DUMPED
    28                              <1> 	eldcall_dump_callcall ELDCALL_CALLCALL_LIST
    29                              <1> %endif
    30                              <1> 
    31                              <1> 	numdef ELD_IDENTICALISE, 0
    32                              <1> 	numdef ELD_DEBUG, 0
    33                              <1> 	numdef ELD_LINKER_PASSES, 1
    34                              <1> 	strdef LISTING, _ELD_LISTING
    35                              <1> 	numdef ELDCALL_OPTIONAL, ELDCALL_OPTIONAL_STATUS
    36                              <1> 	numdef ELDDATA_OPTIONAL, ELDDATA_OPTIONAL_STATUS
    37                              <1> 	numdef ELDDATA_NEXT, ELDDATA_NEXT_STATUS
    38                              <1> 	numdef ELDCALL_NEXT, ELDCALL_NEXT_STATUS
    39                              <1> %if _ELD_IDENTICALISE
    40                              <1>  ;%assign _ELDCALL_OPTIONAL 1
    41                              <1> %endif
    42                              <1> %ifn _ELDCALL_OPTIONAL
    43                              <1> %assign ELDCALL_OPTIONAL_STATUS 2		; not allowed
    44                              <1> %endif
    45                              <1> ;%ifn _ELDDATA_OPTIONAL
    46                              <1> ;%assign ELDDATA_OPTIONAL_STATUS 2		; not allowed
    47                              <1> ;%endif
    48                              <1> 	gendef MAP, ""
    49                              <1> 
    50                              <1> %ifnidni _MAP, ""
    51                              <1>  [map all _MAP]
    52                              <1> %endif
    53                              <1> 
    54                              <1> 
    55                              <1> endresident: equ ($ + _CURRENT_SECTION %+ FIXUP + 15) & ~15
    56                              <1> 
    57                              <1> %if _ELD_LINKER_PASSES
    58                              <1> %assign ELDLINKER 1
    59                              <1> 
    60                              <1> 	struc LINKTABLE
    61 00000000 ????????            <1> ltCodeToCode:	resw 2
    62 00000004 ????????            <1> ltCodeToData:	resw 2
    63 00000008 ????????            <1> ltDataToCode:	resw 2
    64 0000000C ????????            <1> ltDataToData:	resw 2
    65 00000010 ????????            <1> ltLinkData:	resw 2
    66 00000014 ????????            <1> ltLinkCode:	resw 2
    67                              <1> 	endstruc
    68                              <1> %endif
    69                              <1> 
    70                              <1> 
    71                              <1> 		; INP:	es:dx -> loaded initial ELD image
    72                              <1> 		;	 ELD instance structure filled
    73                              <1> 		;	es => ELD code area
    74                              <1> 		;	ds:di -> link info
    75                              <1> 		;	ss:bx -> loaded initial data
    76                              <1> 		;	ss:si -> command line tail
    77                              <1> 		;	cs:ip -> entrypoint
    78                              <1> 		;	ss:sp -> far return address for current mode
    79                              <1> 		; STT:	UP, EI
    80                              <1> linker:
    81                              <1> 		; The first 15 Bytes of the linker should be
    82                              <1> 		;  the same regardless of the linker options
    83                              <1> 		;  used (debug, passes, vstart). This allows
    84                              <1> 		;  the eldcomp ELD to match even if up to 15
    85                              <1> 		;  Bytes of the linker are trailing in the
    86                              <1> 		;  resident part of the ELD.
    87                              <1> 	lframe
    88                              <1>  %if ELDOTHER
    89                              <1> 	lvar dword, linkinfo_other
    90                              <1> 	lvar word, use_hash_other
    91                              <1>  %endif
    92 00000DCF 5589E5              <1> 	lenter
    93                              <1> 	lvar dword, instance
    94 00000DD2 06                  <1> 	 push es
    95 00000DD3 52                  <1> 	 push dx		; -> start of where we're loaded in ELD cs
    96                              <1> 	lvar word, targetsection_low_optional_high
    97 00000DD4 50                  <1> 	 push ax		; placeholder
    98                              <1> 	lequ ?targetsection_low_optional_high, targetsection
    99                              <1> 	lequ ?targetsection_low_optional_high + 1, optional
   100                              <1> 	lvar dword, linkinfo
   101 00000DD5 1E                  <1> 	 push ds
   102 00000DD6 57                  <1> 	 push di		; -> link info (in debugger ss or message seg)
   103                              <1> 	lvar dword, nextreloc
   104 00000DD7 06                  <1> 	 push es		; => ELD cs
   105 00000DD8 52                  <1> 	 push dx		; placeholder
   106                              <1> 	lvar dword, entry
   107 00000DD9 06                  <1> 	 push es		; => ELD cs
   108 00000DDA 50                  <1> 	 push ax		; placeholder
   109 00000DDB 31C0                <1> 	xor ax, ax
   110 00000DDD 813DD1E1            <1> 	cmp word [di + eldlSignature], 0E1D1h
   111                              <1> %if ($ - linker) < 16
   112                              <1>  %error Expected invariant first paragraph of linker
   113                              <1> %endif
   114 00000DE1 7403                <1> 	je @F
   115                              <1> .error_j1:
   116 00000DE3 E9C602              <1> 	jmp .error		; signature mismatch -->
   117                              <1> @@:
   118 00000DE6 837D0601            <1> 	cmp word [di + eldlUseLinkHash], 1
   119 00000DEA 77F7                <1> 	ja .error_j1		; unknown use link hash number -->
   120 00000DEC 7201                <1> 	jb @F
   121                              <1> %if _ELDDATA_NEXT || _ELDCALL_NEXT
   122                              <1> 	dec al			; = -1 if hash used
   123                              <1> %else
   124 00000DEE 48                  <1> 	dec ax
   125                              <1> %endif
   126                              <1> @@:
   127                              <1> 	lvar word, use_hash_low_skip_last_high
   128 00000DEF 50                  <1> 	 push ax		; = -1 if hash used, else 0
   129                              <1> 	lequ ?use_hash_low_skip_last_high, use_hash
   130                              <1> 	lequ ?use_hash_low_skip_last_high + 1, skip_last
   131                              <1> %if _ELD_IDENTICALISE && _ELD_LINKER_PASSES
   132                              <1> 	mov ax, linktable - code
   133                              <1> 	lvar word, lt
   134                              <1> 	 push ax		; -> link tables (a single reference)
   135                              <1> %endif
   136                              <1> %if _ELD_LINKER_PASSES || ELDOTHER || _ELDDATA_OPTIONAL || _ELDCALL_OPTIONAL
   137 00000DF0 31C0                <1> 	xor ax, ax
   138                              <1>  %if _ELD_LINKER_PASSES
   139                              <1> 	lvar word, pass
   140 00000DF2 50                  <1> 	 push ax		; = 0 for linker itself, = 2 for application
   141                              <1> 	lvar word, amounterrors
   142 00000DF3 50                  <1> 	 push ax		; how many distinct errors encountered in pass 2
   143                              <1>  %endif
   144                              <1>  %if _ELD_LINKER_PASSES || _ELDDATA_OPTIONAL || _ELDCALL_OPTIONAL
   145                              <1> 	lvar word, name
   146 00000DF4 50                  <1> 	 push ax		; -> name currently being sought (in our table)
   147                              <1>  %endif
   148                              <1>  %if ELDOTHER
   149                              <1> 	lvar word, other
   150                              <1> 	 push ax		; byte: 0 = own data links, -1 = other data links
   151                              <1>  %endif
   152                              <1>  %if _ELDDATA_OPTIONAL || _ELDCALL_OPTIONAL
   153                              <1> 	lvar word, optionalmissing
   154                              <1> 	 push ax
   155                              <1>  %endif
   156                              <1> %endif
   157 00000DF5 56                  <1> 	push si			; -> command line tail
   158 00000DF6 53                  <1> 	push bx			; -> data block in ELD data area (segment ss)
   159                              <1> 
   160                              <1> 			; simple: add instance base (dx) to code
   161 00000DF7 06                  <1> 	push es
   162 00000DF8 1F                  <1> 	pop ds			; ds = es => ELD cs
   163                              <1> %if _ELD_LINKER_PASSES
   164                              <1> .pass:
   165 00000DF9 8B5EEA              <1> 	mov bx, word [bp + ?pass]	; 0 or 2
   166 00000DFC 01D3                <1> 	add bx, dx		; -> start of the ELD instance in cs, +0 or +2
   167                              <1>  %if _ELD_IDENTICALISE
   168                              <1> 	add bx, word [bp + ?lt]	; add in single reference to linktable
   169                              <1> 	mov si, word [ltCodeToCode + bx]
   170                              <1>  %else
   171 00000DFE 8BB76811            <1> 	mov si, word [linktable - code + ltCodeToCode + bx]
   172                              <1>  %endif
   173                              <1> %else
   174                              <1> 	mov si, internalcodetocoderelocations - code
   175                              <1> %endif		 		; si -> table for code to code (linker or app)
   176 00000E02 01D6                <1> 	add si, dx		; relocate the table pointer itself
   177                              <1> @@:
   178 00000E04 AD                  <1> 	lodsw
   179 00000E05 85C0                <1> 	test ax, ax		; was last ?
   180 00000E07 740B                <1> 	jz @F			; yes -->
   181 00000E09 93                  <1> 	xchg bx, ax		; bx = entry
   182 00000E0A 01D3                <1> 	add bx, dx		; relocate the entry itself
   183                              <1> %if _ELD_CODE_VSTART
   184 00000E0C 812F[0000]          <1> 	sub word [bx], code	; undo adjustment
   185                              <1> %endif
   186 00000E10 0117                <1> 	add word [bx], dx	; relocate word referenced by entry
   187 00000E12 EBF0                <1> 	jmp @B
   188                              <1> 
   189                              <1> @@:
   190                              <1> 			; next, add heap data base (on stack) to code
   191                              <1> %if _ELD_LINKER_PASSES
   192 00000E14 8B5EEA              <1> 	mov bx, word [bp + ?pass]	; 0 or 2
   193 00000E17 01D3                <1> 	add bx, dx		; -> start of the ELD instance in cs, +0 or +2
   194                              <1>  %if _ELD_IDENTICALISE
   195                              <1> 	add bx, word [bp + ?lt]	; add in single reference to linktable
   196                              <1> 	mov si, word [ltCodeToData + bx]
   197                              <1>  %else
   198 00000E19 8BB76C11            <1> 	mov si, word [linktable - code + ltCodeToData + bx]
   199                              <1>  %endif
   200                              <1> %else
   201                              <1> 	mov si, internalcodetodatarelocations - code
   202                              <1> %endif				; si -> table for code to data (linker or app)
   203 00000E1D 01D6                <1> 	add si, dx		; relocate the table pointer itself
   204                              <1> @@:
   205 00000E1F AD                  <1> 	lodsw
   206 00000E20 85C0                <1> 	test ax, ax		; was last ?
   207 00000E22 740C                <1> 	jz @F			; yes -->
   208 00000E24 93                  <1> 	xchg bx, ax		; bx = entry
   209 00000E25 01D3                <1> 	add bx, dx		; relocate the entry itself
   210                              <1> 		; ! access the offset of the data area block, topmost on stack
   211 00000E27 58                  <1> 	pop ax			; ax -> heap data
   212 00000E28 50                  <1> 	push ax
   213                              <1> %if _ELD_DATA_VSTART
   214 00000E29 2D[0000]            <1> 	sub ax, datastart	; undo adjustment
   215                              <1> %endif
   216 00000E2C 0107                <1> 	add word [bx], ax	; relocate word referenced by entry
   217 00000E2E EBEF                <1> 	jmp @B
   218                              <1> 
   219                              <1> @@:
   220                              <1> 
   221                              <1> 			; add instance base (dx) to data
   222                              <1> %if _ELD_LINKER_PASSES
   223 00000E30 8B5EEA              <1> 	mov bx, word [bp + ?pass]
   224 00000E33 01D3                <1> 	add bx, dx
   225                              <1>  %if _ELD_IDENTICALISE
   226                              <1> 	add bx, word [bp + ?lt]
   227                              <1> 	mov si, word [ltDataToCode + bx]
   228                              <1>  %else
   229 00000E35 8BB77011            <1> 	mov si, word [linktable - code + ltDataToCode + bx]
   230                              <1>  %endif
   231                              <1> %else
   232                              <1> 	mov si, internaldatatocoderelocations - code
   233                              <1> %endif
   234 00000E39 01D6                <1> 	add si, dx
   235                              <1> @@:
   236 00000E3B AD                  <1> 	lodsw
   237 00000E3C 83F8FF              <1> 	cmp ax, -1		; was last ?
   238 00000E3F 740F                <1> 	je @F			; yes -->
   239 00000E41 93                  <1> 	xchg bx, ax		; bx = entry
   240                              <1> 		; ! access the offset of the data area block, topmost on stack
   241 00000E42 58                  <1> 	pop ax
   242 00000E43 50                  <1> 	push ax
   243 00000E44 01C3                <1> 	add bx, ax		; relocate the entry itself
   244                              <1> %if _ELD_CODE_VSTART
   245 00000E46 36812F[0000]        <1> 	sub word [ss:bx], code	; undo adjustment
   246                              <1> %endif
   247 00000E4B 360117              <1> 	add word [ss:bx], dx	; relocate word referenced by entry
   248 00000E4E EBEB                <1> 	jmp @B
   249                              <1> 
   250                              <1> @@:
   251                              <1> 			; next, add heap data base (on stack) to data
   252                              <1> %if _ELD_LINKER_PASSES
   253 00000E50 8B5EEA              <1> 	mov bx, word [bp + ?pass]
   254 00000E53 01D3                <1> 	add bx, dx
   255                              <1>  %if _ELD_IDENTICALISE
   256                              <1> 	add bx, word [bp + ?lt]
   257                              <1> 	mov si, word [ltDataToData + bx]
   258                              <1>  %else
   259 00000E55 8BB77411            <1> 	mov si, word [linktable - code + ltDataToData + bx]
   260                              <1>  %endif
   261                              <1> %else
   262                              <1> 	mov si, internaldatatodatarelocations - code
   263                              <1> %endif
   264 00000E59 01D6                <1> 	add si, dx
   265                              <1> @@:
   266 00000E5B AD                  <1> 	lodsw
   267 00000E5C 83F8FF              <1> 	cmp ax, -1		; was last ?
   268 00000E5F 740D                <1> 	je @F			; yes -->
   269 00000E61 93                  <1> 	xchg bx, ax		; bx = entry
   270                              <1> 		; ! access the offset of the data area block, topmost on stack
   271 00000E62 58                  <1> 	pop ax			; ax -> heap data
   272 00000E63 50                  <1> 	push ax
   273 00000E64 01C3                <1> 	add bx, ax		; relocate the entry itself
   274                              <1> %if _ELD_DATA_VSTART
   275 00000E66 2D[0000]            <1> 	sub ax, datastart	; undo adjustment
   276                              <1> %endif
   277 00000E69 360107              <1> 	add word [ss:bx], ax	; relocate word referenced by entry
   278 00000E6C EBED                <1> 	jmp @B
   279                              <1> 
   280                              <1> @@:
   281 00000E6E 8B56FC              <1> 	mov dx, word [bp + ?instance]
   282                              <1> 				; reset (why??) -> ELD instance in ELD cs
   283                              <1> %if _ELD_LINKER_PASSES
   284 00000E71 8B5EEA              <1> 	mov bx, word [bp + ?pass]
   285 00000E74 01D3                <1> 	add bx, dx
   286                              <1>  %if _ELD_IDENTICALISE
   287                              <1> 	add bx, word [bp + ?lt]
   288                              <1> 	add dx, word [ltLinkData + bx]
   289                              <1>  %else
   290 00000E76 03977811            <1> 	add dx, word [linktable - code + ltLinkData + bx]
   291                              <1>  %endif
   292                              <1> %else
   293                              <1> 	add dx, linkerdatarelocations - code
   294                              <1> %endif
   295                              <1> .otherloop:
   296 00000E7A 8956F2              <1> 	mov word [bp + ?nextreloc], dx
   297                              <1> 				; -> data link relocation table
   298                              <1> 
   299                              <1> .datarelocloop:		; must be done before further relocs
   300 00000E7D C576F2              <1> 	lds si, [bp + ?nextreloc]
   301 00000E80 AD                  <1> 	lodsw			; ax = section indicator
   302 00000E81 85C0                <1> 	test ax, ax		; end of table ?
   303 00000E83 7503E90401          <1> 	jz .donedatareloc
   304 00000E88 48                  <1> 	dec ax			; al = 1 if data, 0 if code (NB ah may != 0)
   305                              <1> 		; ! access the offset of the data area block, topmost on stack
   306 00000E89 5B                  <1> 	pop bx
   307 00000E8A 53                  <1> 	push bx			; bx -> ELD data block
   308 00000E8B 8946FA              <1> 	mov word [bp + ?targetsection_low_optional_high], ax
   309 00000E8E 84C0                <1> 	test al, al		; data ?
   310 00000E90 AD                  <1> 	lodsw
   311 00000E91 7504                <1> 	jnz @F			; yes -->
   312 00000E93 0346FC              <1> 	add ax, word [bp + ?instance]
   313                              <1> 				; relocate entry into code
   314 00000E96 A9                  <1> 	db __TEST_IMM16		; (skip add)
   315                              <1> @@:
   316 00000E97 01D8                <1> 	add ax, bx		; relocate entry into data
   317 00000E99 8946EE              <1> 	mov word [bp + ?entry], ax
   318                              <1> 				; save away -> where to patch
   319 00000E9C AD                  <1> 	lodsw			; get unrelocated -> name
   320 00000E9D 8976F2              <1> 	mov word [bp + ?nextreloc], si
   321                              <1> 				; update -> behind relocation table entry
   322                              <1> %if _ELDDATA_NEXT
   323                              <1> 	rol byte [bp + ?skip_last], 1	; skipping ?
   324                              <1> 	jnc @F				; no -->
   325                              <1> 	test byte [bp + ?optional], 8	; is it a last relocation ?
   326                              <1> 	jz .datarelocloop		; no, leave skip_last set -->
   327                              <1> 	not byte [bp + ?skip_last]	; disable skip_last
   328                              <1> 	jmp .datarelocloop
   329                              <1> @@:
   330                              <1> %endif
   331 00000EA0 E8BD00              <1> 	call .build_match	; get ax = scan value, si -> counted string,
   332                              <1> 				;  dl = original value at byte [si]
   333                              <1> 				; NC if symbol already not found before
   334                              <1> 				; CY if to search for the symbol
   335                              <1> %if _ELD_LINKER_PASSES
   336 00000EA3 73D8                <1> 	jnc .datarelocloop	; if duplicate of a not found symbol -->
   337                              <1> %endif
   338 00000EA5 C45EF6              <1> 	les bx, [bp + ?linkinfo]
   339                              <1> %if ELDOTHER
   340                              <1> 	rol byte [bp + ?other], 1
   341                              <1> 	jnc @F
   342                              <1> 	les bx, [bp + ?linkinfo_other]
   343                              <1> @@:
   344                              <1> %endif				; es:bx -> link info table of the ELD host
   345 00000EA8 268B4F08            <1> 	mov cx, word [es:bx + eldlDataAmount]	; amount data link info
   346 00000EAC 268B7F0A            <1> 	mov di, word [es:bx + eldlDataPrefixes]	; -> prefixes or hashes
   347                              <1> .datarelocfind:
   348 00000EB0 83F901              <1> 	cmp cx, 1			; NZ if cx == 0
   349 00000EB3 F2AF                <1> 	repne scasw			; scan initial
   350                              <1> %if _ELDDATA_OPTIONAL
   351                              <1> 	jne .datanotfound_may_be_optional
   352                              <1> %else
   353 00000EB5 7541                <1> 	jne .datanotfound
   354                              <1> %endif
   355 00000EB7 57                  <1> 	push di
   356 00000EB8 51                  <1> 	push cx
   357 00000EB9 56                  <1> 	push si
   358 00000EBA 262B7F0A            <1> 	sub di, word [es:bx + eldlDataPrefixes]	; = double index, 1-based
   359 00000EBE 4F                  <1> 	dec di
   360 00000EBF 4F                  <1> 	dec di				; 0-based
   361 00000EC0 26037F0C            <1> 	add di, word [es:bx + eldlDataEntries]	; -> entry
   362 00000EC4 268B3D              <1> 	mov di, [es:di]			; -> counted suffix/string
   363 00000EC7 B500                <1> 	mov ch, 0
   364 00000EC9 8A0C                <1> 	mov cl, byte [si]		; cx = length
   365 00000ECB 41                  <1> 	inc cx
   366                              <1> 	; cmp al, al			; ZR if length is zero
   367 00000ECC F3A6                <1> 	repe cmpsb			; match ?
   368 00000ECE 5E                  <1> 	pop si
   369 00000ECF 59                  <1> 	pop cx
   370 00000ED0 5F                  <1> 	pop di
   371 00000ED1 75DD                <1> 	jne .datarelocfind		; if not found this time,
   372                              <1> 					;  scan for next initial -->
   373 00000ED3 8814                <1> 	mov byte [si], dl		; restore the original byte at counter
   374 00000ED5 262B7F0A            <1> 	sub di, word [es:bx + eldlDataPrefixes]	; = double index, 1-based
   375 00000ED9 4F                  <1> 	dec di
   376 00000EDA 4F                  <1> 	dec di				; 0-based
   377 00000EDB 26037F0E            <1> 	add di, word [es:bx + eldlDataAddresses]	; -> address (offset)
   378 00000EDF 268B05              <1> 	mov ax, word [es:di]		; get link data from the table
   379 00000EE2 E80700              <1> 	call .address_data_reloc
   380                              <1> %if _ELD_RELOC_VSTART
   381 00000EE5 2D[0000]            <1> 	sub ax, relocateddata		; *not* a relocation
   382                              <1> %endif
   383 00000EE8 0104                <1> 	add word [si], ax		; relocate
   384                              <1> %if _ELDDATA_NEXT
   385                              <1> 	test byte [bp + ?optional], 4	; is it a next relocation ?
   386                              <1> 	jz .datarelocloop
   387                              <1> 	mov byte [bp + ?skip_last], -1	; skip subsequent next/last relocs
   388                              <1> %endif
   389 00000EEA EB91                <1> 	jmp .datarelocloop
   390                              <1> 
   391                              <1> .address_data_reloc:
   392 00000EEC C576EE              <1> 	lds si, [bp + ?entry]		; -> entry if in ELD code instance
   393 00000EEF 807EFA00            <1> 	cmp byte [bp + ?targetsection], 0
   394                              <1> 					; relocation in code ?
   395 00000EF3 7402                <1> 	je @F				; yes -->
   396 00000EF5 16                  <1> 	push ss
   397 00000EF6 1F                  <1> 	pop ds				; => our ELD data block
   398                              <1> @@:
   399 00000EF7 C3                  <1> 	retn
   400                              <1> 
   401                              <1> %if _ELDDATA_OPTIONAL
   402                              <1> .datanotfound_may_be_optional:
   403                              <1> 	mov byte [si], dl		; restore the original byte at counter
   404                              <1> %if _ELDDATA_NEXT
   405                              <1> 	test byte [bp + ?optional], 3	; is it an optional relocation ?
   406                              <1> %else
   407                              <1> 	cmp byte [bp + ?optional], 0	; is it an optional relocation ?
   408                              <1> %endif
   409                              <1> %if _ELD_DEBUG
   410                              <1> 	jnz @F
   411                              <1>  %ifn _ELD_LINKER_PASSES
   412                              <1> 	mov si, 0			; (invalid link)
   413                              <1> linkdatarelocation internalflags6
   414                              <1> 	test si, si
   415                              <1> 	jz .datanotfound
   416                              <1> 	mov si, 0			; (invalid link)
   417                              <1> linkdatarelocation options7
   418                              <1> 	test si, si
   419                              <1> 	jz .datanotfound
   420                              <1>  %else
   421                              <1> 	cmp byte [bp + ?pass], 0
   422                              <1> 	je .datanotfound
   423                              <1>  %endif
   424                              <1> 	houdini				; (the above conditions are for this)
   425                              <1> 	jmp .datanotfound
   426                              <1> @@:
   427                              <1> %else
   428                              <1> 	jz .datanotfound		; no, handle as an error -->
   429                              <1> %endif
   430                              <1> 
   431                              <1> %if ELDDATA_PMREQUIRED_STATUS
   432                              <1> 	mov si, relocateddata
   433                              <1> linkdatarelocation build_option_PM
   434                              <1> 	test si, si			; is it a PM build ?
   435                              <1> 	jz @F				; no --> (treat PM required as optional)
   436                              <1> 	test byte [bp + ?optional], 2	; optional status is PM required ?
   437                              <1> 	jnz .datanotfound		; yes, handle as an error -->
   438                              <1> @@:
   439                              <1> %endif
   440                              <1> 
   441                              <1> %if _ELD_LINKER_PASSES
   442                              <1> %if _ELDDATA_OPTIONAL || _ELDCALL_OPTIONAL
   443                              <1> 	rol byte [bp + ?optionalmissing], 1
   444                              <1> 	jnc .optionaldatamissingmsg
   445                              <1> 	mov si, [bp + ?name]
   446                              <1> 	or byte [si], 80h
   447                              <1> 	not byte [bp + ?optionalmissing]
   448                              <1> 	jmp @F
   449                              <1> .optionaldatamissingmsg:
   450                              <1> %endif
   451                              <1> 	testopt [ss:relocateddata], 2	; debug optional link ?
   452                              <1> linkdatarelocation options7, -3
   453                              <1> 	jz @F				; no -->
   454                              <1> %if _ELDDATA_OPTIONAL || _ELDCALL_OPTIONAL
   455                              <1> 	mov byte [bp + ?optionalmissing + 1], -1
   456                              <1> %endif
   457                              <1> 	mov si, lmsg.warning_data_optional
   458                              <1> internalcoderelocation
   459                              <1> 	call .notfound			; display a warning
   460                              <1> %if _ELDDATA_OPTIONAL || _ELDCALL_OPTIONAL
   461                              <1> 	not byte [bp + ?optionalmissing + 1]
   462                              <1> %endif
   463                              <1> @@:
   464                              <1> %endif
   465                              <1> %if _ELDDATA_NEXT
   466                              <1> 	test byte [bp + ?optional], 4	; is it a next relocation ?
   467                              <1> 	jnz .datarelocloop
   468                              <1> %endif
   469                              <1> 	call .address_data_reloc
   470                              <1> 	and word [si], 0		; indicate optional data link failed
   471                              <1> 	jmp .datarelocloop
   472                              <1> %endif
   473                              <1> 
   474                              <1> 
   475                              <1> %if _ELDCALL_OPTIONAL
   476                              <1> .codenotfound_may_be_optional:
   477                              <1> 	mov byte [si], dl		; restore the original byte at counter
   478                              <1> %if _ELDCALL_NEXT
   479                              <1> 	test byte [bp + ?optional], 3	; is it an optional relocation ?
   480                              <1> %else
   481                              <1> 	cmp byte [bp + ?optional], 0	; is it an optional relocation ?
   482                              <1> %endif
   483                              <1> %if _ELD_DEBUG
   484                              <1> 	jnz @F
   485                              <1>  %ifn _ELD_LINKER_PASSES
   486                              <1> 	mov si, 0			; (invalid link)
   487                              <1> linkdatarelocation internalflags6
   488                              <1> 	test si, si
   489                              <1> 	jz .codenotfound
   490                              <1> 	mov si, 0			; (invalid link)
   491                              <1> linkdatarelocation options7
   492                              <1> 	test si, si
   493                              <1> 	jz .codenotfound
   494                              <1>  %else
   495                              <1> 	cmp byte [bp + ?pass], 0
   496                              <1> 	je .codenotfound
   497                              <1>  %endif
   498                              <1> 	houdini				; (the above conditions are for this)
   499                              <1> 	jmp .codenotfound
   500                              <1> @@:
   501                              <1> %else
   502                              <1> 	jz .codenotfound		; no, handle as an error -->
   503                              <1> %endif
   504                              <1> 
   505                              <1> %if ELDCALL_PMREQUIRED_STATUS
   506                              <1>  %if _ELD_LINKER_PASSES
   507                              <1>   %assign ELDLINKER 0
   508                              <1>  %endif
   509                              <1> 	mov si, relocateddata
   510                              <1> linkdatarelocation build_option_PM
   511                              <1>  %if _ELD_LINKER_PASSES
   512                              <1>   %assign ELDLINKER 1
   513                              <1>  %endif
   514                              <1> 	test si, si			; is it a PM build ?
   515                              <1> 	jz @F				; no --> (treat PM required as optional)
   516                              <1> 	test byte [bp + ?optional], 2	; optional status is PM required ?
   517                              <1> 	jnz .codenotfound		; yes, handle as an error -->
   518                              <1> @@:
   519                              <1> %endif
   520                              <1> 
   521                              <1> %if _ELD_LINKER_PASSES
   522                              <1> %if _ELDDATA_OPTIONAL || _ELDCALL_OPTIONAL
   523                              <1> 	rol byte [bp + ?optionalmissing], 1
   524                              <1> 	jnc .optionalcodemissingmsg
   525                              <1> 	mov si, [bp + ?name]
   526                              <1> 	or byte [si], 80h
   527                              <1> 	not byte [bp + ?optionalmissing]
   528                              <1> 	jmp @F
   529                              <1> .optionalcodemissingmsg:
   530                              <1> %endif
   531                              <1> 	testopt [ss:relocateddata], 2	; debug optional link ?
   532                              <1> linkdatarelocation options7, -3
   533                              <1> 	jz @F				; no -->
   534                              <1> %if _ELDDATA_OPTIONAL || _ELDCALL_OPTIONAL
   535                              <1> 	mov byte [bp + ?optionalmissing + 1], -1
   536                              <1> %endif
   537                              <1> 	mov si, lmsg.warning_code_optional
   538                              <1> internalcoderelocation
   539                              <1> 	call .notfound			; display a warning
   540                              <1> %if _ELDDATA_OPTIONAL || _ELDCALL_OPTIONAL
   541                              <1> 	not byte [bp + ?optionalmissing + 1]
   542                              <1> %endif
   543                              <1> @@:
   544                              <1> %endif
   545                              <1> %if _ELDCALL_NEXT
   546                              <1> 	test byte [bp + ?optional], 4	; is it a next relocation ?
   547                              <1> 	jnz .coderelocloop
   548                              <1> %endif
   549                              <1> 	lds si, [bp + ?entry]		; -> code site (must be in ELD cs)
   550                              <1> 	mov word [si], 9090h
   551                              <1> 	mov byte [si + 2], 90h		; indicate optional code link failed
   552                              <1> 					;  (NOP out the 3-byte call near imm)
   553                              <1> 	jmp .coderelocloop
   554                              <1> %endif
   555                              <1> 
   556                              <1> 
   557                              <1> %if _ELD_LINKER_PASSES
   558                              <1> .datanotfound:
   559 00000EF8 BE[AC16]            <1> 	mov si, lmsg.error_data
   560                              <1> internalcoderelocation
   561 00000EFB E81900              <1> 	call .notfound			; display error
   562 00000EFE 7306                <1> 	jnc .error_j3			; NC if in pass 0, error out now -->
   563 00000F00 FF46E8              <1> 	inc word [bp + ?amounterrors]	; count the amount of errors
   564 00000F03 E977FF              <1> 	jmp .datarelocloop		; go to next relocation entry -->
   565                              <1> 
   566                              <1> .error_j3:
   567 00000F06 E9A301              <1> 	jmp .error
   568                              <1> 
   569                              <1> .codenotfound:
   570 00000F09 BE[C516]            <1> 	mov si, lmsg.error_code
   571                              <1> internalcoderelocation
   572 00000F0C E80800              <1> 	call .notfound			; display error
   573 00000F0F 73F5                <1> 	jnc .error_j3			; NC if in pass 0 -->
   574 00000F11 FF46E8              <1> 	inc word [bp + ?amounterrors]	; count the amount of errors
   575 00000F14 E98400              <1> 	jmp .coderelocloop		; go to next -->
   576                              <1> 
   577                              <1> .notfound:
   578 00000F17 807EEA00            <1> 	cmp byte [bp + ?pass], 0	; pass 0 ?
   579 00000F1B 743A                <1> 	je .notfound.retn		; yes, do not try displaying --> (NC)
   580 00000F1D 16                  <1> 	 push ss
   581 00000F1E 07                  <1> 	 pop es
   582 00000F1F BF[0000]            <1> 	mov di, relocateddata
   583                              <1> linkdatarelocation line_out		; es:di -> line_out buffer
   584 00000F22 E83300              <1> 	call .copy			; copy prefix message
   585 00000F25 8B76E6              <1> 	mov si, word [bp + ?name]
   586 00000F28 AD                  <1> 	lodsw				; = hash
   587 00000F29 E8[0000]EB020000    <1> 	extcall hexword			; display the hash in hex
   588 00000F30 56                  <1> 	push si
   589 00000F31 BE[DE16]            <1> 	mov si, lmsg.error.2
   590                              <1> internalcoderelocation
   591 00000F34 E82100              <1> 	call .copy			; display message fragment
   592 00000F37 5E                  <1> 	pop si
   593                              <1> %if _ELD_LINKER_PASSES
   594 00000F38 56                  <1> 	push si
   595 00000F39 E81C00              <1> 	call .copy			; copy over the full name
   596 00000F3C 5E                  <1> 	pop si
   597                              <1>  %if _ELDDATA_OPTIONAL || _ELDCALL_OPTIONAL
   598                              <1> 	or byte [si], 80h		; mark as failed optional link
   599                              <1> 	rol byte [bp + ?optionalmissing + 1], 1
   600                              <1> 					; was it optional ?
   601                              <1> 	jc @F				; yes -->
   602                              <1>  %endif
   603 00000F3D C60400              <1> 	mov byte [si], 0		; mark as failed (counter byte = 0)
   604                              <1> @@:
   605                              <1> %else
   606                              <1> 	call .copy
   607                              <1> %endif
   608 00000F40 B022                <1> 	mov al, '"'
   609 00000F42 AA                  <1> 	stosb				; end message with a closing quote mark
   610 00000F43 16                  <1> 	 push ss
   611 00000F44 1F                  <1> 	 pop ds
   612 00000F45 E8[0000]EB020000    <1> 	extcall putsline_crlf		; display diagnostic line
   613 00000F4C B8350E              <1> 	mov ax, 0E35h
   614 00000F4F E8[0000]EB020000    <1> 	extcall setrc
   615 00000F56 F9                  <1> 	stc				; CY, diagnostic displayed
   616                              <1> .notfound.retn:
   617 00000F57 C3                  <1> 	retn
   618                              <1> 
   619                              <1> .copy:		; (cannot use extcallcall here)
   620 00000F58 E8[0000]EB020000    <1> 	extcall copy_single_counted_string
   621 00000F5F C3                  <1> 	retn
   622                              <1> %else
   623                              <1> .datanotfound: equ .error
   624                              <1> .codenotfound: equ .error
   625                              <1> %endif
   626                              <1> 
   627                              <1> .build_match:
   628                              <1> %if _ELDDATA_OPTIONAL || _ELDCALL_OPTIONAL
   629                              <1> 	mov byte [bp + ?optionalmissing], 0
   630                              <1> 		; This is needed for eldtestj.asm with debugoptlink.
   631                              <1> 		;  The optional data link sets flag 80h, then the
   632                              <1> 		;  required data link to the same symbol sets this
   633                              <1> 		;  flag but doesn't reset it. So the first optional
   634                              <1> 		;  code link still had this set. Reset here to fix.
   635                              <1> %endif
   636                              <1> %if _ELD_CODE_VSTART
   637 00000F60 2D[0000]            <1> 	sub ax, code			; revert adjustment (= displacement)
   638                              <1> %endif
   639 00000F63 0346FC              <1> 	add ax, word [bp + ?instance]	; make displacement into -> name string
   640 00000F66 96                  <1> 	xchg si, ax			; si -> hash word, counted name string
   641                              <1> %if _ELD_LINKER_PASSES || _ELDDATA_OPTIONAL || _ELDCALL_OPTIONAL
   642 00000F67 8976E6              <1> 	mov word [bp + ?name], si	; save away for diagnostics
   643                              <1> %endif
   644 00000F6A AD                  <1> 	lodsw			; = hash, si -> counted string
   645 00000F6B 8A14                <1> 	mov dl, byte [si]	; dl = original start byte of match
   646                              <1> %if _ELD_LINKER_PASSES
   647 00000F6D 84D2                <1> 	test dl, dl		; marked as already failed ?
   648                              <1> 				;  (80h = optional, 0 = required)
   649 00000F6F 750A                <1> 	jnz @F			; no -->
   650 00000F71 837EE800            <1> 	cmp word [bp + ?amounterrors], 0
   651                              <1> 				; validate error status
   652 00000F75 7503E9A500          <1> 	je .error_j		; no error known ?! cancel quickly -->
   653 00000F7A C3                  <1> 	retn			; (NC)
   654                              <1> 
   655                              <1> @@:
   656                              <1> %else
   657                              <1> 	test dl, dl
   658                              <1> %endif
   659                              <1> %if _ELDDATA_OPTIONAL || _ELDCALL_OPTIONAL
   660                              <1> 	jns @F
   661                              <1> 	and dl, 7Fh
   662                              <1> 	mov byte [si], dl
   663                              <1> 	mov byte [bp + ?optionalmissing], -1
   664                              <1> @@:
   665                              <1> %endif
   666                              <1> %if ELDOTHER
   667                              <1> 	rol byte [bp + ?other], 1
   668                              <1> 	jnc @F
   669                              <1> 	rol byte [bp + ?use_hash_other], 1
   670                              <1> 	jmp @FF
   671                              <1> 
   672                              <1> @@:
   673                              <1> %endif
   674 00000F7B D046EC              <1> 	rol byte [bp + ?use_hash], 1
   675                              <1> @@:
   676                              <1> 		; If to use the hash, then ax = hash and si ->
   677                              <1> 		;  the entire symbol name as a counted string.
   678 00000F7E 720A                <1> 	jc @F			; if to use hash, return now -->
   679 00000F80 AC                  <1> 	lodsb			; al = length
   680 00000F81 91                  <1> 	xchg cx, ax		; cl = length
   681 00000F82 AD                  <1> 	lodsw			; ax = prefix
   682 00000F83 49                  <1> 	dec cx
   683 00000F84 49                  <1> 	dec cx			; cl = adjusted length
   684 00000F85 4E                  <1> 	dec si			; -> second byte of prefix
   685 00000F86 8A14                <1> 	mov dl, byte [si]	; dl = original start byte of match
   686 00000F88 880C                <1> 	mov byte [si], cl	; si -> counted string suffix
   687                              <1> 		; (this name entry has been edited to provide the
   688                              <1> 		;  name suffix as a counted string, as required by
   689                              <1> 		;  the old-style non-hash link info tables.
   690                              <1> 		; it will be reset later by writing dl to si -> the
   691                              <1> 		;  first byte of the match string.)
   692                              <1> @@:
   693                              <1> %if _ELD_LINKER_PASSES
   694 00000F8A F9                  <1> 	stc			; CY
   695                              <1> %endif
   696 00000F8B C3                  <1> 	retn
   697                              <1> 
   698                              <1> 
   699                              <1> .donedatareloc:
   700                              <1> %if ELDOTHER
   701                              <1> 	rol byte [bp + ?other], 1
   702                              <1> 	jc .otherdone		; other link only has data links,
   703                              <1> 				;  so at this point we're done -->
   704                              <1> %endif
   705                              <1> 
   706 00000F8C 8B56FC              <1> 	mov dx, word [bp + ?instance]
   707                              <1> %if _ELD_LINKER_PASSES
   708 00000F8F 8B5EEA              <1> 	mov bx, word [bp + ?pass]
   709 00000F92 01D3                <1> 	add bx, dx
   710                              <1>  %if _ELD_IDENTICALISE
   711                              <1> 	add bx, word [bp + ?lt]
   712                              <1> 	add dx, word [ltLinkCode + bx]
   713                              <1>  %else
   714 00000F94 03977C11            <1> 	add dx, word [linktable - code + ltLinkCode + bx]
   715                              <1>  %endif
   716                              <1> %else
   717                              <1> 	add dx, linkercoderelocations - code
   718                              <1> %endif
   719 00000F98 8956F2              <1> 	mov word [bp + ?nextreloc], dx
   720                              <1> 
   721                              <1> .coderelocloop:
   722 00000F9B C576F2              <1> 	lds si, [bp + ?nextreloc]
   723 00000F9E AD                  <1> 	lodsw
   724                              <1> %if _ELDCALL_OPTIONAL || _ELDCALL_NEXT
   725                              <1> 	dec ax				; optional word is 1-based, get 0-based
   726                              <1> 	js .donecodereloc
   727                              <1> 	mov word [bp + ?targetsection_low_optional_high], ax
   728                              <1> 	lodsw
   729                              <1> %endif
   730 00000F9F 0346FC              <1> 	add ax, word [bp + ?instance]
   731 00000FA2 8946EE              <1> 	mov word [bp + ?entry], ax
   732 00000FA5 AD                  <1> 	lodsw
   733 00000FA6 8976F2              <1> 	mov word [bp + ?nextreloc], si
   734                              <1> %ifn _ELDCALL_OPTIONAL || _ELDCALL_NEXT
   735 00000FA9 85C0                <1> 	test ax, ax			; if no optional word, check -> match
   736 00000FAB 7503E98100          <1> 	jz .donecodereloc
   737                              <1> %endif
   738                              <1> %if _ELDCALL_NEXT
   739                              <1> 	rol byte [bp + ?skip_last], 1	; skipping ?
   740                              <1> 	jnc @F				; no -->
   741                              <1> 	test byte [bp + ?optional], 8	; is it a last relocation ?
   742                              <1> 	jz .coderelocloop		; no, leave skip_last set -->
   743                              <1> 	not byte [bp + ?skip_last]	; disable skip_last
   744                              <1> 	jmp .coderelocloop
   745                              <1> @@:
   746                              <1> %endif
   747 00000FB0 E8ADFF              <1> 	call .build_match
   748                              <1> %if _ELD_LINKER_PASSES
   749 00000FB3 73E6                <1> 	jnc .coderelocloop
   750                              <1> %endif
   751 00000FB5 C45EF6              <1> 	les bx, [bp + ?linkinfo]
   752 00000FB8 268B4F10            <1> 	mov cx, word [es:bx + eldlCodeAmount]	; amount code link info
   753 00000FBC 268B7F12            <1> 	mov di, word [es:bx + eldlCodePrefixes]	; -> prefixes or hashes
   754                              <1> .coderelocfind:
   755 00000FC0 83F901              <1> 	cmp cx, 1			; NZ if cx == 0
   756 00000FC3 F2AF                <1> 	repne scasw			; scan initial
   757                              <1> %if _ELDCALL_OPTIONAL
   758                              <1> 	jne .codenotfound_may_be_optional
   759                              <1> %else
   760                              <1>  %if _ELD_DEBUG
   761                              <1> 	je @F
   762                              <1> 	houdini
   763                              <1> 	jmp .codenotfound
   764                              <1> @@:
   765                              <1>  %else
   766 00000FC5 7403E93FFF          <1> 	jne .codenotfound
   767                              <1>  %endif
   768                              <1> %endif
   769 00000FCA 57                  <1> 	push di
   770 00000FCB 51                  <1> 	push cx
   771 00000FCC 56                  <1> 	push si
   772 00000FCD 262B7F12            <1> 	sub di, word [es:bx + eldlCodePrefixes]	; = double index, 1-based
   773 00000FD1 4F                  <1> 	dec di
   774 00000FD2 4F                  <1> 	dec di				; 0-based
   775 00000FD3 26037F14            <1> 	add di, word [es:bx + eldlCodeEntries]	; -> entry
   776 00000FD7 268B3D              <1> 	mov di, [es:di]			; -> counted suffix/string
   777 00000FDA B500                <1> 	mov ch, 0
   778 00000FDC 8A0C                <1> 	mov cl, byte [si]		; cx = length
   779 00000FDE 41                  <1> 	inc cx
   780                              <1> 	; cmp al, al			; ZR if length is zero
   781 00000FDF F3A6                <1> 	repe cmpsb			; match ?
   782 00000FE1 5E                  <1> 	pop si
   783 00000FE2 59                  <1> 	pop cx
   784 00000FE3 5F                  <1> 	pop di
   785 00000FE4 75DA                <1> 	jne .coderelocfind
   786 00000FE6 8814                <1> 	mov byte [si], dl
   787 00000FE8 262B7F12            <1> 	sub di, word [es:bx + eldlCodePrefixes]	; = double index, 1-based
   788 00000FEC 4F                  <1> 	dec di
   789 00000FED 4F                  <1> 	dec di				; 0-based
   790 00000FEE 01FF                <1> 	add di, di			; quadruple index
   791 00000FF0 26037F16            <1> 	add di, word [es:bx + eldlCodeAddresses]	; -> address (offset, segment)
   792 00000FF4 26FF35              <1> 	push word [es:di]
   793 00000FF7 C576EE              <1> 	lds si, [bp + ?entry]
   794 00000FFA 8F4405              <1> 	pop word [si + 3 + 2]		; call near imm (3), jmp short (2)
   795                              <1> 					;  patch the destination address
   796 00000FFD 803CE8              <1> 	cmp byte [si], 0E8h		; is it as expected ?
   797 00001000 751D                <1> 	jne .error_j
   798 00001002 268B7D02            <1> 	mov di, word [es:di + 2]
   799 00001006 BB[0000]            <1> 	mov bx, relocateddata
   800                              <1> linkdatarelocation linkcall_table	; ss:bx -> link call table
   801 00001009 36833F01            <1> 	cmp word [ss:bx], 1		; is it initialised to format 1 ?
   802 0000100D 7510                <1> 	jne .error_j			; no -->
   803 0000100F 368B4F02            <1> 	mov cx, word [ss:bx + 2]	; get amount of segments
   804 00001013 E30A                <1> 	jcxz .error_j			; none -->
   805                              <1> @@:
   806 00001015 83C304              <1> 	add bx, 4			; -> next segment
   807 00001018 36393F              <1> 	cmp word [ss:bx], di		; value matches ?
   808 0000101B 7405                <1> 	je @F				; yes, found -->
   809 0000101D E2F6                <1> 	loop @B				; try remaining segments
   810                              <1> .error_j:
   811 0000101F E98A00              <1> 	jmp .error
   812                              <1> 
   813                              <1> @@:
   814 00001022 368B5F02            <1> 	mov bx, word [ss:bx + 2]	; -> call destination offset
   815                              <1> 		; si + 3 + delta = bx
   816                              <1> 		; delta = bx - si - 3
   817 00001026 29F3                <1> 	sub bx, si
   818 00001028 83EB03              <1> 	sub bx, 3
   819 0000102B 895C01              <1> 	mov word [si + 1], bx		; patch the call instruction
   820                              <1> %if _ELDCALL_NEXT
   821                              <1> 	test byte [bp + ?optional], 4	; is it a next relocation ?
   822                              <1> 	jz .coderelocloop
   823                              <1> 	mov byte [bp + ?skip_last], -1	; skip subsequent next/last relocs
   824                              <1> %endif
   825 0000102E E96AFF              <1> 	jmp .coderelocloop
   826                              <1> 
   827                              <1> .donecodereloc:
   828                              <1> %if _ELD_LINKER_PASSES
   829 00001031 8B46E8              <1> 	mov ax, word [bp + ?amounterrors]
   830 00001034 85C0                <1> 	test ax, ax
   831 00001036 75E7                <1> 	jnz .error_j
   832 00001038 8B5EEA              <1> 	mov bx, word [bp + ?pass]
   833 0000103B 85DB                <1> 	test bx, bx
   834 0000103D 750B                <1> 	jnz @F
   835 0000103F 43                  <1> 	inc bx
   836 00001040 43                  <1> 	inc bx
   837 00001041 895EEA              <1> 	mov word [bp + ?pass], bx
   838 00001044 8B56FC              <1> 	mov dx, word [bp + ?instance]
   839 00001047 E9AFFD              <1> 	jmp .pass
   840                              <1> 
   841                              <1> @@:
   842                              <1> %endif
   843                              <1> 
   844                              <1> %ifnidni _LISTING, ""
   845                              <1> %assign ELDLINKER 0
   846                              <1> .hint:
   847 0000104A 16                  <1> 	push ss
   848 0000104B 1F                  <1> 	pop ds
   849 0000104C B02D                <1> 	mov al, 2Dh
   850 0000104E E8[0000]EB020000    <1> 	extcall intchk			; ZR if offset = -1 or segment = 0
   851                              <1> 					; CHG: ax, dx, bx
   852 00001055 7437                <1> 	jz .no_hint
   853                              <1> 
   854                              <1> %if ELDOTHER
   855                              <1> 	mov si, debuggeramissig	; ds:si -> our AMIS name strings
   856                              <1> internalcoderelocation
   857                              <1> %endif
   858                              <1> 
   859 00001057 8A26[0000]          <1> 	mov ah, byte [relocateddata]
   860                              <1> linkdatarelocation try_debugger_amis_multiplex_number
   861 0000105B E85500              <1> 	call plex_check
   862 0000105E 7305                <1> 	jnc @F
   863                              <1> 
   864 00001060 B4FF                <1> 	mov ah, 0FFh		; start with multiplex number 0FFh
   865                              <1> .loop_hint:
   866 00001062 E84E00              <1> 	call plex_check
   867                              <1> @@:
   868 00001065 7307                <1> 	jnc .end_hint		; if found --> (NC)
   869 00001067 80EC01              <1> 	sub ah, 1		; search is backward (to find latest installed first), from 0FFh to 00h including
   870 0000106A 73F6                <1> 	jnc .loop_hint		; try next if we didn't check all yet -->
   871 0000106C EB20                <1> 	jmp .no_hint
   872                              <1> 
   873                              <1> .end_hint:
   874 0000106E 50                  <1> 	push ax
   875 0000106F C446FC              <1> 	les ax, [bp + ?instance]
   876 00001072 BF[8514]            <1> 	mov di, listmsg.hint.offset
   877                              <1> internalcoderelocation
   878 00001075 E8[0000]EB020000    <1> 	extcall hexword
   879 0000107C BB[6414]            <1> 	mov bx, listmsg.hint
   880                              <1> internalcoderelocation
   881 0000107F 368B16[0000]        <1> 	mov dx, [ss:relocateddata]
   882                              <1> linkdatarelocation extseg	; must be 86 Mode segment even in PM
   883 00001084 58                  <1> 	pop ax
   884 00001085 B040                <1> 	mov al, 40h		; AMIS message display service
   885 00001087 E8[0000]EB020000    <1> 	extcall call_int2D
   886                              <1> .no_hint:
   887                              <1> %endif
   888                              <1> 
   889                              <1> %if ELDOTHER
   890                              <1> %assign ELDLINKER 0
   891                              <1> 	not byte [bp + ?other]
   892                              <1> 
   893                              <1> 	push ss
   894                              <1> 	pop ds
   895                              <1> 	mov al, 2Dh
   896                              <1> 	extcall intchk			; ZR if offset = -1 or segment = 0
   897                              <1> 					; CHG: ax, dx, bx
   898                              <1> 	jz .no_other
   899                              <1> 
   900                              <1> 	mov si, debuggeramissig	; ds:si -> our AMIS name strings
   901                              <1> internalcoderelocation
   902                              <1> 
   903                              <1> 	mov ah, byte [relocateddata]
   904                              <1> linkdatarelocation try_debugger_amis_multiplex_number
   905                              <1> 	call plex_check
   906                              <1> 	jnc @F
   907                              <1> 
   908                              <1> 	mov ah, 0FFh		; start with multiplex number 0FFh
   909                              <1> .loop_other_debug:
   910                              <1> 	call plex_check
   911                              <1> @@:
   912                              <1> 	jnc .end_other		; if found --> (NC)
   913                              <1> 	sub ah, 1		; search is backward (to find latest installed first), from 0FFh to 00h including
   914                              <1> 	jnc .loop_other_debug	; try next if we didn't check all yet -->
   915                              <1> 
   916                              <1> 	mov si, loaderamissig	; ds:si -> our AMIS name strings
   917                              <1> internalcoderelocation
   918                              <1> 
   919                              <1> 	mov ah, byte [relocateddata]
   920                              <1> linkdatarelocation try_debugger_amis_multiplex_number
   921                              <1> 	call plex_check
   922                              <1> 	jnc @F
   923                              <1> 
   924                              <1> 	mov ah, 0FFh		; start with multiplex number 0FFh
   925                              <1> .loop_other_loader:
   926                              <1> 	call plex_check
   927                              <1> @@:
   928                              <1> 	jnc .end_other		; if found --> (NC)
   929                              <1> 	sub ah, 1		; search is backward (to find latest installed first), from 0FFh to 00h including
   930                              <1> 	jnc .loop_other_loader	; try next if we didn't check all yet -->
   931                              <1> 
   932                              <1> 	jmp .no_other
   933                              <1> 
   934                              <1> .end_other:
   935                              <1> 	mov al, 42h		; AMIS get other link info service
   936                              <1> 	extcall call_int2D
   937                              <1> 	cmp al, 0FFh
   938                              <1> 	jne .no_other
   939                              <1> 
   940                              <1> 	mov ax, si		; selector => PSP
   941                              <1> 	extcall ispm
   942                              <1> 	jz @F
   943                              <1> 	mov ax, dx		; segment => PSP
   944                              <1> @@:
   945                              <1> 	 push ss
   946                              <1> 	 pop ds
   947                              <1> 	mov word [otherds], ax
   948                              <1> internaldatarelocation		; current mode sel/seg
   949                              <1> 	mov word [otherseg], dx
   950                              <1> internaldatarelocation		; remember segment
   951                              <1> 
   952                              <1> 	mov ax, cx		; selector => link info
   953                              <1> 	extcall ispm
   954                              <1> 	jz @F
   955                              <1> 	mov ax, bx		; segment => link info
   956                              <1> @@:
   957                              <1> 	mov word [bp + ?linkinfo_other], di
   958                              <1> 	mov word [bp + ?linkinfo_other + 2], ax
   959                              <1> 
   960                              <1> 	mov ds, ax		; => link info
   961                              <1> 	xor ax, ax
   962                              <1> 	cmp word [di + eldlSignature], 0E1D1h
   963                              <1> 	jne .error_other
   964                              <1> 	cmp word [di + eldlUseLinkHash], 1
   965                              <1> 	ja .error_other
   966                              <1> 	jb @F
   967                              <1> 	dec ax
   968                              <1> @@:
   969                              <1> 	mov word [bp + ?use_hash_other], ax
   970                              <1> 
   971                              <1> 	mov dx, word [bp + ?instance]
   972                              <1> 	add dx, linkerotherdatarelocations - code
   973                              <1> 	jmp .otherloop
   974                              <1> 
   975                              <1> .error_other:
   976                              <1> 	push cs
   977                              <1> 	pop ds
   978                              <1> 	mov ax, 0E33h
   979                              <1> 	extcall setrc
   980                              <1> 	mov dx, lmsg.error_other
   981                              <1> internalcoderelocation
   982                              <1> 	jmp @F
   983                              <1> 
   984                              <1> .no_other:
   985                              <1> 	push cs
   986                              <1> 	pop ds
   987                              <1> 	mov ax, 0E34h
   988                              <1> 	extcall setrc
   989                              <1> 	mov dx, lmsg.no_other
   990                              <1> internalcoderelocation
   991                              <1> @@:
   992                              <1> 	extcall putsz
   993                              <1> .error_j2:
   994                              <1> 	jmp .error
   995                              <1> 
   996                              <1> .otherdone:
   997                              <1>  %if _ELD_LINKER_PASSES
   998                              <1> 	mov ax, word [bp + ?amounterrors]
   999                              <1> 	test ax, ax
  1000                              <1> 	jnz .error_j2
  1001                              <1>  %endif
  1002                              <1> %endif
  1003                              <1> 
  1004 0000108E 5B                  <1> 	pop bx				; -> our heap data
  1005 0000108F 5E                  <1> 	pop si				; -> our command line tail
  1006 00001090 16                  <1> 	 push ss
  1007 00001091 1F                  <1> 	 pop ds
  1008 00001092 C47EFC              <1> 	les di, [bp + ?instance]
  1009 00001095 268B4502            <1> 	mov ax, word [es:di + eldiEndCode]
  1010                              <1> houdini
  1011 00001099 2D[D00D]            <1> 	sub ax, strict word endresident + code
  1012                              <1> internalcoderelocation
  1013 0000109C 26C74502[D00D]      <1> 	mov word [es:di + eldiEndCode], endresident + code
  1014                              <1> internalcoderelocation
  1015 000010A2 2906[0000]          <1> 	sub word [relocateddata], ax
  1016                              <1> linkdatarelocation extseg_used
  1017                              <1> %if _DATA_SIZE == 0
  1018                              <1> 	xor ax, ax
  1019                              <1> 	mov word [es:di + eldiStartData], ax
  1020                              <1> 	mov word [es:di + eldiEndData], ax
  1021                              <1> %endif
  1022 000010A6 89EC5D              <1> 	lleave code
  1023                              <1> 		; INP:	es => ELD code segment
  1024                              <1> 		;	ds:si -> command line tail
  1025                              <1> 		;	ds:bx -> ELD data block
  1026                              <1> 		;	ss:sp -> far return address for current mode
  1027                              <1> 		; STT:	ds = ss, UP, EI
  1028 000010A9 E98CFC              <1> 	jmp start
  1029                              <1> 
  1030                              <1> .error:
  1031 000010AC 89EC5D              <1> 	lleave
  1032 000010AF B8FFFF              <1> 	mov ax, -1
  1033 000010B2 CB                  <1> 	retf
  1034                              <1> 
  1035                              <1> 
  1036                              <1> %ifnidni _LISTING, ""
  1037                              <1>  %assign ELDHINT 1
  1038                              <1> %else
  1039                              <1>  %assign ELDHINT 0
  1040                              <1> %endif
  1041                              <1> 
  1042                              <1> %if ELDOTHER || ELDHINT
  1043                              <1> 		; INP:	ah = multiplex number to check
  1044                              <1> 		;	(if ELDOTHER:)
  1045                              <1> 		;	 cs:si -> 16-byte AMIS signature to check
  1046                              <1> 		; OUT:	CY if multiplex number unused or no signature match,
  1047                              <1> 		;	 bp, ah, ds unmodified
  1048                              <1> 		;	NC if match found,
  1049                              <1> 		;	 ah = multiplex number (unmodified)
  1050                              <1> 		; CHG:	di, es, cx, dx
  1051                              <1> 		;	(if ELDOTHER:) bx
  1052                              <1> 		;	(if not ELDOTHER:) si
  1053                              <1> plex_check:
  1054 000010B3 16                  <1> 	push ss
  1055 000010B4 1F                  <1> 	pop ds
  1056 000010B5 F606[0000]08        <1> 	testopt [relocateddata], 8
  1057                              <1> linkdatarelocation internalflags4, -3
  1058 000010BA 740B                <1> 	jz @F
  1059                              <1> %if ELDOTHER
  1060                              <1> 	mov bx, relocateddata
  1061                              <1> linkdatarelocation amis_multiplex_number, -2, optional
  1062                              <1> 	test bx, bx
  1063                              <1> 	jz @F
  1064                              <1> 	cmp ah, byte [bx]
  1065                              <1> 	je .notfound		; do not use our own multiplexer -->
  1066                              <1> %else
  1067 000010BC BE[0000]            <1> 	mov si, relocateddata
  1068                              <1> linkdatarelocation amis_multiplex_number, -2, optional
  1069 000010BF 85F6                <1> 	test si, si
  1070 000010C1 7404                <1> 	jz @F
  1071 000010C3 3A24                <1> 	cmp ah, byte [si]
  1072 000010C5 7420                <1> 	je .notfound		; do not use our own multiplexer -->
  1073                              <1> %endif
  1074                              <1> @@:
  1075 000010C7 B000                <1> 	mov al, 00h		; AMIS installation check
  1076 000010C9 E8[0000]EB020000    <1> 	extcall call_int2D	; AMIS (or "DOS reserved" = iret if no AMIS present)
  1077 000010D0 3CFF                <1> 	cmp al, 0FFh
  1078 000010D2 7513                <1> 	jne .notfound
  1079 000010D4 0E                  <1> 	push cs
  1080 000010D5 1F                  <1> 	pop ds
  1081                              <1> %if ELDOTHER
  1082                              <1> 	push si
  1083                              <1> 	extcall setes2dx	; es:di -> name strings of AMIS multiplexer that just answered
  1084                              <1> 	mov cx, 8		; Ignore description, only compare vendor and program name
  1085                              <1> 	repe cmpsw
  1086                              <1> 	pop si
  1087                              <1> %else
  1088 000010D6 BE[5414]            <1> 	mov si, debuggeramissig	; ds:si -> our AMIS name strings
  1089                              <1> internalcoderelocation
  1090 000010D9 E8[0000]EB020000    <1> 	extcall setes2dx	; es:di -> name strings of AMIS multiplexer that just answered
  1091 000010E0 B90800              <1> 	mov cx, 8		; Ignore description, only compare vendor and program name
  1092 000010E3 F3A7                <1> 	repe cmpsw
  1093                              <1> %endif
  1094 000010E5 7401                <1> 	je .checkret		; ZR, NC = match -->
  1095                              <1> .notfound:
  1096 000010E7 F9                  <1> 	stc			; CY no match
  1097                              <1> .checkret:
  1098 000010E8 C3                  <1> 	retn
  1099                              <1> %endif
  1100                              <1> 
  1101                              <1> 
  1102 000010E9 00<rep 3h>          <1> 	align 4, db 0
  1103                              <1> linkercoderelocations:
  1104                              <1> %if _ELDCALL_OPTIONAL || _ELDCALL_NEXT
  1105                              <1> 	dw ELDCALL_CODE_RELOCATIONS_OPTIONAL, 0
  1106                              <1> %else
  1107 000010EC 2200[8D14]A80C-     <1> 	dw ELDCALL_CODE_RELOCATIONS, 0, 0
  1107 000010F2 [9C14]B00C[A814]B8- <1>
  1107 000010F9 0C[B414]C00C[BB14]- <1>
  1107 00001100 C80C[C414]D00C-     <1>
  1107 00001106 [CC14]D80C[D414]E0- <1>
  1107 0000110D 0C[DB14]E80C[E314]- <1>
  1107 00001114 F00C[ED14]F80C-     <1>
  1107 0000111A [F914]000D[0315]08- <1>
  1107 00001121 0D[0E15]100D[1815]- <1>
  1107 00001128 180D[2215]200D-     <1>
  1107 0000112E [3215]280D[5B15]30- <1>
  1107 00001135 0D[7815]890D[BB14]- <1>
  1107 0000113C 4E10[8215]7510-     <1>
  1107 00001142 [0E15]8710[8B15]C9- <1>
  1107 00001149 10[8B15]D910[9815]- <1>
  1107 00001150 00000000            <1>
  1108                              <1> %endif
  1109                              <1> 
  1110                              <1> %if _ELD_LINKER_PASSES
  1111                              <1> linkerlinkercoderelocations:
  1112                              <1> %if _ELDCALL_OPTIONAL || _ELDCALL_NEXT
  1113                              <1> 	dw ELDCALL_LINKER_CODE_RELOCATIONS_OPTIONAL, 0
  1114                              <1> %else
  1115 00001154 290F[0E15]450F-     <1> 	dw ELDCALL_LINKER_CODE_RELOCATIONS, 0, 0
  1115 0000115A [2215]4F0F[CC14]58- <1>
  1115 00001161 0F[5B15]00000000    <1>
  1116                              <1> %endif
  1117                              <1> 
  1118                              <1> 	align 2, db 0
  1119                              <1> linktable:
  1120                              <1> 	istruc LINKTABLE
  1121                              <1> at ltCodeToCode
  1122 00001168 4614                <1> 	dw internallinkercodetocoderelocations - code
  1123 0000116A 3612                <1> 	dw internalcodetocoderelocations - code
  1124                              <1> at ltCodeToData
  1125 0000116C 4E14                <1> 	dw internallinkercodetodatarelocations - code
  1126 0000116E 6812                <1> 	dw internalcodetodatarelocations - code
  1127                              <1> at ltDataToCode
  1128 00001170 5014                <1> 	dw internallinkerdatatocoderelocations - code
  1129 00001172 0E14                <1> 	dw internaldatatocoderelocations - code
  1130                              <1> at ltDataToData
  1131 00001174 5214                <1> 	dw internallinkerdatatodatarelocations - code
  1132 00001176 1014                <1> 	dw internaldatatodatarelocations - code
  1133                              <1> at ltLinkData
  1134 00001178 3814                <1> 	dw linkerlinkerdatarelocations - code
  1135 0000117A 8011                <1> 	dw linkerdatarelocations - code
  1136                              <1> at ltLinkCode
  1137 0000117C 5411                <1> 	dw linkerlinkercoderelocations - code
  1138 0000117E EC10                <1> 	dw linkercoderelocations - code
  1139                              <1> 	iend
  1140                              <1> %endif
  1141                              <1> 
  1142                              <1> 	align 2, db 0
  1143                              <1> linkerdatarelocations:
  1144 00001180 01004700[A315]0100- <1> 	dw LINK_DATA_RELOCATIONS, 0
  1144 00001188 4900[AD15]01004C00- <1>
  1144 00001190 [B615]01006A00-     <1>
  1144 00001196 [C615]01008E00-     <1>
  1144 0000119C [C615]0100CD00-     <1>
  1144 000011A2 [DC15]0100D600-     <1>
  1144 000011A8 [E715]0100E305-     <1>
  1144 000011AE [F015]01006906-     <1>
  1144 000011B4 [FB15]01007106-     <1>
  1144 000011BA [FB15]0100DD07-     <1>
  1144 000011C0 [F015]01006C08-     <1>
  1144 000011C6 [F015]01006809-     <1>
  1144 000011CC [F015]0100DB09-     <1>
  1144 000011D2 [0516]0100D00A-     <1>
  1144 000011D8 [0516]0100D70A-     <1>
  1144 000011DE [0516]01008A0B-     <1>
  1144 000011E4 [F015]0100410D-     <1>
  1144 000011EA [1716]0100680D-     <1>
  1144 000011F0 [2516]0100780D-     <1>
  1144 000011F6 [3016]0100850D-     <1>
  1144 000011FC [3E16]01009C0D-     <1>
  1144 00001202 [3016]0100A00D-     <1>
  1144 00001208 [C615]0100BB0D-     <1>
  1144 0000120E [C615]0100C10D-     <1>
  1144 00001214 [2516]01005910-     <1>
  1144 0000121A [5E16]01008210-     <1>
  1144 00001220 [E715]0100A410-     <1>
  1144 00001226 [3016]0100B710-     <1>
  1144 0000122C [8316]0101BD10-     <1>
  1144 00001232 [9416]0000          <1>
  1145                              <1> 
  1146                              <1> 	align 2, db 0
  1147                              <1> internalcodetocoderelocations:
  1148 00001236 6500B2004E0754075A- <1> 	dw INTERNAL_CODE_TO_CODE_RELOCATIONS, 0
  1148 0000123F 076007760798079E07- <1>
  1148 00001248 A407AA076F0D740D7C- <1>
  1148 00001251 0D810D980DA30DB60D- <1>
  1148 0000125A BD0D73107D109A10A0- <1>
  1148 00001263 10D7100000          <1>
  1149                              <1> 
  1150                              <1> 	align 2, db 0
  1151                              <1> internalcodetodatarelocations:
  1152 00001268 3400B600C700DB00E9- <1> 	dw INTERNAL_CODE_TO_DATA_RELOCATIONS, 0
  1152 00001271 00ED00F70003011001- <1>
  1152 0000127A 1A0127012B012F0133- <1>
  1152 00001283 0153015D016E017501- <1>
  1152 0000128C 79017C01800187019F- <1>
  1152 00001295 01A201A601B001B501- <1>
  1152 0000129E B901BE01C901CF01D3- <1>
  1152 000012A7 01D901E001E701F301- <1>
  1152 000012B0 09020C02130218021C- <1>
  1152 000012B9 02220226024D025402- <1>
  1152 000012C2 5B0269026F02730277- <1>
  1152 000012CB 029702AF02D102D702- <1>
  1152 000012D4 DD02E402FF0206030E- <1>
  1152 000012DD 031C03300336035303- <1>
  1152 000012E6 5703610373037A0381- <1>
  1152 000012EF 038A03C303CF03D403- <1>
  1152 000012F8 DA03EE0309040F0417- <1>
  1152 00001301 041E04310437043B04- <1>
  1152 0000130A 3F0443044A04620465- <1>
  1152 00001313 046E04730477047C04- <1>
  1152 0000131C 8E0491049A04A104A5- <1>
  1152 00001325 04AA04B404B804C304- <1>
  1152 0000132E D004EB04F8040A050D- <1>
  1152 00001337 0510051B0528054E05- <1>
  1152 00001340 54057B058105A705AD- <1>
  1152 00001349 05C905D005D705DE05- <1>
  1152 00001352 FE0517061C0678068A- <1>
  1152 0000135B 068E069106A006B606- <1>
  1152 00001364 BB06CB06D906E20605- <1>
  1152 0000136D 070B07130718072B07- <1>
  1152 00001376 38074407480768076D- <1>
  1152 0000137F 077C07800786078C07- <1>
  1152 00001388 9207B007B407BA07E8- <1>
  1152 00001391 070B0813081E082B08- <1>
  1152 0000139A 300840084608580864- <1>
  1152 000013A3 089208EF08F9082C09- <1>
  1152 000013AC 3D094C09540960096B- <1>
  1152 000013B5 098409A009AD09B309- <1>
  1152 000013BE C709CF09D309F40902- <1>
  1152 000013C7 0A160A1A0A3D0A520A- <1>
  1152 000013D0 7B0AB80ABF0AC30AC8- <1>
  1152 000013D9 0AF30A0D0B140B1B0B- <1>
  1152 000013E2 220B290B300B370B4D- <1>
  1152 000013EB 0B5F0B720B790BE80B- <1>
  1152 000013F4 EC0B030C0A0C420C47- <1>
  1152 000013FD 0C520C570C6A0C8D0C- <1>
  1152 00001406 490D5E0DC70D0000    <1>
  1153                              <1> 
  1154                              <1> 	align 2, db 0
  1155                              <1> internaldatatocoderelocations:
  1156 0000140E FFFF                <1> 	dw INTERNAL_DATA_TO_CODE_RELOCATIONS, -1
  1157                              <1> 
  1158                              <1> 	align 2, db 0
  1159                              <1> internaldatatodatarelocations:
  1160 00001410 0400060008000A000C- <1> 	dw INTERNAL_DATA_TO_DATA_RELOCATIONS, -1
  1160 00001419 000E00100012001400- <1>
  1160 00001422 160018001A001C0020- <1>
  1160 0000142B 00240028002C003000- <1>
  1160 00001434 3400FFFF            <1>
  1161                              <1> 
  1162                              <1> %if _ELD_LINKER_PASSES
  1163                              <1> 	align 2, db 0
  1164                              <1> linkerlinkerdatarelocations:
  1165 00001438 0100200F[F015]0100- <1> 	dw LINK_LINKER_DATA_RELOCATIONS, 0
  1165 00001440 0710[4D16]0000      <1>
  1166                              <1> 
  1167                              <1> 	align 2, db 0
  1168                              <1> internallinkercodetocoderelocations:
  1169 00001446 F90E0A0F320F0000    <1> 	dw INTERNAL_LINKER_CODE_TO_CODE_RELOCATIONS, 0
  1170                              <1> 
  1171                              <1> 	align 2, db 0
  1172                              <1> internallinkercodetodatarelocations:
  1173 0000144E 0000                <1> 	dw INTERNAL_LINKER_CODE_TO_DATA_RELOCATIONS, 0
  1174                              <1> 
  1175                              <1> 	align 2, db 0
  1176                              <1> internallinkerdatatocoderelocations:
  1177 00001450 FFFF                <1> 	dw INTERNAL_LINKER_DATA_TO_CODE_RELOCATIONS, -1
  1178                              <1> 
  1179                              <1> 	align 2, db 0
  1180                              <1> internallinkerdatatodatarelocations:
  1181 00001452 FFFF                <1> 	dw INTERNAL_LINKER_DATA_TO_DATA_RELOCATIONS, -1
  1182                              <1> %endif
  1183                              <1> 
  1184                              <1> %if ELDOTHER
  1185                              <1> 	align 2, db 0
  1186                              <1> linkerotherdatarelocations:
  1187                              <1> 	dw LINK_OTHER_DATA_RELOCATIONS, 0
  1188                              <1> 
  1189                              <1>  %ifnidn LINK_OTHER_LINKER_DATA_RELOCATIONS, ""
  1190                              <1>   %error Other linker data links not supported
  1191                              <1>  %endif
  1192                              <1> %endif
  1193                              <1> 
  1194                              <1> %if ELDOTHER || ELDHINT
  1195                              <1> 	align 2, db 0
  1196                              <1> debuggeramissig:
  1197 00001454 65636D20<rep 5h>    <1> 		fill 8, 32, db "ecm"
  1198 0000145C 6C446562756720-     <1> 		fill 8, 32, db "lDebug"
  1198 0000145C <rep 2h>            <1>
  1199                              <1> %endif
  1200                              <1> 
  1201                              <1> %if ELDOTHER
  1202                              <1> 	align 2, db 0
  1203                              <1> loaderamissig:
  1204                              <1> 		fill 8, 32, db "ecm"
  1205                              <1> 		fill 8, 32, db "Loader"
  1206                              <1> %endif
  1207                              <1> 
  1208                              <1> %ifnidni _LISTING, ""
  1209                              <1> listmsg:
  1210 00001464 547261634C6973742D- <1> .hint:		db "TracList-add-offset=",_LISTING,"::"
  1210 0000146D 6164642D6F66667365- <1>
  1210 00001476 743D636873746F6F6C- <1>
  1210 0000147F 2E6C73743A3A        <1>
  1211 00001485 2D2D2D2D680D0A00    <1> .hint.offset:	asciz "----h",13,10
  1212                              <1> %endif
  1213                              <1> 
  1214 0000148D 30CD0C636D64335F6E- <1> 	eldcall_dump_names ELDCALL_CODE_NAMES
  1214 00001496 6F745F657874D55509- <1>
  1214 0000149F 736B6970636F6D6D61- <1>
  1214 000014A8 03C309697373747269- <1>
  1214 000014B1 6E673FBABD04636D64- <1>
  1214 000014BA 33DDB90663686B656F- <1>
  1214 000014C3 6C551205707574737A- <1>
  1214 000014CC B21205736574726328- <1>
  1214 000014D5 90046973706DA7AA05- <1>
  1214 000014DE 6572726F723FE80767- <1>
  1214 000014E7 6574776F7264A45509- <1>
  1214 000014F0 736B6970636F6D6D30- <1>
  1214 000014F9 3D8207676574627974- <1>
  1214 00001502 65D9FA086765746477- <1>
  1214 0000150B 6F7264848107686578- <1>
  1214 00001514 776F7264821B076865- <1>
  1214 0000151D 78627974656FA20D70- <1>
  1214 00001526 7574736C696E655F63- <1>
  1214 0000152F 726C66ABFF26646973- <1>
  1214 00001538 705F647861785F7469- <1>
  1214 00001541 6D65735F63785F7769- <1>
  1214 0000154A 6474685F62785F7369- <1>
  1214 00001553 7A652E73746F7265D0- <1>
  1214 0000155C BB1A636F70795F7369- <1>
  1214 00001565 6E676C655F636F756E- <1>
  1214 0000156E 7465645F737472696E- <1>
  1214 00001577 67EBA607646563776F- <1>
  1214 00001580 7264986906696E7463- <1>
  1214 00001589 686B21300A63616C6C- <1>
  1214 00001592 5F696E743244B77408- <1>
  1214 0000159B 7365746573326478    <1>
  1215 000015A3 C30B076C617374636D- <1> 	link_data_dump_names LINK_DATA_NAMES
  1215 000015AC 646B5D06646D79636D- <1>
  1215 000015B5 6454400D6D73672E75- <1>
  1215 000015BE 6E696E7374616C6C97- <1>
  1215 000015C7 B6136578745F636F6D- <1>
  1215 000015D0 6D616E645F68616E64- <1>
  1215 000015D9 6C6572EB4208657874- <1>
  1215 000015E2 647373656CD52D0665- <1>
  1215 000015EB 787473656784E3086C- <1>
  1215 000015F4 696E655F6F75747DB3- <1>
  1215 000015FD 076F7074696F6E73E4- <1>
  1215 00001606 7A0F6C6F61645F756E- <1>
  1215 0000160F 69745F666C6167738D- <1>
  1215 00001618 710B6D73672E696E73- <1>
  1215 00001621 74616C6C5ABC086F70- <1>
  1215 0000162A 74696F6E7337E7D30B- <1>
  1215 00001633 6578747365675F7573- <1>
  1215 0000163C 6564B2400C65787464- <1>
  1215 00001645 6174615F7573656468- <1>
  1215 0000164E 440E6C696E6B63616C- <1>
  1215 00001657 6C5F7461626C65F09E- <1>
  1215 00001660 227472795F64656275- <1>
  1215 00001669 676765725F616D6973- <1>
  1215 00001672 5F6D756C7469706C65- <1>
  1215 0000167B 785F6E756D626572CB- <1>
  1215 00001684 510E696E7465726E61- <1>
  1215 0000168D 6C666C61677334688C- <1>
  1215 00001696 15616D69735F6D756C- <1>
  1215 0000169F 7469706C65785F6E75- <1>
  1215 000016A8 6D626572            <1>
  1216                              <1> %if ELDOTHER
  1217                              <1> 	link_data_dump_names LINK_OTHER_DATA_NAMES
  1218                              <1> %endif
  1219                              <1> 
  1220                              <1> lmsg:
  1221                              <1> %if _ELD_LINKER_PASSES
  1222                              <1> %if _ELDCALL_OPTIONAL
  1223                              <1> .warning_code_optional:		counted "Optional code link missing, hash="
  1224                              <1> %endif
  1225                              <1> %if _ELDDATA_OPTIONAL
  1226                              <1> .warning_data_optional:		counted "Optional data link missing, hash="
  1227                              <1> %endif
  1228 000016AC 1844617461206C696E- <1> .error_data:			counted "Data link missing, hash="
  1228 000016B5 6B206D697373696E67- <1>
  1228 000016BE 2C20686173683D      <1>
  1229 000016C5 18436F6465206C696E- <1> .error_code:			counted "Code link missing, hash="
  1229 000016CE 6B206D697373696E67- <1>
  1229 000016D7 2C20686173683D      <1>
  1230 000016DE 0A682C206C6162656C- <1> .error.2:			counted "h, label ",'"'
  1230 000016E7 2022                <1>
  1231                              <1> %endif
  1232                              <1> %if ELDOTHER
  1233                              <1> .no_other:		asciz "ELD linker: No other link info found!",13,10
  1234                              <1> .error_other:		asciz "ELD linker: Other link info unknown format!",13,10
  1235                              <1> %endif
  1236                              <1> 
  1237 000016E9 00<rep 7h>          <1> 	align 16, db 0
  1955                                  
  1956                                  	align 16
  1957                                  code_size equ $ - code
