     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> 
    36                              <2> 	%imacro internalcoderelocation 0-1.nolist -2
    37                              <2> %assign %%entry $ + _CURRENT_SECTION %+ FIXUP + %1
    38                              <2> %if ELDLINKER
    39                              <2>  %ifidni _CURRENT_SECTION_TYPE, DATA
    40                              <2>   %xdefine INTERNAL_LINKER_DATA_TO_CODE_RELOCATIONS INTERNAL_LINKER_DATA_TO_CODE_RELOCATIONS, %%entry
    41                              <2>  %else
    42                              <2>   %xdefine INTERNAL_LINKER_CODE_TO_CODE_RELOCATIONS INTERNAL_LINKER_CODE_TO_CODE_RELOCATIONS, %%entry
    43                              <2>  %endif
    44                              <2> %else
    45                              <2>  %ifidni _CURRENT_SECTION_TYPE, DATA
    46                              <2>   %xdefine INTERNAL_DATA_TO_CODE_RELOCATIONS INTERNAL_DATA_TO_CODE_RELOCATIONS, %%entry
    47                              <2>  %else
    48                              <2>   %xdefine INTERNAL_CODE_TO_CODE_RELOCATIONS INTERNAL_CODE_TO_CODE_RELOCATIONS, %%entry
    49                              <2>  %endif
    50                              <2> %endif
    51                              <2> 	eldstrictcheck
    52                              <2> 	%endmacro
    53                              <2> 
    54                              <2> 	%imacro internaldatarelocation 0-1.nolist -2
    55                              <2> %assign %%entry $ + _CURRENT_SECTION %+ FIXUP + %1
    56                              <2> %if ELDLINKER
    57                              <2>  %ifidni _CURRENT_SECTION_TYPE, DATA
    58                              <2>   %xdefine INTERNAL_LINKER_DATA_TO_DATA_RELOCATIONS INTERNAL_LINKER_DATA_TO_DATA_RELOCATIONS, %%entry
    59                              <2>  %else
    60                              <2>   %xdefine INTERNAL_LINKER_CODE_TO_DATA_RELOCATIONS INTERNAL_LINKER_CODE_TO_DATA_RELOCATIONS, %%entry
    61                              <2>  %endif
    62                              <2> %else
    63                              <2>  %ifidni _CURRENT_SECTION_TYPE, DATA
    64                              <2>   %xdefine INTERNAL_DATA_TO_DATA_RELOCATIONS INTERNAL_DATA_TO_DATA_RELOCATIONS, %%entry
    65                              <2>  %else
    66                              <2>   %xdefine INTERNAL_CODE_TO_DATA_RELOCATIONS INTERNAL_CODE_TO_DATA_RELOCATIONS, %%entry
    67                              <2>  %endif
    68                              <2> %endif
    69                              <2> 	eldstrictcheck
    70                              <2> 	%endmacro
    71                              <2> 
    72                              <2> ; dw INTERNAL_LINKER_CODE_TO_CODE_RELOCATIONS, 0
    73                              <2> ; dw INTERNAL_LINKER_CODE_TO_DATA_RELOCATIONS, 0
    74                              <2> ; dw INTERNAL_LINKER_DATA_TO_CODE_RELOCATIONS, -1
    75                              <2> ; dw INTERNAL_LINKER_DATA_TO_DATA_RELOCATIONS, -1
    76                              <2> ; dw INTERNAL_CODE_TO_CODE_RELOCATIONS, 0
    77                              <2> ; dw INTERNAL_CODE_TO_DATA_RELOCATIONS, 0
    78                              <2> ; dw INTERNAL_DATA_TO_CODE_RELOCATIONS, -1
    79                              <2> ; dw INTERNAL_DATA_TO_DATA_RELOCATIONS, -1
    80                              <2> 
    81                              <2> 
    82                              <2> %define LINK_DATA_RELOCATIONS ""
    83                              <2> %define LINK_LINKER_DATA_RELOCATIONS ""
    84                              <2> %define LINK_DATA_NAMES db ""
    85                              <2> %define LINK_DATA_DETECTION none, none
    86                              <2> 
    87                              <2> %define LINK_OTHER_DATA_RELOCATIONS ""
    88                              <2> %define LINK_OTHER_LINKER_DATA_RELOCATIONS ""
    89                              <2> %define LINK_OTHER_DATA_NAMES db ""
    90                              <2> %define LINK_OTHER_DATA_DETECTION none, none
    91                              <2> 
    92                              <2> %ifndef ELDOTHER
    93                              <2>  %assign ELDOTHER 0
    94                              <2> %endif
    95                              <2> %assign ELDOTHERLINK 0
    96                              <2> 
    97                              <2> 	%imacro otherlinkdatarelocation 1-3.nolist -2, required
    98                              <2> %if ELDOTHER
    99                              <2>  %assign ELDOTHERLINK 1
   100                              <2> %endif
   101                              <2> 	linkdatarelocation %1, %2, %3
   102                              <2> %assign ELDOTHERLINK 0
   103                              <2> 	%endmacro
   104                              <2> 
   105                              <2> 	%imacro linkdatarelocation 1-3.nolist -2, required
   106                              <2> %assign %%entry $ + _CURRENT_SECTION %+ FIXUP + %2
   107                              <2> %ifidni %3, required
   108                              <2>  %assign %%optional 0
   109                              <2> %elifidni %3, optional
   110                              <2>  %assign %%optional 100h
   111                              <2>  %if ELDDATA_OPTIONAL_STATUS == 0
   112                              <2>   %assign ELDDATA_OPTIONAL_STATUS 1
   113                              <2>  %elif ELDDATA_OPTIONAL_STATUS == 1
   114                              <2>  %else
   115                              <2>   %error Optional data link not allowed here
   116                              <2>  %endif
   117                              <2> %elifidni %3, PM required
   118                              <2>  %assign %%optional 300h
   119                              <2>  %assign ELDDATA_PMREQUIRED_STATUS 1
   120                              <2>  %if ELDDATA_OPTIONAL_STATUS == 0
   121                              <2>   %assign ELDDATA_OPTIONAL_STATUS 1
   122                              <2>  %elif ELDDATA_OPTIONAL_STATUS == 1
   123                              <2>  %else
   124                              <2>   %error Optional data link not allowed here
   125                              <2>  %endif
   126                              <2> %else
   127                              <2>  %fatal Unknown optional keyword
   128                              <2> %endif
   129                              <2> %ifidni _CURRENT_SECTION_TYPE, DATA
   130                              <2>  %assign %%DATASECTION 1
   131                              <2> %else
   132                              <2>  %assign %%DATASECTION 0
   133                              <2> %endif
   134                              <2> 	%if ELDOTHERLINK
   135                              <2> %if ELDLINKER
   136                              <2>  %xdefine LINK_OTHER_LINKER_DATA_RELOCATIONS LINK_OTHER_LINKER_DATA_RELOCATIONS, 1 + %%DATASECTION + %%optional, %%entry, %%name
   137                              <2> %else
   138                              <2>  %xdefine LINK_OTHER_DATA_RELOCATIONS LINK_OTHER_DATA_RELOCATIONS, 1 + %%DATASECTION + %%optional, %%entry, %%name
   139                              <2> %endif
   140                              <2> 	%else
   141                              <2> %if ELDLINKER
   142                              <2>  %xdefine LINK_LINKER_DATA_RELOCATIONS LINK_LINKER_DATA_RELOCATIONS, 1 + %%DATASECTION + %%optional, %%entry, %%name
   143                              <2> %else
   144                              <2>  %xdefine LINK_DATA_RELOCATIONS LINK_DATA_RELOCATIONS, 1 + %%DATASECTION + %%optional, %%entry, %%name
   145                              <2> %endif
   146                              <2> 	%endif
   147                              <2> %defstr %%string %1
   148                              <2> %strlen %%length %%string
   149                              <2> %if %%length > 64
   150                              <2>  %error Too long link name: %1
   151                              <2> %endif
   152                              <2> %define LINK_DATA_CHECK %1
   153                              <2> 	%if ELDOTHERLINK
   154                              <2> 	linkdata_detect LINK_OTHER_DATA_DETECTION
   155                              <2> %if LINK_DATA_NEW
   156                              <2>  %xdefine LINK_OTHER_DATA_DETECTION LINK_OTHER_DATA_DETECTION, %1, %%name
   157                              <2> 	hashdef HASH, %%string
   158                              <2>  %xdefine LINK_OTHER_DATA_NAMES 	LINK_OTHER_DATA_NAMES, %%name:, dw _HASH, {counted %%string}
   160                              <2> %else
   161                              <2>  %%name equ LINK_DATA_DUPLICATE
   162                              <2> %endif
   163                              <2> 	%else
   164                              <2> 	linkdata_detect LINK_DATA_DETECTION
   165                              <2> %if LINK_DATA_NEW
   166                              <2>  %xdefine LINK_DATA_DETECTION LINK_DATA_DETECTION, %1, %%name
   167                              <2> 	hashdef HASH, %%string
   168                              <2>  %xdefine LINK_DATA_NAMES 	LINK_DATA_NAMES, %%name:, dw _HASH, {counted %%string}
   170                              <2> %else
   171                              <2>  %%name equ LINK_DATA_DUPLICATE
   172                              <2> %endif
   173                              <2> 	%endif
   174                              <2> 	eldstrictcheck
   175                              <2> 	%endmacro
   176                              <2> 
   177                              <2> 	%imacro linkdata_detect 2-*.nolist
   178                              <2> %assign LINK_DATA_NEW 1
   179                              <2> %rep (%0 - 2) / 2
   180                              <2>  %rotate 2
   181                              <2>  %ifidni %1, LINK_DATA_CHECK
   182                              <2>   %assign LINK_DATA_NEW 0
   183                              <2>   %xdefine LINK_DATA_DUPLICATE %2
   184                              <2>   %exitrep
   185                              <2>  %endif
   186                              <2> %endrep
   187                              <2> 	%endmacro
   188                              <2> 
   189                              <2> 	%imacro link_data_dump_names 1-*.nolist
   190                              <2> %rep %0
   191                              <2> 	%1
   192                              <2>  %rotate 1
   193                              <2> %endrep
   194                              <2> 	%endmacro
   195                              <2> 
   196                              <2> ; dw LINK_LINKER_DATA_RELOCATIONS, 0, 0
   197                              <2> ; dw LINK_DATA_RELOCATIONS, 0, 0
   198                              <2> ; link_data_dump_names ELDCALL_CODE_NAMES
   199                              <2> 
   200                              <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> 
    55                              <1> 	%imacro extcall 1-2.nolist required
    56                              <1> %ifidni _CURRENT_SECTION_TYPE, DATA
    57                              <1>  %error "ELD call cannot be used in ELD data block"
    58                              <1> %endif
    59                              <1> %assign %%entry $ + _CURRENT_SECTION %+ FIXUP
    60                              <1> %ifidni %2, required
    61                              <1>  %assign %%optional 0
    62                              <1> %elifidni %2, optional
    63                              <1>  %assign %%optional 100h
    64                              <1>  %if ELDCALL_OPTIONAL_STATUS == 0
    65                              <1>   %assign ELDCALL_OPTIONAL_STATUS 1
    66                              <1>  %elif ELDCALL_OPTIONAL_STATUS == 1
    67                              <1>  %else
    68                              <1>   %error Optional code link not allowed here
    69                              <1>  %endif
    70                              <1> %elifidni %2, PM required
    71                              <1>  %assign %%optional 300h
    72                              <1>  %assign ELDCALL_PMREQUIRED_STATUS 1
    73                              <1>  %if ELDCALL_OPTIONAL_STATUS == 0
    74                              <1>   %assign ELDCALL_OPTIONAL_STATUS 1
    75                              <1>  %elif ELDCALL_OPTIONAL_STATUS == 1
    76                              <1>  %else
    77                              <1>   %error Optional code link not allowed here
    78                              <1>  %endif
    79                              <1> %else
    80                              <1>  %fatal Unknown optional keyword
    81                              <1> %endif
    82                              <1> %if 0
    83                              <1> [warning -reloc-rel-word]
    84                              <1> 	call near relocatedzero
    85                              <1> [warning +reloc-rel-word]
    86                              <1> %else
    87                              <1> 	db 0E8h
    88                              <1> reloc	dw relocatedzero
    89                              <1> 	eldstrictcheck
    90                              <1> %endif
    91                              <1> 	jmp strict short %%skipparameter
    92                              <1> 	dw 0
    93                              <1> %%skipparameter:
    94                              <1> %if ELDLINKER
    95                              <1>  %xdefine ELDCALL_LINKER_CODE_RELOCATIONS ELDCALL_LINKER_CODE_RELOCATIONS, %%entry, %%name
    96                              <1>  %xdefine ELDCALL_LINKER_CODE_RELOCATIONS_OPTIONAL ELDCALL_LINKER_CODE_RELOCATIONS_OPTIONAL, 1 + %%optional, %%entry, %%name
    97                              <1> %else
    98                              <1>  %xdefine ELDCALL_CODE_RELOCATIONS ELDCALL_CODE_RELOCATIONS, %%entry, %%name
    99                              <1>  %xdefine ELDCALL_CODE_RELOCATIONS_OPTIONAL ELDCALL_CODE_RELOCATIONS_OPTIONAL, 1 + %%optional, %%entry, %%name
   100                              <1> %endif
   101                              <1> %defstr %%string %1
   102                              <1> %strlen %%length %%string
   103                              <1> %if %%length > 64
   104                              <1>  %error Too long link name: %1
   105                              <1> %endif
   106                              <1> %define ELDCALL_CODE_CHECK %1
   107                              <1> 	linkcode_detect ELDCALL_CODE_DETECTION
   108                              <1> %if ELDCALL_CODE_NEW
   109                              <1>  %xdefine ELDCALL_CODE_DETECTION ELDCALL_CODE_DETECTION, %1, %%name
   110                              <1> 	hashdef HASH, %%string
   111                              <1> %xdefine ELDCALL_CODE_NAMES 	ELDCALL_CODE_NAMES, %%name:, dw _HASH, {counted %%string}
   113                              <1> %else
   114                              <1>  %%name equ ELDCALL_CODE_DUPLICATE
   115                              <1> %endif
   116                              <1> 	%endmacro
   117                              <1> 
   118                              <1> 	%imacro linkcode_detect 2-*.nolist
   119                              <1> %assign ELDCALL_CODE_NEW 1
   120                              <1> %rep (%0 - 2) / 2
   121                              <1>  %rotate 2
   122                              <1>  %ifidni %1, ELDCALL_CODE_CHECK
   123                              <1>   %assign ELDCALL_CODE_NEW 0
   124                              <1>   %xdefine ELDCALL_CODE_DUPLICATE %2
   125                              <1>   %exitrep
   126                              <1>  %endif
   127                              <1> %endrep
   128                              <1> 	%endmacro
   129                              <1> 
   130                              <1> 
   131                              <1> %define ELDCALL_CALLCALL_LIST none
   132                              <1> 
   133                              <1> 	%imacro extcallcall 1.nolist
   134                              <1> 	call %1
   135                              <1> %xdefine ELDCALL_CALLCALL_LIST ELDCALL_CALLCALL_LIST, %1
   136                              <1> 	%endmacro
   137                              <1> 
   138                              <1> %assign ELDCALLCALL_DUMPED 0
   139                              <1> 
   140                              <1> 	%imacro eldcall_dump_callcall 1-*.nolist
   141                              <1> %define ELDCALL_CALLCALL_PROCESSED none
   142                              <1>  %rep %0 - 1
   143                              <1>   %rotate 1
   144                              <1>   %define ELDCALL_CHECK %1
   145                              <1> 	eldcall_callcall_detect ELDCALL_CALLCALL_PROCESSED
   146                              <1>   %if ELDCALL_NEW
   147                              <1>    %xdefine ELDCALL_CALLCALL_PROCESSED ELDCALL_CALLCALL_PROCESSED, %1
   148                              <1> 	align 8, nop
   149                              <1> %1:
   150                              <1> 	extcall %1
   151                              <1> 	retn
   152                              <1>   %endif
   153                              <1>  %endrep
   154                              <1> %unimacro extcallcall 1.nolist
   155                              <1> %assign ELDCALLCALL_DUMPED 1
   156                              <1> %define ELDCALL_CALLCALL_LIST none
   157                              <1> 	%endmacro
   158                              <1> 
   159                              <1> 	%imacro eldcall_callcall_detect 1-*.nolist
   160                              <1> %assign ELDCALL_NEW 1
   161                              <1> %rep %0 - 1
   162                              <1>  %rotate 1
   163                              <1>  %ifidni %1, ELDCALL_CHECK
   164                              <1>   %assign ELDCALL_NEW 0
   165                              <1>   %exitrep
   166                              <1>  %endif
   167                              <1> %endrep
   168                              <1> 	%endmacro
   169                              <1> 
   170                              <1> 	%imacro eldcall_dump_names 1-*.nolist
   171                              <1> %rep %0
   172                              <1> 	%1
   173                              <1>  %rotate 1
   174                              <1> %endrep
   175                              <1> 	%endmacro
   176                              <1> 
   177                              <1> ; eldcall_dump_callcall ELDCALL_CALLCALL_LIST
   178                              <1> ; if using optional code links:
   179                              <1> ;  dw ELDCALL_LINKER_CODE_RELOCATIONS_OPTIONAL, 0
   180                              <1> ;  dw ELDCALL_CODE_RELOCATIONS_OPTIONAL, 0
   181                              <1> ; if not using optional code links:
   182                              <1> ;  dw ELDCALL_LINKER_CODE_RELOCATIONS, 0, 0
   183                              <1> ;  dw ELDCALL_CODE_RELOCATIONS, 0, 0
   184                              <1> ; eldcall_dump_names ELDCALL_CODE_NAMES
   185                              <1> 
   186                              <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> 
    36                              <1> 	%imacro internalcoderelocation 0-1.nolist -2
    37                              <1> %assign %%entry $ + _CURRENT_SECTION %+ FIXUP + %1
    38                              <1> %if ELDLINKER
    39                              <1>  %ifidni _CURRENT_SECTION_TYPE, DATA
    40                              <1>   %xdefine INTERNAL_LINKER_DATA_TO_CODE_RELOCATIONS INTERNAL_LINKER_DATA_TO_CODE_RELOCATIONS, %%entry
    41                              <1>  %else
    42                              <1>   %xdefine INTERNAL_LINKER_CODE_TO_CODE_RELOCATIONS INTERNAL_LINKER_CODE_TO_CODE_RELOCATIONS, %%entry
    43                              <1>  %endif
    44                              <1> %else
    45                              <1>  %ifidni _CURRENT_SECTION_TYPE, DATA
    46                              <1>   %xdefine INTERNAL_DATA_TO_CODE_RELOCATIONS INTERNAL_DATA_TO_CODE_RELOCATIONS, %%entry
    47                              <1>  %else
    48                              <1>   %xdefine INTERNAL_CODE_TO_CODE_RELOCATIONS INTERNAL_CODE_TO_CODE_RELOCATIONS, %%entry
    49                              <1>  %endif
    50                              <1> %endif
    51                              <1> 	eldstrictcheck
    52                              <1> 	%endmacro
    53                              <1> 
    54                              <1> 	%imacro internaldatarelocation 0-1.nolist -2
    55                              <1> %assign %%entry $ + _CURRENT_SECTION %+ FIXUP + %1
    56                              <1> %if ELDLINKER
    57                              <1>  %ifidni _CURRENT_SECTION_TYPE, DATA
    58                              <1>   %xdefine INTERNAL_LINKER_DATA_TO_DATA_RELOCATIONS INTERNAL_LINKER_DATA_TO_DATA_RELOCATIONS, %%entry
    59                              <1>  %else
    60                              <1>   %xdefine INTERNAL_LINKER_CODE_TO_DATA_RELOCATIONS INTERNAL_LINKER_CODE_TO_DATA_RELOCATIONS, %%entry
    61                              <1>  %endif
    62                              <1> %else
    63                              <1>  %ifidni _CURRENT_SECTION_TYPE, DATA
    64                              <1>   %xdefine INTERNAL_DATA_TO_DATA_RELOCATIONS INTERNAL_DATA_TO_DATA_RELOCATIONS, %%entry
    65                              <1>  %else
    66                              <1>   %xdefine INTERNAL_CODE_TO_DATA_RELOCATIONS INTERNAL_CODE_TO_DATA_RELOCATIONS, %%entry
    67                              <1>  %endif
    68                              <1> %endif
    69                              <1> 	eldstrictcheck
    70                              <1> 	%endmacro
    71                              <1> 
    72                              <1> ; dw INTERNAL_LINKER_CODE_TO_CODE_RELOCATIONS, 0
    73                              <1> ; dw INTERNAL_LINKER_CODE_TO_DATA_RELOCATIONS, 0
    74                              <1> ; dw INTERNAL_LINKER_DATA_TO_CODE_RELOCATIONS, -1
    75                              <1> ; dw INTERNAL_LINKER_DATA_TO_DATA_RELOCATIONS, -1
    76                              <1> ; dw INTERNAL_CODE_TO_CODE_RELOCATIONS, 0
    77                              <1> ; dw INTERNAL_CODE_TO_DATA_RELOCATIONS, 0
    78                              <1> ; dw INTERNAL_DATA_TO_CODE_RELOCATIONS, -1
    79                              <1> ; dw INTERNAL_DATA_TO_DATA_RELOCATIONS, -1
    80                              <1> 
    81                              <1> 
    82                              <1> %define LINK_DATA_RELOCATIONS ""
    83                              <1> %define LINK_LINKER_DATA_RELOCATIONS ""
    84                              <1> %define LINK_DATA_NAMES db ""
    85                              <1> %define LINK_DATA_DETECTION none, none
    86                              <1> 
    87                              <1> %define LINK_OTHER_DATA_RELOCATIONS ""
    88                              <1> %define LINK_OTHER_LINKER_DATA_RELOCATIONS ""
    89                              <1> %define LINK_OTHER_DATA_NAMES db ""
    90                              <1> %define LINK_OTHER_DATA_DETECTION none, none
    91                              <1> 
    92                              <1> %ifndef ELDOTHER
    93                              <1>  %assign ELDOTHER 0
    94                              <1> %endif
    95                              <1> %assign ELDOTHERLINK 0
    96                              <1> 
    97                              <1> 	%imacro otherlinkdatarelocation 1-3.nolist -2, required
    98                              <1> %if ELDOTHER
    99                              <1>  %assign ELDOTHERLINK 1
   100                              <1> %endif
   101                              <1> 	linkdatarelocation %1, %2, %3
   102                              <1> %assign ELDOTHERLINK 0
   103                              <1> 	%endmacro
   104                              <1> 
   105                              <1> 	%imacro linkdatarelocation 1-3.nolist -2, required
   106                              <1> %assign %%entry $ + _CURRENT_SECTION %+ FIXUP + %2
   107                              <1> %ifidni %3, required
   108                              <1>  %assign %%optional 0
   109                              <1> %elifidni %3, optional
   110                              <1>  %assign %%optional 100h
   111                              <1>  %if ELDDATA_OPTIONAL_STATUS == 0
   112                              <1>   %assign ELDDATA_OPTIONAL_STATUS 1
   113                              <1>  %elif ELDDATA_OPTIONAL_STATUS == 1
   114                              <1>  %else
   115                              <1>   %error Optional data link not allowed here
   116                              <1>  %endif
   117                              <1> %elifidni %3, PM required
   118                              <1>  %assign %%optional 300h
   119                              <1>  %assign ELDDATA_PMREQUIRED_STATUS 1
   120                              <1>  %if ELDDATA_OPTIONAL_STATUS == 0
   121                              <1>   %assign ELDDATA_OPTIONAL_STATUS 1
   122                              <1>  %elif ELDDATA_OPTIONAL_STATUS == 1
   123                              <1>  %else
   124                              <1>   %error Optional data link not allowed here
   125                              <1>  %endif
   126                              <1> %else
   127                              <1>  %fatal Unknown optional keyword
   128                              <1> %endif
   129                              <1> %ifidni _CURRENT_SECTION_TYPE, DATA
   130                              <1>  %assign %%DATASECTION 1
   131                              <1> %else
   132                              <1>  %assign %%DATASECTION 0
   133                              <1> %endif
   134                              <1> 	%if ELDOTHERLINK
   135                              <1> %if ELDLINKER
   136                              <1>  %xdefine LINK_OTHER_LINKER_DATA_RELOCATIONS LINK_OTHER_LINKER_DATA_RELOCATIONS, 1 + %%DATASECTION + %%optional, %%entry, %%name
   137                              <1> %else
   138                              <1>  %xdefine LINK_OTHER_DATA_RELOCATIONS LINK_OTHER_DATA_RELOCATIONS, 1 + %%DATASECTION + %%optional, %%entry, %%name
   139                              <1> %endif
   140                              <1> 	%else
   141                              <1> %if ELDLINKER
   142                              <1>  %xdefine LINK_LINKER_DATA_RELOCATIONS LINK_LINKER_DATA_RELOCATIONS, 1 + %%DATASECTION + %%optional, %%entry, %%name
   143                              <1> %else
   144                              <1>  %xdefine LINK_DATA_RELOCATIONS LINK_DATA_RELOCATIONS, 1 + %%DATASECTION + %%optional, %%entry, %%name
   145                              <1> %endif
   146                              <1> 	%endif
   147                              <1> %defstr %%string %1
   148                              <1> %strlen %%length %%string
   149                              <1> %if %%length > 64
   150                              <1>  %error Too long link name: %1
   151                              <1> %endif
   152                              <1> %define LINK_DATA_CHECK %1
   153                              <1> 	%if ELDOTHERLINK
   154                              <1> 	linkdata_detect LINK_OTHER_DATA_DETECTION
   155                              <1> %if LINK_DATA_NEW
   156                              <1>  %xdefine LINK_OTHER_DATA_DETECTION LINK_OTHER_DATA_DETECTION, %1, %%name
   157                              <1> 	hashdef HASH, %%string
   158                              <1>  %xdefine LINK_OTHER_DATA_NAMES 	LINK_OTHER_DATA_NAMES, %%name:, dw _HASH, {counted %%string}
   160                              <1> %else
   161                              <1>  %%name equ LINK_DATA_DUPLICATE
   162                              <1> %endif
   163                              <1> 	%else
   164                              <1> 	linkdata_detect LINK_DATA_DETECTION
   165                              <1> %if LINK_DATA_NEW
   166                              <1>  %xdefine LINK_DATA_DETECTION LINK_DATA_DETECTION, %1, %%name
   167                              <1> 	hashdef HASH, %%string
   168                              <1>  %xdefine LINK_DATA_NAMES 	LINK_DATA_NAMES, %%name:, dw _HASH, {counted %%string}
   170                              <1> %else
   171                              <1>  %%name equ LINK_DATA_DUPLICATE
   172                              <1> %endif
   173                              <1> 	%endif
   174                              <1> 	eldstrictcheck
   175                              <1> 	%endmacro
   176                              <1> 
   177                              <1> 	%imacro linkdata_detect 2-*.nolist
   178                              <1> %assign LINK_DATA_NEW 1
   179                              <1> %rep (%0 - 2) / 2
   180                              <1>  %rotate 2
   181                              <1>  %ifidni %1, LINK_DATA_CHECK
   182                              <1>   %assign LINK_DATA_NEW 0
   183                              <1>   %xdefine LINK_DATA_DUPLICATE %2
   184                              <1>   %exitrep
   185                              <1>  %endif
   186                              <1> %endrep
   187                              <1> 	%endmacro
   188                              <1> 
   189                              <1> 	%imacro link_data_dump_names 1-*.nolist
   190                              <1> %rep %0
   191                              <1> 	%1
   192                              <1>  %rotate 1
   193                              <1> %endrep
   194                              <1> 	%endmacro
   195                              <1> 
   196                              <1> ; dw LINK_LINKER_DATA_RELOCATIONS, 0, 0
   197                              <1> ; dw LINK_DATA_RELOCATIONS, 0, 0
   198                              <1> ; link_data_dump_names ELDCALL_CODE_NAMES
   199                              <1> 
   200                              <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-2023 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> lsvefNoDataStart	equ 1
   109                              <1> lsvefPartitionNumber	equ 2
   110                              <1> 
   111                              <1> 	struc LOADCMDLINE, LOADDATA - lsvclBufferLength
   112                              <1> ldCommandLine:
   113 FFFFFEE0 <res 100h>          <1> .start:		resb lsvclBufferLength
   114                              <1> 	endstruc
   115                              <1> 
   116                              <1> ldfHasLBA:	equ 1
   117                              <1> ldfFATInvalid:	equ 2
   118                              <1> ldfFATBuffered:	equ 4
   119                              <1> ldfDataBuffered: equ 8
   120                              <1> 
   121                              <1> 	struc LOADDATA2, LOADDATA - 10h
   122 FFFFFFD0 ????????            <1> ldRootSector:		resd 1
   123 FFFFFFD4 ????                <1> ldEntriesPerSector:	resw 1
   124                              <1> ldDataSegment:		; word
   125 FFFFFFD6 ????                <1> ldLastAvailableSector:	resw 1
   126                              <1> ldDataSector:		; dword
   127 FFFFFFD8 ????                <1> ldParasLeft:		resw 1
   128 FFFFFFDA ????                <1> ldParasDone:		resw 1
   129                              <1> 	endstruc
   130                              <1> 
   131                              <1> 	struc LOADDATA3, LOADDATA2 - 10h
   132 FFFFFFC0 ????????            <1> ldMaxCluster:		resd 1
   133 FFFFFFC4 ????????            <1> ldFileSize:		resd 1
   134 FFFFFFC8 ????????            <1> ldCurrentCluster:	resd 1
   135 FFFFFFCC ????????            <1> ldCurrentSeek:		resd 1
   136                              <1> 	endstruc
   137                              <1> 
   138                              <1> 	struc LBAPACKET
   139 00000000 ????                <1> lpSize:		resw 1
   140 00000002 ????                <1> lpCount:	resw 1
   141 00000004 ????????            <1> lpBuffer:	resd 1
   142 00000008 ????????????????    <1> lpSector:	resq 1
   143                              <1> 	endstruc
   144                              <1> 
   145                              <1> 	struc PARTINFO
   146 00000000 ??                  <1> piBoot:		resb 1
   147 00000001 ??????              <1> piStartCHS:	resb 3
   148 00000004 ??                  <1> piType:		resb 1
   149 00000005 ??????              <1> piEndCHS:	resb 3
   150 00000008 ????????            <1> piStart:	resd 1
   151 0000000C ????????            <1> piLength:	resd 1
   152                              <1> 	endstruc
   153                              <1> 
   154                              <1> ptEmpty:		equ 0
   155                              <1> ptFAT12:		equ 1
   156                              <1> ptFAT16_16BIT_CHS:	equ 4
   157                              <1> ptExtendedCHS:		equ 5
   158                              <1> ptFAT16_CHS:		equ 6
   159                              <1> ptFAT32_CHS:		equ 0Bh
   160                              <1> ptFAT32:		equ 0Ch
   161                              <1> ptFAT16:		equ 0Eh
   162                              <1> ptExtended:		equ 0Fh
   163                              <1> ptLinux:		equ 83h
   164                              <1> ptExtendedLinux:	equ 85h
   165                              <1> 
   166                              <1> 
   167                              <1> 		; Flags of load_unit_flags
   168                              <1> lufForceCHS:		equ 1
   169                              <1> lufForceLBA:		equ 2
   170                              <1> lufForceGeometry:	equ 4
   171                              <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 3017                    at eldhCodeImageLength,	dw code_size
    33 0000000E 0000                    at eldhCodeAllocLength,	dw 0
    34 00000010 80170000                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 491A0000                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> %if _ELD_IDENTICALISE
    38                              <1>  ;%assign _ELDCALL_OPTIONAL 1
    39                              <1> %endif
    40                              <1> %ifn _ELDCALL_OPTIONAL
    41                              <1> %assign ELDCALL_OPTIONAL_STATUS 2		; not allowed
    42                              <1> %endif
    43                              <1> ;%ifn _ELDDATA_OPTIONAL
    44                              <1> ;%assign ELDDATA_OPTIONAL_STATUS 2		; not allowed
    45                              <1> ;%endif
    46                              <1> 	gendef MAP, ""
    47                              <1> 
    48                              <1> %ifnidni _MAP, ""
    49                              <1>  [map all _MAP]
    50                              <1> %endif
    51                              <1> 
    52                              <1> 
    53                              <1> endresident: equ ($ + _CURRENT_SECTION %+ FIXUP + 15) & ~15
    54                              <1> 
    55                              <1> %if _ELD_LINKER_PASSES
    56                              <1> %assign ELDLINKER 1
    57                              <1> 
    58                              <1> 	struc LINKTABLE
    59 00000000 ????????            <1> ltCodeToCode:	resw 2
    60 00000004 ????????            <1> ltCodeToData:	resw 2
    61 00000008 ????????            <1> ltDataToCode:	resw 2
    62 0000000C ????????            <1> ltDataToData:	resw 2
    63 00000010 ????????            <1> ltLinkData:	resw 2
    64 00000014 ????????            <1> ltLinkCode:	resw 2
    65                              <1> 	endstruc
    66                              <1> %endif
    67                              <1> 
    68                              <1> 
    69                              <1> linker:
    70                              <1> 		; The first 15 Bytes of the linker should be
    71                              <1> 		;  the same regardless of the linker options
    72                              <1> 		;  used (debug, passes, vstart). This allows
    73                              <1> 		;  the eldcomp ELD to match even if up to 15
    74                              <1> 		;  Bytes of the linker are trailing in the
    75                              <1> 		;  resident part of the ELD.
    76                              <1> 	lframe
    77                              <1>  %if ELDOTHER
    78                              <1> 	lvar dword, linkinfo_other
    79                              <1> 	lvar word, use_hash_other
    80                              <1>  %endif
    81 00000DCF 5589E5              <1> 	lenter
    82                              <1> 	lvar dword, instance
    83 00000DD2 06                  <1> 	 push es
    84 00000DD3 52                  <1> 	 push dx
    85                              <1> 	lvar word, targetsection_low_optional_high
    86 00000DD4 50                  <1> 	 push ax
    87                              <1> 	lequ ?targetsection_low_optional_high, targetsection
    88                              <1> 	lequ ?targetsection_low_optional_high + 1, optional
    89                              <1> 	lvar dword, linkinfo
    90 00000DD5 1E                  <1> 	 push ds
    91 00000DD6 57                  <1> 	 push di
    92                              <1> 	lvar dword, nextreloc
    93 00000DD7 06                  <1> 	 push es
    94 00000DD8 52                  <1> 	 push dx
    95                              <1> 	lvar dword, entry
    96 00000DD9 06                  <1> 	 push es
    97 00000DDA 50                  <1> 	 push ax		; placeholder
    98 00000DDB 31C0                <1> 	xor ax, ax
    99 00000DDD 813DD1E1            <1> 	cmp word [di + eldlSignature], 0E1D1h
   100                              <1> %if ($ - linker) < 16
   101                              <1>  %error Expected invariant first paragraph of linker
   102                              <1> %endif
   103 00000DE1 7403E95502          <1> 	jne .error_j
   104 00000DE6 837D0601            <1> 	cmp word [di + eldlUseLinkHash], 1
   105 00000DEA 7603E94C02          <1> 	ja .error_j
   106 00000DEF 7201                <1> 	jb @F
   107 00000DF1 48                  <1> 	dec ax
   108                              <1> @@:
   109                              <1> 	lvar word, use_hash
   110 00000DF2 50                  <1> 	 push ax
   111                              <1> %if _ELD_IDENTICALISE && _ELD_LINKER_PASSES
   112                              <1> 	mov ax, linktable - code
   113                              <1> 	lvar word, lt
   114                              <1> 	 push ax
   115                              <1> %endif
   116                              <1> %if _ELD_LINKER_PASSES || ELDOTHER
   117 00000DF3 31C0                <1> 	xor ax, ax
   118                              <1>  %if _ELD_LINKER_PASSES
   119                              <1> 	lvar word, pass
   120 00000DF5 50                  <1> 	 push ax
   121                              <1> 	lvar word, amounterrors
   122 00000DF6 50                  <1> 	 push ax
   123                              <1> 	lvar word, name
   124 00000DF7 50                  <1> 	 push ax
   125                              <1>  %endif
   126                              <1>  %if ELDOTHER
   127                              <1> 	lvar word, other
   128                              <1> 	 push ax
   129                              <1>  %endif
   130                              <1> %endif
   131 00000DF8 56                  <1> 	push si
   132 00000DF9 53                  <1> 	push bx
   133                              <1> 
   134                              <1> 			; simple: add instance base (dx) to code
   135 00000DFA 06                  <1> 	push es
   136 00000DFB 1F                  <1> 	pop ds
   137                              <1> %if _ELD_LINKER_PASSES
   138                              <1> .pass:
   139 00000DFC 8B5EEA              <1> 	mov bx, word [bp + ?pass]
   140 00000DFF 01D3                <1> 	add bx, dx
   141                              <1>  %if _ELD_IDENTICALISE
   142                              <1> 	add bx, word [bp + ?lt]
   143                              <1> 	mov si, word [ltCodeToCode + bx]
   144                              <1>  %else
   145 00000E01 8BB78411            <1> 	mov si, word [linktable - code + ltCodeToCode + bx]
   146                              <1>  %endif
   147                              <1> %else
   148                              <1> 	mov si, internalcodetocoderelocations - code
   149                              <1> %endif
   150 00000E05 01D6                <1> 	add si, dx
   151                              <1> @@:
   152 00000E07 AD                  <1> 	lodsw
   153 00000E08 85C0                <1> 	test ax, ax		; was last ?
   154 00000E0A 740B                <1> 	jz @F			; yes -->
   155 00000E0C 93                  <1> 	xchg bx, ax		; bx = entry
   156 00000E0D 01D3                <1> 	add bx, dx		; relocate the entry itself
   157                              <1> %if _ELD_CODE_VSTART
   158 00000E0F 812F[0000]          <1> 	sub word [bx], code	; undo adjustment
   159                              <1> %endif
   160 00000E13 0117                <1> 	add word [bx], dx	; relocate word referenced by entry
   161 00000E15 EBF0                <1> 	jmp @B
   162                              <1> 
   163                              <1> @@:
   164                              <1> 			; next, add heap data base (on stack) to code
   165                              <1> %if _ELD_LINKER_PASSES
   166 00000E17 8B5EEA              <1> 	mov bx, word [bp + ?pass]
   167 00000E1A 01D3                <1> 	add bx, dx
   168                              <1>  %if _ELD_IDENTICALISE
   169                              <1> 	add bx, word [bp + ?lt]
   170                              <1> 	mov si, word [ltCodeToData + bx]
   171                              <1>  %else
   172 00000E1C 8BB78811            <1> 	mov si, word [linktable - code + ltCodeToData + bx]
   173                              <1>  %endif
   174                              <1> %else
   175                              <1> 	mov si, internalcodetodatarelocations - code
   176                              <1> %endif
   177 00000E20 01D6                <1> 	add si, dx
   178                              <1> @@:
   179 00000E22 AD                  <1> 	lodsw
   180 00000E23 85C0                <1> 	test ax, ax		; was last ?
   181 00000E25 740C                <1> 	jz @F			; yes -->
   182 00000E27 93                  <1> 	xchg bx, ax		; bx = entry
   183 00000E28 01D3                <1> 	add bx, dx		; relocate the entry itself
   184 00000E2A 58                  <1> 	pop ax			; ax -> heap data
   185 00000E2B 50                  <1> 	push ax
   186                              <1> %if _ELD_DATA_VSTART
   187 00000E2C 2D[0000]            <1> 	sub ax, datastart	; undo adjustment
   188                              <1> %endif
   189 00000E2F 0107                <1> 	add word [bx], ax	; relocate word referenced by entry
   190 00000E31 EBEF                <1> 	jmp @B
   191                              <1> 
   192                              <1> @@:
   193                              <1> 
   194                              <1> 			; add instance base (dx) to data
   195                              <1> %if _ELD_LINKER_PASSES
   196 00000E33 8B5EEA              <1> 	mov bx, word [bp + ?pass]
   197 00000E36 01D3                <1> 	add bx, dx
   198                              <1>  %if _ELD_IDENTICALISE
   199                              <1> 	add bx, word [bp + ?lt]
   200                              <1> 	mov si, word [ltDataToCode + bx]
   201                              <1>  %else
   202 00000E38 8BB78C11            <1> 	mov si, word [linktable - code + ltDataToCode + bx]
   203                              <1>  %endif
   204                              <1> %else
   205                              <1> 	mov si, internaldatatocoderelocations - code
   206                              <1> %endif
   207 00000E3C 01D6                <1> 	add si, dx
   208                              <1> @@:
   209 00000E3E AD                  <1> 	lodsw
   210 00000E3F 83F8FF              <1> 	cmp ax, -1		; was last ?
   211 00000E42 740F                <1> 	je @F			; yes -->
   212 00000E44 93                  <1> 	xchg bx, ax		; bx = entry
   213 00000E45 58                  <1> 	pop ax
   214 00000E46 50                  <1> 	push ax
   215 00000E47 01C3                <1> 	add bx, ax		; relocate the entry itself
   216                              <1> %if _ELD_CODE_VSTART
   217 00000E49 36812F[0000]        <1> 	sub word [ss:bx], code	; undo adjustment
   218                              <1> %endif
   219 00000E4E 360117              <1> 	add word [ss:bx], dx	; relocate word referenced by entry
   220 00000E51 EBEB                <1> 	jmp @B
   221                              <1> 
   222                              <1> @@:
   223                              <1> 			; next, add heap data base (on stack) to data
   224                              <1> %if _ELD_LINKER_PASSES
   225 00000E53 8B5EEA              <1> 	mov bx, word [bp + ?pass]
   226 00000E56 01D3                <1> 	add bx, dx
   227                              <1>  %if _ELD_IDENTICALISE
   228                              <1> 	add bx, word [bp + ?lt]
   229                              <1> 	mov si, word [ltDataToData + bx]
   230                              <1>  %else
   231 00000E58 8BB79011            <1> 	mov si, word [linktable - code + ltDataToData + bx]
   232                              <1>  %endif
   233                              <1> %else
   234                              <1> 	mov si, internaldatatodatarelocations - code
   235                              <1> %endif
   236 00000E5C 01D6                <1> 	add si, dx
   237                              <1> @@:
   238 00000E5E AD                  <1> 	lodsw
   239 00000E5F 83F8FF              <1> 	cmp ax, -1		; was last ?
   240 00000E62 740D                <1> 	je @F			; yes -->
   241 00000E64 93                  <1> 	xchg bx, ax		; bx = entry
   242 00000E65 58                  <1> 	pop ax			; ax -> heap data
   243 00000E66 50                  <1> 	push ax
   244 00000E67 01C3                <1> 	add bx, ax		; relocate the entry itself
   245                              <1> %if _ELD_DATA_VSTART
   246 00000E69 2D[0000]            <1> 	sub ax, datastart	; undo adjustment
   247                              <1> %endif
   248 00000E6C 360107              <1> 	add word [ss:bx], ax	; relocate word referenced by entry
   249 00000E6F EBED                <1> 	jmp @B
   250                              <1> 
   251                              <1> @@:
   252 00000E71 8B56FC              <1> 	mov dx, word [bp + ?instance]
   253                              <1> %if _ELD_LINKER_PASSES
   254 00000E74 8B5EEA              <1> 	mov bx, word [bp + ?pass]
   255 00000E77 01D3                <1> 	add bx, dx
   256                              <1>  %if _ELD_IDENTICALISE
   257                              <1> 	add bx, word [bp + ?lt]
   258                              <1> 	add dx, word [ltLinkData + bx]
   259                              <1>  %else
   260 00000E79 03979411            <1> 	add dx, word [linktable - code + ltLinkData + bx]
   261                              <1>  %endif
   262                              <1> %else
   263                              <1> 	add dx, linkerdatarelocations - code
   264                              <1> %endif
   265                              <1> .otherloop:
   266 00000E7D 8956F2              <1> 	mov word [bp + ?nextreloc], dx
   267                              <1> 
   268                              <1> .datarelocloop:		; must be done before further relocs
   269 00000E80 C576F2              <1> 	lds si, [bp + ?nextreloc]
   270 00000E83 AD                  <1> 	lodsw			; ax = section indicator
   271 00000E84 85C0                <1> 	test ax, ax		; end of table ?
   272 00000E86 7503E92301          <1> 	jz .donedatareloc
   273 00000E8B 48                  <1> 	dec ax			; al = 1 if data, 0 if code
   274 00000E8C 5B                  <1> 	pop bx
   275 00000E8D 53                  <1> 	push bx			; bx -> ELD data block
   276 00000E8E 8946FA              <1> 	mov word [bp + ?targetsection_low_optional_high], ax
   277 00000E91 84C0                <1> 	test al, al		; data ?
   278 00000E93 AD                  <1> 	lodsw
   279 00000E94 7504                <1> 	jnz @F			; yes -->
   280 00000E96 0346FC              <1> 	add ax, word [bp + ?instance]
   281                              <1> 				; relocate entry into code
   282 00000E99 A9                  <1> 	db __TEST_IMM16		; (skip add)
   283                              <1> @@:
   284 00000E9A 01D8                <1> 	add ax, bx		; relocate entry into data
   285 00000E9C 8946EE              <1> 	mov word [bp + ?entry], ax
   286 00000E9F AD                  <1> 	lodsw
   287 00000EA0 8976F2              <1> 	mov word [bp + ?nextreloc], si
   288 00000EA3 E8DC00              <1> 	call .build_match
   289                              <1> %if _ELD_LINKER_PASSES
   290 00000EA6 73D8                <1> 	jnc .datarelocloop
   291                              <1> %endif
   292 00000EA8 C45EF6              <1> 	les bx, [bp + ?linkinfo]
   293                              <1> %if ELDOTHER
   294                              <1> 	rol byte [bp + ?other], 1
   295                              <1> 	jnc @F
   296                              <1> 	les bx, [bp + ?linkinfo_other]
   297                              <1> @@:
   298                              <1> %endif
   299 00000EAB 268B4F08            <1> 	mov cx, word [es:bx + eldlDataAmount]	; amount data link info
   300 00000EAF 268B7F0A            <1> 	mov di, word [es:bx + eldlDataPrefixes]	; -> prefixes or hashes
   301                              <1> .datarelocfind:
   302 00000EB3 F2AF                <1> 	repne scasw			; scan initial
   303 00000EB5 7541                <1> 	jne .datarelocnotfound
   304 00000EB7 57                  <1> 	push di
   305 00000EB8 51                  <1> 	push cx
   306 00000EB9 56                  <1> 	push si
   307 00000EBA 262B7F0A            <1> 	sub di, word [es:bx + eldlDataPrefixes]	; = double index, 1-based
   308 00000EBE 4F                  <1> 	dec di
   309 00000EBF 4F                  <1> 	dec di				; 0-based
   310 00000EC0 26037F0C            <1> 	add di, word [es:bx + eldlDataEntries]	; -> entry
   311 00000EC4 268B3D              <1> 	mov di, [es:di]			; -> counted suffix/string
   312 00000EC7 B500                <1> 	mov ch, 0
   313 00000EC9 8A0C                <1> 	mov cl, byte [si]		; cx = length
   314 00000ECB 41                  <1> 	inc cx
   315                              <1> 	; cmp al, al			; ZR if length is zero
   316 00000ECC F3A6                <1> 	repe cmpsb			; match ?
   317 00000ECE 5E                  <1> 	pop si
   318 00000ECF 59                  <1> 	pop cx
   319 00000ED0 5F                  <1> 	pop di
   320 00000ED1 75E0                <1> 	jne .datarelocfind
   321 00000ED3 8814                <1> 	mov byte [si], dl
   322 00000ED5 262B7F0A            <1> 	sub di, word [es:bx + eldlDataPrefixes]	; = double index, 1-based
   323 00000ED9 4F                  <1> 	dec di
   324 00000EDA 4F                  <1> 	dec di				; 0-based
   325 00000EDB 26037F0E            <1> 	add di, word [es:bx + eldlDataAddresses]	; -> address (offset)
   326 00000EDF 268B05              <1> 	mov ax, word [es:di]
   327 00000EE2 E80700              <1> 	call .address_data_reloc
   328                              <1> %if _ELD_RELOC_VSTART
   329 00000EE5 2D[0000]            <1> 	sub ax, relocateddata		; *not* a relocation
   330                              <1> %endif
   331 00000EE8 0104                <1> 	add word [si], ax		; relocate
   332 00000EEA EB94                <1> 	jmp .datarelocloop
   333                              <1> 
   334                              <1> .address_data_reloc:
   335 00000EEC C576EE              <1> 	lds si, [bp + ?entry]		; -> entry if in ELD code instance
   336 00000EEF 807EFA00            <1> 	cmp byte [bp + ?targetsection], 0
   337                              <1> 					; relocation in code ?
   338 00000EF3 7402                <1> 	je @F				; yes -->
   339 00000EF5 16                  <1> 	push ss
   340 00000EF6 1F                  <1> 	pop ds				; => our ELD data block
   341                              <1> @@:
   342 00000EF7 C3                  <1> 	retn
   343                              <1> 
   344                              <1> .datarelocnotfound:
   345 00000EF8 8814                <1> 	mov byte [si], dl
   346 00000EFA 807EFB00            <1> 	cmp byte [bp + ?optional], 0
   347                              <1> %if _ELD_DEBUG
   348                              <1> 	jne @F
   349                              <1>  %ifn _ELD_LINKER_PASSES
   350                              <1> 	mov si, 0			; (invalid link)
   351                              <1> linkdatarelocation internalflags6
   352                              <1> 	test si, si
   353                              <1> 	jz .datanotfound
   354                              <1> 	mov si, 0			; (invalid link)
   355                              <1> linkdatarelocation options7
   356                              <1> 	test si, si
   357                              <1> 	jz .datanotfound
   358                              <1>  %else
   359                              <1> 	cmp byte [bp + ?pass], 0
   360                              <1> 	je .datanotfound
   361                              <1>  %endif
   362                              <1> 	houdini
   363                              <1> 	jmp .datanotfound
   364                              <1> @@:
   365                              <1> %else
   366 00000EFE 7417                <1> 	je .datanotfound
   367                              <1> %endif
   368                              <1> 
   369                              <1> %if ELDDATA_PMREQUIRED_STATUS
   370                              <1> 	mov si, relocateddata
   371                              <1> linkdatarelocation build_option_PM
   372                              <1> 	test si, si
   373                              <1> 	jz @F
   374                              <1> 	test byte [bp + ?optional], 2
   375                              <1> 	jnz .datanotfound
   376                              <1> @@:
   377                              <1> %endif
   378                              <1> 
   379                              <1> %if _ELD_LINKER_PASSES
   380 00000F00 36F606[0000]02      <1> 	testopt [ss:relocateddata], 2
   381                              <1> linkdatarelocation options7, -3
   382 00000F06 7406                <1> 	jz @F
   383 00000F08 BE[D016]            <1> 	mov si, lmsg.warning_data_optional
   384                              <1> internalcoderelocation
   385 00000F0B E82B00              <1> 	call .notfound
   386                              <1> @@:
   387                              <1> %endif
   388 00000F0E E8DBFF              <1> 	call .address_data_reloc
   389 00000F11 832400              <1> 	and word [si], 0		; indicate optional data link failed
   390 00000F14 E969FF              <1> 	jmp .datarelocloop
   391                              <1> 
   392                              <1> 
   393                              <1> %if _ELDCALL_OPTIONAL
   394                              <1> .coderelocnotfound:
   395                              <1> 	mov byte [si], dl
   396                              <1> 	cmp byte [bp + ?optional], 0
   397                              <1> %if _ELD_DEBUG
   398                              <1> 	jne @F
   399                              <1>  %ifn _ELD_LINKER_PASSES
   400                              <1> 	mov si, 0			; (invalid link)
   401                              <1> linkdatarelocation internalflags6
   402                              <1> 	test si, si
   403                              <1> 	jz .codenotfound
   404                              <1> 	mov si, 0			; (invalid link)
   405                              <1> linkdatarelocation options7
   406                              <1> 	test si, si
   407                              <1> 	jz .codenotfound
   408                              <1>  %else
   409                              <1> 	cmp byte [bp + ?pass], 0
   410                              <1> 	je .codenotfound
   411                              <1>  %endif
   412                              <1> 	houdini
   413                              <1> 	jmp .codenotfound
   414                              <1> @@:
   415                              <1> %else
   416                              <1> 	je .codenotfound
   417                              <1> %endif
   418                              <1> 
   419                              <1> %if ELDCALL_PMREQUIRED_STATUS
   420                              <1>  %if _ELD_LINKER_PASSES
   421                              <1>   %assign ELDLINKER 0
   422                              <1>  %endif
   423                              <1> 	mov si, relocateddata
   424                              <1> linkdatarelocation build_option_PM
   425                              <1>  %if _ELD_LINKER_PASSES
   426                              <1>   %assign ELDLINKER 1
   427                              <1>  %endif
   428                              <1> 	test si, si
   429                              <1> 	jz @F
   430                              <1> 	test byte [bp + ?optional], 2
   431                              <1> 	jnz .codenotfound
   432                              <1> @@:
   433                              <1> %endif
   434                              <1> 
   435                              <1> %if _ELD_LINKER_PASSES
   436                              <1> 	testopt [ss:relocateddata], 2
   437                              <1> linkdatarelocation options7, -3
   438                              <1> 	jz @F
   439                              <1> 	mov si, lmsg.warning_code_optional
   440                              <1> internalcoderelocation
   441                              <1> 	call .notfound
   442                              <1> @@:
   443                              <1> %endif
   444                              <1> 	lds si, [bp + ?entry]
   445                              <1> 	mov word [si], 9090h
   446                              <1> 	mov byte [si + 2], 90h		; indicate optional code link failed
   447                              <1> 	jmp .coderelocloop
   448                              <1> %endif
   449                              <1> 
   450                              <1> 
   451                              <1> %if _ELD_LINKER_PASSES
   452                              <1> .datanotfound:
   453 00000F17 BE[F216]            <1> 	mov si, lmsg.error_data
   454                              <1> internalcoderelocation
   455 00000F1A E81C00              <1> 	call .notfound
   456 00000F1D 7203E91901          <1> 	jnc .error_j
   457 00000F22 FF46E8              <1> 	inc word [bp + ?amounterrors]
   458 00000F25 E958FF              <1> 	jmp .datarelocloop
   459                              <1> 
   460                              <1> .codenotfound:
   461 00000F28 BE[0B17]            <1> 	mov si, lmsg.error_code
   462                              <1> internalcoderelocation
   463 00000F2B E80B00              <1> 	call .notfound
   464 00000F2E 7203E90801          <1> 	jnc .error_j
   465 00000F33 FF46E8              <1> 	inc word [bp + ?amounterrors]
   466 00000F36 E98400              <1> 	jmp .coderelocloop
   467                              <1> 
   468                              <1> .notfound:
   469 00000F39 807EEA00            <1> 	cmp byte [bp + ?pass], 0
   470 00000F3D 743A                <1> 	je @F				; --> (NC)
   471 00000F3F 16                  <1> 	 push ss
   472 00000F40 07                  <1> 	 pop es
   473 00000F41 BF[0000]            <1> 	mov di, relocateddata
   474                              <1> linkdatarelocation line_out
   475 00000F44 E83300              <1> 	call .copy
   476 00000F47 8B76E6              <1> 	mov si, word [bp + ?name]
   477 00000F4A AD                  <1> 	lodsw
   478 00000F4B E8[0000]EB020000    <1> 	extcall hexword
   479 00000F52 56                  <1> 	push si
   480 00000F53 BE[2417]            <1> 	mov si, lmsg.error.2
   481                              <1> internalcoderelocation
   482 00000F56 E82100              <1> 	call .copy
   483 00000F59 5E                  <1> 	pop si
   484                              <1> %if _ELD_LINKER_PASSES
   485 00000F5A 56                  <1> 	push si
   486 00000F5B E81C00              <1> 	call .copy
   487 00000F5E 5E                  <1> 	pop si
   488 00000F5F C60400              <1> 	mov byte [si], 0		; mark as failed
   489                              <1> %else
   490                              <1> 	call .copy
   491                              <1> %endif
   492 00000F62 B022                <1> 	mov al, '"'
   493 00000F64 AA                  <1> 	stosb
   494 00000F65 16                  <1> 	 push ss
   495 00000F66 1F                  <1> 	 pop ds
   496 00000F67 E8[0000]EB020000    <1> 	extcall putsline_crlf
   497 00000F6E B8350E              <1> 	mov ax, 0E35h
   498 00000F71 E8[0000]EB020000    <1> 	extcall setrc
   499 00000F78 F9                  <1> 	stc				; CY, diagnostic displayed
   500                              <1> @@:
   501 00000F79 C3                  <1> 	retn
   502                              <1> 
   503                              <1> .copy:
   504 00000F7A E8[0000]EB020000    <1> 	extcall copy_single_counted_string
   505 00000F81 C3                  <1> 	retn
   506                              <1> %else
   507                              <1> .datanotfound: equ .error_j
   508                              <1> .codenotfound: equ .error_j
   509                              <1> %endif
   510                              <1> 
   511                              <1> .build_match:
   512                              <1> %if _ELD_CODE_VSTART
   513 00000F82 2D[0000]            <1> 	sub ax, code
   514                              <1> %endif
   515 00000F85 0346FC              <1> 	add ax, word [bp + ?instance]
   516 00000F88 96                  <1> 	xchg si, ax
   517                              <1> %if _ELD_LINKER_PASSES
   518 00000F89 8976E6              <1> 	mov word [bp + ?name], si
   519                              <1> %endif
   520 00000F8C AD                  <1> 	lodsw			; = hash, si -> counted string
   521 00000F8D 8A14                <1> 	mov dl, byte [si]
   522                              <1> %if _ELD_LINKER_PASSES
   523 00000F8F 84D2                <1> 	test dl, dl		; marked as already failed ?
   524 00000F91 750A                <1> 	jnz @F
   525 00000F93 837EE800            <1> 	cmp word [bp + ?amounterrors], 0
   526 00000F97 7503E99F00          <1> 	je .error_j
   527 00000F9C C3                  <1> 	retn			; (NC)
   528                              <1> 
   529                              <1> @@:
   530                              <1> %endif
   531                              <1> %if ELDOTHER
   532                              <1> 	rol byte [bp + ?other], 1
   533                              <1> 	jnc @F
   534                              <1> 	rol byte [bp + ?use_hash_other], 1
   535                              <1> 	jmp @FF
   536                              <1> 
   537                              <1> @@:
   538                              <1> %endif
   539 00000F9D D046EC              <1> 	rol byte [bp + ?use_hash], 1
   540                              <1> @@:
   541 00000FA0 720A                <1> 	jc @F
   542 00000FA2 AC                  <1> 	lodsb
   543 00000FA3 91                  <1> 	xchg cx, ax		; cl = length
   544 00000FA4 AD                  <1> 	lodsw			; ax = prefix
   545 00000FA5 49                  <1> 	dec cx
   546 00000FA6 49                  <1> 	dec cx
   547 00000FA7 4E                  <1> 	dec si
   548 00000FA8 8A14                <1> 	mov dl, byte [si]
   549 00000FAA 880C                <1> 	mov byte [si], cl	; si -> counted string suffix
   550                              <1> @@:
   551                              <1> %if _ELD_LINKER_PASSES
   552 00000FAC F9                  <1> 	stc			; CY
   553                              <1> %endif
   554 00000FAD C3                  <1> 	retn
   555                              <1> 
   556                              <1> 
   557                              <1> .donedatareloc:
   558                              <1> %if ELDOTHER
   559                              <1> 	rol byte [bp + ?other], 1
   560                              <1> 	jc .otherdone
   561                              <1> %endif
   562                              <1> 
   563 00000FAE 8B56FC              <1> 	mov dx, word [bp + ?instance]
   564                              <1> %if _ELD_LINKER_PASSES
   565 00000FB1 8B5EEA              <1> 	mov bx, word [bp + ?pass]
   566 00000FB4 01D3                <1> 	add bx, dx
   567                              <1>  %if _ELD_IDENTICALISE
   568                              <1> 	add bx, word [bp + ?lt]
   569                              <1> 	add dx, word [ltLinkCode + bx]
   570                              <1>  %else
   571 00000FB6 03979811            <1> 	add dx, word [linktable - code + ltLinkCode + bx]
   572                              <1>  %endif
   573                              <1> %else
   574                              <1> 	add dx, linkercoderelocations - code
   575                              <1> %endif
   576 00000FBA 8956F2              <1> 	mov word [bp + ?nextreloc], dx
   577                              <1> 
   578                              <1> .coderelocloop:
   579 00000FBD C576F2              <1> 	lds si, [bp + ?nextreloc]
   580 00000FC0 AD                  <1> 	lodsw
   581                              <1> %if _ELDCALL_OPTIONAL
   582                              <1> 	dec ax
   583                              <1> 	js .donecodereloc
   584                              <1> 	mov word [bp + ?targetsection_low_optional_high], ax
   585                              <1> 	lodsw
   586                              <1> %endif
   587 00000FC1 0346FC              <1> 	add ax, word [bp + ?instance]
   588 00000FC4 8946EE              <1> 	mov word [bp + ?entry], ax
   589 00000FC7 AD                  <1> 	lodsw
   590 00000FC8 8976F2              <1> 	mov word [bp + ?nextreloc], si
   591                              <1> %ifn _ELDCALL_OPTIONAL
   592 00000FCB 85C0                <1> 	test ax, ax
   593 00000FCD 747E                <1> 	jz .donecodereloc
   594                              <1> %endif
   595 00000FCF E8B0FF              <1> 	call .build_match
   596                              <1> %if _ELD_LINKER_PASSES
   597 00000FD2 73E9                <1> 	jnc .coderelocloop
   598                              <1> %endif
   599 00000FD4 C45EF6              <1> 	les bx, [bp + ?linkinfo]
   600 00000FD7 268B4F10            <1> 	mov cx, word [es:bx + eldlCodeAmount]	; amount code link info
   601 00000FDB 268B7F12            <1> 	mov di, word [es:bx + eldlCodePrefixes]	; -> prefixes or hashes
   602                              <1> .coderelocfind:
   603 00000FDF F2AF                <1> 	repne scasw			; scan initial
   604                              <1> %if _ELDCALL_OPTIONAL
   605                              <1> 	jne .coderelocnotfound
   606                              <1> %else
   607                              <1>  %if _ELD_DEBUG
   608                              <1> 	je @F
   609                              <1> 	houdini
   610                              <1> 	jmp .codenotfound
   611                              <1> @@:
   612                              <1>  %else
   613 00000FE1 7403E942FF          <1> 	jne .codenotfound
   614                              <1>  %endif
   615                              <1> %endif
   616 00000FE6 57                  <1> 	push di
   617 00000FE7 51                  <1> 	push cx
   618 00000FE8 56                  <1> 	push si
   619 00000FE9 262B7F12            <1> 	sub di, word [es:bx + eldlCodePrefixes]	; = double index, 1-based
   620 00000FED 4F                  <1> 	dec di
   621 00000FEE 4F                  <1> 	dec di				; 0-based
   622 00000FEF 26037F14            <1> 	add di, word [es:bx + eldlCodeEntries]	; -> entry
   623 00000FF3 268B3D              <1> 	mov di, [es:di]			; -> counted suffix/string
   624 00000FF6 B500                <1> 	mov ch, 0
   625 00000FF8 8A0C                <1> 	mov cl, byte [si]		; cx = length
   626 00000FFA 41                  <1> 	inc cx
   627                              <1> 	; cmp al, al			; ZR if length is zero
   628 00000FFB F3A6                <1> 	repe cmpsb			; match ?
   629 00000FFD 5E                  <1> 	pop si
   630 00000FFE 59                  <1> 	pop cx
   631 00000FFF 5F                  <1> 	pop di
   632 00001000 75DD                <1> 	jne .coderelocfind
   633 00001002 8814                <1> 	mov byte [si], dl
   634 00001004 262B7F12            <1> 	sub di, word [es:bx + eldlCodePrefixes]	; = double index, 1-based
   635 00001008 4F                  <1> 	dec di
   636 00001009 4F                  <1> 	dec di				; 0-based
   637 0000100A 01FF                <1> 	add di, di			; quadruple index
   638 0000100C 26037F16            <1> 	add di, word [es:bx + eldlCodeAddresses]	; -> address (offset, segment)
   639 00001010 26FF35              <1> 	push word [es:di]
   640 00001013 C576EE              <1> 	lds si, [bp + ?entry]
   641 00001016 8F4405              <1> 	pop word [si + 3 + 2]		; call near imm (3), jmp short (2)
   642                              <1> 					;  patch the destination address
   643 00001019 803CE8              <1> 	cmp byte [si], 0E8h		; is it as expected ?
   644 0000101C 751D                <1> 	jne .error_j
   645 0000101E 268B7D02            <1> 	mov di, word [es:di + 2]
   646 00001022 BB[0000]            <1> 	mov bx, relocateddata
   647                              <1> linkdatarelocation linkcall_table	; ss:bx -> link call table
   648 00001025 36833F01            <1> 	cmp word [ss:bx], 1		; is it initialised to format 1 ?
   649 00001029 7510                <1> 	jne .error_j			; no -->
   650 0000102B 368B4F02            <1> 	mov cx, word [ss:bx + 2]	; get amount of segments
   651 0000102F E30A                <1> 	jcxz .error_j			; none -->
   652                              <1> @@:
   653 00001031 83C304              <1> 	add bx, 4			; -> next segment
   654 00001034 36393F              <1> 	cmp word [ss:bx], di		; value matches ?
   655 00001037 7405                <1> 	je @F				; yes, found -->
   656 00001039 E2F6                <1> 	loop @B				; try remaining segments
   657                              <1> .error_j:
   658 0000103B E98A00              <1> 	jmp .error
   659                              <1> 
   660                              <1> @@:
   661 0000103E 368B5F02            <1> 	mov bx, word [ss:bx + 2]	; -> call destination offset
   662                              <1> 		; si + 3 + delta = bx
   663                              <1> 		; delta = bx - si - 3
   664 00001042 29F3                <1> 	sub bx, si
   665 00001044 83EB03              <1> 	sub bx, 3
   666 00001047 895C01              <1> 	mov word [si + 1], bx		; patch the call instruction
   667 0000104A E970FF              <1> 	jmp .coderelocloop
   668                              <1> 
   669                              <1> .donecodereloc:
   670                              <1> %if _ELD_LINKER_PASSES
   671 0000104D 8B46E8              <1> 	mov ax, word [bp + ?amounterrors]
   672 00001050 85C0                <1> 	test ax, ax
   673 00001052 75E7                <1> 	jnz .error_j
   674 00001054 8B5EEA              <1> 	mov bx, word [bp + ?pass]
   675 00001057 85DB                <1> 	test bx, bx
   676 00001059 750B                <1> 	jnz @F
   677 0000105B 43                  <1> 	inc bx
   678 0000105C 43                  <1> 	inc bx
   679 0000105D 895EEA              <1> 	mov word [bp + ?pass], bx
   680 00001060 8B56FC              <1> 	mov dx, word [bp + ?instance]
   681 00001063 E996FD              <1> 	jmp .pass
   682                              <1> 
   683                              <1> @@:
   684                              <1> %endif
   685                              <1> 
   686                              <1> %ifnidni _LISTING, ""
   687                              <1> %assign ELDLINKER 0
   688                              <1> .hint:
   689 00001066 16                  <1> 	push ss
   690 00001067 1F                  <1> 	pop ds
   691 00001068 B02D                <1> 	mov al, 2Dh
   692 0000106A E8[0000]EB020000    <1> 	extcall intchk			; ZR if offset = -1 or segment = 0
   693                              <1> 					; CHG: ax, dx, bx
   694 00001071 7437                <1> 	jz .no_hint
   695                              <1> 
   696 00001073 8A26[0000]          <1> 	mov ah, byte [relocateddata]
   697                              <1> linkdatarelocation try_debugger_amis_multiplex_number
   698 00001077 E85500              <1> 	call plex_check
   699 0000107A 7305                <1> 	jnc @F
   700                              <1> 
   701 0000107C B4FF                <1> 	mov ah, 0FFh		; start with multiplex number 0FFh
   702                              <1> .loop_hint:
   703 0000107E E84E00              <1> 	call plex_check
   704                              <1> @@:
   705 00001081 7307                <1> 	jnc .end_hint		; if found --> (NC)
   706 00001083 80EC01              <1> 	sub ah, 1		; search is backward (to find latest installed first), from 0FFh to 00h including
   707 00001086 73F6                <1> 	jnc .loop_hint		; try next if we didn't check all yet -->
   708 00001088 EB20                <1> 	jmp .no_hint
   709                              <1> 
   710                              <1> .end_hint:
   711 0000108A 50                  <1> 	push ax
   712 0000108B C446FC              <1> 	les ax, [bp + ?instance]
   713 0000108E BF[A914]            <1> 	mov di, listmsg.hint.offset
   714                              <1> internalcoderelocation
   715 00001091 E8[0000]EB020000    <1> 	extcall hexword
   716 00001098 BB[8814]            <1> 	mov bx, listmsg.hint
   717                              <1> internalcoderelocation
   718 0000109B 368B16[0000]        <1> 	mov dx, [ss:relocateddata]
   719                              <1> linkdatarelocation extseg	; must be 86 Mode segment even in PM
   720 000010A0 58                  <1> 	pop ax
   721 000010A1 B040                <1> 	mov al, 40h		; AMIS message display service
   722 000010A3 E8[0000]EB020000    <1> 	extcall call_int2D
   723                              <1> .no_hint:
   724                              <1> %endif
   725                              <1> 
   726                              <1> %if ELDOTHER
   727                              <1> %assign ELDLINKER 0
   728                              <1> 	not byte [bp + ?other]
   729                              <1> 
   730                              <1> 	push ss
   731                              <1> 	pop ds
   732                              <1> 	mov al, 2Dh
   733                              <1> 	extcall intchk			; ZR if offset = -1 or segment = 0
   734                              <1> 					; CHG: ax, dx, bx
   735                              <1> 	jz .no_other
   736                              <1> 
   737                              <1> 	mov ah, byte [relocateddata]
   738                              <1> linkdatarelocation try_debugger_amis_multiplex_number
   739                              <1> 	call plex_check
   740                              <1> 	jnc @F
   741                              <1> 
   742                              <1> 	mov ah, 0FFh		; start with multiplex number 0FFh
   743                              <1> .loop_other:
   744                              <1> 	call plex_check
   745                              <1> @@:
   746                              <1> 	jnc .end_other		; if found --> (NC)
   747                              <1> 	sub ah, 1		; search is backward (to find latest installed first), from 0FFh to 00h including
   748                              <1> 	jnc .loop_other		; try next if we didn't check all yet -->
   749                              <1> 	jmp .no_other
   750                              <1> 
   751                              <1> .end_other:
   752                              <1> 	mov al, 42h		; AMIS get other link info service
   753                              <1> 	extcall call_int2D
   754                              <1> 	cmp al, 0FFh
   755                              <1> 	jne .no_other
   756                              <1> 
   757                              <1> 	mov ax, si		; selector => PSP
   758                              <1> 	extcall ispm
   759                              <1> 	jz @F
   760                              <1> 	mov ax, dx		; segment => PSP
   761                              <1> @@:
   762                              <1> 	 push ss
   763                              <1> 	 pop ds
   764                              <1> 	mov word [otherds], ax
   765                              <1> internaldatarelocation		; current mode sel/seg
   766                              <1> 	mov word [otherseg], dx
   767                              <1> internaldatarelocation		; remember segment
   768                              <1> 
   769                              <1> 	mov ax, cx		; selector => link info
   770                              <1> 	extcall ispm
   771                              <1> 	jz @F
   772                              <1> 	mov ax, bx		; segment => link info
   773                              <1> @@:
   774                              <1> 	mov word [bp + ?linkinfo_other], di
   775                              <1> 	mov word [bp + ?linkinfo_other + 2], ax
   776                              <1> 
   777                              <1> 	mov ds, ax		; => link info
   778                              <1> 	xor ax, ax
   779                              <1> 	cmp word [di + eldlSignature], 0E1D1h
   780                              <1> 	jne .error_other
   781                              <1> 	cmp word [di + eldlUseLinkHash], 1
   782                              <1> 	ja .error_other
   783                              <1> 	jb @F
   784                              <1> 	dec ax
   785                              <1> @@:
   786                              <1> 	mov word [bp + ?use_hash_other], ax
   787                              <1> 
   788                              <1> 	mov dx, word [bp + ?instance]
   789                              <1> 	add dx, linkerotherdatarelocations - code
   790                              <1> 	jmp .otherloop
   791                              <1> 
   792                              <1> .error_other:
   793                              <1> 	push cs
   794                              <1> 	pop ds
   795                              <1> 	mov ax, 0E33h
   796                              <1> 	extcall setrc
   797                              <1> 	mov dx, lmsg.error_other
   798                              <1> internalcoderelocation
   799                              <1> 	jmp @F
   800                              <1> 
   801                              <1> .no_other:
   802                              <1> 	push cs
   803                              <1> 	pop ds
   804                              <1> 	mov ax, 0E34h
   805                              <1> 	extcall setrc
   806                              <1> 	mov dx, lmsg.no_other
   807                              <1> internalcoderelocation
   808                              <1> @@:
   809                              <1> 	extcall putsz
   810                              <1> 	jmp .error
   811                              <1> 
   812                              <1> .otherdone:
   813                              <1> %endif
   814                              <1> 
   815 000010AA 5B                  <1> 	pop bx				; -> our heap data
   816 000010AB 5E                  <1> 	pop si				; -> our command line tail
   817 000010AC 16                  <1> 	 push ss
   818 000010AD 1F                  <1> 	 pop ds
   819 000010AE C47EFC              <1> 	les di, [bp + ?instance]
   820 000010B1 268B4502            <1> 	mov ax, word [es:di + eldiEndCode]
   821                              <1> houdini
   822 000010B5 2D[D00D]            <1> 	sub ax, strict word endresident + code
   823                              <1> internalcoderelocation
   824 000010B8 26C74502[D00D]      <1> 	mov word [es:di + eldiEndCode], endresident + code
   825                              <1> internalcoderelocation
   826 000010BE 2906[0000]          <1> 	sub word [relocateddata], ax
   827                              <1> linkdatarelocation extseg_used
   828                              <1> %if _DATA_SIZE == 0
   829                              <1> 	xor ax, ax
   830                              <1> 	mov word [es:di + eldiStartData], ax
   831                              <1> 	mov word [es:di + eldiEndData], ax
   832                              <1> %endif
   833 000010C2 89EC5D              <1> 	lleave code
   834                              <1> 		; INP:	es => ELD code segment
   835                              <1> 		;	ds:si -> command line tail
   836                              <1> 		;	ds:bx -> ELD data block
   837                              <1> 		;	ss:sp -> far return address for current mode
   838                              <1> 		; STT:	ds = ss, UP, EI
   839 000010C5 E970FC              <1> 	jmp start
   840                              <1> 
   841                              <1> .error:
   842 000010C8 89EC5D              <1> 	lleave
   843 000010CB B8FFFF              <1> 	mov ax, -1
   844 000010CE CB                  <1> 	retf
   845                              <1> 
   846                              <1> 
   847                              <1> %ifnidni _LISTING, ""
   848                              <1>  %assign ELDHINT 1
   849                              <1> %else
   850                              <1>  %assign ELDHINT 0
   851                              <1> %endif
   852                              <1> 
   853                              <1> %if ELDOTHER || ELDHINT
   854                              <1> 		; INP:	ah = multiplex number to check
   855                              <1> 		; OUT:	CY if multiplex number unused or no signature match,
   856                              <1> 		;	 bp, ah, ds unmodified
   857                              <1> 		;	NC if match found,
   858                              <1> 		;	 ah = multiplex number (unmodified)
   859                              <1> 		; CHG:	si, di, es, cx, dx
   860                              <1> plex_check:
   861 000010CF 16                  <1> 	push ss
   862 000010D0 1F                  <1> 	pop ds
   863 000010D1 F606[0000]08        <1> 	testopt [relocateddata], 8
   864                              <1> linkdatarelocation internalflags4, -3
   865 000010D6 740B                <1> 	jz @F
   866 000010D8 BE[0000]            <1> 	mov si, relocateddata
   867                              <1> linkdatarelocation amis_multiplex_number, -2, optional
   868 000010DB 85F6                <1> 	test si, si
   869 000010DD 7404                <1> 	jz @F
   870 000010DF 3A24                <1> 	cmp ah, byte [si]
   871 000010E1 7420                <1> 	je .notfound		; do not use our own multiplexer -->
   872                              <1> @@:
   873 000010E3 B000                <1> 	mov al, 00h		; AMIS installation check
   874 000010E5 E8[0000]EB020000    <1> 	extcall call_int2D	; AMIS (or "DOS reserved" = iret if no AMIS present)
   875 000010EC 3CFF                <1> 	cmp al, 0FFh
   876 000010EE 7513                <1> 	jne .notfound
   877 000010F0 0E                  <1> 	push cs
   878 000010F1 1F                  <1> 	pop ds
   879 000010F2 BE[7814]            <1> 	mov si, debuggeramissig	; ds:si -> our AMIS name strings
   880                              <1> internalcoderelocation
   881 000010F5 E8[0000]EB020000    <1> 	extcall setes2dx	; es:di -> name strings of AMIS multiplexer that just answered
   882 000010FC B90800              <1> 	mov cx, 8		; Ignore description, only compare vendor and program name
   883 000010FF F3A7                <1> 	repe cmpsw
   884 00001101 7401                <1> 	je .checkret		; ZR, NC = match -->
   885                              <1> .notfound:
   886 00001103 F9                  <1> 	stc			; CY no match
   887                              <1> .checkret:
   888 00001104 C3                  <1> 	retn
   889                              <1> %endif
   890                              <1> 
   891                              <1> 
   892 00001105 00<rep 3h>          <1> 	align 4, db 0
   893                              <1> linkercoderelocations:
   894                              <1> %if _ELDCALL_OPTIONAL
   895                              <1> 	dw ELDCALL_CODE_RELOCATIONS_OPTIONAL, 0
   896                              <1> %else
   897 00001108 2200[B114]A80C-     <1> 	dw ELDCALL_CODE_RELOCATIONS, 0, 0
   897 0000110E [C014]B00C[CC14]B8- <1>
   897 00001115 0C[D814]C00C[DF14]- <1>
   897 0000111C C80C[E814]D00C-     <1>
   897 00001122 [F014]D80C[F814]E0- <1>
   897 00001129 0C[FF14]E80C[0715]- <1>
   897 00001130 F00C[1115]F80C-     <1>
   897 00001136 [1D15]000D[2715]08- <1>
   897 0000113D 0D[3215]100D[3C15]- <1>
   897 00001144 180D[4615]200D-     <1>
   897 0000114A [5615]280D[7F15]30- <1>
   897 00001151 0D[9C15]890D[DF14]- <1>
   897 00001158 6A10[A615]9110-     <1>
   897 0000115E [3215]A310[AF15]E5- <1>
   897 00001165 10[AF15]F510[BC15]- <1>
   897 0000116C 00000000            <1>
   898                              <1> %endif
   899                              <1> 
   900                              <1> %if _ELD_LINKER_PASSES
   901                              <1> linkerlinkercoderelocations:
   902                              <1> %if _ELDCALL_OPTIONAL
   903                              <1> 	dw ELDCALL_LINKER_CODE_RELOCATIONS_OPTIONAL, 0
   904                              <1> %else
   905 00001170 4B0F[3215]670F-     <1> 	dw ELDCALL_LINKER_CODE_RELOCATIONS, 0, 0
   905 00001176 [4615]710F[F014]7A- <1>
   905 0000117D 0F[7F15]00000000    <1>
   906                              <1> %endif
   907                              <1> 
   908                              <1> 	align 2, db 0
   909                              <1> linktable:
   910                              <1> 	istruc LINKTABLE
   911                              <1> at ltCodeToCode
   912 00001184 6814                <1> 	dw internallinkercodetocoderelocations - code
   913 00001186 5212                <1> 	dw internalcodetocoderelocations - code
   914                              <1> at ltCodeToData
   915 00001188 7214                <1> 	dw internallinkercodetodatarelocations - code
   916 0000118A 8412                <1> 	dw internalcodetodatarelocations - code
   917                              <1> at ltDataToCode
   918 0000118C 7414                <1> 	dw internallinkerdatatocoderelocations - code
   919 0000118E 2A14                <1> 	dw internaldatatocoderelocations - code
   920                              <1> at ltDataToData
   921 00001190 7614                <1> 	dw internallinkerdatatodatarelocations - code
   922 00001192 2C14                <1> 	dw internaldatatodatarelocations - code
   923                              <1> at ltLinkData
   924 00001194 5414                <1> 	dw linkerlinkerdatarelocations - code
   925 00001196 9C11                <1> 	dw linkerdatarelocations - code
   926                              <1> at ltLinkCode
   927 00001198 7011                <1> 	dw linkerlinkercoderelocations - code
   928 0000119A 0811                <1> 	dw linkercoderelocations - code
   929                              <1> 	iend
   930                              <1> %endif
   931                              <1> 
   932                              <1> 	align 2, db 0
   933                              <1> linkerdatarelocations:
   934 0000119C 01004700[C715]0100- <1> 	dw LINK_DATA_RELOCATIONS, 0
   934 000011A4 4900[D115]01004C00- <1>
   934 000011AC [DA15]01006A00-     <1>
   934 000011B2 [EA15]01008E00-     <1>
   934 000011B8 [EA15]0100CD00-     <1>
   934 000011BE [0016]0100D600-     <1>
   934 000011C4 [0B16]0100E305-     <1>
   934 000011CA [1416]01006906-     <1>
   934 000011D0 [1F16]01007106-     <1>
   934 000011D6 [1F16]0100DD07-     <1>
   934 000011DC [1416]01006C08-     <1>
   934 000011E2 [1416]01006809-     <1>
   934 000011E8 [1416]0100DB09-     <1>
   934 000011EE [2916]0100D00A-     <1>
   934 000011F4 [2916]0100D70A-     <1>
   934 000011FA [2916]01008A0B-     <1>
   934 00001200 [1416]0100410D-     <1>
   934 00001206 [3B16]0100680D-     <1>
   934 0000120C [4916]0100780D-     <1>
   934 00001212 [5416]0100850D-     <1>
   934 00001218 [6216]01009C0D-     <1>
   934 0000121E [5416]0100A00D-     <1>
   934 00001224 [EA15]0100BB0D-     <1>
   934 0000122A [EA15]0100C10D-     <1>
   934 00001230 [4916]01007510-     <1>
   934 00001236 [8216]01009E10-     <1>
   934 0000123C [0B16]0100C010-     <1>
   934 00001242 [5416]0100D310-     <1>
   934 00001248 [A716]0101D910-     <1>
   934 0000124E [B816]0000          <1>
   935                              <1> 
   936                              <1> 	align 2, db 0
   937                              <1> internalcodetocoderelocations:
   938 00001252 6500B2004E0754075A- <1> 	dw INTERNAL_CODE_TO_CODE_RELOCATIONS, 0
   938 0000125B 076007760798079E07- <1>
   938 00001264 A407AA076F0D740D7C- <1>
   938 0000126D 0D810D980DA30DB60D- <1>
   938 00001276 BD0D8F109910B610BC- <1>
   938 0000127F 10F3100000          <1>
   939                              <1> 
   940                              <1> 	align 2, db 0
   941                              <1> internalcodetodatarelocations:
   942 00001284 3400B600C700DB00E9- <1> 	dw INTERNAL_CODE_TO_DATA_RELOCATIONS, 0
   942 0000128D 00ED00F70003011001- <1>
   942 00001296 1A0127012B012F0133- <1>
   942 0000129F 0153015D016E017501- <1>
   942 000012A8 79017C01800187019F- <1>
   942 000012B1 01A201A601B001B501- <1>
   942 000012BA B901BE01C901CF01D3- <1>
   942 000012C3 01D901E001E701F301- <1>
   942 000012CC 09020C02130218021C- <1>
   942 000012D5 02220226024D025402- <1>
   942 000012DE 5B0269026F02730277- <1>
   942 000012E7 029702AF02D102D702- <1>
   942 000012F0 DD02E402FF0206030E- <1>
   942 000012F9 031C03300336035303- <1>
   942 00001302 5703610373037A0381- <1>
   942 0000130B 038A03C303CF03D403- <1>
   942 00001314 DA03EE0309040F0417- <1>
   942 0000131D 041E04310437043B04- <1>
   942 00001326 3F0443044A04620465- <1>
   942 0000132F 046E04730477047C04- <1>
   942 00001338 8E0491049A04A104A5- <1>
   942 00001341 04AA04B404B804C304- <1>
   942 0000134A D004EB04F8040A050D- <1>
   942 00001353 0510051B0528054E05- <1>
   942 0000135C 54057B058105A705AD- <1>
   942 00001365 05C905D005D705DE05- <1>
   942 0000136E FE0517061C0678068A- <1>
   942 00001377 068E069106A006B606- <1>
   942 00001380 BB06CB06D906E20605- <1>
   942 00001389 070B07130718072B07- <1>
   942 00001392 38074407480768076D- <1>
   942 0000139B 077C07800786078C07- <1>
   942 000013A4 9207B007B407BA07E8- <1>
   942 000013AD 070B0813081E082B08- <1>
   942 000013B6 300840084608580864- <1>
   942 000013BF 089208EF08F9082C09- <1>
   942 000013C8 3D094C09540960096B- <1>
   942 000013D1 098409A009AD09B309- <1>
   942 000013DA C709CF09D309F40902- <1>
   942 000013E3 0A160A1A0A3D0A520A- <1>
   942 000013EC 7B0AB80ABF0AC30AC8- <1>
   942 000013F5 0AF30A0D0B140B1B0B- <1>
   942 000013FE 220B290B300B370B4D- <1>
   942 00001407 0B5F0B720B790BE80B- <1>
   942 00001410 EC0B030C0A0C420C47- <1>
   942 00001419 0C520C570C6A0C8D0C- <1>
   942 00001422 490D5E0DC70D0000    <1>
   943                              <1> 
   944                              <1> 	align 2, db 0
   945                              <1> internaldatatocoderelocations:
   946 0000142A FFFF                <1> 	dw INTERNAL_DATA_TO_CODE_RELOCATIONS, -1
   947                              <1> 
   948                              <1> 	align 2, db 0
   949                              <1> internaldatatodatarelocations:
   950 0000142C 0400060008000A000C- <1> 	dw INTERNAL_DATA_TO_DATA_RELOCATIONS, -1
   950 00001435 000E00100012001400- <1>
   950 0000143E 160018001A001C0020- <1>
   950 00001447 00240028002C003000- <1>
   950 00001450 3400FFFF            <1>
   951                              <1> 
   952                              <1> %if _ELD_LINKER_PASSES
   953                              <1> 	align 2, db 0
   954                              <1> linkerlinkerdatarelocations:
   955 00001454 0100030F[4916]0100- <1> 	dw LINK_LINKER_DATA_RELOCATIONS, 0
   955 0000145C 420F[1416]01002310- <1>
   955 00001464 [7116]0000          <1>
   956                              <1> 
   957                              <1> 	align 2, db 0
   958                              <1> internallinkercodetocoderelocations:
   959 00001468 090F180F290F540F00- <1> 	dw INTERNAL_LINKER_CODE_TO_CODE_RELOCATIONS, 0
   959 00001471 00                  <1>
   960                              <1> 
   961                              <1> 	align 2, db 0
   962                              <1> internallinkercodetodatarelocations:
   963 00001472 0000                <1> 	dw INTERNAL_LINKER_CODE_TO_DATA_RELOCATIONS, 0
   964                              <1> 
   965                              <1> 	align 2, db 0
   966                              <1> internallinkerdatatocoderelocations:
   967 00001474 FFFF                <1> 	dw INTERNAL_LINKER_DATA_TO_CODE_RELOCATIONS, -1
   968                              <1> 
   969                              <1> 	align 2, db 0
   970                              <1> internallinkerdatatodatarelocations:
   971 00001476 FFFF                <1> 	dw INTERNAL_LINKER_DATA_TO_DATA_RELOCATIONS, -1
   972                              <1> %endif
   973                              <1> 
   974                              <1> %if ELDOTHER
   975                              <1> 	align 2, db 0
   976                              <1> linkerotherdatarelocations:
   977                              <1> 	dw LINK_OTHER_DATA_RELOCATIONS, 0
   978                              <1> 
   979                              <1>  %ifnidn LINK_OTHER_LINKER_DATA_RELOCATIONS, ""
   980                              <1>   %error Other linker data links not supported
   981                              <1>  %endif
   982                              <1> %endif
   983                              <1> 
   984                              <1> %if ELDOTHER || ELDHINT
   985                              <1> 	align 2, db 0
   986                              <1> debuggeramissig:
   987 00001478 65636D20<rep 5h>    <1> 		fill 8, 32, db "ecm"
   988 00001480 6C446562756720-     <1> 		fill 8, 32, db "lDebug"
   988 00001480 <rep 2h>            <1>
   989                              <1> %endif
   990                              <1> 
   991                              <1> %ifnidni _LISTING, ""
   992                              <1> listmsg:
   993 00001488 547261634C6973742D- <1> .hint:		db "TracList-add-offset=",_LISTING,"::"
   993 00001491 6164642D6F66667365- <1>
   993 0000149A 743D636873746F6F6C- <1>
   993 000014A3 2E6C73743A3A        <1>
   994 000014A9 2D2D2D2D680D0A00    <1> .hint.offset:	asciz "----h",13,10
   995                              <1> %endif
   996                              <1> 
   997 000014B1 30CD0C636D64335F6E- <1> 	eldcall_dump_names ELDCALL_CODE_NAMES
   997 000014BA 6F745F657874D55509- <1>
   997 000014C3 736B6970636F6D6D61- <1>
   997 000014CC 03C309697373747269- <1>
   997 000014D5 6E673FBABD04636D64- <1>
   997 000014DE 33DDB90663686B656F- <1>
   997 000014E7 6C551205707574737A- <1>
   997 000014F0 B21205736574726328- <1>
   997 000014F9 90046973706DA7AA05- <1>
   997 00001502 6572726F723FE80767- <1>
   997 0000150B 6574776F7264A45509- <1>
   997 00001514 736B6970636F6D6D30- <1>
   997 0000151D 3D8207676574627974- <1>
   997 00001526 65D9FA086765746477- <1>
   997 0000152F 6F7264848107686578- <1>
   997 00001538 776F7264821B076865- <1>
   997 00001541 78627974656FA20D70- <1>
   997 0000154A 7574736C696E655F63- <1>
   997 00001553 726C66ABFF26646973- <1>
   997 0000155C 705F647861785F7469- <1>
   997 00001565 6D65735F63785F7769- <1>
   997 0000156E 6474685F62785F7369- <1>
   997 00001577 7A652E73746F7265D0- <1>
   997 00001580 BB1A636F70795F7369- <1>
   997 00001589 6E676C655F636F756E- <1>
   997 00001592 7465645F737472696E- <1>
   997 0000159B 67EBA607646563776F- <1>
   997 000015A4 7264986906696E7463- <1>
   997 000015AD 686B21300A63616C6C- <1>
   997 000015B6 5F696E743244B77408- <1>
   997 000015BF 7365746573326478    <1>
   998 000015C7 C30B076C617374636D- <1> 	link_data_dump_names LINK_DATA_NAMES
   998 000015D0 646B5D06646D79636D- <1>
   998 000015D9 6454400D6D73672E75- <1>
   998 000015E2 6E696E7374616C6C97- <1>
   998 000015EB B6136578745F636F6D- <1>
   998 000015F4 6D616E645F68616E64- <1>
   998 000015FD 6C6572EB4208657874- <1>
   998 00001606 647373656CD52D0665- <1>
   998 0000160F 787473656784E3086C- <1>
   998 00001618 696E655F6F75747DB3- <1>
   998 00001621 076F7074696F6E73E4- <1>
   998 0000162A 7A0F6C6F61645F756E- <1>
   998 00001633 69745F666C6167738D- <1>
   998 0000163C 710B6D73672E696E73- <1>
   998 00001645 74616C6C5ABC086F70- <1>
   998 0000164E 74696F6E7337E7D30B- <1>
   998 00001657 6578747365675F7573- <1>
   998 00001660 6564B2400C65787464- <1>
   998 00001669 6174615F7573656468- <1>
   998 00001672 440E6C696E6B63616C- <1>
   998 0000167B 6C5F7461626C65F09E- <1>
   998 00001684 227472795F64656275- <1>
   998 0000168D 676765725F616D6973- <1>
   998 00001696 5F6D756C7469706C65- <1>
   998 0000169F 785F6E756D626572CB- <1>
   998 000016A8 510E696E7465726E61- <1>
   998 000016B1 6C666C61677334688C- <1>
   998 000016BA 15616D69735F6D756C- <1>
   998 000016C3 7469706C65785F6E75- <1>
   998 000016CC 6D626572            <1>
   999                              <1> %if ELDOTHER
  1000                              <1> 	link_data_dump_names LINK_OTHER_DATA_NAMES
  1001                              <1> %endif
  1002                              <1> 
  1003                              <1> lmsg:
  1004                              <1> %if _ELD_LINKER_PASSES
  1005                              <1> %if _ELDCALL_OPTIONAL
  1006                              <1> .warning_code_optional:		counted "Optional code link missing, hash="
  1007                              <1> %endif
  1008 000016D0 214F7074696F6E616C- <1> .warning_data_optional:		counted "Optional data link missing, hash="
  1008 000016D9 2064617461206C696E- <1>
  1008 000016E2 6B206D697373696E67- <1>
  1008 000016EB 2C20686173683D      <1>
  1009 000016F2 1844617461206C696E- <1> .error_data:			counted "Data link missing, hash="
  1009 000016FB 6B206D697373696E67- <1>
  1009 00001704 2C20686173683D      <1>
  1010 0000170B 18436F6465206C696E- <1> .error_code:			counted "Code link missing, hash="
  1010 00001714 6B206D697373696E67- <1>
  1010 0000171D 2C20686173683D      <1>
  1011 00001724 0A682C206C6162656C- <1> .error.2:			counted "h, label ",'"'
  1011 0000172D 2022                <1>
  1012                              <1> %endif
  1013                              <1> %if ELDOTHER
  1014                              <1> .no_other:		asciz "ELD linker: No other link info found!",13,10
  1015                              <1> .error_other:		asciz "ELD linker: Other link info unknown format!",13,10
  1016                              <1> %endif
  1017                              <1> 
  1018 0000172F 00                  <1> 	align 16, db 0
  1955                                  
  1956                                  	align 16
  1957                                  code_size equ $ - code
