     1                                  
     2                                  ; Public Domain
     3                                  
     4                                  ; test install command: install; s $ psp:0 l 10 CD; s uninstall
     5                                  ; test run command: $ psp:0 l 10 CD; .; .
     6                                  
     7                                  %include "lmacros3.mac"
     1                              <1> [list -]
    14                              <2> [list -]
    14                              <1> [list -]
     8                                  %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
     9                                  %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
    10                                  %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
    11                                  
    12                                  %assign _CATCHINT0C 0
    13                                  %assign _CATCHINT0D 0
    14                                  %assign _CATCHINTFAULTCOND 0
    15                                  %assign _DEBUG 0
    16                                  %assign _DELAY_BEFORE_BP 0
    17                                  %assign _DHIGHLIGHT 0
    18                                  %assign _GETLINEHIGHLIGHT 0
    19                                  %assign _IMMASM 0
    20                                  %assign _INPUT_FILE_BOOT 0
    21                                  %assign _INPUT_FILE_HANDLES 0
    22                                  %assign _MS_0RANGE_COMPAT 0
    23                                  %assign _PM 0
    24                                  %assign _RH 0
    25                                  %assign _SYMBOLIC 0
    26                                  %assign _VXCHG 0
    27                                  %include "options.mac"
     1                              <1> 
     2                              <1> %if 0
     3                              <1> 
     4                              <1> lDebug options and internal flags
     5                              <1> 
     6                              <1> Copyright (C) 2008-2023 E. C. Masloch
     7                              <1> 
     8                              <1> Usage of the works is permitted provided that this
     9                              <1> instrument is retained with the works, so that any entity
    10                              <1> that uses the works is notified of this instrument.
    11                              <1> 
    12                              <1> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    13                              <1> 
    14                              <1> %endif
    15                              <1> 
    16                              <1> 
    17                              <1> dispregs32	equ	  1	; RX: 32-bit register display (R, T/P/G)
    18                              <1> traceints	equ	  2	; TM: trace into interrupts (T)
    19                              <1> cpdepchars	equ	  4	; allow dumping of CP-dependent characters (D, DX)
    20                              <1> fakeindos	equ	  8	; always assume InDOS flag non-zero (all)
    21                              <1> nonpagingdevice	equ	 10h	; disallow paged output with [more] prompt (all exc. P, T)
    22                              <1> 	; This option was never used anywhere:
    23                              <1> ; pagingdevice	equ	 20h	; allow paged output with [more] prompt (all exc. P, T)
    24                              <1> 				; paged output is by default on if the output device is StdOut, else off
    25                              <1> hexrn		equ	 40h	; display raw hexadecimal content of FPU registers (RN)
    26                              <1> ;novdd		equ	 80h	; don't use a registered NTVDM VDD (L, W)
    27                              <1> nondospaging	equ	100h	; paging: don't use DOS for input when waiting for a key
    28                              <1> opt1_86mnohlt	equ	200h	; (86 Mode:) HLT doesn't work, don't use it
    29                              <1> biosidles	equ	400h	; don't idle with HLT or Int2F.1680, only call BIOS Int16.00
    30                              <1> opt_usegetinput	equ	800h	; use getinput for int 21h interactive input
    31                              <1> use_si_units	equ    1000h	; in disp_*_size use SI units (kB = 1000, etc)
    32                              <1> use_jedec_units	equ    2000h	; in disp_*_size use JEDEC units (kB = 1024)
    33                              <1> enable_serial	equ    4000h	; enable serial I/O (preferred over DOS or BIOS terminal)
    34                              <1> int8_disable_serial equ	   8000h	; disable serial I/O when breaking due to intr8
    35                              <1> gg_do_not_skip_bp equ	 1_0000h	; gg: do not skip a breakpoint (bb or gg)
    36                              <1> gg_no_autorepeat equ	 2_0000h	; gg: do not auto-repeat
    37                              <1> tp_do_not_skip_bp equ	 4_0000h	; T/TP/P: do not skip a (bb) breakpoint
    38                              <1> gg_bb_hit_no_repeat equ	 8_0000h	; gg: do not auto-repeat after bb hit
    39                              <1> tp_bb_hit_no_repeat equ	10_0000h	; T/TP/P: do not auto-repeat after bb hit
    40                              <1> gg_unexpected_no_repeat equ 20_0000h	; gg: do not auto-repeat after unexpectedinterrupt
    41                              <1> tp_unexpected_no_repeat equ 40_0000h	; T/TP/P
    42                              <1> ss_no_dump:		equ 80_0000h
    43                              <1> %if _SYMBOLIC
    44                              <1> dd_no_blanks_sym:	equ 100_0000h
    45                              <1> zz_no_pm_xms:		equ 200_0000h
    46                              <1> %endif
    47                              <1> rr_disasm_no_rept:	equ 1000_0000h
    48                              <1> rr_disasm_no_show:	equ 2000_0000h
    49                              <1> opt_cmdline_quiet_input:equ 4000_0000h
    50                              <1> opt_cmdline_quiet_output:equ 8000_0000h
    51                              <1> %if _SYMBOLIC
    52                              <1> DEFAULTOPTIONS	equ zz_no_pm_xms
    53                              <1> %else
    54                              <1> DEFAULTOPTIONS	equ 0
    55                              <1> %endif
    56                              <1> 
    57                              <1> 
    58                              <1> opt2_db_header:		equ 1
    59                              <1> opt2_db_trailer:	equ 2
    60                              <1> opt2_dw_header:		equ 10h
    61                              <1> opt2_dw_trailer:	equ 20h
    62                              <1> opt2_dd_header:		equ 100h
    63                              <1> opt2_dd_trailer:	equ 200h
    64                              <1> opt2_getinput_dpmi:	equ 800h
    65                              <1> opt2_hh_compat:		equ 1000h
    66                              <1> opt2_getc_idle:		equ 2000h
    67                              <1> opt2_getc_idle_dpmi:	equ 4000h
    68                              <1> opt2_re_cancel_tpg:	equ 8000h
    69                              <1> opt2_nn_compat:		equ 1_0000h
    70                              <1> opt2_nn_capitalise:	equ 2_0000h
    71                              <1> %if _MS_0RANGE_COMPAT
    72                              <1> opt2_0range_compat:	equ 4_0000h
    73                              <1> %endif
    74                              <1> opt2_rr16_compat:	equ 8_0000h
    75                              <1> opt2_r_prompt_compat:	equ 10_0000h
    76                              <1> opt2_r_separate:	equ 20_0000h
    77                              <1> opt2_r_linebreak_always:equ 40_0000h
    78                              <1> opt2_dpminohlt:		equ 8000_0000h	; DPMI doesn't like hlt
    79                              <1> DEFAULTOPTIONS2	equ opt2_dw_header | opt2_dd_header | opt2_getc_idle_dpmi | opt2_dpminohlt
    80                              <1> 
    81                              <1> 
    82                              <1> opt3_tt_no_paging:	equ 1
    83                              <1> opt3_tp_no_paging:	equ 2
    84                              <1> opt3_pp_no_paging:	equ 4
    85                              <1> opt3_gg_no_paging:	equ 8
    86                              <1> opt3_silence_paging_set:equ 100h
    87                              <1> opt3_silence_paging_on:	equ 200h
    88                              <1> opt3_paging_rc:		equ 1000h
    89                              <1> opt3_paging_yy:		equ 2000h
    90                              <1> opt3_paging_re:		equ 4000h
    91                              <1> opt3_r_highlight_diff:	equ 10000h
    92                              <1> opt3_r_highlight_dumb:	equ 20000h
    93                              <1> opt3_r_highlight_full:	equ 40000h
    94                              <1> opt3_r_highlight_eip:	equ 80000h
    95                              <1> %if _PM
    96                              <1> opt3_ss_b_bit_set:	equ   10_0000h
    97                              <1>  %if _BREAK_INSTALLDPMI
    98                              <1> opt3_break_installdpmi:	equ   20_0000h
    99                              <1>  %endif
   100                              <1> %endif
   101                              <1> %if _DHIGHLIGHT
   102                              <1> opt3_d_highlight:	equ   80_0000h
   103                              <1> %endif
   104                              <1> %if _GETLINEHIGHLIGHT
   105                              <1> opt3_getline_highlight:	equ  100_0000h
   106                              <1> %endif
   107                              <1> opt3_no_idle_2F:	equ  200_0000h
   108                              <1> %if _DELAY_BEFORE_BP
   109                              <1> opt3_delay_before_bp:	equ  400_0000h
   110                              <1> %endif
   111                              <1> opt3_no_call_amis:	equ  800_0000h
   112                              <1> opt3_disable_autorepeat:equ 1000_0000h
   113                              <1> opt3_check_ctrlc_keyb:	equ 2000_0000h
   114                              <1> opt3_check_ctrlc_0bh:	equ 4000_0000h
   115                              <1> opt3_tsr_quit_leave_tf:	equ 8000_0000h
   116                              <1> DEFAULTOPTIONS3	equ opt3_tt_no_paging | opt3_tp_no_paging 		| opt3_pp_no_paging | opt3_gg_no_paging 		| opt3_check_ctrlc_keyb | opt3_check_ctrlc_0bh
   119                              <1> 
   120                              <1> 
   121                              <1> opt4_int_2F_hook:	equ 2
   122                              <1> opt4_int_08_hook:	equ 4
   123                              <1> opt4_int_2D_hook:	equ 8
   124                              <1> %if _CATCHINTFAULTCOND
   125                              <1> opt4_int_fault_hook:	equ 10h
   126                              <1> %endif
   127                              <1> opt4_int_serial_force:	equ 1_0000h
   128                              <1> opt4_int_2F_force:	equ 2_0000h
   129                              <1> opt4_int_08_force:	equ 4_0000h
   130                              <1> opt4_int_2D_force:	equ 8_0000h
   131                              <1> %if _CATCHINT0D
   132                              <1> opt4_int_0D_force:	equ   10_0000h
   133                              <1> %endif
   134                              <1> %if _CATCHINT0C
   135                              <1> opt4_int_0C_force:	equ   20_0000h
   136                              <1> %endif
   137                              <1> opt4_int_00_force:	equ  100_0000h
   138                              <1> opt4_int_01_force:	equ  200_0000h
   139                              <1> opt4_int_03_force:	equ  400_0000h
   140                              <1> opt4_int_06_force:	equ  800_0000h
   141                              <1> opt4_int_18_force:	equ 1000_0000h
   142                              <1> opt4_int_19_force:	equ 2000_0000h
   143                              <1> opt4_int_09_force:	equ 4000_0000h	; not used at the same time as 15h
   144                              <1> opt4_int_15_force:	equ 4000_0000h	; not used at the same time as 09h
   145                              <1> opt4_int_07_force:	equ 8000_0000h
   146                              <1> DEFAULTOPTIONS4 equ opt4_int_2F_hook
   147                              <1> 
   148                              <1> 
   149                              <1> %if _VXCHG
   150                              <1> opt6_vv_mode:		equ 1
   151                              <1> opt6_vv_keep:		equ 2
   152                              <1> opt6_vv_int16:		equ 10h
   153                              <1>  %if _VXCHG_DEFAULT_ON
   154                              <1> DEFAULTOPTIONS6 equ opt6_share_serial_irq | opt6_vv_mode
   155                              <1>  %else
   156                              <1> DEFAULTOPTIONS6 equ opt6_share_serial_irq
   157                              <1>  %endif
   158                              <1> %else
   159                              <1> DEFAULTOPTIONS6 equ opt6_share_serial_irq
   160                              <1> %endif
   161                              <1> %if _DEBUG
   162                              <1> opt6_debug_exception_late:	equ  20h
   163                              <1> opt6_debug_exception_early:	equ  40h
   164                              <1>  %if _DEBUG_COND
   165                              <1> opt6_debug_exception:	equ  80h
   166                              <1> opt6_debug_mode:	equ 100h
   167                              <1>  %endif
   168                              <1> %endif
   169                              <1> opt6_bios_output:	equ 200h
   170                              <1> opt6_flat_binary:	equ 400h
   171                              <1> opt6_big_stack:		equ 800h
   172                              <1> opt6_40_columns:	equ 1000h
   173                              <1> opt6_40_indent_odd:	equ 2000h
   174                              <1> opt6_40_dash:		equ 4000h
   175                              <1> opt6_share_serial_irq:	equ 1_0000h
   176                              <1> opt6_serial_EOI_call:	equ 2_0000h
   177                              <1> %if _RH
   178                              <1> opt6_rh_mode:		equ 10_0000h
   179                              <1> %endif
   180                              <1> %if _DEBUG
   181                              <1> opt6_debug_putrunint_early:	equ  40_0000h
   182                              <1>  %if _DEBUG_COND
   183                              <1> opt6_debug_putrunint:		equ  80_0000h
   184                              <1>  %endif
   185                              <1> %endif
   186                              <1> opt6_bios_io:		equ 100_0000h
   187                              <1> opt6_immasm_display_uu:	equ 200_0000h
   188                              <1> opt6_immasm_debug:	equ 400_0000h
   189                              <1> opt6_immasm_flag:	equ 800_0000h
   190                              <1> opt6_immasm_nobranch:	equ 1000_0000h
   191                              <1> opt6_r_flags_style2:	equ 2000_0000h
   192                              <1> opt6_r_flags_style3:	equ 4000_0000h
   193                              <1> opt6_r_linebreak_conditional:	equ 8000_0000h
   194                              <1> 
   195                              <1> 
   196                              <1> DEFAULTOPTIONS7 equ opt7_no_tsr_ll
   197                              <1> opt7_no_free_oneshot_eld:	equ 1
   198                              <1> opt7_debug_optional_link:	equ 2
   199                              <1> opt7_quiet_install:		equ 4
   200                              <1> opt7_quick_run:			equ 8
   201                              <1> opt7_houdini:			equ 100h
   202                              <1> opt7_no_ensure:			equ 1000h
   203                              <1> opt7_no_tsr_ll:			equ 2000h
   204                              <1> 
   205                              <1> 
   206                              <1> oldpacket	equ	  1	; Int25/Int26 packet method available (L, W)
   207                              <1> newpacket	equ	  2	; Int21.7305 packet method available (L, W)
   208                              <1> ntpacket	equ	  4	; VDD registered and usable (L, W)
   209                              <1> pagedcommand	equ	  8	; allows paging in puts
   210                              <1> notstdinput	equ	 10h	; DEBUG's StdIn isn't a device with StdIn bit (is file or other device)
   211                              <1> inputfile	equ	 20h	; DEBUG's StdIn is a file, notstdinput also set
   212                              <1> notstdoutput	equ	 40h	; DEBUG's StdOut isn't a device with StdOut bit (is file or other device)
   213                              <1> outputfile	equ	  80h	; DEBUG's StdOut is a file, notstdoutput also set
   214                              <1> hooked2F	equ	 100h	; Int2F hooked
   215                              <1> nohook2F	equ	 200h	; don't hook Int2F.1687 (required for Win9x, DosEmu?)
   216                              <1> unused_dif1_dpminohlt equ 400h	; DPMI doesn't like hlt
   217                              <1> protectedmode	equ	 800h	; in (DPMI) protected mode
   218                              <1> debuggeeA20	equ	1000h	; state of debuggee's A20
   219                              <1> debuggerA20	equ	2000h	; state of debugger's A20 (will be on if possible)
   220                              <1> nodosloaded	equ	4000h	; No DOS loaded currently (Boot loader mode)
   221                              <1> has386		equ	8000h	; CPU is a 386
   222                              <1> usecharcounter	equ    1_0000h	; don't reset charcounter between calls to puts
   223                              <1> runningnt	equ    2_0000h	; running in NTVDM
   224                              <1> canswitchmode	equ    4_0000h	; can switch modes (auxbuff large enough, DPMI mode switch set up)
   225                              <1> modeswitched	equ    8_0000h	; switched mode (now in the mode that we weren't entered in)
   226                              <1> promptwaiting	equ   10_0000h	; puts: any more output needs to display a prompt first
   227                              <1> switchbuffer	equ   20_0000h	; mode switch needs a buffer (auxbuff)
   228                              <1> tsrmode		equ   40_0000h	; in TSR mode; DPI and DPP not valid
   229                              <1> attachedterm	equ   80_0000h	; the attached process terminated
   230                              <1> runningdosemu	equ  100_0000h	; running in dosemu
   231                              <1> ; load_is_ldp	equ  200_0000h	; boot load: partition specified as "ldp"
   232                              <1> tt_while:	equ  400_0000h	; tt: while condition specified
   233                              <1> tt_p:		equ  800_0000h	; tt: proceed past repeated string instructions
   234                              <1> tt_silent_mode:	equ 1000_0000h	; tt: run should be silent (dump at end)
   235                              <1> tt_silence:	equ 2000_0000h	; tt: silent writing (write to auxbuff instead)
   236                              <1> tt_no_bb:	equ 4000_0000h	; tt: do not use bb breakpoints
   237                              <1> tt_no_bb_first:	equ 8000_0000h	; tt: do not use bb breakpoints at first
   238                              <1> 
   239                              <1> 
   240                              <1> dif2_gg_is_first:	equ   1
   241                              <1> dif2_gg_skip_non_cseip:	equ   2
   242                              <1> dif2_gg_skip_cseip:	equ   4
   243                              <1> dif2_gg_is_gg:		equ   8
   244                              <1> dif2_gg_first_detected:	equ  10h
   245                              <1> dif2_gg_again:		equ  20h
   246                              <1> dif2_tpg_proceed_bp_set:equ  40h
   247                              <1> dif2_tpg_keep_proceed_bp: equ 80h
   248                              <1> dif2_tpg_have_bp:	equ 100h
   249                              <1> dif2_tpg_adjusted_cseip:equ 200h
   250                              <1> dif2_tpg_do_not_adjust:	equ 400h
   251                              <1> dif2_bp_failure:	equ 800h
   252                              <1> dif2_is_pp:		equ 1000h
   253                              <1> %if _SYMBOLIC
   254                              <1> dif2_createdprocess:	equ 800_0000h	; created empty debuggee process
   255                              <1> dif2_sym_req_xms:	equ 2000h
   256                              <1> dif2_sym_req_86mm:	equ 4000h
   257                              <1> dif2_sym_req_mask equ dif2_sym_req_86mm | dif2_sym_req_xms
   258                              <1> dif2_no_pm_xms:		equ 1_0000h
   259                              <1> dif2_xms_detection_done:equ 2_0000h
   260                              <1> %endif
   261                              <1> %if _INPUT_FILE_HANDLES
   262                              <1> dif2_input_file:	equ 10_0000h
   263                              <1> dif2_closed_input_file:	equ 20_0000h
   264                              <1> %endif
   265                              <1> dif2_did_getline_file:	equ 40_0000h
   266                              <1> %if _SYMBOLIC
   267                              <1> dif2_poison:		equ 80_0000h
   268                              <1> %endif
   269                              <1> dif2_boot_loaded_kernel:equ 100_0000h
   270                              <1> %if _INPUT_FILE_BOOT
   271                              <1> dif2_input_file_boot:	equ 200_0000h
   272                              <1> dif2_closed_input_file_boot:	equ 400_0000h
   273                              <1> %endif
   274                              <1> dif2_in_silence_dump:	equ 1000_0000h
   275                              <1> dif2_int31_segment:	equ 2000_0000h
   276                              <1> dif2_nn_compat:		equ 4000_0000h
   277                              <1> dif2_nn_capitalise:	equ 8000_0000h
   278                              <1> 
   279                              <1> 
   280                              <1> dif3_load_is_ldp:	equ 1	; boot load: partition specified as "ldp"
   281                              <1> dif3_load_is_sdp:	equ 2	; boot load: partition specified as "sdp"
   282                              <1> dif3_load_is_ydp:	equ 4	; boot load: partition specified as "ydp"
   283                              <1> dif3_load_is_dp:	equ dif3_load_is_ldp 				| dif3_load_is_sdp 				| dif3_load_is_ydp
   286                              <1> dif3_load_dir_dir:	equ 8
   287                              <1> dif3_input_terminal_override:	equ 10h
   288                              <1> dif3_input_serial_override:	equ 20h
   289                              <1> dif3_if_not:		equ 40h
   290                              <1> dif3_partition_changed:	equ 80h
   291                              <1> ;
   292                              <1> dif3_input_cmdline:	equ 100h; input reading from cmdline_buffer
   293                              <1> dif3_input_cmdline_closed: equ 200h
   294                              <1> dif3_at_line_end:	equ 400h
   295                              <1> dif3_quiet_input_single:equ 800h
   296                              <1> dif3_quiet_output:	equ 1000h
   297                              <1> dif3_unquiet_error:	equ 2000h
   298                              <1> dif3_unquiet_prompt:	equ 4000h
   299                              <1> dif3_unquiet:		equ dif3_unquiet_error | dif3_unquiet_prompt
   300                              <1> dif3_return_eof:	equ 8000h
   301                              <1> dif3_highlighting:	equ 1_0000h
   302                              <1> dif3_do_not_highlight:	equ 2_0000h
   303                              <1> dif3_int10_highlight:	equ 2_0000h
   304                              <1> dif3_nosymbols_1:	equ 4_0000h
   305                              <1> dif3_nosymbols_2:	equ 8_0000h
   306                              <1> %if _PM
   307                              <1> dif3_ss_b_bit_set:	equ  10_0000h
   308                              <1> %endif
   309                              <1> dif3_gotint19:		equ  20_0000h
   310                              <1> dif3_prior_pm:		equ  40_0000h
   311                              <1> %if _DELAY_BEFORE_BP
   312                              <1> dif3_delayed		equ  80_0000h
   313                              <1> %endif
   314                              <1> dif3_input_re:		equ 100_0000h	; input reading from re_buffer
   315                              <1> dif3_input_re_closed:	equ 200_0000h
   316                              <1> dif3_accept_getrange_0:	equ 400_0000h
   317                              <1> %if _INPUT_FILE_HANDLES || _INPUT_FILE_BOOT
   318                              <1> dif3_in_if:		equ 800_0000h
   319                              <1> %endif
   320                              <1> dif3_auxbuff_guarded_1:	equ 1000_0000h
   321                              <1> dif3_auxbuff_guarded_2:	equ 2000_0000h
   322                              <1> dif3_auxbuff_guarded_3:	equ 4000_0000h
   323                              <1> dif3_sss_is_reverse:	equ 8000_0000h
   324                              <1> 
   325                              <1> 
   326                              <1> dif4_int_serial_hooked:	equ 1
   327                              <1> dif4_int_2F_hooked:	equ 2
   328                              <1> dif4_int_08_hooked:	equ 4
   329                              <1> dif4_int_2D_hooked:	equ 8
   330                              <1> %if _CATCHINTFAULTCOND && _CATCHINT0D
   331                              <1> dif4_int_0D_hooked:	equ 10h
   332                              <1> %endif
   333                              <1> %if _CATCHINTFAULTCOND && _CATCHINT0C
   334                              <1> dif4_int_0C_hooked:	equ 20h
   335                              <1> %endif
   336                              <1> 
   337                              <1> 
   338                              <1> %if _VXCHG
   339                              <1> dif6_vv_mode:		equ 1
   340                              <1> %endif
   341                              <1> dif6_in_hook2F:		equ 2
   342                              <1> dif6_in_amis_hook2F:	equ 4
   343                              <1> dif6_debug_mode:	equ 100h
   344                              <1> dif6_locked:		equ 200h
   345                              <1> %if _RH
   346                              <1> dif6_rh_mode_was:	equ  8_0000h
   347                              <1> dif6_rh_mode:		equ 10_0000h
   348                              <1> dif6_rh_mode_2:		equ 20_0000h
   349                              <1> %endif
   350                              <1> dif6_device_mode:	equ 40_0000h
   351                              <1> dif6_cpdepchars:	equ 80_0000h
   352                              <1> %if _IMMASM
   353                              <1> dif6_immasm_no_output:	equ 100_0000h
   354                              <1> dif6_immasm:		equ 200_0000h
   355                              <1> dif6_immasm_rel8:	equ 400_0000h
   356                              <1> %endif
   357                              <1> 
   358                              <1> 
   359                              <1> disasm_lowercase	equ 1
   360                              <1> disasm_commablank	equ 2
   361                              <1> disasm_nasm		equ 4
   362                              <1> disasm_lowercase_refmem:equ 8
   363                              <1> disasm_show_short:	equ 10h
   364                              <1> disasm_show_near:	equ 20h
   365                              <1> disasm_show_far:	equ 40h
   366                              <1> disasm_nec:		equ 80h
   367                              <1> disasm_40_columns:	equ 100h
   368                              <1> disasm_no_indent:	equ 200h
   369                              <1> disasm_msdebug_mnemonofs: equ 400h
   370                              <1> disasm_a16_memref:	equ 1000h
   371                              <1> disasm_a32_memref:	equ 2000h
   372                              <1> disasm_a16_string:	equ 4000h
   373                              <1> disasm_a32_string:	equ 8000h
   374                              <1> disasm_hide_modrm:	equ 10000h
   375                              <1> disasm_asize_loop_nasm:	equ 20000h
   376                              <1> disasm_modrm_always:	equ 40000h
   377                              <1> DEFAULTASMOPTIONS equ disasm_lowercase|disasm_commablank|disasm_nasm 	| disasm_a16_memref | disasm_a32_memref 	| disasm_a16_string | disasm_a32_string
    28                                  
    29                                  
    30                                  	cpu 8086
    31                                  
    32                                  	addsection RELOCATEDDATA, nobits vstart=_ELD_RELOC_VSTART
    33                                  relocateddata:
    34                                  
    35                                  	addsection HEADER, start=0
    36                                  
    37                                  	istruc ELD_HEADERX
    38                                  at eldhxHeader
    39                                  		; ELD executable header
    40                                  	istruc ELD_HEADER
    41 00000000 454C4431                at eldhSignature,	db "ELD1"
    42 00000004 000000                  			db 0,0,0
    43 00000007 1A                      			db 26
    44 00000008 60000000                at eldhCodeOffset,	dd CODEOFFSET
    45 0000000C B014                    at eldhCodeImageLength,	dw code_size
    46 0000000E 0000                    at eldhCodeAllocLength,	dw 0
    47 00000010 10150000                at eldhDataOffset,	dd DATAOFFSET
    48 00000014 A000                    at eldhDataImageLength,	dw data_size
    49 00000016 5001                    at eldhDataAllocLength,	dw total_data_size - data_size
    50 00000018 A009                    at eldhCodeEntrypoint,	dw linker - code
    51                                  at eldhReserved
    52 0000001A 00<rep 4h>2400          at eldhExtensionSize,	dw header_extension_end - $$
    53                                  	iend
    54 00000020 [30000000]              at eldhxDescriptionOffset,	dd description
    55                                  PUT_ELDHX_DATETIME_OFFSET
    56                                  header_extension_end:
    57 00000024 00<rep Ch>              	iend
    58                                  
    59 00000030 50726F766964652053-     description:		asciz "Provide S (search memory) command."
    59 00000039 202873656172636820-
    59 00000042 6D656D6F7279292063-
    59 0000004B 6F6D6D616E642E00   
    60                                  
    61                                  
    62 00000053 00<rep Dh>              	align 16, db 0
    63                                  
    64                                  	eldstrict on
    65                                  
    66                                  CODEOFFSET equ $ - $$
    67                                  	addsection CODE, follows=HEADER vstart=_ELD_CODE_VSTART
    68                                  %define CODEFIXUP - code + 0
    69                                  code:
    70                                  code_start:
    71                                  		; ELD instance header
    72                                  	istruc ELD_INSTANCE
    73                                  at eldiStartCode
    74 00000000 00<rep 2h>              at eldiEndCode
    75 00000002 00<rep 2h>              at eldiStartData
    76 00000004 00<rep 2h>              at eldiEndData
    77 00000006 00<rep 2h>5320636D-     at eldiIdentifier,	fill 8, 32, db "S cmd"
    77 0000000C 6420<rep 3h>       
    78 00000010 00<rep 2h>732E6C73-     at eldiListing,		asciz _ELD_LISTING
    78 00000016 7400               
    79 00000018 00<rep 8h>              	iend
    80                                  
    81                                  
    82                                  DATAOFFSET equ CODEOFFSET + code_size
    83                                  	addsection DATA, follows=CODE vstart=_ELD_DATA_VSTART
    84                                  %define DATAFIXUP - datastart + 0
    85                                  datastart:
    86                                  PUT_ELD_DATETIME
    87                                  
    88                                  
    89                                  	usesection CODE
    90                                  
    91                                  command:
    92 00000020 EB08                    	jmp strict short .entry
    93                                  .chain:
    94 00000022 E8[0000]EB020000        	extcall cmd3_not_ext, required	; must NOT be extcallcall
    95 00000029 90                      	times 10 - ($ - command) nop
    96                                  .entry:
    97 0000002A 56                      	push si
    98 0000002B 3C2D                    	cmp al, '-'
    99 0000002D 7503                    	jne @F
   100 0000002F E89E07                  	extcallcall skipcomma
   101                                  @@:
   102 00000032 4E                      	dec si
   103                                  
   104                                  %if 0
   105                                  	lodsb
   106                                  	extcallcall uppercase
   107                                  	cmp al, 'S'
   108                                  	je @F
   109                                  .transfer_to_chain:
   110                                  	pop si
   111                                  	dec si
   112                                  	lodsb
   113                                  	jmp .chain
   114                                  
   115                                  @@:
   116                                  	dec si			; -> at 'S'
   117                                  reloc	mov dx, msg.sleep
   118                                  internaldatarelocation
   119                                  	extcallcall isstring?	; check for "SLEEP"
   120                                  	je .transfer_to_chain
   121                                  	inc si			; skip 'S'
   122                                  %else
   123                                  		; better detection: require S to match as
   124                                  		;  a string, so cannot mean any ELDs.
   125                                  		;  implies that it is not handled if the user
   126                                  		;  enters S with the address immediately behind
   127                                  		;  the S without a blank or comma.
   128 00000033 BA[1A00]                reloc	mov dx, msg.s
   129                                  internaldatarelocation
   130 00000036 E89F07                  	extcallcall isstring?
   131 00000039 7405                    	je .ours
   132                                  .transfer_to_chain:
   133 0000003B 5E                      	pop si
   134 0000003C 4E                      	dec si
   135 0000003D AC                      	lodsb
   136 0000003E EBE2                    	jmp .chain
   137                                  %endif
   138                                  
   139                                  .ours:
   140 00000040 58                      	pop ax
   141 00000041 E88C07                  	extcallcall skipcomma
   142 00000044 4E                      	dec si
   143 00000045 C706[0000][0000]        reloc2	mov word [relocateddata], relocateddata
   144                                  linkdatarelocation lastcmd, -4
   145                                  linkdatarelocation dmycmd
   146 0000004B BA[0000]                reloc	mov dx, relocateddata
   147                                  linkdatarelocation msg.uninstall
   148 0000004E E88707                  	extcallcall isstring?
   149 00000051 7407                    	je uninstall
   150 00000053 AC                      	lodsb
   151 00000054 E87F00                  	call sss
   152 00000057 E88607                  	extcallcall cmd3
   153                                  
   154                                  uninstall:
   155 0000005A AC                      	lodsb
   156 0000005B E88A07                  	extcallcall chkeol
   157                                  
   158 0000005E 8E06[0000]              reloc	mov es, word [relocateddata]
   159                                  linkdatarelocation extdssel
   160 00000062 E88B07                  	extcallcall ispm
   161 00000065 7404                    	jz @F
   162 00000067 8E06[0000]              reloc	mov es, word [relocateddata]
   163                                  linkdatarelocation extseg
   164                                  @@:
   165 0000006B 06                      	push es
   166 0000006C 1F                      	pop ds
   167 0000006D 31DB                    	xor bx, bx		; = 0 (no prior, modify ext_command_handler)
   168 0000006F BF[2000]                reloc	mov di, command		; di -> us
   169                                  internalcoderelocation
   170 00000072 368B36[0000]            reloc	mov si, word [ss:relocateddata]
   171                                  linkdatarelocation ext_command_handler
   172                                  				; si -> first
   173 00000077 85F6                    	test si, si		; none installed ?
   174 00000079 7450                    	jz .error		; error -->
   175                                  
   176                                  .loop:
   177 0000007B 39F7                    	cmp di, si		; found ?
   178 0000007D 740D                    	je .bx			; yes, use bx -->
   179 0000007F 89F3                    	mov bx, si		; bx -> prior handler
   180 00000081 AD                      	lodsw			; skip entrypoint jmp strict short
   181 00000082 AC                      	lodsb			; get first byte of chainer
   182 00000083 3CE9                    	cmp al, 0E9h		; expecting jmp near ?
   183 00000085 7544                    	jne .error		; no, error -->
   184 00000087 AD                      	lodsw			; get rel16 displacement
   185 00000088 01C6                    	add si, ax		; -> next handler
   186 0000008A EBEF                    	jmp .loop
   187                                  
   188                                  .bx:
   189 0000008C 85DB                    	test bx, bx		; any prior ?
   190 0000008E 751A                    	jnz .bxnz		; yes -->
   191 00000090 AF                      	scasw			; skip entrypoint jmp strict short
   192 00000091 803DE8                  	cmp byte [di], 0E8h	; is it a call to cmd3_not_ext ?
   193 00000094 7507                    	jne @F			; no -->
   194                                  				; yes, reset ext_command_handler to zero
   195                                  .setbx:
   196 00000096 36891E[0000]            reloc	mov word [ss:relocateddata], bx
   197                                  linkdatarelocation ext_command_handler
   198 0000009B EB1E                    	jmp .done
   199                                  
   200                                  @@:
   201 0000009D 803DE9                  	cmp byte [di], 0E9h	; validate
   202 000000A0 7529                    	jne .error		; failure -->
   203 000000A2 47                      	inc di			; -> rel16 displacement
   204 000000A3 8B1D                    	mov bx, word [di]	; get displacement
   205 000000A5 AF                      	scasw			; -> after jmp near
   206 000000A6 01FB                    	add bx, di		; -> next handler
   207 000000A8 EBEC                    	jmp .setbx		; set ext_command_handler to next
   208                                  
   209                                  .bxnz:
   210 000000AA 89DE                    	mov si, bx		; -> prior handler with us as downlink
   211 000000AC 87FE                    	xchg di, si		; si -> ours, di -> prior
   212 000000AE A7                      	cmpsw			; skip entrypoint jmp strict short
   213 000000AF A4                      	movsb			; copy 0E8h/0E9h
   214 000000B0 AD                      	lodsw			; ax = near rel16 displacement
   215 000000B1 01F0                    	add ax, si		; add in our base (= absolute offset)
   216 000000B3 29F8                    	sub ax, di
   217 000000B5 48                      	dec ax
   218 000000B6 48                      	dec ax			; subtract new base (= relative displacement)
   219 000000B7 AB                      	stosw			; store new rel16 displacement
   220 000000B8 A5                      	movsw			; jmp strict short
   221 000000B9 A5                      	movsw			; linkcall target
   222 000000BA A4                      	movsb			; trailer
   223                                  .done:
   224 000000BB 8026[1000]FE            reloc	clropt [code + eldiFlags], eldifResident
   225                                  internalcoderelocation -3	; mark block as free
   226 000000C0 BA[4F00]                reloc	mov dx, msg.uninstall_done
   227                                  internaldatarelocation
   228                                  @@:
   229 000000C3 16                      	push ss
   230 000000C4 1F                      	pop ds
   231 000000C5 E83007                  	extcallcall putsz
   232 000000C8 E81507                  	extcallcall cmd3	; return
   233                                  
   234                                  .error:
   235 000000CB B8010E                  	mov ax, 0E01h
   236 000000CE E82F07                  	extcallcall setrc
   237 000000D1 BA[6800]                reloc	mov dx, msg.uninstall_error
   238                                  internaldatarelocation
   239 000000D4 EBED                    	jmp @B
   240                                  
   241                                  
   242                                  %define relocated(address) relocateddata
   243                                  %assign ELD 1
   244                                  %assign _PM 1
   245                                  %assign _ONLY386 0
   246                                  %assign _ONLYNON386 0
   247                                  %assign _SWHILEBUFFER 0
   248                                  %assign _SCOUNT 1
   249                                  %assign _SDUMP 1
   250                                  %assign _SDUMPDISPLACEMENT 1
   251                                  %assign _SREVERSE 1
   252                                  %assign _AUXBUFFSIZE 8192 + 16
   253                                  %define lDEBUG_CODE CODE
   254                                  %define lDEBUG_DATA_ENTRY DATA
   255                                  %define dualcall call
   256                                  	cpu 8086
   257                                  %assign _WPT_LABELS 0
   258                                  
   259                                  %include "386.mac"
     1                              <1> 
     2                              <1> %if 0
     3                              <1> 
     4                              <1> lDebug 386 patch macros
     5                              <1> 
     6                              <1> Copyright (C) 2008-2023 E. C. Masloch
     7                              <1> 
     8                              <1> Usage of the works is permitted provided that this
     9                              <1> instrument is retained with the works, so that any entity
    10                              <1> that uses the works is notified of this instrument.
    11                              <1> 
    12                              <1> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    13                              <1> 
    14                              <1> %endif
    15                              <1> 
    16                              <1> 	numdef WPT_LABELS, 0
    17                              <1> 		; This used to be required, because CODESECTIONFIXUP used
    18                              <1> 		;  ldebug_data_entry_size, which is not yet defined during
    19                              <1> 		;  assembling of (most) lDEBUG_CODE fragments.
    20                              <1> 		; However, assembling DebugX with this option selected
    21                              <1> 		;  took more than 2 minutes, so the non-label variant
    22                              <1> 		;  is clearly to be preferred when available.
    23                              <1> 		; Now that lDEBUG_CODE has vstart=0 we can use the
    24                              <1> 		;  CODESECTIONFIXUP again and thus disable this option.
    25                              <1> 
    26                              <1> %define PATCH_NO386_TABLE ""
    27                              <1> %define PATCH_386_TABLE ""
    28                              <1> %define PATCH_NO386_TABLE2 ""
    29                              <1> %define PATCH_386_TABLE2 ""
    30                              <1> %define PATCH_NO386_TABLEENTRY ""
    31                              <1> %define PATCH_386_TABLEENTRY ""
    32                              <1> 
    33                              <1> %if _ONLY386
    34                              <1> 		; Default patch macros if only running on 386+.
    35                              <1> %define _386_o32 o32
    36                              <1> %define _386_a32 a32
    37                              <1> %define _386_jmps jmp short
    38                              <1> %define _386_jmpn jmp near
    39                              <1> %define _no386_jmps comment
    40                              <1> %define _no386_jmpn comment
    41                              <1> 	%macro _386 0-1+.nolist
    42                              <1> [cpu 386]			; change CPU type
    43                              <1> 		%1		; write instruction
    44                              <1> __CPU__				; reset CPU type
    45                              <1> 	%endmacro
    46                              <1> %define _no386 comment
    47                              <1> %elif _ONLYNON386
    48                              <1> 		; Default patch macros if only running on non-386.
    49                              <1> %define _386_o32
    50                              <1> %define _386_a32
    51                              <1> %define _386_jmps comment
    52                              <1> %define _386_jmpn comment
    53                              <1> %define _no386_jmps jmp short
    54                              <1> %define _no386_jmpn jmp near
    55                              <1> %define _386 comment
    56                              <1> %define _no386
    57                              <1> %else
    58                              <1> 
    59                              <1> ; These macros are to make DEBUG's 386 support as small as
    60                              <1> ; possible. To achieve this, two patch tables are created
    61                              <1> ; in the initialisation code. One of the tables is used if
    62                              <1> ; the CPU is a 386+, the other one if it isn't. The bytes
    63                              <1> ; pointed to in the used table are over-written with NOP
    64                              <1> ; instructions. (The patched bytes are usually address or
    65                              <1> ; operand size prefixes or jumps that branch to 386/non-386
    66                              <1> ; code.)
    67                              <1> 
    68                              <1> ; There are a few special patches that require the
    69                              <1> ; initialisation code to write specific bytes other than
    70                              <1> ; NOP instructions for lower resident memory usage.
    71                              <1> ; Two are in the run: code, three in pmentry.asm.
    72                              <1> 
    73                              <1> 	%macro patch386 2+.nolist
    74                              <1> %ifidn _CURRENT_SECTION, lDEBUG_CODE
    75                              <1>  %define PATCH_%{1}386_TABLE %[PATCH_%{1}386_TABLE], %2
    76                              <1> %elifidn _CURRENT_SECTION, lDEBUG_CODE2
    77                              <1>  %define PATCH_%{1}386_TABLE2 %[PATCH_%{1}386_TABLE2], %2
    78                              <1> %elifidn _CURRENT_SECTION, lDEBUG_DATA_ENTRY
    79                              <1>  %define PATCH_%{1}386_TABLEENTRY %[PATCH_%{1}386_TABLEENTRY], %2
    80                              <1> %else
    81                              <1>  %error Wrong section
    82                              <1> %endif
    83                              <1> 	%endmacro
    84                              <1> 
    85                              <1> %if _WPT_LABELS
    86                              <1> 	; These forms provide verbose info by defining a
    87                              <1> 	; meaningful label for each patch. That fills up
    88                              <1> 	; the map file and might take longer though.
    89                              <1> 		; Operand size 32-bit prefix if 386+ CPU
    90                              <1> 	%macro _386_o32 0-1+.nolist
    91                              <1> %%386_o32:	o32
    92                              <1> patch386 NO, %%386_o32
    93                              <1> 		%1
    94                              <1> 	%endmacro
    95                              <1> 
    96                              <1> 		; Address size 32-bit prefix if 386+ CPU
    97                              <1> 	%macro _386_a32 0-1+.nolist
    98                              <1> %%386_a32:	a32
    99                              <1> patch386 NO, %%386_a32
   100                              <1> 		%1
   101                              <1> 	%endmacro
   102                              <1> 
   103                              <1> 		; Short jump if 386+ CPU
   104                              <1> 	%macro _386_jmps 1.nolist
   105                              <1> %%386_jmps:	jmp short %1
   106                              <1> patch386 NO, %%386_jmps,%%386_jmps+1
   107                              <1> 	%endmacro
   108                              <1> 
   109                              <1> 		; Near jump if 386+ CPU
   110                              <1> 	%macro _386_jmpn 1.nolist
   111                              <1> %%386_jmpn:	jmp near %1
   112                              <1> patch386 NO, %%386_jmpn,%%386_jmpn+1,%%386_jmpn+2
   113                              <1> 	%endmacro
   114                              <1> 
   115                              <1> 		; Short jump if no 386+ CPU
   116                              <1> 	%macro _no386_jmps 1.nolist
   117                              <1> %%no386_jmps:	jmp short %1
   118                              <1> patch386 , %%no386_jmps,%%no386_jmps+1
   119                              <1> 	%endmacro
   120                              <1> 
   121                              <1> 		; Near jump if no 386+ CPU
   122                              <1> 	%macro _no386_jmpn 1.nolist
   123                              <1> %%no386_jmpn:	jmp near %1
   124                              <1> patch386 , %%no386_jmpn,%%no386_jmpn+1,%%no386_jmpn+2
   125                              <1> 	%endmacro
   126                              <1> 
   127                              <1> 		; Instruction if 386+ CPU
   128                              <1> 	%macro _386 0-1+.nolist
   129                              <1> [cpu 386]			; change CPU type
   130                              <1> %%386_instr:	%1		; write instruction
   131                              <1> __CPU__				; reset CPU type
   132                              <1> 
   133                              <1> %assign %%INSTRCOUNT 0
   134                              <1> %rep $-%%386_instr		; count size of instruction
   135                              <1>  patch386 NO, %%386_instr+%[%%INSTRCOUNT]
   136                              <1> 				; write a patch for each byte
   137                              <1>  %assign %%INSTRCOUNT %%INSTRCOUNT+1
   138                              <1> %endrep
   139                              <1> %undef %%INSTRCOUNT
   140                              <1> 	%endmacro
   141                              <1> 
   142                              <1> 		; Instruction if no 386+ CPU
   143                              <1> 	%macro _no386 0-1+.nolist
   144                              <1> %%no386_instr:	%1		; write instruction
   145                              <1> 
   146                              <1> %assign %%INSTRCOUNT 0
   147                              <1> %rep $-%%no386_instr		; count size of instruction
   148                              <1>  patch386 , %%no386_instr+%[%%INSTRCOUNT]
   149                              <1> 				; write a patch for each byte
   150                              <1>  %assign %%INSTRCOUNT %%INSTRCOUNT+1
   151                              <1> %endrep
   152                              <1> %undef %%INSTRCOUNT
   153                              <1> 	%endmacro
   154                              <1> %else	; 0
   155                              <1> 		; Operand size 32-bit prefix if 386+ CPU
   156                              <1> 	%macro _386_o32 0-1+.nolist
   157                              <1> _386		o32
   158                              <1> 		%1
   159                              <1> 	%endmacro
   160                              <1> 
   161                              <1> 		; Address size 32-bit prefix if 386+ CPU
   162                              <1> 	%macro _386_a32 0-1+.nolist
   163                              <1> _386		a32
   164                              <1> 		%1
   165                              <1> 	%endmacro
   166                              <1> 
   167                              <1> 		; Short jump if 386+ CPU
   168                              <1> 	%macro _386_jmps 1.nolist
   169                              <1> _386		jmp short %1
   170                              <1> 	%endmacro
   171                              <1> 
   172                              <1> 		; Near jump if 386+ CPU
   173                              <1> 	%macro _386_jmpn 1.nolist
   174                              <1> _386		jmp near %1
   175                              <1> 	%endmacro
   176                              <1> 
   177                              <1> 		; Short jump if no 386+ CPU
   178                              <1> 	%macro _no386_jmps 1.nolist
   179                              <1> _no386		jmp short %1
   180                              <1> 	%endmacro
   181                              <1> 
   182                              <1> 		; Near jump if no 386+ CPU
   183                              <1> 	%macro _no386_jmpn 1.nolist
   184                              <1> _no386		jmp near %1
   185                              <1> 	%endmacro
   186                              <1> 
   187                              <1> 		; Instruction if 386+ CPU
   188                              <1> 	%macro _386 0-1+.nolist
   189                              <1> %push
   190                              <1> [cpu 386]			; change CPU type
   191                              <1> %assign %$entry $ + _CURRENT_SECTION %+ FIXUP
   192                              <1> 		%1		; write instruction
   193                              <1> __CPU__				; reset CPU type
   194                              <1> 
   195                              <1> %rep ($ + _CURRENT_SECTION %+ FIXUP) - %$entry
   196                              <1> 				; count size of instruction
   197                              <1>  patch386 NO, %[%$entry]	; write a patch for each byte
   198                              <1>  %assign %$entry %$entry+1
   199                              <1> %endrep
   200                              <1> %pop
   201                              <1> 	%endmacro
   202                              <1> 
   203                              <1> 		; Instruction if no 386+ CPU
   204                              <1> 	%macro _no386 0-1+.nolist
   205                              <1> %push
   206                              <1> %assign %$entry $ + _CURRENT_SECTION %+ FIXUP
   207                              <1> 		%1		; write instruction
   208                              <1> 
   209                              <1> %rep ($ + _CURRENT_SECTION %+ FIXUP) - %$entry
   210                              <1> 				; count size of instruction
   211                              <1>  patch386 , %[%$entry]		; write a patch for each byte
   212                              <1>  %assign %$entry %$entry+1
   213                              <1> %endrep
   214                              <1> %pop
   215                              <1> 	%endmacro
   216                              <1> %endif	; 1
   217                              <1> 
   218                              <1> 
   219                              <1> %endif
   220                              <1> 
   221                              <1> 		; Patch macros but for cases where the 386+
   222                              <1> 		; instructions should only be generated for
   223                              <1> 		; DEBUGX (i.e. for 32-bit DPMI addressing code).
   224                              <1> %if _PM
   225                              <1> %define _386_PM_o32	_386_o32
   226                              <1> %define _386_PM_a32	_386_a32
   227                              <1> %define _386_PM_jmps	_386_jmps
   228                              <1> %define _386_PM_jmpn	_386_jmpn
   229                              <1> %define _386_PM		_386
   230                              <1> %else
   231                              <1> %define _386_PM_o32
   232                              <1> %define _386_PM_a32
   233                              <1> %define _386_PM_jmps	comment
   234                              <1> %define _386_PM_jmpn	comment
   235                              <1> %define _386_PM		comment
   236                              <1> %endif
   237                              <1> 
   238                              <1> 
   239                              <1> %macro __writepatchtable2 0-*.nolist
   240                              <1> %if %0 & 1
   241                              <1>  %fatal Expected even number of arguments
   242                              <1> %endif
   243                              <1> %rep %0 >> 1
   244                              <1> 	%1 %2
   245                              <1> %rotate 2
   246                              <1> %endrep
   247                              <1> %endmacro
   248                              <1> 
   249                              <1> %macro __patchtable2_entry 0.nolist
   250                              <1>   ; only if this isn't the first (pseudo-)entry
   251                              <1>   %if %$lastcount != 0
   252                              <1>     %assign %$runscount %[%$runscount]+1
   253                              <1>    ; if the offset from %$previous is less than 255
   254                              <1>    %if (%$last-%$previous) < 255
   255                              <1>     %assign %$$method2tablesize %$$method2tablesize+1
   256                              <1>     ; then write a single byte (number of bytes not to patch between)
   257                              <1>     %xdefine %$$method2list %$$method2list,db,%$last-%$previous
   258                              <1>    %else
   259                              <1>     ; otherwise write a 255 ("reposition") and write the 16-bit address afterwards
   260                              <1>     %assign %$$method2tablesize %$$method2tablesize+3
   261                              <1>     %xdefine %$$method2list %$$method2list,db,255,dw,%$last
   262                              <1>     %assign %$reposcount %[%$reposcount]+1
   263                              <1>    %endif
   264                              <1>    %if %$lastcount == 1
   265                              <1>     %assign %$onecount %[%$onecount]+1
   266                              <1>    %endif
   267                              <1>    %assign %$$method2tablesize %$$method2tablesize+1
   268                              <1>    ; and write the number of bytes to be patched
   269                              <1>    %xdefine %$$method2list %$$method2list,db,%$lastcount
   270                              <1>    ; define %$previous for the next entry: it points to the next non-patched byte
   271                              <1>    %define %$previous (%[%$last]+%[%$lastcount])
   272                              <1>   %endif
   273                              <1> %endmacro
   274                              <1> 
   275                              <1> %macro writepatchtable 2-*.nolist
   276                              <1> 
   277                              <1> 	numdef %{1}_FORCE_METHOD, 0
   278                              <1> %push
   279                              <1> 		; Determine length of simple table:
   280                              <1> %assign %$method1tablesize (%0 - 2)*2
   281                              <1> 
   282                              <1> %if !_%{1}_FORCE_METHOD || _%{1}_FORCE_METHOD == 2
   283                              <1> 		; Determine length of complicated table:
   284                              <1> %assign %$method2tablesize 0
   285                              <1> %define %$method2list db,""
   286                              <1> %push
   287                              <1> %if _WPT_LABELS
   288                              <1>  %define %$previous code_start	; if list contains labels
   289                              <1> %else
   290                              <1>  %define %$previous 0
   291                              <1> %endif
   292                              <1> %define %$last %[%$previous]
   293                              <1> %assign %$lastcount 0
   294                              <1> %assign %$onecount 0
   295                              <1> %assign %$reposcount 0
   296                              <1> %assign %$bytescount %0 - 2
   297                              <1> %assign %$runscount 0
   298                              <1> %rotate 1
   299                              <1> %rep %0 - 2
   300                              <1>  %rotate 1
   301                              <1>  ;if  it continues the previous patch   and not too long   and this isn't the first
   302                              <1>  %if ((%$last+%$lastcount) == %1) && (%$lastcount < 255) && (%$lastcount != 0)
   303                              <1>   ; then do not write an entry, just increase the patch's size
   304                              <1>   %assign %$lastcount %[%$lastcount]+1
   305                              <1>  %else
   306                              <1>   ; otherwise write the last entry
   307                              <1>   __patchtable2_entry
   308                              <1>   ; define new %$last to this parameter, %$lastcount to one
   309                              <1>   %define %$last %1
   310                              <1>   %assign %$lastcount 1
   311                              <1>  %endif
   312                              <1> %endrep
   313                              <1> __patchtable2_entry
   314                              <1> 
   315                              <1> ; at the end, there's a patch with offset 0, size 0
   316                              <1> %assign %$$method2tablesize %$$method2tablesize+2
   317                              <1> %xdefine %$$method2list %$$method2list,db,0,db,0
   318                              <1> 
   319                              <1> %assign %$$onecount %$onecount
   320                              <1> %assign %$$reposcount %$reposcount
   321                              <1> %assign %$$bytescount %$bytescount
   322                              <1> %assign %$$runscount %$runscount
   323                              <1> %pop
   324                              <1> %rotate 1
   325                              <1> %endif
   326                              <1> 
   327                              <1> %if _%{1}_FORCE_METHOD == 2
   328                              <1>  %define __%{1}_method 2
   329                              <1> %elif _%{1}_FORCE_METHOD == 1
   330                              <1>  %define __%{1}_method 1
   331                              <1> %else
   332                              <1>  %if _%{1}_FORCE_METHOD
   333                              <1>   %fatal Invalid forced method selected: _%{1}_FORCE_METHOD
   334                              <1>  %endif
   335                              <1>  %if %$method1tablesize > (%$method2tablesize+20)
   336                              <1>   %define __%{1}_method 2
   337                              <1>  %else
   338                              <1>   %define __%{1}_method 1
   339                              <1>  %endif
   340                              <1> %endif
   341                              <1> 
   342                              <1> 
   343                              <1> %1:
   344                              <1> %if __%{1}_method == 2
   345                              <1> 	__writepatchtable2 %$method2list
   346                              <1> 	endarea %1
   347                              <1> %assign %$size %1_size
   348                              <1> %warning %1: %$size bytes (Method 2)
   349                              <1> %warning 1B=%$onecount repo=%$reposcount run=%$runscount byte=%$bytescount
   350                              <1> %else
   351                              <1> %rotate 1
   352                              <1> %rep %0 - 2
   353                              <1> %rotate 1
   354                              <1> 	dw %1
   355                              <1> %endrep
   356                              <1> %rotate 1
   357                              <1> 	endarea %1
   358                              <1> %assign %$size %1_size
   359                              <1> %warning %1: %$size bytes (Method 1)
   360                              <1> %endif
   361                              <1> %pop
   362                              <1> %endmacro
   260                                  
   261                                  %include "ssshared.asm"
     1                              <1> 
     2                              <1> %if 0
     3                              <1> 
     4                              <1> lDebug S commands (search, sleep)
     5                              <1> 
     6                              <1> Copyright (C) 1995-2003 Paul Vojta
     7                              <1> Copyright (C) 2008-2024 E. C. Masloch
     8                              <1> 
     9                              <1> Usage of the works is permitted provided that this
    10                              <1> instrument is retained with the works, so that any entity
    11                              <1> that uses the works is notified of this instrument.
    12                              <1> 
    13                              <1> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    14                              <1> 
    15                              <1> %endif
    16                              <1> 
    17                              <1> 
    18                              <1> 	usesection lDEBUG_CODE
    19                              <1> 
    20                              <1> ..@sss_access_start:
    21                              <1> 
    22                              <1> 		; S command - search for a string of bytes.
    23                              <1> sss:
    24                              <1>  %ifn ELD
    25                              <1> 	dec si
    26                              <1> 	dec si			; -> at 'S'
    27                              <1> 	mov dx, msg.sleep
    28                              <1> 	call isstring?		; check for "SLEEP"
    29                              <1> 	je sleepcmd
    30                              <1> 	inc si			; skip 'S'
    31                              <1> 	lodsb			; load next
    32                              <1>  %endif
    33                              <1> 
    34                              <1> %if _SREVERSE
    35 000000D6 8026[0300]7F        <1> reloc	clropt [relocated(internalflags3)], dif3_sss_is_reverse
    36                              <1> linkdatarelocation internalflags3, -3
    37                              <1> %endif
    38                              <1> 
    39 000000DB 8B1E[0000]          <1> reloc	mov bx, word [relocated(reg_ds)]	; get search range
    40                              <1> linkdatarelocation reg_ds
    41 000000DF 66                  <1> 	_386_PM_o32		; xor ecx, ecx
    42 000000E0 31C9                <1> 	xor cx, cx
    43 000000E2 E82307              <1> 	extcallcall getrangeX	; get address range into BX:(E)DX..BX:(E)CX
    44 000000E5 E82807              <1> 	extcallcall skipcomm0
    45 000000E8 66                  <1> 	_386_PM_o32		; push edx
    46 000000E9 52                  <1> 	push dx
    47 000000EA 66                  <1> 	_386_PM_o32		; push ecx
    48 000000EB 51                  <1> 	push cx
    49 000000EC 53                  <1> 	push bx
    50                              <1> 
    51 000000ED C606[0000]00        <1> reloc	mov byte [relocated(sss_silent_count_used)], 0
    52                              <1> linkdatarelocation sss_silent_count_used, -3
    53                              <1> %if ELD
    54 000000F2 C606[8A00]00        <1> reloc	mov byte [tagbuffer], 0	; clear caps and wild flags for scasb
    55                              <1> internaldatarelocation -3
    56 000000F7 C606[E601]00        <1> reloc	mov byte [sss_range_used], 0
    57                              <1> internaldatarelocation -3
    58 000000FC C706[E401][8605]    <1> reloc2	mov word [sss_repe_cmpsb_for_range], do_repe_cmpsb
    59                              <1> internaldatarelocation -4
    60                              <1> internalcoderelocation
    61                              <1> %endif
    62                              <1> 
    63                              <1> %if _SREVERSE
    64 00000102 BA[3C00]            <1> reloc	mov dx, msg.reverse
    65                              <1> internaldatarelocation
    66 00000105 4E                  <1> 	dec si
    67 00000106 E8CF06              <1> 	extcallcall isstring?
    68 00000109 7509                <1> 	jne @F
    69                              <1> 
    70 0000010B 800E[0300]80        <1> reloc	setopt [relocated(internalflags3)], dif3_sss_is_reverse
    71                              <1> linkdatarelocation internalflags3, -3
    72 00000110 E8BD06              <1> 	extcallcall skipcomma
    73 00000113 4E                  <1> 	dec si
    74                              <1> @@:
    75                              <1> %else
    76                              <1> 	dec si
    77                              <1> %endif
    78                              <1> 
    79 00000114 BA[2F00]            <1> reloc	mov dx, msg.silent
    80                              <1> internaldatarelocation
    81 00000117 E8BE06              <1> 	extcallcall isstring?
    82 0000011A 7516                <1> 	jne @F
    83 0000011C E8F906              <1> 	extcallcall skipequals
    84 0000011F E8FE06              <1> 	extcallcall getdword
    85 00000122 8916[0000]          <1> reloc	mov word [relocated(sss_silent_count)], dx
    86                              <1> linkdatarelocation sss_silent_count
    87 00000126 891E[0200]          <1> reloc	mov word [relocated(sss_silent_count) + 2], bx
    88                              <1> linkdatarelocation sss_silent_count
    89 0000012A F616[0000]          <1> reloc	not byte [relocated(sss_silent_count_used)]
    90                              <1> linkdatarelocation sss_silent_count_used
    91 0000012E E8DF06              <1> 	extcallcall skipcomm0
    92 00000131 4E                  <1> 	dec si
    93                              <1> @@:
    94                              <1> 
    95 00000132 BA[3600]            <1> reloc	mov dx, msg.range
    96                              <1> internaldatarelocation
    97 00000135 E8A006              <1> 	extcallcall isstring?
    98 00000138 AC                  <1> 	lodsb
    99 00000139 7534                <1> 	jne .notrange
   100                              <1> 
   101                              <1> %if ELD
   102 0000013B E8D206              <1> 	extcallcall skipcomm0
   103 0000013E 4E                  <1> 	dec si
   104 0000013F BA[2A00]            <1> reloc	mov dx, msg.caps
   105                              <1> internaldatarelocation
   106 00000142 E89306              <1> 	extcallcall isstring?
   107 00000145 AC                  <1> 	lodsb
   108 00000146 750E                <1> 	jne .notrangecaps
   109 00000148 E8C506              <1> 	extcallcall skipcomm0
   110                              <1> 
   111 0000014B 800E[8A00]02        <1> reloc	or byte [tagbuffer], 2	; set caps flag for scasb
   112                              <1> internaldatarelocation -3
   113 00000150 C706[E401][8D05]    <1> reloc2	mov word [sss_repe_cmpsb_for_range], do_repe_cmpsb_caps
   114                              <1> internaldatarelocation -4
   115                              <1> internalcoderelocation
   116                              <1> .notrangecaps:
   117                              <1> %endif
   118                              <1> 
   119 00000156 8B1E[0000]          <1> reloc	mov bx, word [relocated(reg_ds)]	; get search range
   120                              <1> linkdatarelocation reg_ds
   121 0000015A 31C9                <1> 	xor cx, cx
   122 0000015C E8A906              <1> 	extcallcall getrangeX	; try to get second range
   123 0000015F 56                  <1> 	push si
   124 00000160 E88506              <1> 	extcallcall chkeol	; and insure end-of-line
   125                              <1> 				; successful if it returned
   126 00000163 66                  <1> 	_386_PM_o32		; mov esi, edx
   127 00000164 89D6                <1> 	mov si, dx		; bx:esi-> source string
   128 00000166 66                  <1> 	_386_PM_o32		; sub ecx, edx
   129 00000167 29D1                <1> 	sub cx, dx		; ecx = count - 1
   130                              <1> %if ELD
   131 00000169 F616[E601]          <1> reloc	not byte [sss_range_used]
   132                              <1> internaldatarelocation
   133                              <1> %endif
   134 0000016D EB2F                <1> 	jmp short .setesedi
   135                              <1> 
   136                              <1> .notrange:
   137                              <1> %if ELD
   138 0000016F E83A05              <1> 	call getstr_sss		; get string of bytes
   139                              <1> %else
   140                              <1> 	nearcall getstr
   141                              <1> %endif
   142 00000172 56                  <1> 	push si
   143 00000173 81EF[0000]          <1> reloc	sub di, strict word relocated(line_out)
   144                              <1> 				; di = number of bytes to look for
   145                              <1> linkdatarelocation line_out
   146 00000177 7503E94706          <1> 	jz error
   147 0000017C 89F9                <1> 	mov cx, di
   148 0000017E 4F                  <1> 	dec di			;     minus one
   149 0000017F BE[0000]            <1> reloc	mov si, relocated(line_out)
   150                              <1> linkdatarelocation line_out
   151 00000182 57                  <1> 	push di
   152                              <1> 
   153                              <1> %if _SWHILEBUFFER && ! ELD
   154                              <1>  %if _WHILEBUFFSIZE < 264
   155                              <1>   %error WHILE buffer not large enough for search pattern
   156                              <1>  %endif
   157                              <1> 	testopt [internalflags], tt_while
   158                              <1> 	jnz .use_auxbuff
   159                              <1> 	mov di, while_buffer
   160                              <1> 	push di
   161                              <1> 	rep movsb
   162                              <1> 	pop si
   163                              <1> _386_PM	movzx esi, si
   164                              <1> 	jmp .use_whilebuffer
   165                              <1> %endif
   166                              <1> 
   167                              <1> %if 1 && ELD
   168 00000183 81F90801            <1> 	cmp cx, patternbuffer.size
   169 00000187 7603E93706          <1> 	ja error
   170 0000018C BF[D600]            <1> reloc	mov di, patternbuffer
   171                              <1> internaldatarelocation
   172 0000018F 57                  <1> 	push di
   173 00000190 F3A4                <1> 	rep movsb
   174 00000192 5E                  <1> 	pop si
   175 00000193 660FB7F6            <1> _386_PM	movzx esi, si
   176                              <1> 	; jmp .use_whilebuffer
   177                              <1> %else
   178                              <1> .use_auxbuff:
   179                              <1> 	extcallcall guard_auxbuff
   180                              <1> reloc	mov es, word [relocated(auxbuff_segorsel)]
   181                              <1> linkdatarelocation auxbuff_segorsel
   182                              <1> 	xor di, di
   183                              <1> 	rep movsb		; move to auxbuff
   184                              <1> 	_386_PM_o32	; xor esi, esi
   185                              <1> 	xor si, si
   186                              <1> %endif
   187                              <1> .use_whilebuffer:
   188 00000197 8CC3                <1> 	mov bx, es		; bx:esi -> auxbuff
   189 00000199 59                  <1> 	pop cx
   190 0000019A 660FB7C9            <1> _386_PM	movzx ecx, cx		; ecx = count - 1
   191                              <1> .setesedi:
   192                              <1> %if _SCOUNT || ELD
   193 0000019E 53                  <1> 	push bx
   194 0000019F E8[0000]EB020000    <1> 	extcall count_store, optional
   195 000001A6 5B                  <1> 	pop bx
   196                              <1> %endif
   197 000001A7 16                  <1> 	push ss
   198 000001A8 07                  <1> 	pop es
   199 000001A9 BF[0000]            <1> reloc	mov di, relocated(search_results)
   200                              <1> linkdatarelocation search_results
   201 000001AC 51                  <1> 	push cx
   202                              <1> %if ELD
   203                              <1> 	houdini
   204 000001AD B9[0000]            <1> reloc	mov cx, relocated(search_results_amount)
   205                              <1> linkdatarelocation search_results_amount
   206 000001B0 B8[0000]            <1> reloc	mov ax, relocated(0)
   207                              <1> linkdatarelocation build_option_PM
   208 000001B3 85C0                <1> 	test ax, ax
   209 000001B5 7402                <1> 	jz @F
   210 000001B7 89C8                <1> 	mov ax, cx
   211                              <1> @@:
   212 000001B9 01C9                <1> 	add cx, cx		; times 2
   213 000001BB 01C1                <1> 	add cx, ax		; PM: times 3, else: times 2
   214                              <1> %elif _PM
   215                              <1> 	mov cx, (6 * search_results_amount) >> 1
   216                              <1> %else
   217                              <1> 	mov cx, (4 * search_results_amount) >> 1
   218                              <1> %endif
   219 000001BD 31C0                <1> 	xor ax, ax
   220 000001BF A3[0000]            <1> reloc	mov word [relocated(sscounter)], ax
   221                              <1> linkdatarelocation sscounter
   222 000001C2 A3[0200]            <1> reloc	mov word [relocated(sscounter) + 2], ax
   223                              <1> linkdatarelocation sscounter
   224 000001C5 F3AB                <1> 	rep stosw
   225 000001C7 59                  <1> 	pop cx
   226                              <1> 
   227                              <1>  %if ELD
   228 000001C8 F606[8A00]03        <1> reloc	test byte [tagbuffer + 0], 3
   229                              <1> internaldatarelocation -3
   230 000001CD 7408                <1> 	jz .simple
   231                              <1> .difficult:
   232 000001CF B8[E405]            <1> reloc	mov ax, difficult_scasb
   233                              <1> internalcoderelocation
   234 000001D2 BF[D305]            <1> reloc	mov di, difficult_repne_scasb
   235                              <1> internalcoderelocation
   236 000001D5 EB06                <1> 	jmp @F
   237                              <1> 
   238                              <1> .simple:
   239 000001D7 B8[8005]            <1> reloc	mov ax, do_scasb
   240                              <1> internalcoderelocation
   241 000001DA BF[7905]            <1> reloc	mov di, do_repne_scasb
   242                              <1> internalcoderelocation
   243                              <1> @@:
   244 000001DD A3[E001]            <1> reloc	mov word [sss_scasb], ax
   245                              <1> internaldatarelocation
   246 000001E0 893E[DE01]          <1> reloc	mov word [sss_repne_scasb], di
   247                              <1> internaldatarelocation
   248                              <1> 
   249 000001E4 D006[E601]          <1> reloc	rol byte [sss_range_used], 1
   250                              <1> internaldatarelocation
   251 000001E8 7216                <1> 	jc .simple_match
   252 000001EA 31C0                <1> 	xor ax, ax
   253 000001EC BF[8A00]            <1> reloc	mov di, tagbuffer
   254                              <1> internaldatarelocation
   255 000001EF 51                  <1> 	push cx
   256 000001F0 B92600              <1> 	mov cx, words(tagbuffer.size)
   257 000001F3 F3AF                <1> 	repe scasw
   258 000001F5 59                  <1> 	pop cx
   259 000001F6 7408                <1> 	je .simple_match
   260                              <1> 
   261                              <1> .difficult_match:
   262 000001F8 C706[E201][9C05]    <1> reloc2	mov word [sss_repe_cmpsb], difficult_repe_cmpsb
   263                              <1> internaldatarelocation -4
   264                              <1> internalcoderelocation
   265 000001FE EB06                <1> 	jmp @F
   266                              <1> 
   267                              <1> .simple_match:
   268 00000200 A1[E401]            <1> reloc	mov ax, word [sss_repe_cmpsb_for_range]
   269                              <1> internaldatarelocation
   270 00000203 A3[E201]            <1> reloc	mov word [sss_repe_cmpsb], ax
   271                              <1> internaldatarelocation
   272                              <1> @@:
   273                              <1>  %endif
   274 00000206 E8[0000]EB020000    <1> 	extcall prephack	; set up for the interrupt vector hack
   275 0000020D E81806              <1> 	extcallcall dohack
   276 00000210 8EDB                <1> 	mov ds, bx
   277 00000212 5F                  <1> 	pop di			; original si
   278 00000213 07                  <1> 	pop es
   279                              <1>  %if ELD
   280 00000214 B8[0000]            <1> reloc	mov ax, relocated(0)
   281                              <1> linkdatarelocation build_option_PM
   282 00000217 85C0                <1> 	test ax, ax
   283 00000219 7403                <1> 	jz @F
   284                              <1>  %endif
   285 0000021B E97B01              <1> 	_386_PM_jmpn .386init	; 386 -->
   286                              <1> @@:
   287                              <1> .init:
   288                              <1>  %if ELD
   289 0000021E 66                  <1> 	_386_PM_o32		; pop ebx
   290 0000021F 5B                  <1> 	pop bx
   291 00000220 66                  <1> 	_386_PM_o32		; pop edx
   292 00000221 5A                  <1> 	pop dx
   293                              <1>  %else
   294                              <1> 	pop bx
   295                              <1> 	pop dx
   296                              <1>  %endif
   297                              <1> .init_popped:
   298 00000222 29D3                <1> 	sub bx, dx		; bx = number of bytes in search range minus one
   299 00000224 29CB                <1> 	sub bx, cx		; = number of possible positions of string minus 1
   300 00000226 7303E96401          <1> 	jb .error_unhack_di
   301 0000022B 89D7                <1> 	mov di, dx
   302 0000022D 89CA                <1> 	mov dx, cx
   303 0000022F 89D9                <1> 	mov cx, bx
   304                              <1> 
   305                              <1> 		; ds:si-> search string, length (dx+1)
   306                              <1> 		; es:di-> data to search in, (cx+1) bytes
   307                              <1> %if _SREVERSE
   308 00000231 36F606[0300]80      <1> reloc	testopt [ss:relocated(internalflags3)], dif3_sss_is_reverse
   309                              <1> linkdatarelocation internalflags3, -3
   310 00000237 751F                <1> 	jnz .reverse
   311                              <1> %endif
   312                              <1> .loop:
   313 00000239 0C01                <1> 	or al, 1		; NZ (iff cx==0, repne scasb doesn't change ZF)
   314 0000023B 56                  <1> 	push si
   315 0000023C AC                  <1> 	lodsb			; first character in al
   316                              <1>  %if ELD
   317 0000023D F8                  <1> _386_PM	clc
   318 0000023E 36FF16[DE01]        <1> reloc	call near [ss:sss_repne_scasb]
   319                              <1> internaldatarelocation
   320                              <1>  %else
   321                              <1> 	repne scasb		; look for first byte
   322                              <1>  %endif
   323 00000243 740D                <1> 	je .foundbyte
   324                              <1>  %if ELD
   325 00000245 F8                  <1> _386_PM	clc
   326 00000246 36FF16[E001]        <1> reloc	call near [ss:sss_scasb]
   327                              <1> internaldatarelocation
   328                              <1>  %else
   329                              <1> 	scasb			; count in cx was cnt-1
   330                              <1>  %endif
   331 0000024B 753F                <1> 	jne .done
   332                              <1> .found_last_byte:
   333 0000024D E86000              <1> 	call .handle_found_byte
   334 00000250 EB3A                <1> 	jmp .done
   335                              <1> 
   336                              <1> .foundbyte:
   337 00000252 E85B00              <1> 	call .handle_found_byte
   338 00000255 5E                  <1> 	pop si
   339 00000256 EBE1                <1> 	jmp .loop		; cx = 0 if one to search,
   340                              <1> 				;  cx = 1 if two to search, etc
   341                              <1> 
   342                              <1> %if _SREVERSE
   343                              <1> .reverse:
   344 00000258 01CF                <1> 	add di, cx		; -> last position to check
   345                              <1> .reverseloop:
   346 0000025A 0C01                <1> 	or al, 1		; NZ (iff cx==0, repne scasb doesn't change ZF)
   347 0000025C 56                  <1> 	push si
   348 0000025D AC                  <1> 	lodsb			; first character in al
   349 0000025E FD                  <1> 	std			; no AMD erratum workaround needed
   350                              <1>  %if ELD
   351 0000025F F8                  <1> _386_PM	clc
   352 00000260 36FF16[DE01]        <1> reloc	call near [ss:sss_repne_scasb]
   353                              <1> internaldatarelocation
   354                              <1>  %else
   355                              <1> 	repne scasb		; look for first byte
   356                              <1>  %endif
   357 00000265 7416                <1> 	je .reversefoundbyte
   358                              <1>  %if ELD
   359 00000267 F8                  <1> _386_PM	clc
   360 00000268 36FF16[E001]        <1> reloc	call near [ss:sss_scasb]
   361                              <1> internaldatarelocation
   362                              <1>  %else
   363                              <1> 	scasb			; count in cx was cnt-1
   364                              <1>  %endif
   365 0000026D 751D                <1> 	jne .done
   366                              <1> .reversefound_last_byte:
   367 0000026F FC                  <1> 	cld
   368 00000270 83C702              <1> 	add di, 2
   369 00000273 38C0                <1> 	cmp al, al		; ZR for case if dx = 0
   370 00000275 E83800              <1> 	call .handle_found_byte
   371 00000278 83EF02              <1> 	sub di, 2
   372 0000027B EB0F                <1> 	jmp .done
   373                              <1> 
   374                              <1> .reversefoundbyte:
   375 0000027D FC                  <1> 	cld
   376 0000027E 83C702              <1> 	add di, 2
   377 00000281 38C0                <1> 	cmp al, al		; ZR for case if dx = 0
   378 00000283 E82A00              <1> 	call .handle_found_byte
   379 00000286 83EF02              <1> 	sub di, 2
   380 00000289 5E                  <1> 	pop si
   381 0000028A EBCE                <1> 	jmp .reverseloop	; cx = 0 if one to search,
   382                              <1> 				;  cx = 1 if two to search, etc
   383                              <1> %endif
   384                              <1> 
   385                              <1> .done:
   386 0000028C 5E                  <1> 	pop si			; discard
   387                              <1> .commondone:
   388 0000028D FC                  <1> 	cld
   389 0000028E 16                  <1> 	push ss
   390 0000028F 1F                  <1> 	pop ds
   391 00000290 E89D05              <1> 	extcallcall unhack
   392 00000293 BF[0000]            <1> reloc	mov di, relocated(line_out)
   393                              <1> linkdatarelocation line_out
   394                              <1> 
   395 00000296 A1[0200]            <1> reloc	mov ax, word [relocated(sscounter) + 2]
   396                              <1> linkdatarelocation sscounter
   397 00000299 85C0                <1> 	test ax, ax
   398 0000029B 7403                <1> 	jz .nohighcounter
   399 0000029D E89805              <1> 	extcallcall hexword
   400                              <1> .nohighcounter:
   401                              <1> 
   402 000002A0 A1[0000]            <1> reloc	mov ax, word [relocated(sscounter)]
   403                              <1> linkdatarelocation sscounter
   404 000002A3 E89205              <1> 	extcallcall hexword
   405 000002A6 E89705              <1> 	extcallcall putsline
   406 000002A9 BA[4400]            <1> reloc	mov dx, msg.matches
   407                              <1> internaldatarelocation
   408                              <1> %if ELD
   409 000002AC E84905              <1> 	extcallcall putsz
   410 000002AF C3                  <1> 	retn
   411                              <1> %else
   412                              <1> 	jmp putsz
   413                              <1> %endif
   414                              <1> 
   415                              <1> 
   416                              <1> 		; INP:	ZR
   417                              <1> .handle_found_byte:
   418 000002B0 51                  <1> 	push cx
   419 000002B1 57                  <1> 	push di
   420 000002B2 89D1                <1> 	mov cx, dx
   421                              <1>  %if ELD
   422 000002B4 F8                  <1> _386_PM	clc
   423 000002B5 36FF16[E201]        <1> reloc	call near [ss:sss_repe_cmpsb]
   424                              <1> internaldatarelocation
   425                              <1>  %else
   426                              <1> 	repe cmpsb		; compare string behind first byte
   427                              <1>  %endif
   428                              <1> 		; If we're searching for a single-byte value then
   429                              <1> 		;  dx is equal to zero here. In that case cx gets
   430                              <1> 		;  the value zero and then repe cmpsb does not
   431                              <1> 		;  alter ZF, meaning it will stay ZR (as noted for
   432                              <1> 		;  the comment INP section).
   433 000002BA 5F                  <1> 	pop di
   434 000002BB 7402                <1> 	je .display		; if equal
   435                              <1> .next:
   436 000002BD 59                  <1> 	pop cx
   437 000002BE C3                  <1> 	retn
   438                              <1> 
   439                              <1> .display:
   440 000002BF 8CC3                <1> 	mov bx, es
   441 000002C1 57                  <1> 	push di
   442 000002C2 1E                  <1> 	push ds
   443 000002C3 06                  <1> 	push es
   444 000002C4 16                  <1> 	 push ss
   445 000002C5 1F                  <1> 	 pop ds
   446 000002C6 E86705              <1> 	extcallcall unhack	; undo the interrupt vector hack and restore es
   447 000002C9 57                  <1> 	push di
   448 000002CA 833E[0200]00        <1> reloc	cmp word [relocated(sscounter) + 2], strict byte 0
   449                              <1> linkdatarelocation sscounter, -3
   450 000002CF 752E                <1> 	jne @F
   451 000002D1 8B3E[0000]          <1> reloc	mov di, word [relocated(sscounter)]
   452                              <1> linkdatarelocation sscounter
   453 000002D5 81FF[0000]          <1> reloc	cmp di, strict word relocated(search_results_amount)
   454                              <1> linkdatarelocation search_results_amount
   455 000002D9 7324                <1> 	jae @F
   456                              <1> %if ELD && _PM
   457 000002DB B8[0000]            <1> reloc	mov ax, relocated(0)
   458                              <1> linkdatarelocation build_option_PM
   459 000002DE 01FF                <1> 	add di, di		; times 2
   460 000002E0 85C0                <1> 	test ax, ax		; PM build ?
   461 000002E2 7402                <1> 	jz .idxnotpm		; no --> (ax == zero)
   462 000002E4 89F8                <1> 	mov ax, di		; = times 2
   463                              <1> .idxnotpm:
   464 000002E6 01FF                <1> 	add di, di		; times 4
   465 000002E8 01C7                <1> 	add di, ax		; _PM: times 4 + times 2 = times 6, else: times 4
   466                              <1> %elif _PM
   467                              <1> 	add di, di		; times 2
   468                              <1> 	mov ax, di		; = times 2
   469                              <1> 	add di, di		; times 4
   470                              <1> 	add di, ax		; times 4 + times 2 = times 6
   471                              <1> %else
   472                              <1> 	add di, di		; times 2
   473                              <1> 	add di, di		; times 4
   474                              <1> %endif
   475 000002EA 81C7[0000]          <1> reloc	add di, strict word relocated(search_results)
   476                              <1> linkdatarelocation search_results
   477                              <1> 
   478 000002EE 58                  <1> 	pop ax
   479 000002EF 50                  <1> 	push ax
   480 000002F0 48                  <1> 	dec ax
   481 000002F1 AB                  <1> 	stosw
   482                              <1> %if _PM
   483                              <1>  %if ELD
   484 000002F2 B8[0000]            <1> reloc	mov ax, relocated(0)
   485                              <1> linkdatarelocation build_option_PM
   486 000002F5 85C0                <1> 	test ax, ax
   487 000002F7 7403                <1> 	jz .storenotpm
   488                              <1>  %endif
   489 000002F9 31C0                <1> 	xor ax, ax
   490 000002FB AB                  <1> 	stosw
   491                              <1> .storenotpm:
   492                              <1> %endif
   493 000002FC 89D8                <1> 	mov ax, bx
   494 000002FE AB                  <1> 	stosw
   495                              <1> 
   496                              <1> @@:
   497 000002FF 8306[0000]01        <1> reloc	add word [relocated(sscounter)], strict byte 1
   498                              <1> linkdatarelocation sscounter, -3
   499 00000304 8316[0200]00        <1> reloc	adc word [relocated(sscounter) + 2], strict byte 0
   500                              <1> linkdatarelocation sscounter, -3
   501 00000309 D006[0000]          <1> reloc	rol byte [relocated(sss_silent_count_used)], 1
   502                              <1> linkdatarelocation sss_silent_count_used
   503 0000030D 7317                <1> 	jnc @F
   504 0000030F A1[0000]            <1> reloc	mov ax, word [relocated(sss_silent_count)]
   505                              <1> linkdatarelocation sss_silent_count
   506 00000312 0B06[0200]          <1> reloc	or ax, word [relocated(sss_silent_count) + 2]
   507                              <1> linkdatarelocation sss_silent_count
   508 00000316 58                  <1> 	pop ax
   509 00000317 52                  <1> 	push dx
   510 00000318 746B                <1> 	jz .nodisplay
   511 0000031A 5A                  <1> 	pop dx
   512 0000031B 50                  <1> 	push ax
   513 0000031C 832E[0000]01        <1> reloc	sub word [relocated(sss_silent_count)], strict byte 1
   514                              <1> linkdatarelocation sss_silent_count, -3
   515 00000321 831E[0200]00        <1> reloc	sbb word [relocated(sss_silent_count) + 2], strict byte 0
   516                              <1> linkdatarelocation sss_silent_count, -3
   517                              <1> @@:
   518 00000326 89D8                <1> 	mov ax, bx
   519 00000328 BF[0000]            <1> reloc	mov di, relocated(line_out)
   520                              <1> linkdatarelocation line_out
   521 0000032B E80A05              <1> 	extcallcall hexword	; 4 (segment)
   522 0000032E B03A                <1> 	mov al, ':'
   523 00000330 AA                  <1> 	stosb			; +1=5
   524 00000331 58                  <1> 	pop ax
   525 00000332 48                  <1> 	dec ax
   526 00000333 E80205              <1> 	extcallcall hexword
   527                              <1> %if _SDUMP
   528 00000336 F606[0200]80        <1> reloc	testopt [relocated(options)], ss_no_dump
   529                              <1> linkdatarelocation options, -3
   530 0000033B 7544                <1> 	jnz .no_dump
   531 0000033D F9                  <1> 	stc
   532 0000033E 11D0                <1> 	adc ax, dx		; -> behind result
   533 00000340 763F                <1> 	jbe .noresult		; end of segment
   534 00000342 89C6                <1> 	mov si, ax		; cannot be zero
   535                              <1> 
   536                              <1> %if _SDUMPDISPLACEMENT
   537 00000344 660FB7D2            <1> _386_PM	movzx edx, dx
   538 00000348 E8CF01              <1> 	call sss_calculate_displacement
   539                              <1> 
   540 0000034B 89FB                <1> 	mov bx, di
   541 0000034D 01C3                <1> 	add bx, ax
   542 0000034F 01C3                <1> 	add bx, ax
   543 00000351 01C3                <1> 	add bx, ax
   544                              <1> %else
   545                              <1> 	mov ax, 32<<8|32
   546                              <1> 	stosw
   547                              <1> 	lea bx, [di+3*16]
   548                              <1> %endif
   549                              <1> 
   550 00000353 89F1                <1> 	mov cx, si		; cannot be zero
   551 00000355 F7D9                <1> 	neg cx			; cannot be zero
   552                              <1> %if _SDUMPDISPLACEMENT
   553 00000357 39C1                <1> 	cmp cx, ax
   554                              <1> %else
   555                              <1> 	cmp cx, byte 16
   556                              <1> %endif
   557 00000359 7602                <1> 	jbe .cxdone
   558                              <1> %if _SDUMPDISPLACEMENT
   559 0000035B 89C1                <1> 	mov cx, ax
   560                              <1> %else
   561                              <1> 	mov cx, 16
   562                              <1> %endif
   563                              <1> .cxdone:			; cx cannot be zero
   564 0000035D 1F                  <1> 	 pop ds
   565 0000035E 1E                  <1> 	 push ds		; restore search's segment
   566                              <1> %if _SDUMPDISPLACEMENT
   567 0000035F 50                  <1> 	push ax
   568                              <1> %endif
   569 00000360 51                  <1> 	push cx
   570                              <1> .disploop:
   571 00000361 AC                  <1> 	lodsb
   572 00000362 E8E304              <1> 	extcallcall dd_store
   573 00000365 B020                <1> 	mov al, 32
   574 00000367 AA                  <1> 	stosb
   575 00000368 E2F7                <1> 	loop .disploop
   576 0000036A 59                  <1> 	pop cx
   577                              <1> %if _SDUMPDISPLACEMENT
   578 0000036B 58                  <1> 	pop ax
   579                              <1> %endif
   580 0000036C 16                  <1> 	 push ss
   581 0000036D 1F                  <1> 	 pop ds
   582 0000036E F7D9                <1> 	neg cx
   583                              <1> %if _SDUMPDISPLACEMENT
   584 00000370 01C1                <1> 	add cx, ax
   585                              <1> %else
   586                              <1> 	add cx, byte 16
   587                              <1> %endif
   588 00000372 7407                <1> 	jz .noblanks
   589                              <1> .loopblanks:
   590 00000374 B82020              <1> 	mov ax, 32<<8|32
   591 00000377 AB                  <1> 	stosw
   592 00000378 AA                  <1> 	stosb
   593 00000379 E2F9                <1> 	loop .loopblanks
   594                              <1> .noblanks:
   595 0000037B C645E72D            <1> 	mov byte [di-(1+(8*3))], '-'
   596 0000037F 89DF                <1> 	mov di, bx
   597                              <1> .noresult:
   598                              <1> .no_dump:
   599                              <1> %endif	; _SDUMP
   600 00000381 52                  <1> 	push dx
   601 00000382 E8CB04              <1> 	extcallcall putsline_crlf
   602                              <1> .nodisplay:
   603 00000385 E8A004              <1> 	extcallcall dohack
   604 00000388 5A                  <1> 	pop dx
   605 00000389 07                  <1> 	pop es
   606 0000038A 1F                  <1> 	pop ds
   607 0000038B 5F                  <1> 	pop di
   608 0000038C E92EFF              <1> 	jmp .next
   609                              <1> 
   610                              <1> 
   611                              <1> .error_unhack_di:
   612 0000038F 16                  <1> 	push ss
   613 00000390 1F                  <1> 	pop ds
   614 00000391 E89C04              <1> 	extcallcall unhack
   615 00000394 89FE                <1> 	mov si, di
   616 00000396 E92A04              <1> 	jmp error
   617                              <1> 
   618                              <1> 
   619                              <1> %if _PM
   620                              <1> 	subcpu 386
   621                              <1> 
   622                              <1> .386init:
   623 00000399 665B                <1> 	pop ebx
   624 0000039B 665A                <1> 	pop edx
   625 0000039D E85004              <1> 	extcallcall ispm
   626 000003A0 0F857EFE            <1> 	jnz .init_popped	; not PM -->
   627 000003A4 6629D3              <1> 	sub ebx, edx		; ebx = number of bytes in search range minus one
   628 000003A7 6629CB              <1> 	sub ebx, ecx		; = number of possible positions of string minus 1
   629 000003AA 72E3                <1> 	jb .error_unhack_di
   630 000003AC 6689D7              <1> 	mov edi, edx
   631 000003AF 6689CA              <1> 	mov edx, ecx
   632 000003B2 6689D9              <1> 	mov ecx, ebx
   633                              <1> 
   634                              <1> 		; ds:esi-> search string, length (edx+1)
   635                              <1> 		; es:edi-> data to search in, (ecx+1) bytes
   636                              <1> 		; Although 386+ RM still uses 64 KiB segments, it allows
   637                              <1> 		; us to use the 32-bit addressing variant of the string
   638                              <1> 		; instructions as long as we never access any byte above
   639                              <1> 		; the 64 KiB limit. (Even if the index register contains
   640                              <1> 		; 00010000h after an instruction executed.)
   641                              <1> %if _SREVERSE
   642 000003B5 36F606[0300]80      <1> reloc	testopt [ss:relocated(internalflags3)], dif3_sss_is_reverse
   643                              <1> linkdatarelocation internalflags3, -3
   644 000003BB 7522                <1> 	jnz .386reverse
   645                              <1> %endif
   646                              <1> .386loop:
   647 000003BD 0C01                <1> 	or al, 1		; NZ (iff cx==0, repne scasb doesn't change ZF)
   648 000003BF 6656                <1> 	push esi
   649 000003C1 67AC                <1> 	a32 lodsb		; first character in al
   650                              <1>  %if ELD
   651 000003C3 F9                  <1> _386_PM	stc
   652 000003C4 36FF16[DE01]        <1> reloc	call near [ss:sss_repne_scasb]
   653                              <1> internaldatarelocation
   654                              <1>  %else
   655                              <1> 	a32 repne scasb		; look for first byte
   656                              <1>  %endif
   657 000003C9 740D                <1> 	je .386foundbyte
   658                              <1>  %if ELD
   659 000003CB F9                  <1> _386_PM	stc
   660 000003CC 36FF16[E001]        <1> reloc	call near [ss:sss_scasb]
   661                              <1> internaldatarelocation
   662                              <1>  %else
   663                              <1> 	a32 scasb		; count in ecx was cnt-1
   664                              <1>  %endif
   665 000003D1 7548                <1> 	jne .386done
   666                              <1> .386found_last_byte:
   667 000003D3 E84A00              <1> 	call .386handle_found_byte
   668 000003D6 EB43                <1> 	jmp .386done
   669                              <1> 
   670                              <1> .386foundbyte:
   671 000003D8 E84500              <1> 	call .386handle_found_byte
   672 000003DB 665E                <1> 	pop esi
   673 000003DD EBDE                <1> 	jmp .386loop		; ecx = 0 if one to search,
   674                              <1> 				;  ecx = 1 if two to search, etc
   675                              <1> 
   676                              <1> %if _SREVERSE
   677                              <1> .386reverse:
   678 000003DF 6601CF              <1> 	add edi, ecx		; -> last position to check
   679                              <1> .386reverseloop:
   680 000003E2 0C01                <1> 	or al, 1		; NZ (iff cx==0, repne scasb doesn't change ZF)
   681 000003E4 6656                <1> 	push esi
   682 000003E6 67AC                <1> 	a32 lodsb		; first character in al
   683 000003E8 FD                  <1> 	std			; no AMD erratum workaround needed
   684                              <1>  %if ELD
   685 000003E9 F9                  <1> _386_PM	stc
   686 000003EA 36FF16[DE01]        <1> reloc	call near [ss:sss_repne_scasb]
   687                              <1> internaldatarelocation
   688                              <1>  %else
   689                              <1> 	a32 repne scasb		; look for first byte
   690                              <1>  %endif
   691 000003EF 7418                <1> 	je .386reversefoundbyte
   692                              <1>  %if ELD
   693 000003F1 F9                  <1> _386_PM	stc
   694 000003F2 36FF16[E001]        <1> reloc	call near [ss:sss_scasb]
   695                              <1> internaldatarelocation
   696                              <1>  %else
   697                              <1> 	a32 scasb		; count in ecx was cnt-1
   698                              <1>  %endif
   699 000003F7 7522                <1> 	jne .386done
   700                              <1> .386reversefound_last_byte:
   701 000003F9 FC                  <1> 	cld
   702 000003FA 6683C702            <1> 	add edi, 2
   703 000003FE 38C0                <1> 	cmp al, al		; ZR for case if edx = 0
   704 00000400 E81D00              <1> 	call .386handle_found_byte
   705 00000403 6683EF02            <1> 	sub edi, 2
   706 00000407 EB12                <1> 	jmp .386done
   707                              <1> 
   708                              <1> .386reversefoundbyte:
   709 00000409 FC                  <1> 	cld
   710 0000040A 6683C702            <1> 	add edi, 2
   711 0000040E 38C0                <1> 	cmp al, al		; ZR for case if edx = 0
   712 00000410 E80D00              <1> 	call .386handle_found_byte
   713 00000413 6683EF02            <1> 	sub edi, 2
   714 00000417 665E                <1> 	pop esi
   715 00000419 EBC7                <1> 	jmp .386reverseloop	; ecx = 0 if one to search,
   716                              <1> 				;  ecx = 1 if two to search, etc
   717                              <1> %endif
   718                              <1> 
   719                              <1> .386done:
   720 0000041B 665E                <1> 	pop esi			; discard
   721 0000041D E96DFE              <1> 	jmp .commondone
   722                              <1> 
   723                              <1> 
   724                              <1> 		; INP:	ZR
   725                              <1> .386handle_found_byte:
   726 00000420 6651                <1> 	push ecx
   727 00000422 6657                <1> 	push edi
   728 00000424 6689D1              <1> 	mov ecx, edx
   729                              <1>  %if ELD
   730 00000427 F9                  <1> _386_PM	stc
   731 00000428 36FF16[E201]        <1> reloc	call near [ss:sss_repe_cmpsb]
   732                              <1> internaldatarelocation
   733                              <1>  %else
   734                              <1> 	a32 repe cmpsb		; compare string behind first byte
   735                              <1>  %endif
   736                              <1> 		; If we're searching for a single-byte value then
   737                              <1> 		;  edx is equal to zero here. In that case ecx gets
   738                              <1> 		;  the value zero and then a32 repe cmpsb does not
   739                              <1> 		;  alter ZF, meaning it will stay ZR (as noted for
   740                              <1> 		;  the comment INP section).
   741 0000042D 665F                <1> 	pop edi
   742 0000042F 7403                <1> 	je .386display		; if equal
   743                              <1> .386next:
   744 00000431 6659                <1> 	pop ecx
   745 00000433 C3                  <1> 	retn
   746                              <1> 
   747                              <1> .386display:
   748 00000434 8CC3                <1> 	mov bx, es
   749 00000436 6657                <1> 	push edi
   750 00000438 1E                  <1> 	push ds
   751 00000439 06                  <1> 	push es
   752 0000043A 16                  <1> 	 push ss
   753 0000043B 1F                  <1> 	 pop ds
   754 0000043C E8F103              <1> 	extcallcall unhack	; undo the interrupt vector hack and restore es
   755 0000043F 6657                <1> 	push edi
   756 00000441 668B3E[0000]        <1> reloc	mov edi, dword [relocated(sscounter)]
   757                              <1> linkdatarelocation sscounter
   758 00000446 6681FF[00000000]    <1> reloc	cmp edi, strict dword relocated(search_results_amount)
   759                              <1> linkdatarelocation search_results_amount, -4	; low word of the dword !
   760 0000044D 7317                <1> 	jae @F
   761 0000044F 01FF                <1> 	add di, di		; * 2
   762 00000451 89F8                <1> 	mov ax, di
   763 00000453 01FF                <1> 	add di, di		; * 4
   764 00000455 01C7                <1> 	add di, ax		; * 4 + * 2 = * 6
   765 00000457 81C7[0000]          <1> reloc	add di, relocated(search_results)
   766                              <1> linkdatarelocation search_results
   767 0000045B 6658                <1> 	pop eax
   768 0000045D 6650                <1> 	push eax
   769 0000045F 6648                <1> 	dec eax
   770 00000461 66AB                <1> 	stosd
   771 00000463 89D8                <1> 	mov ax, bx
   772 00000465 AB                  <1> 	stosw
   773                              <1> 
   774                              <1> @@:
   775 00000466 66FF06[0000]        <1> reloc	inc dword [relocated(sscounter)]
   776                              <1> linkdatarelocation sscounter
   777 0000046B D006[0000]          <1> reloc	rol byte [relocated(sss_silent_count_used)], 1
   778                              <1> linkdatarelocation sss_silent_count_used
   779 0000046F 731A                <1> 	jnc @F
   780 00000471 66833E[0000]00      <1> reloc	cmp dword [relocated(sss_silent_count)], strict byte 0
   781                              <1> linkdatarelocation sss_silent_count, -3
   782 00000477 6658                <1> 	pop eax
   783 00000479 52                  <1> 	push dx
   784 0000047A 0F849100            <1> 	je .386nodisplay
   785 0000047E 5A                  <1> 	pop dx
   786 0000047F 6650                <1> 	push eax
   787 00000481 832E[0000]01        <1> reloc	sub word [relocated(sss_silent_count)], strict byte 1
   788                              <1> linkdatarelocation sss_silent_count, -3
   789 00000486 831E[0200]00        <1> reloc	sbb word [relocated(sss_silent_count) + 2], strict byte 0
   790                              <1> linkdatarelocation sss_silent_count, -3
   791                              <1> @@:
   792 0000048B 89D8                <1> 	mov ax, bx
   793 0000048D BF[0000]            <1> reloc	mov di, relocated(line_out)
   794                              <1> linkdatarelocation line_out
   795 00000490 E8A503              <1> 	extcallcall hexword	; 4 (segment)
   796 00000493 B03A                <1> 	mov al, ':'
   797 00000495 AA                  <1> 	stosb			; +1=5
   798 00000496 6658                <1> 	pop eax
   799 00000498 6648                <1> 	dec eax
   800 0000049A E8BB03              <1> 	extcallcall test_high_limit
   801 0000049D 7407                <1> 	jz .noa32
   802 0000049F E8[0000]EB020000    <1> 	extcall hexword_high, PM required
   803                              <1> .noa32:
   804 000004A6 E88F03              <1> 	extcallcall hexword
   805                              <1> %if _SDUMP
   806 000004A9 F606[0200]80        <1> reloc	testopt [relocated(options)], ss_no_dump
   807                              <1> linkdatarelocation options, -3
   808 000004AE 755B                <1> 	jnz .386_no_dump
   809 000004B0 F9                  <1> 	stc
   810 000004B1 6611D0              <1> 	adc eax, edx		; -> behind result
   811 000004B4 7655                <1> 	jbe .386noresult	; end of segment
   812 000004B6 6689C6              <1> 	mov esi, eax
   813                              <1> 		; esi is at most 10000h in a 64 KiB segment.
   814                              <1> 		;  The jcxz at .386cxdone will branch if si = 0,
   815                              <1> 		;  which is only possible if esi = 10000h.
   816                              <1> 		; esi is never zero here.
   817                              <1> 
   818                              <1> %if _SDUMPDISPLACEMENT
   819 000004B9 E85E00              <1> 	call sss_calculate_displacement
   820                              <1> %else
   821                              <1> 	mov ax, 32<<8|32
   822                              <1> 	stosw
   823                              <1> %endif
   824                              <1> 
   825 000004BC 5B                  <1> 	pop bx			; get search selector
   826 000004BD 53                  <1> 	push bx
   827 000004BE E89703              <1> 	extcallcall test_high_limit
   828 000004C1 7508                <1> 	jnz .386_high_limit
   829                              <1> 
   830                              <1> .386_low_limit:
   831 000004C3 89F1                <1> 	mov cx, si		; 0 if at end of 64 KiB limit, else nonzero
   832 000004C5 F7D9                <1> 	neg cx			; 0 if at end of 64 KiB limit, else nonzero
   833                              <1> %if _SDUMPDISPLACEMENT
   834 000004C7 39C1                <1> 	cmp cx, ax
   835                              <1> %else
   836                              <1> 	cmp cx, byte 16		; below or equal maximum dump length ?
   837                              <1> %endif
   838 000004C9 EB0D                <1> 	jmp @F
   839                              <1> 
   840                              <1> .386_high_limit:
   841 000004CB 6689F1              <1> 	mov ecx, esi		; cannot be 0
   842 000004CE 66F7D9              <1> 	neg ecx			; cannot be 0
   843                              <1> %if _SDUMPDISPLACEMENT
   844 000004D1 660FB7C0            <1> 	movzx eax, ax
   845 000004D5 6639C1              <1> 	cmp ecx, eax
   846                              <1> %else
   847                              <1> 	cmp ecx, byte 16	; below or equal maximum dump length ?
   848                              <1> %endif
   849                              <1> @@:
   850 000004D8 7602                <1> 	jbe .386cxdone		; (e)cx <= maximum dump length, use cx
   851                              <1> %if _SDUMPDISPLACEMENT
   852 000004DA 89C1                <1> 	mov cx, ax
   853                              <1> %else
   854                              <1> 	mov cx, 16		; reset cx (ecxh is not used)
   855                              <1> %endif
   856                              <1> .386cxdone:
   857 000004DC E32D                <1> 	jcxz .386noresult	; if at end of 64 KiB limit -->
   858                              <1> 		; (The displacement is already written here. Oh well.)
   859                              <1> %if _SDUMPDISPLACEMENT
   860 000004DE 89FB                <1> 	mov bx, di
   861 000004E0 01C3                <1> 	add bx, ax
   862 000004E2 01C3                <1> 	add bx, ax
   863 000004E4 01C3                <1> 	add bx, ax
   864                              <1> %else
   865                              <1> 	lea bx, [di+3*16]
   866                              <1> %endif
   867 000004E6 1F                  <1> 	 pop ds
   868 000004E7 1E                  <1> 	 push ds		; restore search's segment
   869                              <1> %if _SDUMPDISPLACEMENT
   870 000004E8 50                  <1> 	push ax
   871                              <1> %endif
   872 000004E9 51                  <1> 	push cx
   873                              <1> .386disploop:
   874 000004EA 67AC                <1> 	a32 lodsb
   875 000004EC E85903              <1> 	extcallcall dd_store
   876 000004EF B020                <1> 	mov al, 32
   877 000004F1 AA                  <1> 	stosb
   878 000004F2 E2F6                <1> 	loop .386disploop
   879 000004F4 59                  <1> 	pop cx
   880                              <1> %if _SDUMPDISPLACEMENT
   881 000004F5 58                  <1> 	pop ax
   882                              <1> %endif
   883 000004F6 16                  <1> 	 push ss
   884 000004F7 1F                  <1> 	 pop ds
   885 000004F8 F7D9                <1> 	neg cx
   886                              <1> %if _SDUMPDISPLACEMENT
   887 000004FA 01C1                <1> 	add cx, ax
   888                              <1> %else
   889                              <1> 	add cx, byte 16
   890                              <1> %endif
   891 000004FC 7407                <1> 	jz .386noblanks
   892                              <1> .386loopblanks:
   893 000004FE B82020              <1> 	mov ax, 32<<8|32
   894 00000501 AB                  <1> 	stosw
   895 00000502 AA                  <1> 	stosb
   896 00000503 E2F9                <1> 	loop .386loopblanks
   897                              <1> .386noblanks:
   898 00000505 C645E72D            <1> 	mov byte [di-(1+(8*3))], '-'
   899 00000509 89DF                <1> 	mov di, bx
   900                              <1> .386noresult:
   901                              <1> .386_no_dump:
   902                              <1> %endif	; _SDUMP
   903 0000050B 52                  <1> 	push dx
   904 0000050C E84103              <1> 	extcallcall putsline_crlf
   905                              <1> .386nodisplay:
   906 0000050F E81603              <1> 	extcallcall dohack
   907 00000512 5A                  <1> 	pop dx
   908 00000513 07                  <1> 	pop es
   909 00000514 1F                  <1> 	pop ds
   910 00000515 665F                <1> 	pop edi
   911 00000517 E917FF              <1> 	jmp .386next
   912                              <1> 
   913                              <1> subcpureset
   914                              <1> %endif	; _PM
   915                              <1> 
   916                              <1> 
   917                              <1> %if _SDUMPDISPLACEMENT
   918                              <1> 
   919                              <1> 		; INP:	(e)dx = length of pattern - 1
   920                              <1> 		;	es:di -> where to write, within line_out
   921                              <1> 		;	di <= line_out + 13
   922                              <1> 		;	di >= line_out + 9
   923                              <1> 		; OUT:	bx = table offset
   924                              <1> 		;	ax = how many bytes to dump (13 .. 16)
   925                              <1> 		; CHG:	-
   926                              <1> sss_calculate_displacement:
   927                              <1> 
   928 0000051A 31DB                <1> 	xor bx, bx
   929 0000051C 66                  <1> 	_386_PM_o32
   930 0000051D 42                  <1> 	inc dx			; = pattern length (can overflow)
   931 0000051E B306                <1> _386_PM	mov bl, 6		; dword needed
   932 00000520 66F7C2000000FF      <1> _386_PM	test edx, 0FF00_0000h
   933 00000527 7513                <1> _386_PM	jnz @F
   934 00000529 B304                <1> _386_PM	mov bl, 4		; 3byte needed
   935 0000052B 66F7C20000FF00      <1> _386_PM	test edx, 0FF_0000h
   936 00000532 7508                <1> _386_PM	jnz @F
   937 00000534 B302                <1> 	mov bl, 2		; word needed
   938 00000536 84F6                <1> 	test dh, dh
   939 00000538 7502                <1> 	jnz @F
   940 0000053A B300                <1> 	mov bl, 0		; byte needed
   941                              <1> @@:
   942                              <1> 
   943 0000053C B8202B              <1> 	mov ax, " +"
   944 0000053F AB                  <1> 	stosw			; common prefix
   945 00000540 66                  <1> 	_386_PM_o32
   946 00000541 89D0                <1> 	mov ax, dx
   947 00000543 FF97[0000]          <1> reloc	call near [word sss_displacement_write_table + bx]
   948                              <1> internaldatarelocation
   949                              <1> 				; write displacement number
   950 00000547 66                  <1> 	_386_PM_o32
   951 00000548 4A                  <1> 	dec dx			; restore
   952                              <1> 
   953 00000549 B82020              <1> 	mov ax, 32 | 32 << 8
   954 0000054C AB                  <1> 	stosw			; write blanks
   955 0000054D 89F8                <1> 	mov ax, di
   956 0000054F 2D[0000]            <1> reloc	sub ax, strict word relocated(line_out)
   957                              <1> linkdatarelocation line_out	; = length written so far (<= 25, >= 15)
   958 00000552 F7D8                <1> 	neg ax			; minus length written so far (>= -25, <= -15)
   959 00000554 83C04F              <1> 	add ax, 79		; 79 minus length written so far
   960                              <1> 				;  = how many columns remaining (>= 54, <= 64)
   961 00000557 D1E8                <1> 	shr ax, 1
   962 00000559 D1E8                <1> 	shr ax, 1		; divide by 4 (>= 13, <= 16)
   963                              <1> 				;  = how many bytes can be dumped
   964 0000055B C3                  <1> 	retn
   965                              <1> 
   966                              <1> 
   967                              <1> 	usesection lDEBUG_DATA_ENTRY
   968                              <1> 	align 2, db 0
   969                              <1> sss_displacement_write_table:
   970 00000000 [5C05]              <1> reloc	dw .byte
   971                              <1> internalcoderelocation
   972 00000002 [6005]              <1> reloc	dw .word
   973                              <1> internalcoderelocation
   974                              <1>  %if _PM && ! _ONLYNON386
   975 00000004 [6405]              <1> reloc	dw .3byte
   976                              <1> internalcoderelocation
   977 00000006 [7105]              <1> reloc	dw .dword
   978                              <1> internalcoderelocation
   979                              <1>  %endif
   980                              <1> 
   981                              <1> 	usesection lDEBUG_CODE
   982                              <1> 
   983                              <1>  %if ELD
   984                              <1> .byte:
   985 0000055C E80103              <1> 	extcallcall hexbyte
   986 0000055F C3                  <1> 	retn
   987                              <1> .word:
   988 00000560 E8D502              <1> 	extcallcall hexword
   989 00000563 C3                  <1> 	retn
   990                              <1>   %if _PM && ! _ONLYNON386
   991                              <1> .3byte:
   992                              <1>  subcpu 386
   993 00000564 66C1C810            <1> 	ror eax, 16
   994 00000568 E8F502              <1> 	extcallcall hexbyte
   995 0000056B 66C1C010            <1> 	rol eax, 16
   996                              <1>  subcpureset
   997 0000056F EBEF                <1> 	jmp .word
   998                              <1> .dword:
   999 00000571 E8[0000]EB020000    <1> 	extcall hexdword, PM required
  1000 00000578 C3                  <1> 	retn
  1001                              <1>   %endif
  1002                              <1>  %else
  1003                              <1> .byte: equ hexbyte
  1004                              <1> .word: equ hexword
  1005                              <1>   %if _PM && ! _ONLYNON386
  1006                              <1> .3byte:
  1007                              <1>  subcpu 386
  1008                              <1> 	ror eax, 16
  1009                              <1> 	call hexbyte
  1010                              <1> 	rol eax, 16
  1011                              <1>  subcpureset
  1012                              <1> 	jmp .word
  1013                              <1> .dword: equ hexdword
  1014                              <1>   %endif
  1015                              <1>  %endif
  1016                              <1> %endif
  1017                              <1> 
  1018                              <1> %if ELD
  1019                              <1> do_repne_scasb:
  1020 00000579 0F829B00            <1> _386_PM	jc do_repne_scasb_a32
  1021 0000057D F2AE                <1> 	repne scasb
  1022 0000057F C3                  <1> 	retn
  1023                              <1> 
  1024                              <1> do_scasb:
  1025 00000580 0F829500            <1> _386_PM	jc do_scasb_a32
  1026 00000584 AE                  <1> 	scasb
  1027 00000585 C3                  <1> 	retn
  1028                              <1> 
  1029                              <1> do_repe_cmpsb:
  1030 00000586 0F829200            <1> _386_PM	jc do_repe_cmpsb_a32
  1031 0000058A F3A6                <1> 	repe cmpsb
  1032 0000058C C3                  <1> 	retn
  1033                              <1> 
  1034                              <1> do_repe_cmpsb_caps:
  1035 0000058D 0F828F00            <1> _386_PM	jc do_repe_cmpsb_caps_a32
  1036 00000591 E308                <1> 	jcxz .retn
  1037                              <1> .loop:
  1038 00000593 AC                  <1> 	lodsb
  1039 00000594 B702                <1> 	mov bh, 2		; caps flag
  1040 00000596 E85400              <1> 	call difficult_scasb_a16
  1041 00000599 E1F8                <1> 	loope .loop
  1042                              <1> .retn:
  1043 0000059B C3                  <1> 	retn
  1044                              <1> 
  1045                              <1> difficult_repe_cmpsb:
  1046 0000059C 0F828E00            <1> _386_PM	jc difficult_repe_cmpsb_a32
  1047 000005A0 E330                <1> 	jcxz .retn
  1048                              <1> 	lframe
  1049 000005A2 5589E5              <1> 	lenter
  1050 000005A5 31DB                <1> 	xor bx, bx
  1051 000005A7 53                  <1> 	 push bx		; ?idx = 0
  1052                              <1> 	lvar word, idx
  1053 000005A8 B302                <1> 	mov bl, 2		; skip initial tag
  1054                              <1> .loop:
  1055 000005AA 51                  <1> 	push cx
  1056 000005AB 89D9                <1> 	mov cx, bx		; cl = how many tags to skip times 2
  1057 000005AD 8B5EFE              <1> 	mov bx, word [bp + ?idx]; + tagbuffer -> current tag byte
  1058 000005B0 368AAF[8A00]        <1> reloc	mov ch, byte [ss:word tagbuffer + bx]
  1059                              <1> internaldatarelocation		; get current tag byte
  1060 000005B5 D2ED                <1> 	shr ch, cl		; shift down tag to bit 0 and 1
  1061 000005B7 80C102              <1> 	add cl, 2		; next tag
  1062 000005BA 80F908              <1> 	cmp cl, 8		; need to increment ?idx ?
  1063 000005BD 7205                <1> 	jb @F			; no -->
  1064 000005BF B100                <1> 	mov cl, 0		; reset for next iteration
  1065 000005C1 FF46FE              <1> 	inc word [bp + ?idx]	; point at next tag byte
  1066                              <1> @@:
  1067 000005C4 89CB                <1> 	mov bx, cx		; bl = shift count for next tag,
  1068                              <1> 				; bh bit 0 and 1 = tag
  1069 000005C6 59                  <1> 	pop cx
  1070 000005C7 AC                  <1> 	lodsb
  1071 000005C8 53                  <1> 	push bx			; preserve shift count
  1072 000005C9 E82100              <1> 	call difficult_scasb_a16
  1073 000005CC 5B                  <1> 	pop bx
  1074 000005CD E1DB                <1> 	loope .loop
  1075 000005CF 89EC5D              <1> 	lleave
  1076                              <1> .retn:
  1077 000005D2 C3                  <1> 	retn
  1078                              <1> 
  1079                              <1> 
  1080                              <1> difficult_repne_scasb:
  1081 000005D3 368A3E[8A00]        <1> reloc	mov bh, byte [ss:tagbuffer]
  1082                              <1> internaldatarelocation
  1083 000005D8 0F828800            <1> _386_PM	jc difficult_repne_scasb_a32
  1084 000005DC E305                <1> 	jcxz .ret
  1085                              <1> .loop:
  1086 000005DE E80C00              <1> 	call difficult_scasb_a16
  1087 000005E1 E0FB                <1> 	loopne .loop
  1088                              <1> .ret:
  1089 000005E3 C3                  <1> 	retn
  1090                              <1> 
  1091                              <1> difficult_scasb:
  1092 000005E4 368A3E[8A00]        <1> reloc	mov bh, byte [ss:tagbuffer]
  1093                              <1> internaldatarelocation
  1094 000005E9 0F828100            <1> _386_PM	jc difficult_scasb_a32
  1095                              <1> difficult_scasb_a16:
  1096 000005ED F6C701              <1> 	test bh, 1
  1097 000005F0 7522                <1> 	jnz .wild
  1098 000005F2 F6C702              <1> 	test bh, 2
  1099 000005F5 7502                <1> 	jnz .caps
  1100 000005F7 AE                  <1> 	scasb
  1101 000005F8 C3                  <1> 	retn
  1102                              <1> 
  1103                              <1> .caps:
  1104 000005F9 57                  <1> 	push di
  1105 000005FA AE                  <1> 	scasb
  1106 000005FB 7415                <1> 	je .ret_stack		; ZR
  1107 000005FD 3C41                <1> 	cmp al, 'A'
  1108 000005FF 7211                <1> 	jb .ret_stack		; NZ
  1109 00000601 3C5A                <1> 	cmp al, 'Z'
  1110 00000603 7608                <1> 	jbe .toggle
  1111 00000605 3C61                <1> 	cmp al, 'a'
  1112 00000607 7209                <1> 	jb .ret_stack		; NZ
  1113 00000609 3C7A                <1> 	cmp al, 'z'
  1114 0000060B 7705                <1> 	ja .ret_stack		; NZ
  1115                              <1> .toggle:
  1116 0000060D 5F                  <1> 	pop di
  1117 0000060E 3420                <1> 	xor al, 32		; try other caps status
  1118 00000610 AE                  <1> 	scasb
  1119 00000611 C3                  <1> 	retn
  1120                              <1> 
  1121                              <1> .ret_stack:
  1122 00000612 5B                  <1> 	pop bx
  1123 00000613 C3                  <1> 	retn
  1124                              <1> 
  1125                              <1> .wild:
  1126 00000614 AE                  <1> 	scasb
  1127 00000615 38C0                <1> 	cmp al, al
  1128 00000617 C3                  <1> 	retn
  1129                              <1> 
  1130                              <1> 
  1131                              <1>  %if _PM
  1132                              <1> 	subcpu 386
  1133                              <1> do_repne_scasb_a32:
  1134 00000618 F2                  <1> 	repne
  1135                              <1> 
  1136                              <1> do_scasb_a32:
  1137 00000619 67AE                <1> 	a32 scasb
  1138 0000061B C3                  <1> 	retn
  1139                              <1> 
  1140                              <1> do_repe_cmpsb_a32:
  1141 0000061C F367A6              <1> 	a32 repe cmpsb
  1142 0000061F C3                  <1> 	retn
  1143                              <1> 
  1144                              <1> do_repe_cmpsb_caps_a32:
  1145 00000620 67E30A              <1> 	jecxz .retn
  1146                              <1> .loop:
  1147 00000623 67AC                <1> 	a32 lodsb
  1148 00000625 B702                <1> 	mov bh, 2		; caps flag
  1149 00000627 E84400              <1> 	call difficult_scasb_a32
  1150 0000062A 67E1F6              <1> 	loope .loop, ecx
  1151                              <1> .retn:
  1152 0000062D C3                  <1> 	retn
  1153                              <1> 
  1154                              <1> difficult_repe_cmpsb_a32:
  1155 0000062E 67E332              <1> 	jecxz .retn
  1156                              <1> 	lframe
  1157 00000631 5589E5              <1> 	lenter
  1158 00000634 31DB                <1> 	xor bx, bx
  1159 00000636 53                  <1> 	 push bx		; ?idx = 0
  1160                              <1> 	lvar word, idx
  1161 00000637 B302                <1> 	mov bl, 2		; skip initial tag
  1162                              <1> .loop:
  1163 00000639 51                  <1> 	push cx
  1164 0000063A 89D9                <1> 	mov cx, bx		; cl = how many tags to skip times 2
  1165 0000063C 8B5EFE              <1> 	mov bx, word [bp + ?idx]; + tagbuffer -> current tag byte
  1166 0000063F 368AAF[8A00]        <1> reloc	mov ch, byte [ss:word tagbuffer + bx]
  1167                              <1> internaldatarelocation		; get current tag byte
  1168 00000644 D2ED                <1> 	shr ch, cl		; shift down tag to bit 0 and 1
  1169 00000646 80C102              <1> 	add cl, 2		; next tag
  1170 00000649 80F908              <1> 	cmp cl, 8		; need to increment ?idx ?
  1171 0000064C 7205                <1> 	jb @F			; no -->
  1172 0000064E B100                <1> 	mov cl, 0		; reset for next iteration
  1173 00000650 FF46FE              <1> 	inc word [bp + ?idx]	; point at next tag byte
  1174                              <1> @@:
  1175 00000653 89CB                <1> 	mov bx, cx		; bl = shift count for next tag,
  1176                              <1> 				; bh bit 0 and 1 = tag
  1177 00000655 59                  <1> 	pop cx
  1178 00000656 67AC                <1> 	a32 lodsb
  1179 00000658 53                  <1> 	push bx			; preserve shift count
  1180 00000659 E81200              <1> 	call difficult_scasb_a32
  1181 0000065C 5B                  <1> 	pop bx
  1182 0000065D 67E1D9              <1> 	loope .loop, ecx
  1183 00000660 89EC5D              <1> 	lleave
  1184                              <1> .retn:
  1185 00000663 C3                  <1> 	retn
  1186                              <1> 
  1187                              <1> 
  1188                              <1> difficult_repne_scasb_a32:
  1189 00000664 67E306              <1> 	jecxz .ret
  1190                              <1> .loop:
  1191 00000667 E80400              <1> 	call difficult_scasb_a32
  1192 0000066A 67E0FA              <1> 	loopne .loop, ecx
  1193                              <1> .ret:
  1194 0000066D C3                  <1> 	retn
  1195                              <1> 
  1196                              <1> difficult_scasb_a32:
  1197 0000066E F6C701              <1> 	test bh, 1
  1198 00000671 7528                <1> 	jnz .wild
  1199 00000673 F6C702              <1> 	test bh, 2
  1200 00000676 7503                <1> 	jnz .caps
  1201 00000678 67AE                <1> 	a32 scasb
  1202 0000067A C3                  <1> 	retn
  1203                              <1> 
  1204                              <1> .caps:
  1205 0000067B 6657                <1> 	push edi
  1206 0000067D 67AE                <1> 	a32 scasb
  1207 0000067F 7417                <1> 	je .ret_stack		; ZR
  1208 00000681 3C41                <1> 	cmp al, 'A'
  1209 00000683 7213                <1> 	jb .ret_stack		; NZ
  1210 00000685 3C5A                <1> 	cmp al, 'Z'
  1211 00000687 7608                <1> 	jbe .toggle
  1212 00000689 3C61                <1> 	cmp al, 'a'
  1213 0000068B 720B                <1> 	jb .ret_stack		; NZ
  1214 0000068D 3C7A                <1> 	cmp al, 'z'
  1215 0000068F 7707                <1> 	ja .ret_stack		; NZ
  1216                              <1> .toggle:
  1217 00000691 665F                <1> 	pop edi
  1218 00000693 3420                <1> 	xor al, 32		; try other caps status
  1219 00000695 67AE                <1> 	a32 scasb
  1220 00000697 C3                  <1> 	retn
  1221                              <1> 
  1222                              <1> .ret_stack:
  1223 00000698 665B                <1> 	pop ebx
  1224 0000069A C3                  <1> 	retn
  1225                              <1> 
  1226                              <1> .wild:
  1227 0000069B 67AE                <1> 	a32 scasb
  1228 0000069D 38C0                <1> 	cmp al, al
  1229 0000069F C3                  <1> 	retn
  1230                              <1> 
  1231                              <1> 	subcpureset
  1232                              <1>  %endif
  1233                              <1> %endif
  1234                              <1> 
  1235                              <1> ..@sss_access_end:
   262                                  
   263                                  
   264                                  %assign _STRNUM 1
   265                                  
   266                                  %if _STRNUM
   267                                  getstr_check_limit:
   268 000006A0 3BBF[1400]              reloc	cmp di, word [word getstr_dispatch_table.limit + bx]
   269                                  internaldatarelocation
   270 000006A4 7703E9C200              	jbe getstr_retn
   271                                  %endif
   272                                  errorj2a:
   273 000006A9 E91701                  	jmp error
   274                                  
   275                                  ;	GETSTR - Get string of bytes.  Put the answer in line_out.
   276                                  ;		Entry	AL	first character
   277                                  ;			SI	address of next character
   278                                  ;		Exit	[line_out] first byte of string
   279                                  ;			DI	address of last+1 byte of string
   280                                  ;		Uses	AX, cx, dx,SI
   281                                  getstr_sss:
   282 000006AC 4E                      	dec si
   283                                  	lframe
   284 000006AD 5589E5                  	lenter
   285 000006B0 B92600                  	mov cx, words(tagbuffer.size)
   286 000006B3 31C0                    	xor ax, ax
   287 000006B5 BF[8A00]                reloc	mov di, tagbuffer
   288                                  internaldatarelocation
   289 000006B8 57                      	 push di		; -> tag buffer
   290                                  	lvar word, idxtagbuffer
   291 000006B9 50                      	 push ax		; = 0
   292                                  	lvar word, tag
   293                                  	lequ 1, tagwild
   294                                  	lequ 2, tagcaps
   295 000006BA F3AB                    	rep stosw		; cx = 0
   296                                  
   297                                  %if _STRNUM
   298 000006BC 53                      	push bx
   299 000006BD 31DB                    	xor bx, bx		; 0 = byte size as default
   300                                  %endif
   301 000006BF E80E01                  	extcallcall skipcomma
   302 000006C2 BF[0000]                reloc	mov di, relocateddata
   303                                  linkdatarelocation line_out
   304 000006C5 E8A001                  	extcallcall iseol?
   305 000006C8 74DF                    	je short errorj2a	; we don't allow empty byte strings
   306                                  
   307                                  getstr_loop:
   308 000006CA E84301                  	extcallcall skipcomm0
   309                                  %if _STRNUM
   310 000006CD 4E                      	dec si			; -> nonblank
   311 000006CE BA[1C00]                reloc	mov dx, msg.as		; "AS" keyword ?
   312                                  internaldatarelocation
   313 000006D1 E80401                  	extcallcall isstring?
   314 000006D4 7517                    	jne .notas		; no -->
   315 000006D6 E8F700                  	extcallcall skipcomma
   316 000006D9 4E                      	dec si			; -> nonblank
   317 000006DA 51                      	push cx
   318 000006DB E89201                  	extcallcall get_length_keyword
   319 000006DE 75C9                    	jnz errorj2a
   320 000006E0 80F902                  	cmp cl, 2		; 0 = bytes, 1 = words, 2 = dwords
   321                                  				; (ch is always zero)
   322 000006E3 77C4                    	ja errorj2a		; higher is invalid -->
   323 000006E5 89CB                    	mov bx, cx
   324 000006E7 01DB                    	add bx, bx		; make a table offset
   325 000006E9 59                      	pop cx
   326 000006EA AC                      	lodsb
   327 000006EB EB65                    	jmp getstr_next
   328                                  
   329                                  .notas:
   330                                  %endif
   331 000006ED BA[2300]                reloc	mov dx, msg.wild
   332                                  internaldatarelocation
   333 000006F0 E8E500                  	extcallcall isstring?
   334 000006F3 7512                    	jne .notwild
   335 000006F5 804EFC01                	setopt [bp + ?tag], ?tagwild
   336                                  %if _STRNUM
   337 000006F9 E8A4FF                  	call getstr_check_limit
   338 000006FC FF97[0E00]              reloc	call near [word getstr_dispatch_table.string + bx]
   339                                  internaldatarelocation
   340                                  %else
   341                                  	inc di
   342                                  	call storetag
   343                                  %endif
   344 00000700 8066FCFE                	clropt [bp + ?tag], ?tagwild
   345                                  .lod:
   346 00000704 AC                      	lodsb
   347 00000705 EB4B                    	jmp getstr_next
   348                                  
   349                                  .notwild:
   350 00000707 BA[2A00]                reloc	mov dx, msg.caps
   351                                  internaldatarelocation
   352 0000070A E8CB00                  	extcallcall isstring?
   353 0000070D 7506                    	jne .notcaps
   354 0000070F 804EFC02                	setopt [bp + ?tag], ?tagcaps
   355 00000713 EBEF                    	jmp .lod
   356                                  
   357                                  .notcaps:
   358 00000715 BA[2800]                reloc	mov dx, msg.uncaps
   359                                  internaldatarelocation
   360 00000718 E8BD00                  	extcallcall isstring?
   361 0000071B 7506                    	jne .notuncaps
   362 0000071D 8066FCFD                	clropt [bp + ?tag], ?tagcaps
   363 00000721 EBE1                    	jmp .lod
   364                                  
   365                                  .notuncaps:
   366 00000723 AC                      	lodsb
   367 00000724 3C27                    	cmp al, "'"
   368 00000726 740D                    	je getstr_start_quote	; if string
   369 00000728 3C22                    	cmp al, '"'
   370 0000072A 7409                    	je getstr_start_quote	; ditto
   371                                  
   372                                  %if _STRNUM
   373 0000072C E871FF                  	call getstr_check_limit
   374 0000072F FF97[0800]              reloc	call near [word getstr_dispatch_table.numeric + bx]
   375                                  internaldatarelocation
   376                                  %else
   377                                  	extcallcall getbyte	; byte in DL
   378                                  	mov byte [di], dl	; store the byte
   379                                  	inc di
   380                                  %endif
   381 00000733 EB1D                    	jmp short getstr_next
   382                                  
   383                                  getstr_start_quote:
   384 00000735 88C4                    	mov ah, al		; save quote character
   385                                  getstr_loop_quoted:
   386 00000737 AC                      	lodsb
   387 00000738 38E0                    	cmp al, ah
   388 0000073A 7411                    	je getstr_quote_quoted	; if possible end of string
   389 0000073C E83901                  	extcallcall iseol?.notsemicolon
   390 0000073F 7503E965FF              	je errorj2a		; if end of line
   391                                  getstr_store_quoted:
   392                                  %if _STRNUM
   393 00000744 E859FF                  	call getstr_check_limit
   394 00000747 FF97[0E00]              reloc	call near [word getstr_dispatch_table.string + bx]
   395                                  internaldatarelocation
   396                                  %else
   397                                  	stosb			; save character and continue
   398                                  %endif
   399 0000074B EBEA                    	jmp short getstr_loop_quoted
   400                                  
   401                                  getstr_quote_quoted:
   402 0000074D AC                      	lodsb
   403 0000074E 38E0                    	cmp al, ah
   404 00000750 74F2                    	je getstr_store_quoted	; if doubled quote character
   405                                  getstr_next:
   406 00000752 E8BB00                  	extcallcall skipcomm0	; go back for more
   407 00000755 E81001                  	extcallcall iseol?
   408 00000758 740D                    	je .ret
   409 0000075A 4E                      	dec si
   410 0000075B BA[1F00]                reloc	mov dx, msg.end
   411                                  internaldatarelocation
   412 0000075E E87700                  	extcallcall isstring?
   413 00000761 AC                      	lodsb
   414 00000762 7403E963FF              	jne getstr_loop			; if not done yet
   415                                  .ret:
   416                                  %if _STRNUM
   417 00000767 5B                      	pop bx
   418                                  %endif
   419 00000768 89EC5D                  	lleave code
   420                                  %if _STRNUM
   421                                  getstr_retn:
   422                                  %endif
   423 0000076B C3                      	retn
   424                                  
   425                                  
   426                                  %if _STRNUM
   427                                  getstr_numeric_byte:
   428 0000076C E81101                  	extcallcall getbyte	; byte in DL
   429 0000076F 8815                    	mov byte [di], dl	; store the byte
   430 00000771 47                      	inc di
   431 00000772 EB2F                    	jmp storetag
   432                                  
   433                                  getstr_numeric_word:
   434 00000774 E81101                  	extcallcall getword	; dx
   435 00000777 8915                    	mov word [di], dx	; store
   436 00000779 AF                      	scasw			; di += 2
   437                                  storetagtwice:
   438 0000077A E82600                  	call storetag
   439 0000077D EB24                    	jmp storetag
   440                                  
   441                                  getstr_numeric_dword:
   442 0000077F 53                      	push bx
   443 00000780 E89D00                  	extcallcall getdword	; bx:dx
   444 00000783 8915                    	mov word [di], dx	; store
   445 00000785 AF                      	scasw			; di += 2
   446 00000786 891D                    	mov word [di], bx	; store
   447 00000788 AF                      	scasw			; di += 2
   448 00000789 5B                      	pop bx
   449 0000078A E8EDFF                  	call storetagtwice
   450 0000078D EBEB                    	jmp storetagtwice
   451                                  
   452                                  
   453                                  getstr_string_word:
   454 0000078F AA                      	stosb			; save character and continue
   455 00000790 E81000                  	call storetag
   456 00000793 B000                    	mov al, 0
   457 00000795 EB0B                    	jmp getstr_string_byte
   458                                  
   459                                  getstr_string_dword:
   460 00000797 AA                      	stosb			; save character and continue
   461 00000798 E8DFFF                  	call storetagtwice
   462 0000079B E80500                  	call storetag
   463 0000079E B000                    	mov al, 0
   464 000007A0 AA                      	stosb
   465 000007A1 AA                      	stosb
   466                                  getstr_string_byte:
   467 000007A2 AA                      	stosb
   468                                  	; fall through
   469                                  
   470                                  storetag:
   471 000007A3 50                      	push ax
   472 000007A4 877EFE                  	xchg di, word [bp + ?idxtagbuffer]
   473 000007A7 81FF[D500]              reloc	cmp di, strict word tagbuffer.end
   474                                  internaldatarelocation
   475 000007AB 7316                    	jae error
   476 000007AD 8A46FC                  	mov al, byte [bp + ?tag]
   477 000007B0 D2E0                    	shl al, cl
   478 000007B2 0805                    	or byte [di], al
   479 000007B4 41                      	inc cx
   480 000007B5 41                      	inc cx
   481 000007B6 80F908                  	cmp cl, 8
   482 000007B9 7203                    	jb @F
   483 000007BB B100                    	mov cl, 0
   484 000007BD 47                      	inc di
   485                                  @@:
   486 000007BE 877EFE                  	xchg di, word [bp + ?idxtagbuffer]
   487 000007C1 58                      	pop ax
   488 000007C2 C3                      	retn
   489                                  
   490                                  
   491                                  	lleave ctx
   492                                  
   493                                  
   494                                  	usesection DATA
   495                                  
   496                                  		; REM:	Dispatch table in section CODE (ELD code segment)
   497                                  	align 2, db 0
   498                                  getstr_dispatch_table:
   499                                  .numeric:
   500 00000008 [6C07]                  reloc		dw getstr_numeric_byte
   501                                  internalcoderelocation
   502 0000000A [7407]                  reloc		dw getstr_numeric_word
   503                                  internalcoderelocation
   504 0000000C [7F07]                  reloc		dw getstr_numeric_dword
   505                                  internalcoderelocation
   506                                  .string:
   507 0000000E [A207]                  reloc		dw getstr_string_byte
   508                                  internalcoderelocation
   509 00000010 [8F07]                  reloc		dw getstr_string_word
   510                                  internalcoderelocation
   511 00000012 [9707]                  reloc		dw getstr_string_dword
   512                                  internalcoderelocation
   513                                  .limit:
   514 00000014 [FFFF]                  reloc		dw relocateddata - 1
   515                                  linkdatarelocation line_out_end
   516 00000016 [FEFF]                  reloc		dw relocateddata - 2
   517                                  linkdatarelocation line_out_end
   518 00000018 [FCFF]                  reloc		dw relocateddata - 4
   519                                  linkdatarelocation line_out_end
   520                                  
   521                                  	usesection CODE
   522                                  %endif	; _STRNUM
   523                                  
   524                                  
   525                                  error:
   526 000007C3 E8[0000]EB020000        	extcall error
   527                                  
   528 000007CA 90<rep 6h>E8[0000]-     	eldcall_dump_callcall ELDCALL_CALLCALL_LIST
   528 000007D3 EB020000C3E8[0000]-
   528 000007DB EB020000C3E8[0000]-
   528 000007E3 EB020000C3E8[0000]-
   528 000007EB EB020000C3E8[0000]-
   528 000007F3 EB020000C3E8[0000]-
   528 000007FB EB020000C3E8[0000]-
   528 00000803 EB020000C3E8[0000]-
   528 0000080B EB020000C3E8[0000]-
   528 00000813 EB020000C3E8[0000]-
   528 0000081B EB020000C3E8[0000]-
   528 00000823 EB020000C3E8[0000]-
   528 0000082B EB020000C3E8[0000]-
   528 00000833 EB020000C3E8[0000]-
   528 0000083B EB020000C3E8[0000]-
   528 00000843 EB020000C3E8[0000]-
   528 0000084B EB020000C3E8[0000]-
   528 00000853 EB020000C3E8[0000]-
   528 0000085B EB020000C3E8[0000]-
   528 00000863 EB020000C3E8[0000]-
   528 0000086B EB020000C3E8[0000]-
   528 00000873 EB020000C3E8[0000]-
   528 0000087B EB020000C3E8[0000]-
   528 00000883 EB020000C3E8[0000]-
   528 0000088B EB020000C3         
   529                                  
   530                                  endinstalled equ ($ + CODEFIXUP + 15) & ~15
   531                                  
   532                                  	align 2, db 0				; align on word boundary
   533                                  		; Table of patches that are to be set NOP if not running on a 386.
   534 00000890 DF0108010101780102-     writepatchtable patch_no386_table, PATCH_NO386_TABLE
   534 00000899 012C0403047D040101-
   534 000008A2 1C010701190107014C-
   534 000008AB 018F047B0107011D01-
   534 000008B4 07013501F40101160C-
   534 000008BD 010601310403040204-
   534 000008C6 03040B0438040D0400-
   534 000008CF 00                 
   534          ******************       warning: patch_no386_table: 64 (Method 2) [-w+user]
   534          ******************       warning: 1B=19 repo=0 run=31 byte=85 [-w+user]
   535                                  %undef PATCH_NO386_TABLE
   536                                  
   537                                  	align 2, db 0
   538                                  		; Table of patches that are to be set NOP if running on a 386.
   539                                  writepatchtable patch_386_table, PATCH_386_TABLE
   539          ******************       warning: patch_386_table: 0 (Method 1) [-w+user]
   540                                  %undef PATCH_386_TABLE
   541                                  
   542                                  
   543                                  start:
   544                                  	houdini
   545 000008D0 56                      	push si
   546 000008D1 BA[0000]                reloc	mov dx, code
   547                                  internalcoderelocation
   548 000008D4 F606[0100]80            reloc	testopt [relocateddata], has386
   549                                  linkdatarelocation internalflags, -3
   550 000008D9 740B                    	jz @F
   551 000008DB BE[D008]                reloc	mov si, patch_386_table		; table of patches to set for 386+
   552                                  internalcoderelocation
   553                                  %if __patch_386_table_method == 1
   554 000008DE B90000                  	mov cx, patch_386_table_size_w
   555 000008E1 E82900                  	call .patch1
   556                                  %else
   557                                  	call .patch2
   558                                  %endif
   559 000008E4 EB35                    	jmp .patch_code1_end
   560                                  
   561                                  @@:
   562 000008E6 BE[9008]                reloc	mov si, patch_no386_table	; table of patches to set for 16-bit CPU
   563                                  internalcoderelocation
   564                                  %if __patch_no386_table_method == 1
   565                                  	mov cx, patch_no386_table_size_w
   566                                  	call .patch1
   567                                  %else
   568 000008E9 E80200                  	call .patch2
   569                                  %endif
   570 000008EC EB2D                    	jmp .patch_code1_end
   571                                  
   572                                  		; Complicated table patch code.
   573                                  %if __patch_no386_table_method == 2 || __patch_386_table_method == 2
   574                                  .patch2:
   575 000008EE BF[0000]                reloc	mov di, code_start		; initialise offset
   576                                  internalcoderelocation
   577 000008F1 31C0                    	xor ax, ax			; initialise ah
   578                                  .looppatch2:
   579 000008F3 2EAC                    	cs lodsb
   580 000008F5 01C7                    	add di, ax			; skip number of bytes to skip
   581 000008F7 3CFF                    	cmp al, 255			; really repositioning?
   582 000008F9 7506                    	jne .l2patch			; no -->
   583 000008FB 97                      	xchg ax, di			; (to preserve ah)
   584 000008FC 2EAD                    	cs lodsw			; ax = new address
   585 000008FE 01D0                    	add ax, dx
   586 00000900 97                      	xchg ax, di			; di = new address
   587                                  .l2patch:
   588 00000901 2EAC                    	cs lodsb
   589 00000903 89C1                    	mov cx, ax			; cx = number of bytes to patch
   590 00000905 E313                    	jcxz .patchesdone		; end of table -->
   591 00000907 B090                    	mov al, 90h			; patch to NOP
   592 00000909 F3AA                    	rep stosb			; patch as many bytes as specified
   593 0000090B EBE6                    	jmp short .looppatch2
   594                                  %endif
   595                                  
   596                                  		; Simple table patch code.
   597                                  %if __patch_no386_table_method == 1 || __patch_386_table_method == 1
   598                                  .patch1:
   599 0000090D E30B                    	jcxz .patchesdone
   600                                  .looppatch1:
   601 0000090F 2EAD                    	cs lodsw			; load address of patch
   602 00000911 01D0                    	add ax, dx
   603 00000913 93                      	xchg bx, ax			; (set bx = ax, CHG ax)
   604 00000914 26C60790                	mov byte [es:bx], 90h		; patch
   605 00000918 E2F5                    	loop .looppatch1
   606                                  %endif
   607                                  .patchesdone:
   608 0000091A C3                      	retn
   609                                  
   610                                  .patch_code1_end:
   611 0000091B 5E                      	pop si
   612                                  
   613 0000091C 8CC3                    	mov bx, es
   614 0000091E 16                      	 push ss
   615 0000091F 07                      	 pop es
   616                                  
   617 00000920 E8ADFE                  	call skipcomma
   618 00000923 4E                      	dec si
   619 00000924 BA[0000]                reloc	mov dx, relocateddata
   620                                  linkdatarelocation msg.install
   621 00000927 E8AEFE                  	call isstring?
   622 0000092A 742D                    	je install
   623 0000092C AC                      	lodsb
   624 0000092D E8A6F7                  	call sss
   625                                  @@:
   626 00000930 E80300                  	call uninstall_oneshot
   627 00000933 31C0                    	xor ax, ax
   628 00000935 CB                      	retf
   629                                  
   630                                  
   631                                  uninstall_oneshot:
   632 00000936 36F606[0000]01          reloc	testopt [ss:relocateddata], 1
   633                                  linkdatarelocation options7, -3
   634 0000093C 751A                    	jnz @F
   635                                  
   636 0000093E 2EA1[0200]              reloc	mov ax, word [cs:code + eldiEndCode]
   637                                  internalcoderelocation
   638 00000942 2E2B06[0000]            reloc	sub ax, word [cs:code + eldiStartCode]
   639                                  internalcoderelocation
   640 00000947 2906[0000]              reloc	sub word [relocateddata], ax
   641                                  linkdatarelocation extseg_used
   642                                  
   643 0000094B 2EA1[0600]              reloc	mov ax, word [cs:code + eldiEndData]
   644                                  internalcoderelocation
   645 0000094F 2E2B06[0400]            reloc	sub ax, word [cs:code + eldiStartData]
   646                                  internalcoderelocation
   647 00000954 2906[0000]              reloc	sub word [relocateddata], ax
   648                                  linkdatarelocation extdata_used
   649                                  @@:
   650 00000958 C3                      	retn
   651                                  
   652                                  
   653                                  install:
   654 00000959 AC                      	lodsb
   655 0000095A E8[0000]EB020000        	extcall chkeol
   656                                  
   657                                  	houdini
   658 00000961 8EC3                    	mov es, bx		; => ext seg (writable)
   659 00000963 B81001                  	mov ax, endresident - endinstalled
   660 00000966 262906[0200]            reloc	sub word [es:code + eldiEndCode], ax
   661                                  internalcoderelocation		; adjust size
   662 0000096B 2906[0000]              reloc	sub word [relocateddata], ax
   663                                  linkdatarelocation extseg_used	; adjust size
   664 0000096F 8B1E[0000]              reloc	mov bx, word [relocateddata]
   665                                  linkdatarelocation ext_command_handler
   666                                  				; -> prior
   667 00000973 BF[2000]                reloc	mov di, command		; -> our handler
   668                                  internalcoderelocation
   669 00000976 85DB                    	test bx, bx		; installing as first ?
   670 00000978 740A                    	jz .only_first		; yes, simple --> (leave as extcall cmd3_not_ext)
   671 0000097A AF                      	scasw			; skip entrypoint jmp strict short
   672 0000097B B0E9                    	mov al, 0E9h		; = jmp near opcode
   673 0000097D AA                      	stosb			; store
   674 0000097E 93                      	xchg ax, bx		; ax -> next handler
   675 0000097F 29F8                    	sub ax, di
   676 00000981 48                      	dec ax
   677 00000982 48                      	dec ax			; ax = ax - (di + 2)
   678 00000983 AB                      	stosw			; store our downlink as rel16 displacement
   679                                  
   680                                  .only_first:
   681 00000984 26800E[1000]01          reloc	setopt [es:code + eldiFlags], eldifResident
   682                                  internalcoderelocation -3	; mark block as resident
   683 0000098A C706[0000][2000]        reloc2	mov word [relocateddata], command
   684                                  linkdatarelocation ext_command_handler, -4
   685                                  internalcoderelocation		; -> our entrypoint
   686                                  
   687 00000990 F606[0000]04            reloc	testopt [relocateddata], 4
   688                                  linkdatarelocation options7, -3
   689 00000995 7506                    	jnz @F
   690 00000997 BA[8900]                reloc	mov dx, msg.installed
   691                                  internaldatarelocation
   692 0000099A E85BFE                  	call putsz
   693                                  @@:
   694 0000099D 31C0                    	xor ax, ax
   695 0000099F CB                      	retf
   696                                  
   697                                  
   698                                  	usesection DATA
   699                                  msg:
   700                                  %if 0
   701                                  .sleep:			asciz "SLEEP"
   702                                  %else
   703 0000001A 5300                    .s:			asciz "S"
   704                                  %endif
   705 0000001C 415300                  .as:			asciz "AS"
   706 0000001F 454E4400                .end:			asciz "END"
   707 00000023 57494C4400              .wild:			asciz "WILD"
   708 00000028 554E                    .uncaps:		db "UN"
   709 0000002A 4341505300              .caps:			asciz "CAPS"
   710 0000002F 53494C454E5400          .silent:		asciz "SILENT"
   711 00000036 52414E474500            .range:			asciz "RANGE"
   712 0000003C 5245564552534500        .reverse:		asciz "REVERSE"
   713 00000044 206D6174636865730D-     .matches:		asciz " matches",13,10
   713 0000004D 0A00               
   714 0000004F 5320636F6D6D616E64-     .uninstall_done:	db "S command uninstalled."
   714 00000058 20756E696E7374616C-
   714 00000061 6C65642E           
   715                                  %if _ELD_RECLAIM_HINT
   716                                  			db " (Don't forget to use reclaim.eld)"
   717                                  %endif
   718 00000065 0D0A00                  			asciz 13,10
   719 00000068 5320636F6D6D616E64-     .uninstall_error:	asciz "S command unable to uninstall!",13,10
   719 00000071 20756E61626C652074-
   719 0000007A 6F20756E696E737461-
   719 00000083 6C6C210D0A00       
   720                                  
   721                                  uinit_data: equ $
   722                                  
   723 00000089 5320636F6D6D616E64-     .installed:	asciz "S command installed.",13,10
   723 00000092 20696E7374616C6C65-
   723 0000009B 642E0D0A00         
   724                                  
   725                                  	align 16, db 0
   726                                  init_data_end:
   727                                  data_size equ $ - datastart
   728                                  
   729                                  	absolute uinit_data
   730                                  
   731 00000089 ??                      	alignb 2
   732                                  tagbuffer:
   733 0000008A <res 4Bh>               .:	resb 300 / 4
   734                                  .end:
   735                                  .size equ .end - .
   736 000000D5 ??                      	alignb 2		; may overflow if odd tagbuffer.size
   737                                  
   738                                  patternbuffer:
   739 000000D6 <res 108h>              .:	resb 264
   740                                  .size equ $ - .
   741                                  
   742                                  	alignb 2
   743                                  sss_repne_scasb:
   744 000001DE ????                    	resw 1
   745                                  sss_scasb:
   746 000001E0 ????                    	resw 1
   747                                  sss_repe_cmpsb:
   748 000001E2 ????                    	resw 1
   749                                  sss_repe_cmpsb_for_range:
   750 000001E4 ????                    	resw 1
   751                                  
   752                                  sss_range_used:
   753 000001E6 ??                      	resb 1
   754                                  
   755                                  %if 0 ;n _RN_AUX
   756                                  	alignb 4
   757                                  rn_rm_buffer:
   758                                  		resb 128
   759                                  %endif
   760                                  
   761 000001E7 <res 9h>                	alignb 16
   762                                  uinit_data_end:
   763                                  resident_data_end:
   764                                  
   765                                  %if uinit_data_end >= init_data_end
   766                                   total_data_size equ $ - datastart
   767                                  %else
   768                                   total_data_size equ init_data_end - datastart
   769                                  %endif
   770                                  %assign _DATA_SIZE total_data_size
   771                                  
   772                                  	usesection CODE
   773                                  
   774                                  %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 000009A0 5589E5              <1> 	lenter
    82                              <1> 	lvar dword, instance
    83 000009A3 06                  <1> 	 push es
    84 000009A4 52                  <1> 	 push dx
    85                              <1> 	lvar word, targetsection_low_optional_high
    86 000009A5 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 000009A6 1E                  <1> 	 push ds
    91 000009A7 57                  <1> 	 push di
    92                              <1> 	lvar dword, nextreloc
    93 000009A8 06                  <1> 	 push es
    94 000009A9 52                  <1> 	 push dx
    95                              <1> 	lvar dword, entry
    96 000009AA 06                  <1> 	 push es
    97 000009AB 50                  <1> 	 push ax		; placeholder
    98 000009AC 31C0                <1> 	xor ax, ax
    99 000009AE 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 000009B2 7403E98C02          <1> 	jne .error_j
   104 000009B7 837D0601            <1> 	cmp word [di + eldlUseLinkHash], 1
   105 000009BB 7603E98302          <1> 	ja .error_j
   106 000009C0 7201                <1> 	jb @F
   107 000009C2 48                  <1> 	dec ax
   108                              <1> @@:
   109                              <1> 	lvar word, use_hash
   110 000009C3 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 000009C4 31C0                <1> 	xor ax, ax
   118                              <1>  %if _ELD_LINKER_PASSES
   119                              <1> 	lvar word, pass
   120 000009C6 50                  <1> 	 push ax
   121                              <1> 	lvar word, amounterrors
   122 000009C7 50                  <1> 	 push ax
   123                              <1> 	lvar word, name
   124 000009C8 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 000009C9 56                  <1> 	push si
   132 000009CA 53                  <1> 	push bx
   133                              <1> 
   134                              <1> 			; simple: add instance base (dx) to code
   135 000009CB 06                  <1> 	push es
   136 000009CC 1F                  <1> 	pop ds
   137                              <1> %if _ELD_LINKER_PASSES
   138                              <1> .pass:
   139 000009CD 8B5EEA              <1> 	mov bx, word [bp + ?pass]
   140 000009D0 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 000009D2 8BB7040E            <1> 	mov si, word [linktable - code + ltCodeToCode + bx]
   146                              <1>  %endif
   147                              <1> %else
   148                              <1> 	mov si, internalcodetocoderelocations - code
   149                              <1> %endif
   150 000009D6 01D6                <1> 	add si, dx
   151                              <1> @@:
   152 000009D8 AD                  <1> 	lodsw
   153 000009D9 85C0                <1> 	test ax, ax		; was last ?
   154 000009DB 740B                <1> 	jz @F			; yes -->
   155 000009DD 93                  <1> 	xchg bx, ax		; bx = entry
   156 000009DE 01D3                <1> 	add bx, dx		; relocate the entry itself
   157                              <1> %if _ELD_CODE_VSTART
   158 000009E0 812F[0000]          <1> 	sub word [bx], code	; undo adjustment
   159                              <1> %endif
   160 000009E4 0117                <1> 	add word [bx], dx	; relocate word referenced by entry
   161 000009E6 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 000009E8 8B5EEA              <1> 	mov bx, word [bp + ?pass]
   167 000009EB 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 000009ED 8BB7080E            <1> 	mov si, word [linktable - code + ltCodeToData + bx]
   173                              <1>  %endif
   174                              <1> %else
   175                              <1> 	mov si, internalcodetodatarelocations - code
   176                              <1> %endif
   177 000009F1 01D6                <1> 	add si, dx
   178                              <1> @@:
   179 000009F3 AD                  <1> 	lodsw
   180 000009F4 85C0                <1> 	test ax, ax		; was last ?
   181 000009F6 740C                <1> 	jz @F			; yes -->
   182 000009F8 93                  <1> 	xchg bx, ax		; bx = entry
   183 000009F9 01D3                <1> 	add bx, dx		; relocate the entry itself
   184 000009FB 58                  <1> 	pop ax			; ax -> heap data
   185 000009FC 50                  <1> 	push ax
   186                              <1> %if _ELD_DATA_VSTART
   187 000009FD 2D[0000]            <1> 	sub ax, datastart	; undo adjustment
   188                              <1> %endif
   189 00000A00 0107                <1> 	add word [bx], ax	; relocate word referenced by entry
   190 00000A02 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 00000A04 8B5EEA              <1> 	mov bx, word [bp + ?pass]
   197 00000A07 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 00000A09 8BB70C0E            <1> 	mov si, word [linktable - code + ltDataToCode + bx]
   203                              <1>  %endif
   204                              <1> %else
   205                              <1> 	mov si, internaldatatocoderelocations - code
   206                              <1> %endif
   207 00000A0D 01D6                <1> 	add si, dx
   208                              <1> @@:
   209 00000A0F AD                  <1> 	lodsw
   210 00000A10 83F8FF              <1> 	cmp ax, -1		; was last ?
   211 00000A13 740F                <1> 	je @F			; yes -->
   212 00000A15 93                  <1> 	xchg bx, ax		; bx = entry
   213 00000A16 58                  <1> 	pop ax
   214 00000A17 50                  <1> 	push ax
   215 00000A18 01C3                <1> 	add bx, ax		; relocate the entry itself
   216                              <1> %if _ELD_CODE_VSTART
   217 00000A1A 36812F[0000]        <1> 	sub word [ss:bx], code	; undo adjustment
   218                              <1> %endif
   219 00000A1F 360117              <1> 	add word [ss:bx], dx	; relocate word referenced by entry
   220 00000A22 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 00000A24 8B5EEA              <1> 	mov bx, word [bp + ?pass]
   226 00000A27 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 00000A29 8BB7100E            <1> 	mov si, word [linktable - code + ltDataToData + bx]
   232                              <1>  %endif
   233                              <1> %else
   234                              <1> 	mov si, internaldatatodatarelocations - code
   235                              <1> %endif
   236 00000A2D 01D6                <1> 	add si, dx
   237                              <1> @@:
   238 00000A2F AD                  <1> 	lodsw
   239 00000A30 83F8FF              <1> 	cmp ax, -1		; was last ?
   240 00000A33 740D                <1> 	je @F			; yes -->
   241 00000A35 93                  <1> 	xchg bx, ax		; bx = entry
   242 00000A36 58                  <1> 	pop ax			; ax -> heap data
   243 00000A37 50                  <1> 	push ax
   244 00000A38 01C3                <1> 	add bx, ax		; relocate the entry itself
   245                              <1> %if _ELD_DATA_VSTART
   246 00000A3A 2D[0000]            <1> 	sub ax, datastart	; undo adjustment
   247                              <1> %endif
   248 00000A3D 360107              <1> 	add word [ss:bx], ax	; relocate word referenced by entry
   249 00000A40 EBED                <1> 	jmp @B
   250                              <1> 
   251                              <1> @@:
   252 00000A42 8B56FC              <1> 	mov dx, word [bp + ?instance]
   253                              <1> %if _ELD_LINKER_PASSES
   254 00000A45 8B5EEA              <1> 	mov bx, word [bp + ?pass]
   255 00000A48 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 00000A4A 0397140E            <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 00000A4E 8956F2              <1> 	mov word [bp + ?nextreloc], dx
   267                              <1> 
   268                              <1> .datarelocloop:		; must be done before further relocs
   269 00000A51 C576F2              <1> 	lds si, [bp + ?nextreloc]
   270 00000A54 AD                  <1> 	lodsw			; ax = section indicator
   271 00000A55 85C0                <1> 	test ax, ax		; end of table ?
   272 00000A57 7503E95401          <1> 	jz .donedatareloc
   273 00000A5C 48                  <1> 	dec ax			; al = 1 if data, 0 if code
   274 00000A5D 5B                  <1> 	pop bx
   275 00000A5E 53                  <1> 	push bx			; bx -> ELD data block
   276 00000A5F 8946FA              <1> 	mov word [bp + ?targetsection_low_optional_high], ax
   277 00000A62 84C0                <1> 	test al, al		; data ?
   278 00000A64 AD                  <1> 	lodsw
   279 00000A65 7504                <1> 	jnz @F			; yes -->
   280 00000A67 0346FC              <1> 	add ax, word [bp + ?instance]
   281                              <1> 				; relocate entry into code
   282 00000A6A A9                  <1> 	db __TEST_IMM16		; (skip add)
   283                              <1> @@:
   284 00000A6B 01D8                <1> 	add ax, bx		; relocate entry into data
   285 00000A6D 8946EE              <1> 	mov word [bp + ?entry], ax
   286 00000A70 AD                  <1> 	lodsw
   287 00000A71 8976F2              <1> 	mov word [bp + ?nextreloc], si
   288 00000A74 E80D01              <1> 	call .build_match
   289                              <1> %if _ELD_LINKER_PASSES
   290 00000A77 73D8                <1> 	jnc .datarelocloop
   291                              <1> %endif
   292 00000A79 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 00000A7C 268B4F08            <1> 	mov cx, word [es:bx + eldlDataAmount]	; amount data link info
   300 00000A80 268B7F0A            <1> 	mov di, word [es:bx + eldlDataPrefixes]	; -> prefixes or hashes
   301                              <1> .datarelocfind:
   302 00000A84 F2AF                <1> 	repne scasw			; scan initial
   303 00000A86 7541                <1> 	jne .datarelocnotfound
   304 00000A88 57                  <1> 	push di
   305 00000A89 51                  <1> 	push cx
   306 00000A8A 56                  <1> 	push si
   307 00000A8B 262B7F0A            <1> 	sub di, word [es:bx + eldlDataPrefixes]	; = double index, 1-based
   308 00000A8F 4F                  <1> 	dec di
   309 00000A90 4F                  <1> 	dec di				; 0-based
   310 00000A91 26037F0C            <1> 	add di, word [es:bx + eldlDataEntries]	; -> entry
   311 00000A95 268B3D              <1> 	mov di, [es:di]			; -> counted suffix/string
   312 00000A98 B500                <1> 	mov ch, 0
   313 00000A9A 8A0C                <1> 	mov cl, byte [si]		; cx = length
   314 00000A9C 41                  <1> 	inc cx
   315                              <1> 	; cmp al, al			; ZR if length is zero
   316 00000A9D F3A6                <1> 	repe cmpsb			; match ?
   317 00000A9F 5E                  <1> 	pop si
   318 00000AA0 59                  <1> 	pop cx
   319 00000AA1 5F                  <1> 	pop di
   320 00000AA2 75E0                <1> 	jne .datarelocfind
   321 00000AA4 8814                <1> 	mov byte [si], dl
   322 00000AA6 262B7F0A            <1> 	sub di, word [es:bx + eldlDataPrefixes]	; = double index, 1-based
   323 00000AAA 4F                  <1> 	dec di
   324 00000AAB 4F                  <1> 	dec di				; 0-based
   325 00000AAC 26037F0E            <1> 	add di, word [es:bx + eldlDataAddresses]	; -> address (offset)
   326 00000AB0 268B05              <1> 	mov ax, word [es:di]
   327 00000AB3 E80700              <1> 	call .address_data_reloc
   328                              <1> %if _ELD_RELOC_VSTART
   329 00000AB6 2D[0000]            <1> 	sub ax, relocateddata		; *not* a relocation
   330                              <1> %endif
   331 00000AB9 0104                <1> 	add word [si], ax		; relocate
   332 00000ABB EB94                <1> 	jmp .datarelocloop
   333                              <1> 
   334                              <1> .address_data_reloc:
   335 00000ABD C576EE              <1> 	lds si, [bp + ?entry]		; -> entry if in ELD code instance
   336 00000AC0 807EFA00            <1> 	cmp byte [bp + ?targetsection], 0
   337                              <1> 					; relocation in code ?
   338 00000AC4 7402                <1> 	je @F				; yes -->
   339 00000AC6 16                  <1> 	push ss
   340 00000AC7 1F                  <1> 	pop ds				; => our ELD data block
   341                              <1> @@:
   342 00000AC8 C3                  <1> 	retn
   343                              <1> 
   344                              <1> .datarelocnotfound:
   345 00000AC9 8814                <1> 	mov byte [si], dl
   346 00000ACB 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 00000ACF 7448                <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 00000AD1 36F606[0000]02      <1> 	testopt [ss:relocateddata], 2
   381                              <1> linkdatarelocation options7, -3
   382 00000AD7 7406                <1> 	jz @F
   383 00000AD9 BE[4814]            <1> 	mov si, lmsg.warning_data_optional
   384                              <1> internalcoderelocation
   385 00000ADC E85C00              <1> 	call .notfound
   386                              <1> @@:
   387                              <1> %endif
   388 00000ADF E8DBFF              <1> 	call .address_data_reloc
   389 00000AE2 832400              <1> 	and word [si], 0		; indicate optional data link failed
   390 00000AE5 E969FF              <1> 	jmp .datarelocloop
   391                              <1> 
   392                              <1> 
   393                              <1> %if _ELDCALL_OPTIONAL
   394                              <1> .coderelocnotfound:
   395 00000AE8 8814                <1> 	mov byte [si], dl
   396 00000AEA 807EFB00            <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 00000AEE 743A                <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 00000AF0 BE[0000]            <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 00000AF3 85F6                <1> 	test si, si
   429 00000AF5 7406                <1> 	jz @F
   430 00000AF7 F646FB02            <1> 	test byte [bp + ?optional], 2
   431 00000AFB 752D                <1> 	jnz .codenotfound
   432                              <1> @@:
   433                              <1> %endif
   434                              <1> 
   435                              <1> %if _ELD_LINKER_PASSES
   436 00000AFD 36F606[0000]02      <1> 	testopt [ss:relocateddata], 2
   437                              <1> linkdatarelocation options7, -3
   438 00000B03 7406                <1> 	jz @F
   439 00000B05 BE[2614]            <1> 	mov si, lmsg.warning_code_optional
   440                              <1> internalcoderelocation
   441 00000B08 E83000              <1> 	call .notfound
   442                              <1> @@:
   443                              <1> %endif
   444 00000B0B C576EE              <1> 	lds si, [bp + ?entry]
   445 00000B0E C7049090            <1> 	mov word [si], 9090h
   446 00000B12 C6440290            <1> 	mov byte [si + 2], 90h		; indicate optional code link failed
   447 00000B16 E9A600              <1> 	jmp .coderelocloop
   448                              <1> %endif
   449                              <1> 
   450                              <1> 
   451                              <1> %if _ELD_LINKER_PASSES
   452                              <1> .datanotfound:
   453 00000B19 BE[6A14]            <1> 	mov si, lmsg.error_data
   454                              <1> internalcoderelocation
   455 00000B1C E81C00              <1> 	call .notfound
   456 00000B1F 7203E91F01          <1> 	jnc .error_j
   457 00000B24 FF46E8              <1> 	inc word [bp + ?amounterrors]
   458 00000B27 E927FF              <1> 	jmp .datarelocloop
   459                              <1> 
   460                              <1> .codenotfound:
   461 00000B2A BE[8314]            <1> 	mov si, lmsg.error_code
   462                              <1> internalcoderelocation
   463 00000B2D E80B00              <1> 	call .notfound
   464 00000B30 7203E90E01          <1> 	jnc .error_j
   465 00000B35 FF46E8              <1> 	inc word [bp + ?amounterrors]
   466 00000B38 E98400              <1> 	jmp .coderelocloop
   467                              <1> 
   468                              <1> .notfound:
   469 00000B3B 807EEA00            <1> 	cmp byte [bp + ?pass], 0
   470 00000B3F 743A                <1> 	je @F				; --> (NC)
   471 00000B41 16                  <1> 	 push ss
   472 00000B42 07                  <1> 	 pop es
   473 00000B43 BF[0000]            <1> 	mov di, relocateddata
   474                              <1> linkdatarelocation line_out
   475 00000B46 E83300              <1> 	call .copy
   476 00000B49 8B76E6              <1> 	mov si, word [bp + ?name]
   477 00000B4C AD                  <1> 	lodsw
   478 00000B4D E8[0000]EB020000    <1> 	extcall hexword
   479 00000B54 56                  <1> 	push si
   480 00000B55 BE[9C14]            <1> 	mov si, lmsg.error.2
   481                              <1> internalcoderelocation
   482 00000B58 E82100              <1> 	call .copy
   483 00000B5B 5E                  <1> 	pop si
   484                              <1> %if _ELD_LINKER_PASSES
   485 00000B5C 56                  <1> 	push si
   486 00000B5D E81C00              <1> 	call .copy
   487 00000B60 5E                  <1> 	pop si
   488 00000B61 C60400              <1> 	mov byte [si], 0		; mark as failed
   489                              <1> %else
   490                              <1> 	call .copy
   491                              <1> %endif
   492 00000B64 B022                <1> 	mov al, '"'
   493 00000B66 AA                  <1> 	stosb
   494 00000B67 16                  <1> 	 push ss
   495 00000B68 1F                  <1> 	 pop ds
   496 00000B69 E8[0000]EB020000    <1> 	extcall putsline_crlf
   497 00000B70 B8350E              <1> 	mov ax, 0E35h
   498 00000B73 E8[0000]EB020000    <1> 	extcall setrc
   499 00000B7A F9                  <1> 	stc				; CY, diagnostic displayed
   500                              <1> @@:
   501 00000B7B C3                  <1> 	retn
   502                              <1> 
   503                              <1> .copy:
   504 00000B7C E8[0000]EB020000    <1> 	extcall copy_single_counted_string
   505 00000B83 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 00000B84 2D[0000]            <1> 	sub ax, code
   514                              <1> %endif
   515 00000B87 0346FC              <1> 	add ax, word [bp + ?instance]
   516 00000B8A 96                  <1> 	xchg si, ax
   517                              <1> %if _ELD_LINKER_PASSES
   518 00000B8B 8976E6              <1> 	mov word [bp + ?name], si
   519                              <1> %endif
   520 00000B8E AD                  <1> 	lodsw			; = hash, si -> counted string
   521 00000B8F 8A14                <1> 	mov dl, byte [si]
   522                              <1> %if _ELD_LINKER_PASSES
   523 00000B91 84D2                <1> 	test dl, dl		; marked as already failed ?
   524 00000B93 750A                <1> 	jnz @F
   525 00000B95 837EE800            <1> 	cmp word [bp + ?amounterrors], 0
   526 00000B99 7503E9A500          <1> 	je .error_j
   527 00000B9E 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 00000B9F D046EC              <1> 	rol byte [bp + ?use_hash], 1
   540                              <1> @@:
   541 00000BA2 720A                <1> 	jc @F
   542 00000BA4 AC                  <1> 	lodsb
   543 00000BA5 91                  <1> 	xchg cx, ax		; cl = length
   544 00000BA6 AD                  <1> 	lodsw			; ax = prefix
   545 00000BA7 49                  <1> 	dec cx
   546 00000BA8 49                  <1> 	dec cx
   547 00000BA9 4E                  <1> 	dec si
   548 00000BAA 8A14                <1> 	mov dl, byte [si]
   549 00000BAC 880C                <1> 	mov byte [si], cl	; si -> counted string suffix
   550                              <1> @@:
   551                              <1> %if _ELD_LINKER_PASSES
   552 00000BAE F9                  <1> 	stc			; CY
   553                              <1> %endif
   554 00000BAF 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 00000BB0 8B56FC              <1> 	mov dx, word [bp + ?instance]
   564                              <1> %if _ELD_LINKER_PASSES
   565 00000BB3 8B5EEA              <1> 	mov bx, word [bp + ?pass]
   566 00000BB6 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 00000BB8 0397180E            <1> 	add dx, word [linktable - code + ltLinkCode + bx]
   572                              <1>  %endif
   573                              <1> %else
   574                              <1> 	add dx, linkercoderelocations - code
   575                              <1> %endif
   576 00000BBC 8956F2              <1> 	mov word [bp + ?nextreloc], dx
   577                              <1> 
   578                              <1> .coderelocloop:
   579 00000BBF C576F2              <1> 	lds si, [bp + ?nextreloc]
   580 00000BC2 AD                  <1> 	lodsw
   581                              <1> %if _ELDCALL_OPTIONAL
   582 00000BC3 48                  <1> 	dec ax
   583 00000BC4 7903E98C00          <1> 	js .donecodereloc
   584 00000BC9 8946FA              <1> 	mov word [bp + ?targetsection_low_optional_high], ax
   585 00000BCC AD                  <1> 	lodsw
   586                              <1> %endif
   587 00000BCD 0346FC              <1> 	add ax, word [bp + ?instance]
   588 00000BD0 8946EE              <1> 	mov word [bp + ?entry], ax
   589 00000BD3 AD                  <1> 	lodsw
   590 00000BD4 8976F2              <1> 	mov word [bp + ?nextreloc], si
   591                              <1> %ifn _ELDCALL_OPTIONAL
   592                              <1> 	test ax, ax
   593                              <1> 	jz .donecodereloc
   594                              <1> %endif
   595 00000BD7 E8AAFF              <1> 	call .build_match
   596                              <1> %if _ELD_LINKER_PASSES
   597 00000BDA 73E3                <1> 	jnc .coderelocloop
   598                              <1> %endif
   599 00000BDC C45EF6              <1> 	les bx, [bp + ?linkinfo]
   600 00000BDF 268B4F10            <1> 	mov cx, word [es:bx + eldlCodeAmount]	; amount code link info
   601 00000BE3 268B7F12            <1> 	mov di, word [es:bx + eldlCodePrefixes]	; -> prefixes or hashes
   602                              <1> .coderelocfind:
   603 00000BE7 F2AF                <1> 	repne scasw			; scan initial
   604                              <1> %if _ELDCALL_OPTIONAL
   605 00000BE9 7403E9FAFE          <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                              <1> 	jne .codenotfound
   614                              <1>  %endif
   615                              <1> %endif
   616 00000BEE 57                  <1> 	push di
   617 00000BEF 51                  <1> 	push cx
   618 00000BF0 56                  <1> 	push si
   619 00000BF1 262B7F12            <1> 	sub di, word [es:bx + eldlCodePrefixes]	; = double index, 1-based
   620 00000BF5 4F                  <1> 	dec di
   621 00000BF6 4F                  <1> 	dec di				; 0-based
   622 00000BF7 26037F14            <1> 	add di, word [es:bx + eldlCodeEntries]	; -> entry
   623 00000BFB 268B3D              <1> 	mov di, [es:di]			; -> counted suffix/string
   624 00000BFE B500                <1> 	mov ch, 0
   625 00000C00 8A0C                <1> 	mov cl, byte [si]		; cx = length
   626 00000C02 41                  <1> 	inc cx
   627                              <1> 	; cmp al, al			; ZR if length is zero
   628 00000C03 F3A6                <1> 	repe cmpsb			; match ?
   629 00000C05 5E                  <1> 	pop si
   630 00000C06 59                  <1> 	pop cx
   631 00000C07 5F                  <1> 	pop di
   632 00000C08 75DD                <1> 	jne .coderelocfind
   633 00000C0A 8814                <1> 	mov byte [si], dl
   634 00000C0C 262B7F12            <1> 	sub di, word [es:bx + eldlCodePrefixes]	; = double index, 1-based
   635 00000C10 4F                  <1> 	dec di
   636 00000C11 4F                  <1> 	dec di				; 0-based
   637 00000C12 01FF                <1> 	add di, di			; quadruple index
   638 00000C14 26037F16            <1> 	add di, word [es:bx + eldlCodeAddresses]	; -> address (offset, segment)
   639 00000C18 26FF35              <1> 	push word [es:di]
   640 00000C1B C576EE              <1> 	lds si, [bp + ?entry]
   641 00000C1E 8F4405              <1> 	pop word [si + 3 + 2]		; call near imm (3), jmp short (2)
   642                              <1> 					;  patch the destination address
   643 00000C21 803CE8              <1> 	cmp byte [si], 0E8h		; is it as expected ?
   644 00000C24 751D                <1> 	jne .error_j
   645 00000C26 268B7D02            <1> 	mov di, word [es:di + 2]
   646 00000C2A BB[0000]            <1> 	mov bx, relocateddata
   647                              <1> linkdatarelocation linkcall_table	; ss:bx -> link call table
   648 00000C2D 36833F01            <1> 	cmp word [ss:bx], 1		; is it initialised to format 1 ?
   649 00000C31 7510                <1> 	jne .error_j			; no -->
   650 00000C33 368B4F02            <1> 	mov cx, word [ss:bx + 2]	; get amount of segments
   651 00000C37 E30A                <1> 	jcxz .error_j			; none -->
   652                              <1> @@:
   653 00000C39 83C304              <1> 	add bx, 4			; -> next segment
   654 00000C3C 36393F              <1> 	cmp word [ss:bx], di		; value matches ?
   655 00000C3F 7405                <1> 	je @F				; yes, found -->
   656 00000C41 E2F6                <1> 	loop @B				; try remaining segments
   657                              <1> .error_j:
   658 00000C43 E98A00              <1> 	jmp .error
   659                              <1> 
   660                              <1> @@:
   661 00000C46 368B5F02            <1> 	mov bx, word [ss:bx + 2]	; -> call destination offset
   662                              <1> 		; si + 3 + delta = bx
   663                              <1> 		; delta = bx - si - 3
   664 00000C4A 29F3                <1> 	sub bx, si
   665 00000C4C 83EB03              <1> 	sub bx, 3
   666 00000C4F 895C01              <1> 	mov word [si + 1], bx		; patch the call instruction
   667 00000C52 E96AFF              <1> 	jmp .coderelocloop
   668                              <1> 
   669                              <1> .donecodereloc:
   670                              <1> %if _ELD_LINKER_PASSES
   671 00000C55 8B46E8              <1> 	mov ax, word [bp + ?amounterrors]
   672 00000C58 85C0                <1> 	test ax, ax
   673 00000C5A 75E7                <1> 	jnz .error_j
   674 00000C5C 8B5EEA              <1> 	mov bx, word [bp + ?pass]
   675 00000C5F 85DB                <1> 	test bx, bx
   676 00000C61 750B                <1> 	jnz @F
   677 00000C63 43                  <1> 	inc bx
   678 00000C64 43                  <1> 	inc bx
   679 00000C65 895EEA              <1> 	mov word [bp + ?pass], bx
   680 00000C68 8B56FC              <1> 	mov dx, word [bp + ?instance]
   681 00000C6B E95FFD              <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 00000C6E 16                  <1> 	push ss
   690 00000C6F 1F                  <1> 	pop ds
   691 00000C70 B02D                <1> 	mov al, 2Dh
   692 00000C72 E8[0000]EB020000    <1> 	extcall intchk			; ZR if offset = -1 or segment = 0
   693                              <1> 					; CHG: ax, dx, bx
   694 00000C79 7437                <1> 	jz .no_hint
   695                              <1> 
   696 00000C7B 8A26[0000]          <1> 	mov ah, byte [relocateddata]
   697                              <1> linkdatarelocation try_debugger_amis_multiplex_number
   698 00000C7F E85500              <1> 	call plex_check
   699 00000C82 7305                <1> 	jnc @F
   700                              <1> 
   701 00000C84 B4FF                <1> 	mov ah, 0FFh		; start with multiplex number 0FFh
   702                              <1> .loop_hint:
   703 00000C86 E84E00              <1> 	call plex_check
   704                              <1> @@:
   705 00000C89 7307                <1> 	jnc .end_hint		; if found --> (NC)
   706 00000C8B 80EC01              <1> 	sub ah, 1		; search is backward (to find latest installed first), from 0FFh to 00h including
   707 00000C8E 73F6                <1> 	jnc .loop_hint		; try next if we didn't check all yet -->
   708 00000C90 EB20                <1> 	jmp .no_hint
   709                              <1> 
   710                              <1> .end_hint:
   711 00000C92 50                  <1> 	push ax
   712 00000C93 C446FC              <1> 	les ax, [bp + ?instance]
   713 00000C96 BF[DF10]            <1> 	mov di, listmsg.hint.offset
   714                              <1> internalcoderelocation
   715 00000C99 E8[0000]EB020000    <1> 	extcall hexword
   716 00000CA0 BB[C410]            <1> 	mov bx, listmsg.hint
   717                              <1> internalcoderelocation
   718 00000CA3 368B16[0000]        <1> 	mov dx, [ss:relocateddata]
   719                              <1> linkdatarelocation extseg	; must be 86 Mode segment even in PM
   720 00000CA8 58                  <1> 	pop ax
   721 00000CA9 B040                <1> 	mov al, 40h		; AMIS message display service
   722 00000CAB 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 00000CB2 5B                  <1> 	pop bx				; -> our heap data
   816 00000CB3 5E                  <1> 	pop si				; -> our command line tail
   817 00000CB4 16                  <1> 	 push ss
   818 00000CB5 1F                  <1> 	 pop ds
   819 00000CB6 C47EFC              <1> 	les di, [bp + ?instance]
   820 00000CB9 268B4502            <1> 	mov ax, word [es:di + eldiEndCode]
   821                              <1> houdini
   822 00000CBD 2D[A009]            <1> 	sub ax, strict word endresident + code
   823                              <1> internalcoderelocation
   824 00000CC0 26C74502[A009]      <1> 	mov word [es:di + eldiEndCode], endresident + code
   825                              <1> internalcoderelocation
   826 00000CC6 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 00000CCA 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 00000CCD E900FC              <1> 	jmp start
   840                              <1> 
   841                              <1> .error:
   842 00000CD0 89EC5D              <1> 	lleave
   843 00000CD3 B8FFFF              <1> 	mov ax, -1
   844 00000CD6 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 00000CD7 16                  <1> 	push ss
   862 00000CD8 1F                  <1> 	pop ds
   863 00000CD9 F606[0000]08        <1> 	testopt [relocateddata], 8
   864                              <1> linkdatarelocation internalflags4, -3
   865 00000CDE 740B                <1> 	jz @F
   866 00000CE0 BE[0000]            <1> 	mov si, relocateddata
   867                              <1> linkdatarelocation amis_multiplex_number, -2, optional
   868 00000CE3 85F6                <1> 	test si, si
   869 00000CE5 7404                <1> 	jz @F
   870 00000CE7 3A24                <1> 	cmp ah, byte [si]
   871 00000CE9 7420                <1> 	je .notfound		; do not use our own multiplexer -->
   872                              <1> @@:
   873 00000CEB B000                <1> 	mov al, 00h		; AMIS installation check
   874 00000CED E8[0000]EB020000    <1> 	extcall call_int2D	; AMIS (or "DOS reserved" = iret if no AMIS present)
   875 00000CF4 3CFF                <1> 	cmp al, 0FFh
   876 00000CF6 7513                <1> 	jne .notfound
   877 00000CF8 0E                  <1> 	push cs
   878 00000CF9 1F                  <1> 	pop ds
   879 00000CFA BE[B410]            <1> 	mov si, debuggeramissig	; ds:si -> our AMIS name strings
   880                              <1> internalcoderelocation
   881 00000CFD E8[0000]EB020000    <1> 	extcall setes2dx	; es:di -> name strings of AMIS multiplexer that just answered
   882 00000D04 B90800              <1> 	mov cx, 8		; Ignore description, only compare vendor and program name
   883 00000D07 F3A7                <1> 	repe cmpsw
   884 00000D09 7401                <1> 	je .checkret		; ZR, NC = match -->
   885                              <1> .notfound:
   886 00000D0B F9                  <1> 	stc			; CY no match
   887                              <1> .checkret:
   888 00000D0C C3                  <1> 	retn
   889                              <1> %endif
   890                              <1> 
   891                              <1> 
   892 00000D0D 00<rep 3h>          <1> 	align 4, db 0
   893                              <1> linkercoderelocations:
   894                              <1> %if _ELDCALL_OPTIONAL
   895 00000D10 01002200[E710]0101- <1> 	dw ELDCALL_CODE_RELOCATIONS_OPTIONAL, 0
   895 00000D18 9F01[F610]01000602- <1>
   895 00000D20 [0411]01039F04-     <1>
   895 00000D26 [0F11]01037105-     <1>
   895 00000D2C [1E11]0100C307-     <1>
   895 00000D32 [2911]0100D007-     <1>
   895 00000D38 [3111]0100D807-     <1>
   895 00000D3E [3D11]0100E007-     <1>
   895 00000D44 [4911]0100E807-     <1>
   895 00000D4A [5011]0100F007-     <1>
   895 00000D50 [5911]0100F807-     <1>
   895 00000D56 [6011]01000008-     <1>
   895 00000D5C [6811]01000808-     <1>
   895 00000D62 [7011]01001008-     <1>
   895 00000D68 [7C11]01001808-     <1>
   895 00000D6E [8811]01002008-     <1>
   895 00000D74 [9511]01002808-     <1>
   895 00000D7A [A011]01003008-     <1>
   895 00000D80 [A911]01003808-     <1>
   895 00000D86 [B211]01004008-     <1>
   895 00000D8C [BC11]01004808-     <1>
   895 00000D92 [C711]01005008-     <1>
   895 00000D98 [D211]01005808-     <1>
   895 00000D9E [E211]01006008-     <1>
   895 00000DA4 [F411]01006808-     <1>
   895 00000DAA [FE11]01007008-     <1>
   895 00000DB0 [0712]01007808-     <1>
   895 00000DB6 [1C12]01008008-     <1>
   895 00000DBC [3212]01008808-     <1>
   895 00000DC2 [3C12]01005A09-     <1>
   895 00000DC8 [5011]0100720C-     <1>
   895 00000DCE [6312]0100990C-     <1>
   895 00000DD4 [B211]0100AB0C-     <1>
   895 00000DDA [6C12]0100ED0C-     <1>
   895 00000DE0 [6C12]0100FD0C-     <1>
   895 00000DE6 [7912]0000          <1>
   896                              <1> %else
   897                              <1> 	dw ELDCALL_CODE_RELOCATIONS, 0, 0
   898                              <1> %endif
   899                              <1> 
   900                              <1> %if _ELD_LINKER_PASSES
   901                              <1> linkerlinkercoderelocations:
   902                              <1> %if _ELDCALL_OPTIONAL
   903 00000DEA 01004D0B[B211]0100- <1> 	dw ELDCALL_LINKER_CODE_RELOCATIONS_OPTIONAL, 0
   903 00000DF2 690B[D211]0100730B- <1>
   903 00000DFA [6811]01007C0B-     <1>
   903 00000E00 [4612]0000          <1>
   904                              <1> %else
   905                              <1> 	dw ELDCALL_LINKER_CODE_RELOCATIONS, 0, 0
   906                              <1> %endif
   907                              <1> 
   908                              <1> 	align 2, db 0
   909                              <1> linktable:
   910                              <1> 	istruc LINKTABLE
   911                              <1> at ltCodeToCode
   912 00000E04 A210                <1> 	dw internallinkercodetocoderelocations - code
   913 00000E06 D40F                <1> 	dw internalcodetocoderelocations - code
   914                              <1> at ltCodeToData
   915 00000E08 AE10                <1> 	dw internallinkercodetodatarelocations - code
   916 00000E0A 0A10                <1> 	dw internalcodetodatarelocations - code
   917                              <1> at ltDataToCode
   918 00000E0C B010                <1> 	dw internallinkerdatatocoderelocations - code
   919 00000E0E 7010                <1> 	dw internaldatatocoderelocations - code
   920                              <1> at ltDataToData
   921 00000E10 B210                <1> 	dw internallinkerdatatodatarelocations - code
   922 00000E12 8610                <1> 	dw internaldatatodatarelocations - code
   923                              <1> at ltLinkData
   924 00000E14 8810                <1> 	dw linkerlinkerdatarelocations - code
   925 00000E16 1C0E                <1> 	dw linkerdatarelocations - code
   926                              <1> at ltLinkCode
   927 00000E18 EA0D                <1> 	dw linkerlinkercoderelocations - code
   928 00000E1A 100D                <1> 	dw linkercoderelocations - code
   929                              <1> 	iend
   930                              <1> %endif
   931                              <1> 
   932                              <1> 	align 2, db 0
   933                              <1> linkerdatarelocations:
   934 00000E1C 01004700[8412]0100- <1> 	dw LINK_DATA_RELOCATIONS, 0
   934 00000E24 4900[8E12]01004C00- <1>
   934 00000E2C [9712]01006000-     <1>
   934 00000E32 [A712]01006900-     <1>
   934 00000E38 [B212]01007500-     <1>
   934 00000E3E [BB12]01009900-     <1>
   934 00000E44 [BB12]0100D800-     <1>
   934 00000E4A [D112]0100DD00-     <1>
   934 00000E50 [E212]0100EF00-     <1>
   934 00000E56 [EB12]01000D01-     <1>
   934 00000E5C [D112]01002401-     <1>
   934 00000E62 [0313]01002801-     <1>
   934 00000E68 [0313]01002C01-     <1>
   934 00000E6E [EB12]01005801-     <1>
   934 00000E74 [E212]01007501-     <1>
   934 00000E7A [1613]01008001-     <1>
   934 00000E80 [1613]0100AA01-     <1>
   934 00000E86 [2113]0100AE01-     <1>
   934 00000E8C [3213]0100B101-     <1>
   934 00000E92 [4A13]0100C001-     <1>
   934 00000E98 [5C13]0100C301-     <1>
   934 00000E9E [5C13]01001502-     <1>
   934 00000EA4 [4A13]01003402-     <1>
   934 00000EAA [D112]01009402-     <1>
   934 00000EB0 [1613]01009702-     <1>
   934 00000EB6 [5C13]0100A102-     <1>
   934 00000EBC [5C13]0100CC02-     <1>
   934 00000EC2 [5C13]0100D302-     <1>
   934 00000EC8 [5C13]0100D702-     <1>
   934 00000ECE [3213]0100DC02-     <1>
   934 00000ED4 [4A13]0100EC02-     <1>
   934 00000EDA [2113]0100F302-     <1>
   934 00000EE0 [4A13]01000103-     <1>
   934 00000EE6 [5C13]01000603-     <1>
   934 00000EEC [5C13]01000B03-     <1>
   934 00000EF2 [EB12]01001003-     <1>
   934 00000EF8 [0313]01001403-     <1>
   934 00000EFE [0313]01001E03-     <1>
   934 00000F04 [0313]01002303-     <1>
   934 00000F0A [0313]01002903-     <1>
   934 00000F10 [1613]01003803-     <1>
   934 00000F16 [6813]0100B803-     <1>
   934 00000F1C [D112]01004404-     <1>
   934 00000F22 [5C13]01004904-     <1>
   934 00000F28 [3213]01005904-     <1>
   934 00000F2E [2113]01006904-     <1>
   934 00000F34 [5C13]01006D04-     <1>
   934 00000F3A [EB12]01007404-     <1>
   934 00000F40 [0313]01008304-     <1>
   934 00000F46 [0313]01008804-     <1>
   934 00000F4C [0313]01008E04-     <1>
   934 00000F52 [1613]0100AB04-     <1>
   934 00000F58 [6813]01005005-     <1>
   934 00000F5E [1613]0100C306-     <1>
   934 00000F64 [1613]02001400-     <1>
   934 00000F6A [7213]02001600-     <1>
   934 00000F70 [7213]02001800-     <1>
   934 00000F76 [7213]0100D608-     <1>
   934 00000F7C [8113]01002509-     <1>
   934 00000F82 [9113]01003909-     <1>
   934 00000F88 [9F13]01004909-     <1>
   934 00000F8E [AA13]01005609-     <1>
   934 00000F94 [B813]01006D09-     <1>
   934 00000F9A [AA13]01007109-     <1>
   934 00000FA0 [BB12]01008C09-     <1>
   934 00000FA6 [BB12]01009209-     <1>
   934 00000FAC [9F13]0100F10A-     <1>
   934 00000FB2 [4A13]01007D0C-     <1>
   934 00000FB8 [D813]0100A60C-     <1>
   934 00000FBE [B212]0100C80C-     <1>
   934 00000FC4 [AA13]0100DB0C-     <1>
   934 00000FCA [FD13]0101E10C-     <1>
   934 00000FD0 [0E14]0000          <1>
   935                              <1> 
   936                              <1> 	align 2, db 0
   937                              <1> internalcodetocoderelocations:
   938 00000FD4 7000BD0000015401D0- <1> 	dw INTERNAL_CODE_TO_CODE_RELOCATIONS, 0
   938 00000FDD 01D301D801DB01FC01- <1>
   938 00000FE6 D208DC08E708EF0840- <1>
   938 00000FEF 0945094D0952096909- <1>
   938 00000FF8 740987098E09970CA1- <1>
   938 00001001 0CBE0CC40CFB0C0000  <1>
   939                              <1> 
   940                              <1> 	align 2, db 0
   941                              <1> internalcodetodatarelocations:
   942 0000100A 3400C100D200F400F9- <1> 	dw INTERNAL_CODE_TO_DATA_RELOCATIONS, 0
   942 00001013 00FE00030115013301- <1>
   942 0000101C 40014D0152016B018D- <1>
   942 00001025 01CA01DE01E201E601- <1>
   942 0000102E ED01FA010102040241- <1>
   942 00001037 02490263026B02AA02- <1>
   942 00001040 B802C703CF03ED03F5- <1>
   942 00001049 032B044505B305D605- <1>
   942 00001052 E7054206A206B606CF- <1>
   942 0000105B 06EE06FE0608071607- <1>
   942 00001064 310749075C07A90798- <1>
   942 0000106D 090000              <1>
   943                              <1> 
   944                              <1> 	align 2, db 0
   945                              <1> internaldatatocoderelocations:
   946 00001070 000002000400060008- <1> 	dw INTERNAL_DATA_TO_CODE_RELOCATIONS, -1
   946 00001079 000A000C000E001000- <1>
   946 00001082 1200FFFF            <1>
   947                              <1> 
   948                              <1> 	align 2, db 0
   949                              <1> internaldatatodatarelocations:
   950 00001086 FFFF                <1> 	dw INTERNAL_DATA_TO_DATA_RELOCATIONS, -1
   951                              <1> 
   952                              <1> %if _ELD_LINKER_PASSES
   953                              <1> 	align 2, db 0
   954                              <1> linkerlinkerdatarelocations:
   955 00001088 0100D40A[9F13]0100- <1> 	dw LINK_LINKER_DATA_RELOCATIONS, 0
   955 00001090 000B[9F13]0100440B- <1>
   955 00001098 [1613]01002B0C-     <1>
   955 0000109E [C713]0000          <1>
   956                              <1> 
   957                              <1> 	align 2, db 0
   958                              <1> internallinkercodetocoderelocations:
   959 000010A2 DA0A060B1A0B2B0B56- <1> 	dw INTERNAL_LINKER_CODE_TO_CODE_RELOCATIONS, 0
   959 000010AB 0B0000              <1>
   960                              <1> 
   961                              <1> 	align 2, db 0
   962                              <1> internallinkercodetodatarelocations:
   963 000010AE 0000                <1> 	dw INTERNAL_LINKER_CODE_TO_DATA_RELOCATIONS, 0
   964                              <1> 
   965                              <1> 	align 2, db 0
   966                              <1> internallinkerdatatocoderelocations:
   967 000010B0 FFFF                <1> 	dw INTERNAL_LINKER_DATA_TO_CODE_RELOCATIONS, -1
   968                              <1> 
   969                              <1> 	align 2, db 0
   970                              <1> internallinkerdatatodatarelocations:
   971 000010B2 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 000010B4 65636D20<rep 5h>    <1> 		fill 8, 32, db "ecm"
   988 000010BC 6C446562756720-     <1> 		fill 8, 32, db "lDebug"
   988 000010BC <rep 2h>            <1>
   989                              <1> %endif
   990                              <1> 
   991                              <1> %ifnidni _LISTING, ""
   992                              <1> listmsg:
   993 000010C4 547261634C6973742D- <1> .hint:		db "TracList-add-offset=",_LISTING,"::"
   993 000010CD 6164642D6F66667365- <1>
   993 000010D6 743D732E6C73743A3A  <1>
   994 000010DF 2D2D2D2D680D0A00    <1> .hint.offset:	asciz "----h",13,10
   995                              <1> %endif
   996                              <1> 
   997 000010E7 30CD0C636D64335F6E- <1> 	eldcall_dump_names ELDCALL_CODE_NAMES
   997 000010F0 6F745F657874100B0B- <1>
   997 000010F9 636F756E745F73746F- <1>
   997 00001102 7265CFF10870726570- <1>
   997 0000110B 6861636B7D670C6865- <1>
   997 00001114 78776F72645F686967- <1>
   997 0000111D 68348A086865786477- <1>
   997 00001126 6F7264A7AA05657272- <1>
   997 0000112F 6F72D55509736B6970- <1>
   997 00001138 636F6D6D6103C30969- <1>
   997 00001141 73737472696E673FBA- <1>
   997 0000114A BD04636D6433DDB906- <1>
   997 00001153 63686B656F6C289004- <1>
   997 0000115C 6973706D5512057075- <1>
   997 00001165 74737AB21205736574- <1>
   997 0000116E 7263B0960967657472- <1>
   997 00001177 616E676558A4550973- <1>
   997 00001180 6B6970636F6D6D30BF- <1>
   997 00001189 BC0A736B6970657175- <1>
   997 00001192 616C73D9FA08676574- <1>
   997 0000119B 64776F72646DC90664- <1>
   997 000011A4 6F6861636B7B140675- <1>
   997 000011AD 6E6861636B84810768- <1>
   997 000011B6 6578776F7264398C08- <1>
   997 000011BF 707574736C696E6563- <1>
   997 000011C8 770864645F73746F72- <1>
   997 000011D1 656FA20D707574736C- <1>
   997 000011DA 696E655F63726C668A- <1>
   997 000011E3 0A0F746573745F6869- <1>
   997 000011EC 67685F6C696D697482- <1>
   997 000011F5 1B0768657862797465- <1>
   997 000011FE E83A066973656F6C3F- <1>
   997 00001207 5AA3126765745F6C65- <1>
   997 00001210 6E6774685F6B657977- <1>
   997 00001219 6F7264849013697365- <1>
   997 00001222 6F6C3F2E6E6F747365- <1>
   997 0000122B 6D69636F6C6F6E3D82- <1>
   997 00001234 07676574627974653F- <1>
   997 0000123D E807676574776F7264- <1>
   997 00001246 D0BB1A636F70795F73- <1>
   997 0000124F 696E676C655F636F75- <1>
   997 00001258 6E7465645F73747269- <1>
   997 00001261 6E67986906696E7463- <1>
   997 0000126A 686B21300A63616C6C- <1>
   997 00001273 5F696E743244B77408- <1>
   997 0000127C 7365746573326478    <1>
   998 00001284 C30B076C617374636D- <1> 	link_data_dump_names LINK_DATA_NAMES
   998 0000128D 646B5D06646D79636D- <1>
   998 00001296 6454400D6D73672E75- <1>
   998 0000129F 6E696E7374616C6CEB- <1>
   998 000012A8 420865787464737365- <1>
   998 000012B1 6CD52D066578747365- <1>
   998 000012BA 6797B6136578745F63- <1>
   998 000012C3 6F6D6D616E645F6861- <1>
   998 000012CC 6E646C6572CA510E69- <1>
   998 000012D5 6E7465726E616C666C- <1>
   998 000012DE 616773335B3B067265- <1>
   998 000012E7 675F64738AF2157373- <1>
   998 000012F0 735F73696C656E745F- <1>
   998 000012F9 636F756E745F757365- <1>
   998 00001302 645235107373735F73- <1>
   998 0000130B 696C656E745F636F75- <1>
   998 00001314 6E7484E3086C696E65- <1>
   998 0000131D 5F6F7574A08A0E7365- <1>
   998 00001326 617263685F72657375- <1>
   998 0000132F 6C7473D78E15736561- <1>
   998 00001338 7263685F726573756C- <1>
   998 00001341 74735F616D6F756E74- <1>
   998 0000134A 55030F6275696C645F- <1>
   998 00001353 6F7074696F6E5F504D- <1>
   998 0000135C BBCC097373636F756E- <1>
   998 00001365 7465727DB3076F7074- <1>
   998 0000136E 696F6E73A0390C6C69- <1>
   998 00001377 6E655F6F75745F656E- <1>
   998 00001380 64899F0D696E746572- <1>
   998 00001389 6E616C666C6167738D- <1>
   998 00001392 710B6D73672E696E73- <1>
   998 0000139B 74616C6C5ABC086F70- <1>
   998 000013A4 74696F6E7337E7D30B- <1>
   998 000013AD 6578747365675F7573- <1>
   998 000013B6 6564B2400C65787464- <1>
   998 000013BF 6174615F7573656468- <1>
   998 000013C8 440E6C696E6B63616C- <1>
   998 000013D1 6C5F7461626C65F09E- <1>
   998 000013DA 227472795F64656275- <1>
   998 000013E3 676765725F616D6973- <1>
   998 000013EC 5F6D756C7469706C65- <1>
   998 000013F5 785F6E756D626572CB- <1>
   998 000013FE 510E696E7465726E61- <1>
   998 00001407 6C666C61677334688C- <1>
   998 00001410 15616D69735F6D756C- <1>
   998 00001419 7469706C65785F6E75- <1>
   998 00001422 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 00001426 214F7074696F6E616C- <1> .warning_code_optional:		counted "Optional code link missing, hash="
  1006 0000142F 20636F6465206C696E- <1>
  1006 00001438 6B206D697373696E67- <1>
  1006 00001441 2C20686173683D      <1>
  1007                              <1> %endif
  1008 00001448 214F7074696F6E616C- <1> .warning_data_optional:		counted "Optional data link missing, hash="
  1008 00001451 2064617461206C696E- <1>
  1008 0000145A 6B206D697373696E67- <1>
  1008 00001463 2C20686173683D      <1>
  1009 0000146A 1844617461206C696E- <1> .error_data:			counted "Data link missing, hash="
  1009 00001473 6B206D697373696E67- <1>
  1009 0000147C 2C20686173683D      <1>
  1010 00001483 18436F6465206C696E- <1> .error_code:			counted "Code link missing, hash="
  1010 0000148C 6B206D697373696E67- <1>
  1010 00001495 2C20686173683D      <1>
  1011 0000149C 0A682C206C6162656C- <1> .error.2:			counted "h, label ",'"'
  1011 000014A5 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 000014A7 00<rep 9h>          <1> 	align 16, db 0
   775                                  
   776                                  	align 16
   777                                  code_size equ $ - code
