     1                                  
     2                                  ; Public Domain
     3                                  
     4                                  ; test install command: install; .; history uninstall
     5                                  ; test run command: ; .; .
     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-2023 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 eldSignature
    26 0000000C ????                <1> eldhCodeImageLength:	resw 1	; amount bytes
    27 0000000E ????                <1> eldhCodeAllocLength:	resw 1	; amount bytes, added to prior
    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
    32 0000001A ????????            <1> eldhReserved:		resb 4	; reserved
    33 0000001E ????                <1> eldhExtensionSize:	resw 1
    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
    40 00000024 ????????            <1> eldhxHelpOffset:	resd 1
    41 00000028 ????????????????    <1> 	alignb 16
    42                              <1> 	endstruc
    43                              <1> 
    44                              <1> 		; ELD instance header
    45                              <1> 	struc ELD_INSTANCE
    46 00000000 ????                <1> eldiStartCode:		resw 1	; -> this structure itself (para aligned)
    47 00000002 ????                <1> eldiEndCode:		resw 1	; -> behind memory used by instance (para aligned)
    48 00000004 ????                <1> eldiStartData:		resw 1	; -> data in data entry section (para aligned), or 0
    49 00000006 ????                <1> eldiEndData:		resw 1	; -> behind data (para aligned), or 0
    50 00000008 ????????????????    <1> eldiIdentifier:		resb 8	; blank-filled text
    51 00000010 ????                <1> eldiFlags:		resw 1	; flags
    52 00000012 <res Eh>            <1> eldiReserved:		resb 14	; reserved
    53                              <1> 	endstruc
    54                              <1> 		; flags for eldiFlags:
    55                              <1> eldifResident:		equ 1
    56                              <1> 
    57                              <1> 		; ELD link info header
    58                              <1> 	struc ELD_LINKINFO
    59 00000000 ????                <1> eldlSignature:		resw 1	; 0E1D1h
    60 00000002 ????????            <1> eldlReserved:		resw 2
    61 00000006 ????                <1> eldlUseLinkHash:	resw 1
    62 00000008 ????                <1> eldlDataAmount:		resw 1
    63 0000000A ????                <1> eldlDataPrefixes:	resw 1
    64 0000000C ????                <1> eldlDataEntries:	resw 1
    65 0000000E ????                <1> eldlDataAddresses:	resw 1
    66 00000010 ????                <1> eldlCodeAmount:		resw 1
    67 00000012 ????                <1> eldlCodePrefixes:	resw 1
    68 00000014 ????                <1> eldlCodeEntries:	resw 1
    69 00000016 ????                <1> eldlCodeAddresses:	resw 1
    70                              <1> 	endstruc
    71                              <1> 
    72                              <1> 	numdef ELD_CODE_VSTART, 9001h
    73                              <1> 	numdef ELD_DATA_VSTART, 8000h
    74                              <1> 	numdef ELD_RELOC_VSTART, 8000h
    75                              <1> 
    76                              <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-2023 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 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-2023 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 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 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]
    25                              <3>  [warning +reloc]
    26                              <3> %elifidni %1, off
    27                              <3>  %assign ELDSTRICT 0
    28                              <3>  [warning -reloc]
    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]
    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]
    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]
    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> 
    34                              <2> 	%imacro internalcoderelocation 0-1.nolist -2
    35                              <2> %assign %%entry $ + _CURRENT_SECTION %+ FIXUP + %1
    36                              <2> %if ELDLINKER
    37                              <2>  %ifidni _CURRENT_SECTION_TYPE, DATA
    38                              <2>   %xdefine INTERNAL_LINKER_DATA_TO_CODE_RELOCATIONS INTERNAL_LINKER_DATA_TO_CODE_RELOCATIONS, %%entry
    39                              <2>  %else
    40                              <2>   %xdefine INTERNAL_LINKER_CODE_TO_CODE_RELOCATIONS INTERNAL_LINKER_CODE_TO_CODE_RELOCATIONS, %%entry
    41                              <2>  %endif
    42                              <2> %else
    43                              <2>  %ifidni _CURRENT_SECTION_TYPE, DATA
    44                              <2>   %xdefine INTERNAL_DATA_TO_CODE_RELOCATIONS INTERNAL_DATA_TO_CODE_RELOCATIONS, %%entry
    45                              <2>  %else
    46                              <2>   %xdefine INTERNAL_CODE_TO_CODE_RELOCATIONS INTERNAL_CODE_TO_CODE_RELOCATIONS, %%entry
    47                              <2>  %endif
    48                              <2> %endif
    49                              <2> 	eldstrictcheck
    50                              <2> 	%endmacro
    51                              <2> 
    52                              <2> 	%imacro internaldatarelocation 0-1.nolist -2
    53                              <2> %assign %%entry $ + _CURRENT_SECTION %+ FIXUP + %1
    54                              <2> %if ELDLINKER
    55                              <2>  %ifidni _CURRENT_SECTION_TYPE, DATA
    56                              <2>   %xdefine INTERNAL_LINKER_DATA_TO_DATA_RELOCATIONS INTERNAL_LINKER_DATA_TO_DATA_RELOCATIONS, %%entry
    57                              <2>  %else
    58                              <2>   %xdefine INTERNAL_LINKER_CODE_TO_DATA_RELOCATIONS INTERNAL_LINKER_CODE_TO_DATA_RELOCATIONS, %%entry
    59                              <2>  %endif
    60                              <2> %else
    61                              <2>  %ifidni _CURRENT_SECTION_TYPE, DATA
    62                              <2>   %xdefine INTERNAL_DATA_TO_DATA_RELOCATIONS INTERNAL_DATA_TO_DATA_RELOCATIONS, %%entry
    63                              <2>  %else
    64                              <2>   %xdefine INTERNAL_CODE_TO_DATA_RELOCATIONS INTERNAL_CODE_TO_DATA_RELOCATIONS, %%entry
    65                              <2>  %endif
    66                              <2> %endif
    67                              <2> 	eldstrictcheck
    68                              <2> 	%endmacro
    69                              <2> 
    70                              <2> ; dw INTERNAL_LINKER_CODE_TO_CODE_RELOCATIONS, 0
    71                              <2> ; dw INTERNAL_LINKER_CODE_TO_DATA_RELOCATIONS, 0
    72                              <2> ; dw INTERNAL_LINKER_DATA_TO_CODE_RELOCATIONS, -1
    73                              <2> ; dw INTERNAL_LINKER_DATA_TO_DATA_RELOCATIONS, -1
    74                              <2> ; dw INTERNAL_CODE_TO_CODE_RELOCATIONS, 0
    75                              <2> ; dw INTERNAL_CODE_TO_DATA_RELOCATIONS, 0
    76                              <2> ; dw INTERNAL_DATA_TO_CODE_RELOCATIONS, -1
    77                              <2> ; dw INTERNAL_DATA_TO_DATA_RELOCATIONS, -1
    78                              <2> 
    79                              <2> 
    80                              <2> %define LINK_DATA_RELOCATIONS ""
    81                              <2> %define LINK_LINKER_DATA_RELOCATIONS ""
    82                              <2> %define LINK_DATA_NAMES db ""
    83                              <2> %define LINK_DATA_DETECTION none, none
    84                              <2> 
    85                              <2> 	%imacro linkdatarelocation 1-3.nolist -2, required
    86                              <2> %assign %%entry $ + _CURRENT_SECTION %+ FIXUP + %2
    87                              <2> %ifidni %3, required
    88                              <2>  %assign %%optional 0
    89                              <2> %elifidni %3, optional
    90                              <2>  %assign %%optional 100h
    91                              <2> %else
    92                              <2>  %fatal Unknown optional keyword
    93                              <2> %endif
    94                              <2> %ifidni _CURRENT_SECTION_TYPE, DATA
    95                              <2>  %assign %%DATASECTION 1
    96                              <2> %else
    97                              <2>  %assign %%DATASECTION 0
    98                              <2> %endif
    99                              <2> %if ELDLINKER
   100                              <2>  %xdefine LINK_LINKER_DATA_RELOCATIONS LINK_LINKER_DATA_RELOCATIONS, 1 + %%DATASECTION + %%optional, %%entry, %%name
   101                              <2> %else
   102                              <2>  %xdefine LINK_DATA_RELOCATIONS LINK_DATA_RELOCATIONS, 1 + %%DATASECTION + %%optional, %%entry, %%name
   103                              <2> %endif
   104                              <2> %defstr %%string %1
   105                              <2> %strlen %%length %%string
   106                              <2> %if %%length > 64
   107                              <2>  %error Too long link name: %1
   108                              <2> %endif
   109                              <2> %define LINK_DATA_CHECK %1
   110                              <2> 	linkdata_detect LINK_DATA_DETECTION
   111                              <2> %if LINK_DATA_NEW
   112                              <2>  %xdefine LINK_DATA_DETECTION LINK_DATA_DETECTION, %1, %%name
   113                              <2> 	hashdef HASH, %%string
   114                              <2>  %xdefine LINK_DATA_NAMES 	LINK_DATA_NAMES, %%name:, dw _HASH, {counted %%string}
   116                              <2> %else
   117                              <2>  %%name equ LINK_DATA_DUPLICATE
   118                              <2> %endif
   119                              <2> 	eldstrictcheck
   120                              <2> 	%endmacro
   121                              <2> 
   122                              <2> 	%imacro linkdata_detect 2-*.nolist
   123                              <2> %assign LINK_DATA_NEW 1
   124                              <2> %rep (%0 - 2) / 2
   125                              <2>  %rotate 2
   126                              <2>  %ifidni %1, LINK_DATA_CHECK
   127                              <2>   %assign LINK_DATA_NEW 0
   128                              <2>   %xdefine LINK_DATA_DUPLICATE %2
   129                              <2>   %exitrep
   130                              <2>  %endif
   131                              <2> %endrep
   132                              <2> 	%endmacro
   133                              <2> 
   134                              <2> 	%imacro link_data_dump_names 1-*.nolist
   135                              <2> %rep %0
   136                              <2> 	%1
   137                              <2>  %rotate 1
   138                              <2> %endrep
   139                              <2> 	%endmacro
   140                              <2> 
   141                              <2> ; dw LINK_LINKER_DATA_RELOCATIONS, 0, 0
   142                              <2> ; dw LINK_DATA_RELOCATIONS, 0, 0
   143                              <2> ; link_data_dump_names ELDCALL_CODE_NAMES
   144                              <2> 
   145                              <2> %endif
    21                              <1> 
    22                              <1> %assign ELDLINKER 0
    23                              <1> 
    24                              <1> 
    25                              <1> 	numdef HOUDINI, 1
    26                              <1> 	numdef HOUDINI_CONDITIONAL, 1
    27                              <1> 
    28                              <1> %imacro houdini 0.nolist
    29                              <1> %if _HOUDINI
    30                              <1>  %if _HOUDINI_CONDITIONAL
    31                              <1> reloc	testopt [ss:relocateddata], 100h
    32                              <1> linkdatarelocation options7, -3
    33                              <1> 	jz %%skip
    34                              <1>  %endif
    35                              <1> reloc	testopt [ss:relocateddata], 100h
    36                              <1> linkdatarelocation internalflags6, -3
    37                              <1> 	jz %%skip
    38                              <1> 	int3
    39                              <1> %%skip:
    40                              <1> %endif
    41                              <1> %endmacro
    42                              <1> 
    43                              <1> %define ELDCALL_CODE_RELOCATIONS ""
    44                              <1> %define ELDCALL_LINKER_CODE_RELOCATIONS ""
    45                              <1> %define ELDCALL_CODE_RELOCATIONS_OPTIONAL ""
    46                              <1> %define ELDCALL_LINKER_CODE_RELOCATIONS_OPTIONAL ""
    47                              <1> %define ELDCALL_CODE_NAMES db ""
    48                              <1> %define ELDCALL_CODE_DETECTION none, none
    49                              <1> %assign ELDCALL_OPTIONAL_STATUS 0		; not any seen yet
    50                              <1> %assign ELDCALL_PMREQUIRED_STATUS 0		; not any seen yet
    51                              <1> 
    52                              <1> 	%imacro extcall 1-2.nolist required
    53                              <1> %ifidni _CURRENT_SECTION_TYPE, DATA
    54                              <1>  %error "ELD call cannot be used in ELD data block"
    55                              <1> %endif
    56                              <1> %assign %%entry $ + _CURRENT_SECTION %+ FIXUP
    57                              <1> %ifidni %2, required
    58                              <1>  %assign %%optional 0
    59                              <1> %elifidni %2, optional
    60                              <1>  %assign %%optional 100h
    61                              <1>  %if ELDCALL_OPTIONAL_STATUS == 0
    62                              <1>   %assign ELDCALL_OPTIONAL_STATUS 1
    63                              <1>  %elif ELDCALL_OPTIONAL_STATUS == 1
    64                              <1>  %else
    65                              <1>   %error Optional code link not allowed here
    66                              <1>  %endif
    67                              <1> %elifidni %2, PM required
    68                              <1>  %assign %%optional 300h
    69                              <1>  %assign ELDCALL_PMREQUIRED_STATUS 1
    70                              <1>  %if ELDCALL_OPTIONAL_STATUS == 0
    71                              <1>   %assign ELDCALL_OPTIONAL_STATUS 1
    72                              <1>  %elif ELDCALL_OPTIONAL_STATUS == 1
    73                              <1>  %else
    74                              <1>   %error Optional code link not allowed here
    75                              <1>  %endif
    76                              <1> %else
    77                              <1>  %fatal Unknown optional keyword
    78                              <1> %endif
    79                              <1> 	call near $
    80                              <1> 	jmp strict short %%skipparameter
    81                              <1> 	dw 0
    82                              <1> %%skipparameter:
    83                              <1> %if ELDLINKER
    84                              <1>  %xdefine ELDCALL_LINKER_CODE_RELOCATIONS ELDCALL_LINKER_CODE_RELOCATIONS, %%entry, %%name
    85                              <1>  %xdefine ELDCALL_LINKER_CODE_RELOCATIONS_OPTIONAL ELDCALL_LINKER_CODE_RELOCATIONS_OPTIONAL, 1 + %%optional, %%entry, %%name
    86                              <1> %else
    87                              <1>  %xdefine ELDCALL_CODE_RELOCATIONS ELDCALL_CODE_RELOCATIONS, %%entry, %%name
    88                              <1>  %xdefine ELDCALL_CODE_RELOCATIONS_OPTIONAL ELDCALL_CODE_RELOCATIONS_OPTIONAL, 1 + %%optional, %%entry, %%name
    89                              <1> %endif
    90                              <1> %defstr %%string %1
    91                              <1> %strlen %%length %%string
    92                              <1> %if %%length > 64
    93                              <1>  %error Too long link name: %1
    94                              <1> %endif
    95                              <1> %define ELDCALL_CODE_CHECK %1
    96                              <1> 	linkcode_detect ELDCALL_CODE_DETECTION
    97                              <1> %if ELDCALL_CODE_NEW
    98                              <1>  %xdefine ELDCALL_CODE_DETECTION ELDCALL_CODE_DETECTION, %1, %%name
    99                              <1> 	hashdef HASH, %%string
   100                              <1> %xdefine ELDCALL_CODE_NAMES 	ELDCALL_CODE_NAMES, %%name:, dw _HASH, {counted %%string}
   102                              <1> %else
   103                              <1>  %%name equ ELDCALL_CODE_DUPLICATE
   104                              <1> %endif
   105                              <1> 	%endmacro
   106                              <1> 
   107                              <1> 	%imacro linkcode_detect 2-*.nolist
   108                              <1> %assign ELDCALL_CODE_NEW 1
   109                              <1> %rep (%0 - 2) / 2
   110                              <1>  %rotate 2
   111                              <1>  %ifidni %1, ELDCALL_CODE_CHECK
   112                              <1>   %assign ELDCALL_CODE_NEW 0
   113                              <1>   %xdefine ELDCALL_CODE_DUPLICATE %2
   114                              <1>   %exitrep
   115                              <1>  %endif
   116                              <1> %endrep
   117                              <1> 	%endmacro
   118                              <1> 
   119                              <1> 
   120                              <1> %define ELDCALL_CALLCALL_LIST none
   121                              <1> 
   122                              <1> 	%imacro extcallcall 1.nolist
   123                              <1> 	call %1
   124                              <1> %xdefine ELDCALL_CALLCALL_LIST ELDCALL_CALLCALL_LIST, %1
   125                              <1> 	%endmacro
   126                              <1> 
   127                              <1> %assign ELDCALLCALL_DUMPED 0
   128                              <1> 
   129                              <1> 	%imacro eldcall_dump_callcall 1-*.nolist
   130                              <1> %define ELDCALL_CALLCALL_PROCESSED none
   131                              <1>  %rep %0 - 1
   132                              <1>   %rotate 1
   133                              <1>   %define ELDCALL_CHECK %1
   134                              <1> 	eldcall_callcall_detect ELDCALL_CALLCALL_PROCESSED
   135                              <1>   %if ELDCALL_NEW
   136                              <1>    %xdefine ELDCALL_CALLCALL_PROCESSED ELDCALL_CALLCALL_PROCESSED, %1
   137                              <1> 	align 8, nop
   138                              <1> %1:
   139                              <1> 	extcall %1
   140                              <1> 	retn
   141                              <1>   %endif
   142                              <1>  %endrep
   143                              <1> %unimacro extcallcall 1.nolist
   144                              <1> %assign ELDCALLCALL_DUMPED 1
   145                              <1> %define ELDCALL_CALLCALL_LIST none
   146                              <1> 	%endmacro
   147                              <1> 
   148                              <1> 	%imacro eldcall_callcall_detect 1-*.nolist
   149                              <1> %assign ELDCALL_NEW 1
   150                              <1> %rep %0 - 1
   151                              <1>  %rotate 1
   152                              <1>  %ifidni %1, ELDCALL_CHECK
   153                              <1>   %assign ELDCALL_NEW 0
   154                              <1>   %exitrep
   155                              <1>  %endif
   156                              <1> %endrep
   157                              <1> 	%endmacro
   158                              <1> 
   159                              <1> 	%imacro eldcall_dump_names 1-*.nolist
   160                              <1> %rep %0
   161                              <1> 	%1
   162                              <1>  %rotate 1
   163                              <1> %endrep
   164                              <1> 	%endmacro
   165                              <1> 
   166                              <1> ; eldcall_dump_callcall ELDCALL_CALLCALL_LIST
   167                              <1> ; if using optional code links:
   168                              <1> ;  dw ELDCALL_LINKER_CODE_RELOCATIONS_OPTIONAL, 0
   169                              <1> ;  dw ELDCALL_CODE_RELOCATIONS_OPTIONAL, 0
   170                              <1> ; if not using optional code links:
   171                              <1> ;  dw ELDCALL_LINKER_CODE_RELOCATIONS, 0, 0
   172                              <1> ;  dw ELDCALL_CODE_RELOCATIONS, 0, 0
   173                              <1> ; eldcall_dump_names ELDCALL_CODE_NAMES
   174                              <1> 
   175                              <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-2023 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> 
    34                              <1> 	%imacro internalcoderelocation 0-1.nolist -2
    35                              <1> %assign %%entry $ + _CURRENT_SECTION %+ FIXUP + %1
    36                              <1> %if ELDLINKER
    37                              <1>  %ifidni _CURRENT_SECTION_TYPE, DATA
    38                              <1>   %xdefine INTERNAL_LINKER_DATA_TO_CODE_RELOCATIONS INTERNAL_LINKER_DATA_TO_CODE_RELOCATIONS, %%entry
    39                              <1>  %else
    40                              <1>   %xdefine INTERNAL_LINKER_CODE_TO_CODE_RELOCATIONS INTERNAL_LINKER_CODE_TO_CODE_RELOCATIONS, %%entry
    41                              <1>  %endif
    42                              <1> %else
    43                              <1>  %ifidni _CURRENT_SECTION_TYPE, DATA
    44                              <1>   %xdefine INTERNAL_DATA_TO_CODE_RELOCATIONS INTERNAL_DATA_TO_CODE_RELOCATIONS, %%entry
    45                              <1>  %else
    46                              <1>   %xdefine INTERNAL_CODE_TO_CODE_RELOCATIONS INTERNAL_CODE_TO_CODE_RELOCATIONS, %%entry
    47                              <1>  %endif
    48                              <1> %endif
    49                              <1> 	eldstrictcheck
    50                              <1> 	%endmacro
    51                              <1> 
    52                              <1> 	%imacro internaldatarelocation 0-1.nolist -2
    53                              <1> %assign %%entry $ + _CURRENT_SECTION %+ FIXUP + %1
    54                              <1> %if ELDLINKER
    55                              <1>  %ifidni _CURRENT_SECTION_TYPE, DATA
    56                              <1>   %xdefine INTERNAL_LINKER_DATA_TO_DATA_RELOCATIONS INTERNAL_LINKER_DATA_TO_DATA_RELOCATIONS, %%entry
    57                              <1>  %else
    58                              <1>   %xdefine INTERNAL_LINKER_CODE_TO_DATA_RELOCATIONS INTERNAL_LINKER_CODE_TO_DATA_RELOCATIONS, %%entry
    59                              <1>  %endif
    60                              <1> %else
    61                              <1>  %ifidni _CURRENT_SECTION_TYPE, DATA
    62                              <1>   %xdefine INTERNAL_DATA_TO_DATA_RELOCATIONS INTERNAL_DATA_TO_DATA_RELOCATIONS, %%entry
    63                              <1>  %else
    64                              <1>   %xdefine INTERNAL_CODE_TO_DATA_RELOCATIONS INTERNAL_CODE_TO_DATA_RELOCATIONS, %%entry
    65                              <1>  %endif
    66                              <1> %endif
    67                              <1> 	eldstrictcheck
    68                              <1> 	%endmacro
    69                              <1> 
    70                              <1> ; dw INTERNAL_LINKER_CODE_TO_CODE_RELOCATIONS, 0
    71                              <1> ; dw INTERNAL_LINKER_CODE_TO_DATA_RELOCATIONS, 0
    72                              <1> ; dw INTERNAL_LINKER_DATA_TO_CODE_RELOCATIONS, -1
    73                              <1> ; dw INTERNAL_LINKER_DATA_TO_DATA_RELOCATIONS, -1
    74                              <1> ; dw INTERNAL_CODE_TO_CODE_RELOCATIONS, 0
    75                              <1> ; dw INTERNAL_CODE_TO_DATA_RELOCATIONS, 0
    76                              <1> ; dw INTERNAL_DATA_TO_CODE_RELOCATIONS, -1
    77                              <1> ; dw INTERNAL_DATA_TO_DATA_RELOCATIONS, -1
    78                              <1> 
    79                              <1> 
    80                              <1> %define LINK_DATA_RELOCATIONS ""
    81                              <1> %define LINK_LINKER_DATA_RELOCATIONS ""
    82                              <1> %define LINK_DATA_NAMES db ""
    83                              <1> %define LINK_DATA_DETECTION none, none
    84                              <1> 
    85                              <1> 	%imacro linkdatarelocation 1-3.nolist -2, required
    86                              <1> %assign %%entry $ + _CURRENT_SECTION %+ FIXUP + %2
    87                              <1> %ifidni %3, required
    88                              <1>  %assign %%optional 0
    89                              <1> %elifidni %3, optional
    90                              <1>  %assign %%optional 100h
    91                              <1> %else
    92                              <1>  %fatal Unknown optional keyword
    93                              <1> %endif
    94                              <1> %ifidni _CURRENT_SECTION_TYPE, DATA
    95                              <1>  %assign %%DATASECTION 1
    96                              <1> %else
    97                              <1>  %assign %%DATASECTION 0
    98                              <1> %endif
    99                              <1> %if ELDLINKER
   100                              <1>  %xdefine LINK_LINKER_DATA_RELOCATIONS LINK_LINKER_DATA_RELOCATIONS, 1 + %%DATASECTION + %%optional, %%entry, %%name
   101                              <1> %else
   102                              <1>  %xdefine LINK_DATA_RELOCATIONS LINK_DATA_RELOCATIONS, 1 + %%DATASECTION + %%optional, %%entry, %%name
   103                              <1> %endif
   104                              <1> %defstr %%string %1
   105                              <1> %strlen %%length %%string
   106                              <1> %if %%length > 64
   107                              <1>  %error Too long link name: %1
   108                              <1> %endif
   109                              <1> %define LINK_DATA_CHECK %1
   110                              <1> 	linkdata_detect LINK_DATA_DETECTION
   111                              <1> %if LINK_DATA_NEW
   112                              <1>  %xdefine LINK_DATA_DETECTION LINK_DATA_DETECTION, %1, %%name
   113                              <1> 	hashdef HASH, %%string
   114                              <1>  %xdefine LINK_DATA_NAMES 	LINK_DATA_NAMES, %%name:, dw _HASH, {counted %%string}
   116                              <1> %else
   117                              <1>  %%name equ LINK_DATA_DUPLICATE
   118                              <1> %endif
   119                              <1> 	eldstrictcheck
   120                              <1> 	%endmacro
   121                              <1> 
   122                              <1> 	%imacro linkdata_detect 2-*.nolist
   123                              <1> %assign LINK_DATA_NEW 1
   124                              <1> %rep (%0 - 2) / 2
   125                              <1>  %rotate 2
   126                              <1>  %ifidni %1, LINK_DATA_CHECK
   127                              <1>   %assign LINK_DATA_NEW 0
   128                              <1>   %xdefine LINK_DATA_DUPLICATE %2
   129                              <1>   %exitrep
   130                              <1>  %endif
   131                              <1> %endrep
   132                              <1> 	%endmacro
   133                              <1> 
   134                              <1> 	%imacro link_data_dump_names 1-*.nolist
   135                              <1> %rep %0
   136                              <1> 	%1
   137                              <1>  %rotate 1
   138                              <1> %endrep
   139                              <1> 	%endmacro
   140                              <1> 
   141                              <1> ; dw LINK_LINKER_DATA_RELOCATIONS, 0, 0
   142                              <1> ; dw LINK_DATA_RELOCATIONS, 0, 0
   143                              <1> ; link_data_dump_names ELDCALL_CODE_NAMES
   144                              <1> 
   145                              <1> %endif
    11                                  
    12                                  	cpu 8086
    13                                  
    14                                  	addsection RELOCATEDDATA, nobits vstart=_ELD_RELOC_VSTART
    15                                  relocateddata:
    16                                  
    17                                  	addsection HEADER, start=0
    18                                  
    19                                  	istruc ELD_HEADERX
    20                                  at eldhxHeader
    21                                  		; ELD executable header
    22                                  	istruc ELD_HEADER
    23 00000000 454C4431                at eldhSignature,	db "ELD1"
    24 00000004 000000                  			db 0,0,0
    25 00000007 1A                      			db 26
    26 00000008 50000000                at eldhCodeOffset,	dd CODEOFFSET
    27 0000000C F009                    at eldhCodeImageLength,	dw code_size
    28 0000000E 0000                    at eldhCodeAllocLength,	dw 0
    29 00000010 400A0000                at eldhDataOffset,	dd DATAOFFSET
    30 00000014 E001                    at eldhDataImageLength,	dw data_size
    31 00000016 0000                    at eldhDataAllocLength,	dw total_data_size - data_size
    32 00000018 9902                    at eldhCodeEntrypoint,	dw linker - code
    33                                  at eldhReserved
    34 0000001A 00<rep 4h>2800          at eldhExtensionSize,	dw header_extension_end - $$
    35                                  	iend
    36 00000020 [30000000]              at eldhxDescriptionOffset,	dd description
    37 00000024 320B0000                at eldhxHelpOffset,		dd DATAOFFSET + msg.help - datastart
    38                                  header_extension_end:
    39 00000028 00<rep 8h>              	iend
    40                                  
    41 00000030 50726F766964652048-     description:		asciz "Provide HISTORY utility."
    41 00000039 4953544F5259207574-
    41 00000042 696C6974792E00     
    42                                  
    43                                  
    44 00000049 00<rep 7h>              	align 16, db 0
    45                                  
    46                                  CODEOFFSET equ $ - $$
    47                                  	addsection CODE, follows=HEADER vstart=_ELD_CODE_VSTART
    48                                  %define CODEFIXUP - code + 0
    49                                  code:
    50                                  		; ELD instance header
    51                                  	istruc ELD_INSTANCE
    52                                  at eldiStartCode
    53 00000000 00<rep 2h>              at eldiEndCode
    54 00000002 00<rep 2h>              at eldiStartData
    55 00000004 00<rep 2h>              at eldiEndData
    56 00000006 00<rep 2h>48495354-     at eldiIdentifier,	fill 8, 32, db "HISTORY"
    56 0000000C 4F525920           
    57 00000010 00<rep 10h>             	iend
    58                                  
    59                                  
    60                                  command:
    61 00000020 EB08                    	jmp strict short .entry
    62                                  .chain:
    63 00000022 E8FDFFEB020000          	extcall cmd3_not_ext, required	; must NOT be extcallcall
    64 00000029 90                      	times 10 - ($ - command) nop
    65                                  .entry:
    66 0000002A 56                      	push si
    67 0000002B 3C2D                    	cmp al, '-'
    68 0000002D 7503                    	jne @F
    69 0000002F E86E01                  	extcallcall skipcomma
    70                                  @@:
    71 00000032 4E                      	dec si
    72                                  
    73 00000033 BA[0000]                	mov dx, msg.history
    74                                  internaldatarelocation
    75 00000036 E86F01                  	extcallcall isstring?
    76 00000039 7405                    	je .ours
    77 0000003B 5E                      	pop si
    78 0000003C 4E                      	dec si
    79 0000003D AC                      	lodsb
    80 0000003E EBE2                    	jmp .chain
    81                                  
    82                                  .ours:
    83 00000040 58                      	pop ax
    84 00000041 E85C01                  	extcallcall skipcomma
    85 00000044 4E                      	dec si
    86 00000045 BA[0000]                	mov dx, relocateddata
    87                                  linkdatarelocation msg.uninstall
    88 00000048 E85D01                  	extcallcall isstring?
    89 0000004B 741D                    	je uninstall
    90 0000004D BA[0800]                	mov dx, msg.clear
    91                                  internaldatarelocation
    92 00000050 E85501                  	extcallcall isstring?
    93 00000053 7410                    	je clear
    94 00000055 BA[0E00]                	mov dx, msg.show
    95                                  internaldatarelocation
    96 00000058 E84D01                  	extcallcall isstring?
    97                                  	; je
    98 0000005B AC                      	lodsb
    99 0000005C E85101                  	extcallcall chkeol
   100 0000005F E88800                  	call run_show
   101                                  @@:
   102 00000062 E85301                  	extcallcall cmd3
   103                                  
   104                                  clear:
   105 00000065 E87800                  	call run_clear
   106 00000068 EBF8                    	jmp @B
   107                                  
   108                                  uninstall:
   109 0000006A AC                      	lodsb
   110 0000006B E84201                  	extcallcall chkeol
   111                                  
   112 0000006E 8E06[0000]              	mov es, word [relocateddata]
   113                                  linkdatarelocation extdssel
   114 00000072 E84B01                  	extcallcall ispm
   115 00000075 7404                    	jz @F
   116 00000077 8E06[0000]              	mov es, word [relocateddata]
   117                                  linkdatarelocation extseg
   118                                  @@:
   119 0000007B 06                      	push es
   120 0000007C 1F                      	pop ds
   121 0000007D 31DB                    	xor bx, bx		; = 0 (no prior, modify ext_command_handler)
   122 0000007F BF[2000]                	mov di, command		; di -> us
   123                                  internalcoderelocation
   124 00000082 368B36[0000]            	mov si, word [ss:relocateddata]
   125                                  linkdatarelocation ext_command_handler
   126                                  				; si -> first
   127 00000087 85F6                    	test si, si		; none installed ?
   128 00000089 7450                    	jz .error		; error -->
   129                                  
   130                                  .loop:
   131 0000008B 39F7                    	cmp di, si		; found ?
   132 0000008D 740D                    	je .bx			; yes, use bx -->
   133 0000008F 89F3                    	mov bx, si		; bx -> prior handler
   134 00000091 AD                      	lodsw			; skip entrypoint jmp strict short
   135 00000092 AC                      	lodsb			; get first byte of chainer
   136 00000093 3CE9                    	cmp al, 0E9h		; expecting jmp near ?
   137 00000095 7544                    	jne .error		; no, error -->
   138 00000097 AD                      	lodsw			; get rel16 displacement
   139 00000098 01C6                    	add si, ax		; -> next handler
   140 0000009A EBEF                    	jmp .loop
   141                                  
   142                                  .bx:
   143 0000009C 85DB                    	test bx, bx		; any prior ?
   144 0000009E 751A                    	jnz .bxnz		; yes -->
   145 000000A0 AF                      	scasw			; skip entrypoint jmp strict short
   146 000000A1 803DE8                  	cmp byte [di], 0E8h	; is it a call to cmd3_not_ext ?
   147 000000A4 7507                    	jne @F			; no -->
   148                                  				; yes, reset ext_command_handler to zero
   149                                  .setbx:
   150 000000A6 36891E[0000]            	mov word [ss:relocateddata], bx
   151                                  linkdatarelocation ext_command_handler
   152 000000AB EB1E                    	jmp .done
   153                                  
   154                                  @@:
   155 000000AD 803DE9                  	cmp byte [di], 0E9h	; validate
   156 000000B0 7529                    	jne .error		; failure -->
   157 000000B2 47                      	inc di			; -> rel16 displacement
   158 000000B3 8B1D                    	mov bx, word [di]	; get displacement
   159 000000B5 AF                      	scasw			; -> after jmp near
   160 000000B6 01FB                    	add bx, di		; -> next handler
   161 000000B8 EBEC                    	jmp .setbx		; set ext_command_handler to next
   162                                  
   163                                  .bxnz:
   164 000000BA 89DE                    	mov si, bx		; -> prior handler with us as downlink
   165 000000BC 87FE                    	xchg di, si		; si -> ours, di -> prior
   166 000000BE A7                      	cmpsw			; skip entrypoint jmp strict short
   167 000000BF A4                      	movsb			; copy 0E8h/0E9h
   168 000000C0 AD                      	lodsw			; ax = near rel16 displacement
   169 000000C1 01F0                    	add ax, si		; add in our base (= absolute offset)
   170 000000C3 29F8                    	sub ax, di
   171 000000C5 48                      	dec ax
   172 000000C6 48                      	dec ax			; subtract new base (= relative displacement)
   173 000000C7 AB                      	stosw			; store new rel16 displacement
   174 000000C8 A5                      	movsw			; jmp strict short
   175 000000C9 A5                      	movsw			; linkcall target
   176 000000CA A4                      	movsb			; trailer
   177                                  .done:
   178 000000CB 8026[1000]FE            	clropt [code + eldiFlags], eldifResident
   179                                  internalcoderelocation -3	; mark block as free
   180 000000D0 BA[1300]                	mov dx, msg.uninstall_done
   181                                  internaldatarelocation
   182                                  @@:
   183 000000D3 16                      	push ss
   184 000000D4 1F                      	pop ds
   185 000000D5 E8F000                  	extcallcall putsz
   186 000000D8 E8DD00                  	extcallcall cmd3	; return
   187                                  
   188                                  .error:
   189 000000DB BA[5400]                	mov dx, msg.uninstall_error
   190                                  internaldatarelocation
   191 000000DE EBF3                    	jmp @B
   192                                  
   193                                  
   194                                  run_clear:
   195 000000E0 E8A400                  	call get_history_first_last
   196 000000E3 8B07                    	mov ax, word [bx]
   197 000000E5 87D3                    	xchg dx, bx
   198 000000E7 8907                    	mov word [bx], ax
   199 000000E9 C3                      	retn
   200                                  
   201                                  
   202                                  run_show:
   203 000000EA 36F606[0100]017409-     	houdini
   203 000000F2 36F606[0100]017401-
   203 000000FA CC                 
   204 000000FB 16                      	push ss
   205 000000FC 07                      	pop es
   206 000000FD C606[F200]00            	mov byte [history_data_entry], 0
   207                                  internaldatarelocation -3
   208 00000102 B8[0000]                	mov ax, relocateddata
   209                                  linkdatarelocation historyformat, -2, optional
   210 00000105 85C0                    	test ax, ax
   211 00000107 7508                    	jnz @F
   212 00000109 BA[7B00]                	mov dx, msg.history_none
   213                                  internaldatarelocation
   214                                  .putsz_end:
   215 0000010C E8B900                  	extcallcall putsz
   216 0000010F EB75                    	jmp .end
   217                                  
   218                                  @@:
   219 00000111 83F802                  	cmp ax, 2
   220 00000114 7207                    	jb .in_data_entry
   221 00000116 7409                    	je .in_separate
   222                                  
   223 00000118 BA[9D00]                	mov dx, msg.history_unknown
   224                                  internaldatarelocation
   225 0000011B EBEF                    	jmp .putsz_end
   226                                  
   227                                  .in_data_entry:
   228 0000011D F616[F200]              	not byte [history_data_entry]
   229                                  internaldatarelocation
   230                                  .in_separate:
   231 00000121 E86300                  	call get_history_first_last
   232 00000124 89D6                    	mov si, dx
   233 00000126 87F3                    	xchg si, bx
   234 00000128 8B34                    	mov si, [si]
   235 0000012A 8B1F                    	mov bx, [bx]
   236 0000012C 36F606[0100]017409-     houdini
   236 00000134 36F606[0100]017401-
   236 0000013C CC                 
   237 0000013D 4E                      	dec si
   238 0000013E 4E                      	dec si
   239 0000013F 31D2                    	xor dx, dx
   240 00000141 D006[F200]              	rol byte [history_data_entry], 1
   241                                  internaldatarelocation
   242 00000145 730A                    	jnc .not_entry
   243 00000147 BA[0000]                	mov dx, relocateddata
   244                                  linkdatarelocation historybuffer, -2, optional
   245 0000014A 85D2                    	test dx, dx
   246 0000014C 7503                    	jnz @F
   247 0000014E E84400                  	call history_missing
   248                                  @@:
   249                                  .not_entry:
   250                                  
   251                                  .loop:
   252 00000151 BF[0000]                	mov di, relocateddata
   253                                  linkdatarelocation line_out
   254 00000154 39DE                    	cmp si, bx
   255 00000156 722E                    	jb .done
   256                                  
   257 00000158 D006[F200]              	rol byte [history_data_entry], 1
   258                                  internaldatarelocation
   259 0000015C 720B                    	jc .not_seg
   260 0000015E 53                      	push bx
   261 0000015F BB[0000]                	mov bx, relocateddata
   262                                  linkdatarelocation history.segorsel, -2, optional
   263 00000162 85DB                    	test bx, bx
   264 00000164 742F                    	jz history_missing	; bx on stack discarded
   265 00000166 8E1F                    	mov ds, word [bx]
   266 00000168 5B                      	pop bx
   267                                  .not_seg:
   268                                  	; extcallcall decword
   269 00000169 AD                      	lodsw			; ax -> behind entry
   270 0000016A 01D0                    	add ax, dx
   271 0000016C 8B0C                    	mov cx, [si]		; cx -> behind prior entry, start of this
   272 0000016E 01D1                    	add cx, dx
   273 00000170 96                      	xchg ax, si		; si -> behind
   274 00000171 29CE                    	sub si, cx		; si = length
   275 00000173 87F1                    	xchg si, cx		; cx = length, si -> text
   276 00000175 F3A4                    	rep movsb
   277 00000177 96                      	xchg ax, si		; restore si -> next high array entry
   278 00000178 83EE04                  	sub si, 4
   279 0000017B 16                      	push ss
   280 0000017C 1F                      	pop ds
   281 0000017D 52                      	 push dx
   282 0000017E 53                      	 push bx
   283 0000017F E84E00                  	extcallcall putsline_crlf
   284 00000182 5B                      	 pop bx
   285 00000183 5A                      	 pop dx
   286 00000184 EBCB                    	jmp .loop
   287                                  
   288                                  .done:
   289                                  .end:
   290 00000186 C3                      	retn
   291                                  
   292                                  
   293                                  get_history_first_last:
   294 00000187 BB[0000]                	mov bx, relocateddata
   295                                  linkdatarelocation history.first, -2, optional
   296 0000018A BA[0000]                	mov dx, relocateddata
   297                                  linkdatarelocation history.last, -2, optional
   298 0000018D 85DB                    	test bx, bx
   299 0000018F 7404                    	jz @F
   300 00000191 85D2                    	test dx, dx
   301 00000193 7507                    	jnz @FF
   302                                  
   303                                  @@:
   304                                  history_missing:
   305 00000195 BA[B900]                	mov dx, msg.history_missing
   306                                  internaldatarelocation
   307 00000198 E82D00                  	extcallcall putsz
   308 0000019B 59                      	pop cx
   309                                  @@:
   310 0000019C C3                      	retn
   311                                  
   312                                  
   313 0000019D 90<rep 3h>E8FDFFEB-     	eldcall_dump_callcall ELDCALL_CALLCALL_LIST
   313 000001A4 020000C3E8FDFFEB02-
   313 000001AD 0000C3E8FDFFEB0200-
   313 000001B6 00C3E8FDFFEB020000-
   313 000001BF C3E8FDFFEB020000C3-
   313 000001C8 E8FDFFEB020000C3E8-
   313 000001D1 FDFFEB020000C3     
   314                                  
   315                                  endinstalled equ ($ + CODEFIXUP + 15) & ~15
   316                                  
   317                                  
   318                                  start:
   319 000001D8 8CC3                    	mov bx, es
   320 000001DA 16                      	 push ss
   321 000001DB 07                      	 pop es
   322 000001DC E8C1FF                  	call skipcomma
   323 000001DF 4E                      	dec si
   324 000001E0 BA[0000]                	mov dx, relocateddata
   325                                  linkdatarelocation msg.install
   326 000001E3 E8C2FF                  	call isstring?
   327 000001E6 744D                    	je install
   328 000001E8 BA[0E00]                	mov dx, msg.show
   329                                  internaldatarelocation
   330 000001EB E8BAFF                  	call isstring?
   331 000001EE 7418                    	je .show
   332 000001F0 BA[0800]                	mov dx, msg.clear
   333                                  internaldatarelocation
   334 000001F3 E8B2FF                  	call isstring?
   335 000001F6 7415                    	je .clear
   336                                  
   337 000001F8 AC                      	lodsb
   338 000001F9 E8B4FF                  	call chkeol
   339 000001FC BA[F200]                	mov dx, msg.help
   340                                  internaldatarelocation
   341 000001FF E8C6FF                  	call putsz
   342                                  @@:
   343 00000202 E80D00                  	call uninstall_oneshot
   344 00000205 31C0                    	xor ax, ax
   345 00000207 CB                      	retf
   346                                  
   347                                  .show:
   348 00000208 E8DFFE                  	call run_show
   349 0000020B EBF5                    	jmp @B
   350                                  
   351                                  .clear:
   352 0000020D E8D0FE                  	call run_clear
   353 00000210 EBF0                    	jmp @B
   354                                  
   355                                  
   356                                  uninstall_oneshot:
   357 00000212 36F606[0000]01          	testopt [ss:relocateddata], 1
   358                                  linkdatarelocation options7, -3
   359 00000218 751A                    	jnz @F
   360                                  
   361 0000021A 2EA1[0200]              	mov ax, word [cs:code + eldiEndCode]
   362                                  internalcoderelocation
   363 0000021E 2E2B06[0000]            	sub ax, word [cs:code + eldiStartCode]
   364                                  internalcoderelocation
   365 00000223 2906[0000]              	sub word [relocateddata], ax
   366                                  linkdatarelocation extseg_used
   367                                  
   368 00000227 2EA1[0600]              	mov ax, word [cs:code + eldiEndData]
   369                                  internalcoderelocation
   370 0000022B 2E2B06[0400]            	sub ax, word [cs:code + eldiStartData]
   371                                  internalcoderelocation
   372 00000230 2906[0000]              	sub word [relocateddata], ax
   373                                  linkdatarelocation extdata_used
   374                                  @@:
   375 00000234 C3                      	retn
   376                                  
   377                                  
   378                                  install:
   379 00000235 AC                      	lodsb
   380 00000236 E8FDFFEB020000          	extcall chkeol
   381                                  
   382 0000023D 36F606[0100]017409-     	houdini
   382 00000245 36F606[0100]017401-
   382 0000024D CC                 
   383 0000024E 8EC3                    	mov es, bx		; => ext seg (writable)
   384 00000250 B8C000                  	mov ax, endresident - endinstalled
   385 00000253 262906[0200]            	sub word [es:code + eldiEndCode], ax
   386                                  internalcoderelocation		; adjust size
   387 00000258 2906[0000]              	sub word [relocateddata], ax
   388                                  linkdatarelocation extseg_used	; adjust size
   389 0000025C B8E000                  	mov ax, init_data_end - resident_data_end
   390 0000025F 262906[0600]            	sub word [es:code + eldiEndData], ax
   391                                  internalcoderelocation		; adjust size
   392 00000264 2906[0000]              	sub word [relocateddata], ax
   393                                  linkdatarelocation extdata_used	; adjust size
   394 00000268 8B1E[0000]              	mov bx, word [relocateddata]
   395                                  linkdatarelocation ext_command_handler
   396                                  				; -> prior
   397 0000026C BF[2000]                	mov di, command		; -> our handler
   398                                  internalcoderelocation
   399 0000026F 85DB                    	test bx, bx		; installing as first ?
   400 00000271 740A                    	jz .only_first		; yes, simple --> (leave as extcall cmd3_not_ext)
   401 00000273 AF                      	scasw			; skip entrypoint jmp strict short
   402 00000274 B0E9                    	mov al, 0E9h		; = jmp near opcode
   403 00000276 AA                      	stosb			; store
   404 00000277 93                      	xchg ax, bx		; ax -> next handler
   405 00000278 29F8                    	sub ax, di
   406 0000027A 48                      	dec ax
   407 0000027B 48                      	dec ax			; ax = ax - (di + 2)
   408 0000027C AB                      	stosw			; store our downlink as rel16 displacement
   409                                  
   410                                  .only_first:
   411 0000027D 26800E[1000]01          	setopt [es:code + eldiFlags], eldifResident
   412                                  internalcoderelocation -3	; mark block as resident
   413 00000283 C706[0000][2000]        	mov word [relocateddata], command
   414                                  linkdatarelocation ext_command_handler, -4
   415                                  internalcoderelocation		; -> our entrypoint
   416                                  
   417 00000289 F606[0000]04            	testopt [relocateddata], 4
   418                                  linkdatarelocation options7, -3
   419 0000028E 7506                    	jnz @F
   420 00000290 BA[B501]                	mov dx, msg.installed
   421                                  internaldatarelocation
   422 00000293 E832FF                  	call putsz
   423                                  @@:
   424 00000296 31C0                    	xor ax, ax
   425 00000298 CB                      	retf
   426                                  
   427                                  
   428                                  DATAOFFSET equ CODEOFFSET + code_size
   429                                  	addsection DATA, follows=CODE vstart=_ELD_DATA_VSTART
   430                                  %define DATAFIXUP - datastart + 0
   431                                  datastart:
   432                                  
   433                                  msg:
   434 00000000 484953544F525900        .history:		asciz "HISTORY"
   435 00000008 434C45415200            .clear:			asciz "CLEAR"
   436 0000000E 53484F5700              .show:			asciz "SHOW"
   437 00000013 484953544F52592075-     .uninstall_done:	asciz "HISTORY utility uninstalled. (Don't forget to use reclaim.eld)",13,10
   437 0000001C 74696C69747920756E-
   437 00000025 696E7374616C6C6564-
   437 0000002E 2E2028446F6E277420-
   437 00000037 666F7267657420746F-
   437 00000040 20757365207265636C-
   437 00000049 61696D2E656C64290D-
   437 00000052 0A00               
   438 00000054 484953544F52592075-     .uninstall_error:	asciz "HISTORY utility unable to uninstall!",13,10
   438 0000005D 74696C69747920756E-
   438 00000066 61626C6520746F2075-
   438 0000006F 6E696E7374616C6C21-
   438 00000078 0D0A00             
   439 0000007B 0D0A4E6F2068697374-     .history_none:		asciz 13,10,"No history format link found.",13,10
   439 00000084 6F727920666F726D61-
   439 0000008D 74206C696E6B20666F-
   439 00000096 756E642E0D0A00     
   440 0000009D 0D0A556E6B6E6F776E-     .history_unknown:	asciz 13,10,"Unknown history format.",13,10
   440 000000A6 20686973746F727920-
   440 000000AF 666F726D61742E0D0A-
   440 000000B8 00                 
   441 000000B9 486973746F7279206C-     .history_missing:	asciz "History last or first displacement or segment missing.",13,10
   441 000000C2 617374206F72206669-
   441 000000CB 72737420646973706C-
   441 000000D4 6163656D656E74206F-
   441 000000DD 72207365676D656E74-
   441 000000E6 206D697373696E672E-
   441 000000EF 0D0A00             
   442                                  
   443                                  uinit_data: equ $
   444                                  
   445 000000F2 484953544F52592075-     .help:		db "HISTORY utility. Available commands:",13,10
   445 000000FB 74696C6974792E2041-
   445 00000104 7661696C61626C6520-
   445 0000010D 636F6D6D616E64733A-
   445 00000116 0D0A               
   446 00000118 0D0A                    		db 13,10
   447 0000011A 53484F57090953686F-     		db "SHOW",9,9,"Show all of history",13,10
   447 00000123 7720616C6C206F6620-
   447 0000012C 686973746F72790D0A 
   448 00000135 434C4541520909436C-     		db "CLEAR",9,9,"Clear history",13,10
   448 0000013E 65617220686973746F-
   448 00000147 72790D0A           
   449 0000014B 494E5354414C4C0909-     		db "INSTALL",9,9,"(ELD load only) Install utility resident",13,10
   449 00000154 28454C44206C6F6164-
   449 0000015D 206F6E6C792920496E-
   449 00000166 7374616C6C20757469-
   449 0000016F 6C6974792072657369-
   449 00000178 64656E740D0A       
   450 0000017E 554E494E5354414C4C-     		db "UNINSTALL",9,"(Resident only) Uninstall resident utility",13,10
   450 00000187 09285265736964656E-
   450 00000190 74206F6E6C79292055-
   450 00000199 6E696E7374616C6C20-
   450 000001A2 7265736964656E7420-
   450 000001AB 7574696C6974790D0A 
   451 000001B4 00                      		asciz
   452 000001B5 484953544F52592075-     .installed:		asciz "HISTORY utility installed.",13,10
   452 000001BE 74696C69747920696E-
   452 000001C7 7374616C6C65642E0D-
   452 000001D0 0A00               
   453                                  
   454 000001D2 00<rep Eh>              	align 16, db 0
   455                                  init_data_end:
   456                                  data_size equ $ - datastart
   457                                  
   458                                  	absolute uinit_data
   459                                  history_data_entry:
   460 000000F2 ??                      	resb 1
   461                                  
   462 000000F3 <res Dh>                	alignb 16
   463                                  uinit_data_end:
   464                                  resident_data_end:
   465                                  
   466                                  %if uinit_data_end >= init_data_end
   467                                   total_data_size equ $ - datastart
   468                                  %else
   469                                   total_data_size equ init_data_end - datastart
   470                                  %endif
   471                                  %assign _DATA_SIZE total_data_size
   472                                  
   473                                  	usesection CODE
   474                                  
   475                                  %include "eldlink.asm"
     1                              <1> %if 0
     2                              <1> 
     3                              <1> Extensions for lDebug linker
     4                              <1> 
     5                              <1> Copyright (C) 2008-2023 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-2023 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 eldSignature
    26                              <2> eldhCodeImageLength:	resw 1	; amount bytes
    27                              <2> eldhCodeAllocLength:	resw 1	; amount bytes, added to prior
    28                              <2> eldhDataOffset:		resd 1
    29                              <2> eldhDataImageLength:	resw 1	; (zero allowed)
    30                              <2> eldhDataAllocLength:	resw 1	; (zero allowed)
    31                              <2> eldhCodeEntrypoint:	resw 1
    32                              <2> eldhReserved:		resb 4	; reserved
    33                              <2> eldhExtensionSize:	resw 1
    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
    40                              <2> eldhxHelpOffset:	resd 1
    41                              <2> 	alignb 16
    42                              <2> 	endstruc
    43                              <2> 
    44                              <2> 		; ELD instance header
    45                              <2> 	struc ELD_INSTANCE
    46                              <2> eldiStartCode:		resw 1	; -> this structure itself (para aligned)
    47                              <2> eldiEndCode:		resw 1	; -> behind memory used by instance (para aligned)
    48                              <2> eldiStartData:		resw 1	; -> data in data entry section (para aligned), or 0
    49                              <2> eldiEndData:		resw 1	; -> behind data (para aligned), or 0
    50                              <2> eldiIdentifier:		resb 8	; blank-filled text
    51                              <2> eldiFlags:		resw 1	; flags
    52                              <2> eldiReserved:		resb 14	; reserved
    53                              <2> 	endstruc
    54                              <2> 		; flags for eldiFlags:
    55                              <2> eldifResident:		equ 1
    56                              <2> 
    57                              <2> 		; ELD link info header
    58                              <2> 	struc ELD_LINKINFO
    59                              <2> eldlSignature:		resw 1	; 0E1D1h
    60                              <2> eldlReserved:		resw 2
    61                              <2> eldlUseLinkHash:	resw 1
    62                              <2> eldlDataAmount:		resw 1
    63                              <2> eldlDataPrefixes:	resw 1
    64                              <2> eldlDataEntries:	resw 1
    65                              <2> eldlDataAddresses:	resw 1
    66                              <2> eldlCodeAmount:		resw 1
    67                              <2> eldlCodePrefixes:	resw 1
    68                              <2> eldlCodeEntries:	resw 1
    69                              <2> eldlCodeAddresses:	resw 1
    70                              <2> 	endstruc
    71                              <2> 
    72                              <2> 	numdef ELD_CODE_VSTART, 9001h
    73                              <2> 	numdef ELD_DATA_VSTART, 8000h
    74                              <2> 	numdef ELD_RELOC_VSTART, 8000h
    75                              <2> 
    76                              <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_DEBUG, 0
    32                              <1> 	numdef ELD_LINKER_PASSES, 1
    33                              <1> 	strdef LISTING, ""
    34                              <1> 	numdef ELDCALL_OPTIONAL, ELDCALL_OPTIONAL_STATUS
    35                              <1> %ifn _ELDCALL_OPTIONAL
    36                              <1> %assign ELDCALL_OPTIONAL_STATUS 2		; not allowed
    37                              <1> %endif
    38                              <1> 
    39                              <1> 
    40                              <1> endresident: equ ($ + _CURRENT_SECTION %+ FIXUP + 15) & ~15
    41                              <1> 
    42                              <1> %if _ELD_LINKER_PASSES
    43                              <1> %assign ELDLINKER 1
    44                              <1> 
    45                              <1> 	struc LINKTABLE
    46 00000000 ????????            <1> ltCodeToCode:	resw 2
    47 00000004 ????????            <1> ltCodeToData:	resw 2
    48 00000008 ????????            <1> ltDataToCode:	resw 2
    49 0000000C ????????            <1> ltDataToData:	resw 2
    50 00000010 ????????            <1> ltLinkData:	resw 2
    51 00000014 ????????            <1> ltLinkCode:	resw 2
    52                              <1> 	endstruc
    53                              <1> %endif
    54                              <1> 
    55                              <1> 
    56                              <1> linker:
    57                              <1> 		; The first 15 Bytes of the linker should be
    58                              <1> 		;  the same regardless of the linker options
    59                              <1> 		;  used (debug, passes, vstart). This allows
    60                              <1> 		;  the eldcomp ELD to match even if up to 15
    61                              <1> 		;  Bytes of the linker are trailing in the
    62                              <1> 		;  resident part of the ELD.
    63                              <1> 	lframe
    64 00000299 5589E5              <1> 	lenter
    65                              <1> 	lvar dword, instance
    66 0000029C 06                  <1> 	 push es
    67 0000029D 52                  <1> 	 push dx
    68                              <1> 	lvar word, targetsection_low_optional_high
    69 0000029E 50                  <1> 	 push ax
    70                              <1> 	lequ ?targetsection_low_optional_high, targetsection
    71                              <1> 	lequ ?targetsection_low_optional_high + 1, optional
    72                              <1> 	lvar dword, linkinfo
    73 0000029F 1E                  <1> 	 push ds
    74 000002A0 57                  <1> 	 push di
    75                              <1> 	lvar dword, nextreloc
    76 000002A1 06                  <1> 	 push es
    77 000002A2 52                  <1> 	 push dx
    78                              <1> 	lvar dword, entry
    79 000002A3 06                  <1> 	 push es
    80 000002A4 50                  <1> 	 push ax		; placeholder
    81 000002A5 31C0                <1> 	xor ax, ax
    82 000002A7 813DD1E1            <1> 	cmp word [di + eldlSignature], 0E1D1h
    83                              <1> %if ($ - linker) < 16
    84                              <1>  %error Expected invariant first paragraph of linker
    85                              <1> %endif
    86 000002AB 7403E94A02          <1> 	jne .error_j
    87 000002B0 837D0601            <1> 	cmp word [di + eldlUseLinkHash], 1
    88 000002B4 7603E94102          <1> 	ja .error_j
    89 000002B9 7201                <1> 	jb @F
    90 000002BB 48                  <1> 	dec ax
    91                              <1> @@:
    92                              <1> 	lvar word, use_hash
    93 000002BC 50                  <1> 	 push ax
    94                              <1> %if _ELD_LINKER_PASSES
    95 000002BD 31C0                <1> 	xor ax, ax
    96                              <1> 	lvar word, pass
    97 000002BF 50                  <1> 	 push ax
    98                              <1> 	lvar word, amounterrors
    99 000002C0 50                  <1> 	 push ax
   100                              <1> 	lvar word, name
   101 000002C1 50                  <1> 	 push ax
   102                              <1> %endif
   103 000002C2 56                  <1> 	push si
   104 000002C3 53                  <1> 	push bx
   105                              <1> 
   106                              <1> 			; simple: add instance base (dx) to code
   107 000002C4 06                  <1> 	push es
   108 000002C5 1F                  <1> 	pop ds
   109                              <1> %if _ELD_LINKER_PASSES
   110                              <1> .pass:
   111 000002C6 8B5EEA              <1> 	mov bx, word [bp + ?pass]
   112 000002C9 01D3                <1> 	add bx, dx
   113 000002CB 8BB72406            <1> 	mov si, word [linktable - code + ltCodeToCode + bx]
   114                              <1> %else
   115                              <1> 	mov si, internalcodetocoderelocations - code
   116                              <1> %endif
   117 000002CF 01D6                <1> 	add si, dx
   118                              <1> @@:
   119 000002D1 AD                  <1> 	lodsw
   120 000002D2 85C0                <1> 	test ax, ax		; was last ?
   121 000002D4 740B                <1> 	jz @F			; yes -->
   122 000002D6 93                  <1> 	xchg bx, ax		; bx = entry
   123 000002D7 01D3                <1> 	add bx, dx		; relocate the entry itself
   124                              <1> %if _ELD_CODE_VSTART
   125 000002D9 812F[0000]          <1> 	sub word [bx], code	; undo adjustment
   126                              <1> %endif
   127 000002DD 0117                <1> 	add word [bx], dx	; relocate word referenced by entry
   128 000002DF EBF0                <1> 	jmp @B
   129                              <1> 
   130                              <1> @@:
   131                              <1> 			; next, add heap data base (on stack) to code
   132                              <1> %if _ELD_LINKER_PASSES
   133 000002E1 8B5EEA              <1> 	mov bx, word [bp + ?pass]
   134 000002E4 01D3                <1> 	add bx, dx
   135 000002E6 8BB72806            <1> 	mov si, word [linktable - code + ltCodeToData + bx]
   136                              <1> %else
   137                              <1> 	mov si, internalcodetodatarelocations - code
   138                              <1> %endif
   139 000002EA 01D6                <1> 	add si, dx
   140                              <1> @@:
   141 000002EC AD                  <1> 	lodsw
   142 000002ED 85C0                <1> 	test ax, ax		; was last ?
   143 000002EF 740C                <1> 	jz @F			; yes -->
   144 000002F1 93                  <1> 	xchg bx, ax		; bx = entry
   145 000002F2 01D3                <1> 	add bx, dx		; relocate the entry itself
   146 000002F4 58                  <1> 	pop ax			; ax -> heap data
   147 000002F5 50                  <1> 	push ax
   148                              <1> %if _ELD_DATA_VSTART
   149 000002F6 2D[0000]            <1> 	sub ax, datastart	; undo adjustment
   150                              <1> %endif
   151 000002F9 0107                <1> 	add word [bx], ax	; relocate word referenced by entry
   152 000002FB EBEF                <1> 	jmp @B
   153                              <1> 
   154                              <1> @@:
   155                              <1> 
   156                              <1> 			; add instance base (dx) to data
   157                              <1> %if _ELD_LINKER_PASSES
   158 000002FD 8B5EEA              <1> 	mov bx, word [bp + ?pass]
   159 00000300 01D3                <1> 	add bx, dx
   160 00000302 8BB72C06            <1> 	mov si, word [linktable - code + ltDataToCode + bx]
   161                              <1> %else
   162                              <1> 	mov si, internaldatatocoderelocations - code
   163                              <1> %endif
   164 00000306 01D6                <1> 	add si, dx
   165                              <1> @@:
   166 00000308 AD                  <1> 	lodsw
   167 00000309 83F8FF              <1> 	cmp ax, -1		; was last ?
   168 0000030C 740F                <1> 	je @F			; yes -->
   169 0000030E 93                  <1> 	xchg bx, ax		; bx = entry
   170 0000030F 58                  <1> 	pop ax
   171 00000310 50                  <1> 	push ax
   172 00000311 01C3                <1> 	add bx, ax		; relocate the entry itself
   173                              <1> %if _ELD_CODE_VSTART
   174 00000313 36812F[0000]        <1> 	sub word [ss:bx], code	; undo adjustment
   175                              <1> %endif
   176 00000318 360117              <1> 	add word [ss:bx], dx	; relocate word referenced by entry
   177 0000031B EBEB                <1> 	jmp @B
   178                              <1> 
   179                              <1> @@:
   180                              <1> 			; next, add heap data base (on stack) to data
   181                              <1> %if _ELD_LINKER_PASSES
   182 0000031D 8B5EEA              <1> 	mov bx, word [bp + ?pass]
   183 00000320 01D3                <1> 	add bx, dx
   184 00000322 8BB73006            <1> 	mov si, word [linktable - code + ltDataToData + bx]
   185                              <1> %else
   186                              <1> 	mov si, internaldatatodatarelocations - code
   187                              <1> %endif
   188 00000326 01D6                <1> 	add si, dx
   189                              <1> @@:
   190 00000328 AD                  <1> 	lodsw
   191 00000329 83F8FF              <1> 	cmp ax, -1		; was last ?
   192 0000032C 740D                <1> 	je @F			; yes -->
   193 0000032E 93                  <1> 	xchg bx, ax		; bx = entry
   194 0000032F 58                  <1> 	pop ax			; ax -> heap data
   195 00000330 50                  <1> 	push ax
   196 00000331 01C3                <1> 	add bx, ax		; relocate the entry itself
   197                              <1> %if _ELD_DATA_VSTART
   198 00000333 2D[0000]            <1> 	sub ax, datastart	; undo adjustment
   199                              <1> %endif
   200 00000336 360107              <1> 	add word [ss:bx], ax	; relocate word referenced by entry
   201 00000339 EBED                <1> 	jmp @B
   202                              <1> 
   203                              <1> @@:
   204 0000033B 8B56FC              <1> 	mov dx, word [bp + ?instance]
   205                              <1> %if _ELD_LINKER_PASSES
   206 0000033E 8B5EEA              <1> 	mov bx, word [bp + ?pass]
   207 00000341 01D3                <1> 	add bx, dx
   208 00000343 03973406            <1> 	add dx, word [linktable - code + ltLinkData + bx]
   209                              <1> %else
   210                              <1> 	add dx, linkerdatarelocations - code
   211                              <1> %endif
   212 00000347 8956F2              <1> 	mov word [bp + ?nextreloc], dx
   213                              <1> 
   214                              <1> .datarelocloop:		; must be done before further relocs
   215 0000034A C576F2              <1> 	lds si, [bp + ?nextreloc]
   216 0000034D AD                  <1> 	lodsw			; ax = section indicator
   217 0000034E 85C0                <1> 	test ax, ax		; end of table ?
   218 00000350 7503E91801          <1> 	jz .donedatareloc
   219 00000355 48                  <1> 	dec ax			; al = 1 if data, 0 if code
   220 00000356 5B                  <1> 	pop bx
   221 00000357 53                  <1> 	push bx			; bx -> ELD data block
   222 00000358 8946FA              <1> 	mov word [bp + ?targetsection_low_optional_high], ax
   223 0000035B 84C0                <1> 	test al, al		; data ?
   224 0000035D AD                  <1> 	lodsw
   225 0000035E 7504                <1> 	jnz @F			; yes -->
   226 00000360 0346FC              <1> 	add ax, word [bp + ?instance]
   227                              <1> 				; relocate entry into code
   228 00000363 A9                  <1> 	db __TEST_IMM16		; (skip add)
   229                              <1> @@:
   230 00000364 01D8                <1> 	add ax, bx		; relocate entry into data
   231 00000366 8946EE              <1> 	mov word [bp + ?entry], ax
   232 00000369 AD                  <1> 	lodsw
   233 0000036A 8976F2              <1> 	mov word [bp + ?nextreloc], si
   234 0000036D E8D100              <1> 	call .build_match
   235                              <1> %if _ELD_LINKER_PASSES
   236 00000370 73D8                <1> 	jnc .datarelocloop
   237                              <1> %endif
   238 00000372 C45EF6              <1> 	les bx, [bp + ?linkinfo]
   239 00000375 268B4F08            <1> 	mov cx, word [es:bx + eldlDataAmount]	; amount data link info
   240 00000379 268B7F0A            <1> 	mov di, word [es:bx + eldlDataPrefixes]	; -> prefixes or hashes
   241                              <1> .datarelocfind:
   242 0000037D F2AF                <1> 	repne scasw			; scan initial
   243 0000037F 7541                <1> 	jne .datarelocnotfound
   244 00000381 57                  <1> 	push di
   245 00000382 51                  <1> 	push cx
   246 00000383 56                  <1> 	push si
   247 00000384 262B7F0A            <1> 	sub di, word [es:bx + eldlDataPrefixes]	; = double index, 1-based
   248 00000388 4F                  <1> 	dec di
   249 00000389 4F                  <1> 	dec di				; 0-based
   250 0000038A 26037F0C            <1> 	add di, word [es:bx + eldlDataEntries]	; -> entry
   251 0000038E 268B3D              <1> 	mov di, [es:di]			; -> counted suffix/string
   252 00000391 B500                <1> 	mov ch, 0
   253 00000393 8A0C                <1> 	mov cl, byte [si]		; cx = length
   254 00000395 41                  <1> 	inc cx
   255                              <1> 	; cmp al, al			; ZR if length is zero
   256 00000396 F3A6                <1> 	repe cmpsb			; match ?
   257 00000398 5E                  <1> 	pop si
   258 00000399 59                  <1> 	pop cx
   259 0000039A 5F                  <1> 	pop di
   260 0000039B 75E0                <1> 	jne .datarelocfind
   261 0000039D 8814                <1> 	mov byte [si], dl
   262 0000039F 262B7F0A            <1> 	sub di, word [es:bx + eldlDataPrefixes]	; = double index, 1-based
   263 000003A3 4F                  <1> 	dec di
   264 000003A4 4F                  <1> 	dec di				; 0-based
   265 000003A5 26037F0E            <1> 	add di, word [es:bx + eldlDataAddresses]	; -> address (offset)
   266 000003A9 268B05              <1> 	mov ax, word [es:di]
   267 000003AC E80700              <1> 	call .address_data_reloc
   268                              <1> %if _ELD_RELOC_VSTART
   269 000003AF 2D[0000]            <1> 	sub ax, relocateddata		; *not* a relocation
   270                              <1> %endif
   271 000003B2 0104                <1> 	add word [si], ax		; relocate
   272 000003B4 EB94                <1> 	jmp .datarelocloop
   273                              <1> 
   274                              <1> .address_data_reloc:
   275 000003B6 C576EE              <1> 	lds si, [bp + ?entry]		; -> entry if in ELD code instance
   276 000003B9 807EFA00            <1> 	cmp byte [bp + ?targetsection], 0
   277                              <1> 					; relocation in code ?
   278 000003BD 7402                <1> 	je @F				; yes -->
   279 000003BF 16                  <1> 	push ss
   280 000003C0 1F                  <1> 	pop ds				; => our ELD data block
   281                              <1> @@:
   282 000003C1 C3                  <1> 	retn
   283                              <1> 
   284                              <1> .datarelocnotfound:
   285 000003C2 8814                <1> 	mov byte [si], dl
   286 000003C4 807EFB00            <1> 	cmp byte [bp + ?optional], 0
   287                              <1> %if _ELD_DEBUG
   288                              <1> 	jne @F
   289                              <1>  %ifn _ELD_LINKER_PASSES
   290                              <1> 	mov si, 0			; (invalid link)
   291                              <1> linkdatarelocation internalflags6
   292                              <1> 	test si, si
   293                              <1> 	jz .datanotfound
   294                              <1> 	mov si, 0			; (invalid link)
   295                              <1> linkdatarelocation options7
   296                              <1> 	test si, si
   297                              <1> 	jz .datanotfound
   298                              <1>  %else
   299                              <1> 	cmp byte [bp + ?pass], 0
   300                              <1> 	je .datanotfound
   301                              <1>  %endif
   302                              <1> 	houdini
   303                              <1> 	jmp .datanotfound
   304                              <1> @@:
   305                              <1> %else
   306 000003C8 7417                <1> 	je .datanotfound
   307                              <1> %endif
   308                              <1> %if _ELD_LINKER_PASSES
   309 000003CA 36F606[0000]02      <1> 	testopt [ss:relocateddata], 2
   310                              <1> linkdatarelocation options7, -3
   311 000003D0 7406                <1> 	jz @F
   312 000003D2 BE[8409]            <1> 	mov si, lmsg.warning_data_optional
   313                              <1> internalcoderelocation
   314 000003D5 E82A00              <1> 	call .notfound
   315                              <1> @@:
   316                              <1> %endif
   317 000003D8 E8DBFF              <1> 	call .address_data_reloc
   318 000003DB 832400              <1> 	and word [si], 0		; indicate optional data link failed
   319 000003DE E969FF              <1> 	jmp .datarelocloop
   320                              <1> 
   321                              <1> 
   322                              <1> %if _ELDCALL_OPTIONAL
   323                              <1> .coderelocnotfound:
   324                              <1> 	mov byte [si], dl
   325                              <1> 	cmp byte [bp + ?optional], 0
   326                              <1> %if _ELD_DEBUG
   327                              <1> 	jne @F
   328                              <1>  %ifn _ELD_LINKER_PASSES
   329                              <1> 	mov si, 0			; (invalid link)
   330                              <1> linkdatarelocation internalflags6
   331                              <1> 	test si, si
   332                              <1> 	jz .codenotfound
   333                              <1> 	mov si, 0			; (invalid link)
   334                              <1> linkdatarelocation options7
   335                              <1> 	test si, si
   336                              <1> 	jz .codenotfound
   337                              <1>  %else
   338                              <1> 	cmp byte [bp + ?pass], 0
   339                              <1> 	je .codenotfound
   340                              <1>  %endif
   341                              <1> 	houdini
   342                              <1> 	jmp .codenotfound
   343                              <1> @@:
   344                              <1> %else
   345                              <1> 	je .codenotfound
   346                              <1> %endif
   347                              <1> 
   348                              <1> %if ELDCALL_PMREQUIRED_STATUS
   349                              <1>  %if _ELD_LINKER_PASSES
   350                              <1>   %assign ELDLINKER 0
   351                              <1>  %endif
   352                              <1> 	mov si, relocateddata
   353                              <1> linkdatarelocation build_option_PM
   354                              <1>  %if _ELD_LINKER_PASSES
   355                              <1>   %assign ELDLINKER 1
   356                              <1>  %endif
   357                              <1> 	test si, si
   358                              <1> 	jz @F
   359                              <1> 	test byte [bp + ?optional], 2
   360                              <1> 	jnz .codenotfound
   361                              <1> @@:
   362                              <1> %endif
   363                              <1> 
   364                              <1> %if _ELD_LINKER_PASSES
   365                              <1> 	testopt [ss:relocateddata], 2
   366                              <1> linkdatarelocation options7, -3
   367                              <1> 	jz @F
   368                              <1> 	mov si, lmsg.warning_code_optional
   369                              <1> internalcoderelocation
   370                              <1> 	call .notfound
   371                              <1> @@:
   372                              <1> %endif
   373                              <1> 	lds si, [bp + ?entry]
   374                              <1> 	mov word [si], 9090h
   375                              <1> 	mov byte [si + 2], 90h		; indicate optional code link failed
   376                              <1> 	jmp .coderelocloop
   377                              <1> %endif
   378                              <1> 
   379                              <1> 
   380                              <1> %if _ELD_LINKER_PASSES
   381                              <1> .datanotfound:
   382 000003E1 BE[A609]            <1> 	mov si, lmsg.error_data
   383                              <1> internalcoderelocation
   384 000003E4 E81B00              <1> 	call .notfound
   385 000003E7 7203E90E01          <1> 	jnc .error_j
   386 000003EC FF46E8              <1> 	inc word [bp + ?amounterrors]
   387 000003EF E958FF              <1> 	jmp .datarelocloop
   388                              <1> 
   389                              <1> .codenotfound:
   390 000003F2 BE[BF09]            <1> 	mov si, lmsg.error_code
   391                              <1> internalcoderelocation
   392 000003F5 E80A00              <1> 	call .notfound
   393 000003F8 7203E9FD00          <1> 	jnc .error_j
   394 000003FD FF46E8              <1> 	inc word [bp + ?amounterrors]
   395 00000400 EB7A                <1> 	jmp .coderelocloop
   396                              <1> 
   397                              <1> .notfound:
   398 00000402 807EEA00            <1> 	cmp byte [bp + ?pass], 0
   399 00000406 7430                <1> 	je @F				; --> (NC)
   400 00000408 16                  <1> 	 push ss
   401 00000409 07                  <1> 	 pop es
   402 0000040A BF[0000]            <1> 	mov di, relocateddata
   403                              <1> linkdatarelocation line_out
   404 0000040D E82900              <1> 	call .copy
   405 00000410 8B76E6              <1> 	mov si, word [bp + ?name]
   406 00000413 AD                  <1> 	lodsw
   407 00000414 E8FDFFEB020000      <1> 	extcall hexword
   408 0000041B 56                  <1> 	push si
   409 0000041C BE[D809]            <1> 	mov si, lmsg.error.2
   410                              <1> internalcoderelocation
   411 0000041F E81700              <1> 	call .copy
   412 00000422 5E                  <1> 	pop si
   413                              <1> %if _ELD_LINKER_PASSES
   414 00000423 56                  <1> 	push si
   415 00000424 E81200              <1> 	call .copy
   416 00000427 5E                  <1> 	pop si
   417 00000428 C60400              <1> 	mov byte [si], 0		; mark as failed
   418                              <1> %else
   419                              <1> 	call .copy
   420                              <1> %endif
   421 0000042B B022                <1> 	mov al, '"'
   422 0000042D AA                  <1> 	stosb
   423 0000042E 16                  <1> 	 push ss
   424 0000042F 1F                  <1> 	 pop ds
   425 00000430 E8FDFFEB020000      <1> 	extcall putsline_crlf
   426 00000437 F9                  <1> 	stc				; CY, diagnostic displayed
   427                              <1> @@:
   428 00000438 C3                  <1> 	retn
   429                              <1> 
   430                              <1> .copy:
   431 00000439 E8FDFFEB020000      <1> 	extcall copy_single_counted_string
   432 00000440 C3                  <1> 	retn
   433                              <1> %else
   434                              <1> .datanotfound: equ .error_j
   435                              <1> .codenotfound: equ .error_j
   436                              <1> %endif
   437                              <1> 
   438                              <1> .build_match:
   439                              <1> %if _ELD_CODE_VSTART
   440 00000441 2D[0000]            <1> 	sub ax, code
   441                              <1> %endif
   442 00000444 0346FC              <1> 	add ax, word [bp + ?instance]
   443 00000447 96                  <1> 	xchg si, ax
   444                              <1> %if _ELD_LINKER_PASSES
   445 00000448 8976E6              <1> 	mov word [bp + ?name], si
   446                              <1> %endif
   447 0000044B AD                  <1> 	lodsw			; = hash, si -> counted string
   448 0000044C 8A14                <1> 	mov dl, byte [si]
   449                              <1> %if _ELD_LINKER_PASSES
   450 0000044E 84D2                <1> 	test dl, dl		; marked as already failed ?
   451 00000450 750A                <1> 	jnz @F
   452 00000452 837EE800            <1> 	cmp word [bp + ?amounterrors], 0
   453 00000456 7503E99F00          <1> 	je .error_j
   454 0000045B C3                  <1> 	retn			; (NC)
   455                              <1> 
   456                              <1> @@:
   457                              <1> %endif
   458 0000045C D046EC              <1> 	rol byte [bp + ?use_hash], 1
   459 0000045F 720A                <1> 	jc @F
   460 00000461 AC                  <1> 	lodsb
   461 00000462 91                  <1> 	xchg cx, ax		; cl = length
   462 00000463 AD                  <1> 	lodsw			; ax = prefix
   463 00000464 49                  <1> 	dec cx
   464 00000465 49                  <1> 	dec cx
   465 00000466 4E                  <1> 	dec si
   466 00000467 8A14                <1> 	mov dl, byte [si]
   467 00000469 880C                <1> 	mov byte [si], cl	; si -> counted string suffix
   468                              <1> @@:
   469                              <1> %if _ELD_LINKER_PASSES
   470 0000046B F9                  <1> 	stc			; CY
   471                              <1> %endif
   472 0000046C C3                  <1> 	retn
   473                              <1> 
   474                              <1> 
   475                              <1> .donedatareloc:
   476 0000046D 8B56FC              <1> 	mov dx, word [bp + ?instance]
   477                              <1> %if _ELD_LINKER_PASSES
   478 00000470 8B5EEA              <1> 	mov bx, word [bp + ?pass]
   479 00000473 01D3                <1> 	add bx, dx
   480 00000475 03973806            <1> 	add dx, word [linktable - code + ltLinkCode + bx]
   481                              <1> %else
   482                              <1> 	add dx, linkercoderelocations - code
   483                              <1> %endif
   484 00000479 8956F2              <1> 	mov word [bp + ?nextreloc], dx
   485                              <1> 
   486                              <1> .coderelocloop:
   487 0000047C C576F2              <1> 	lds si, [bp + ?nextreloc]
   488 0000047F AD                  <1> 	lodsw
   489                              <1> %if _ELDCALL_OPTIONAL
   490                              <1> 	dec ax
   491                              <1> 	js .donecodereloc
   492                              <1> 	mov word [bp + ?targetsection_low_optional_high], ax
   493                              <1> 	lodsw
   494                              <1> %endif
   495 00000480 0346FC              <1> 	add ax, word [bp + ?instance]
   496 00000483 8946EE              <1> 	mov word [bp + ?entry], ax
   497 00000486 AD                  <1> 	lodsw
   498 00000487 8976F2              <1> 	mov word [bp + ?nextreloc], si
   499                              <1> %ifn _ELDCALL_OPTIONAL
   500 0000048A 85C0                <1> 	test ax, ax
   501 0000048C 747E                <1> 	jz .donecodereloc
   502                              <1> %endif
   503 0000048E E8B0FF              <1> 	call .build_match
   504                              <1> %if _ELD_LINKER_PASSES
   505 00000491 73E9                <1> 	jnc .coderelocloop
   506                              <1> %endif
   507 00000493 C45EF6              <1> 	les bx, [bp + ?linkinfo]
   508 00000496 268B4F10            <1> 	mov cx, word [es:bx + eldlCodeAmount]	; amount code link info
   509 0000049A 268B7F12            <1> 	mov di, word [es:bx + eldlCodePrefixes]	; -> prefixes or hashes
   510                              <1> .coderelocfind:
   511 0000049E F2AF                <1> 	repne scasw			; scan initial
   512                              <1> %if _ELDCALL_OPTIONAL
   513                              <1> 	jne .coderelocnotfound
   514                              <1> %else
   515                              <1>  %if _ELD_DEBUG
   516                              <1> 	je @F
   517                              <1> 	houdini
   518                              <1> 	jmp .codenotfound
   519                              <1> @@:
   520                              <1>  %else
   521 000004A0 7403E94DFF          <1> 	jne .codenotfound
   522                              <1>  %endif
   523                              <1> %endif
   524 000004A5 57                  <1> 	push di
   525 000004A6 51                  <1> 	push cx
   526 000004A7 56                  <1> 	push si
   527 000004A8 262B7F12            <1> 	sub di, word [es:bx + eldlCodePrefixes]	; = double index, 1-based
   528 000004AC 4F                  <1> 	dec di
   529 000004AD 4F                  <1> 	dec di				; 0-based
   530 000004AE 26037F14            <1> 	add di, word [es:bx + eldlCodeEntries]	; -> entry
   531 000004B2 268B3D              <1> 	mov di, [es:di]			; -> counted suffix/string
   532 000004B5 B500                <1> 	mov ch, 0
   533 000004B7 8A0C                <1> 	mov cl, byte [si]		; cx = length
   534 000004B9 41                  <1> 	inc cx
   535                              <1> 	; cmp al, al			; ZR if length is zero
   536 000004BA F3A6                <1> 	repe cmpsb			; match ?
   537 000004BC 5E                  <1> 	pop si
   538 000004BD 59                  <1> 	pop cx
   539 000004BE 5F                  <1> 	pop di
   540 000004BF 75DD                <1> 	jne .coderelocfind
   541 000004C1 8814                <1> 	mov byte [si], dl
   542 000004C3 262B7F12            <1> 	sub di, word [es:bx + eldlCodePrefixes]	; = double index, 1-based
   543 000004C7 4F                  <1> 	dec di
   544 000004C8 4F                  <1> 	dec di				; 0-based
   545 000004C9 01FF                <1> 	add di, di			; quadruple index
   546 000004CB 26037F16            <1> 	add di, word [es:bx + eldlCodeAddresses]	; -> address (offset, segment)
   547 000004CF 26FF35              <1> 	push word [es:di]
   548 000004D2 C576EE              <1> 	lds si, [bp + ?entry]
   549 000004D5 8F4405              <1> 	pop word [si + 3 + 2]		; call near imm (3), jmp short (2)
   550                              <1> 					;  patch the destination address
   551 000004D8 803CE8              <1> 	cmp byte [si], 0E8h		; is it as expected ?
   552 000004DB 751D                <1> 	jne .error_j
   553 000004DD 268B7D02            <1> 	mov di, word [es:di + 2]
   554 000004E1 BB[0000]            <1> 	mov bx, relocateddata
   555                              <1> linkdatarelocation linkcall_table	; ss:bx -> link call table
   556 000004E4 36833F01            <1> 	cmp word [ss:bx], 1		; is it initialised to format 1 ?
   557 000004E8 7510                <1> 	jne .error_j			; no -->
   558 000004EA 368B4F02            <1> 	mov cx, word [ss:bx + 2]	; get amount of segments
   559 000004EE E30A                <1> 	jcxz .error_j			; none -->
   560                              <1> @@:
   561 000004F0 83C304              <1> 	add bx, 4			; -> next segment
   562 000004F3 36393F              <1> 	cmp word [ss:bx], di		; value matches ?
   563 000004F6 7405                <1> 	je @F				; yes, found -->
   564 000004F8 E2F6                <1> 	loop @B				; try remaining segments
   565                              <1> .error_j:
   566 000004FA E99B00              <1> 	jmp .error
   567                              <1> 
   568                              <1> @@:
   569 000004FD 368B5F02            <1> 	mov bx, word [ss:bx + 2]	; -> call destination offset
   570                              <1> 		; si + 3 + delta = bx
   571                              <1> 		; delta = bx - si - 3
   572 00000501 29F3                <1> 	sub bx, si
   573 00000503 83EB03              <1> 	sub bx, 3
   574 00000506 895C01              <1> 	mov word [si + 1], bx		; patch the call instruction
   575 00000509 E970FF              <1> 	jmp .coderelocloop
   576                              <1> 
   577                              <1> .donecodereloc:
   578                              <1> %if _ELD_LINKER_PASSES
   579 0000050C 8B46E8              <1> 	mov ax, word [bp + ?amounterrors]
   580 0000050F 85C0                <1> 	test ax, ax
   581 00000511 75E7                <1> 	jnz .error_j
   582 00000513 8B5EEA              <1> 	mov bx, word [bp + ?pass]
   583 00000516 85DB                <1> 	test bx, bx
   584 00000518 750B                <1> 	jnz @F
   585 0000051A 43                  <1> 	inc bx
   586 0000051B 43                  <1> 	inc bx
   587 0000051C 895EEA              <1> 	mov word [bp + ?pass], bx
   588 0000051F 8B56FC              <1> 	mov dx, word [bp + ?instance]
   589 00000522 E9A1FD              <1> 	jmp .pass
   590                              <1> 
   591                              <1> @@:
   592                              <1> %endif
   593                              <1> 
   594                              <1> %ifnidni _LISTING, ""
   595                              <1> %assign ELDLINKER 0
   596                              <1> .hint:
   597 00000525 16                  <1> 	push ss
   598 00000526 1F                  <1> 	pop ds
   599 00000527 B02D                <1> 	mov al, 2Dh
   600 00000529 E8FDFFEB020000      <1> 	extcall intchk			; ZR if offset = -1 or segment = 0
   601                              <1> 					; CHG: ax, dx, bx
   602 00000530 7437                <1> 	jz .no_hint
   603                              <1> 
   604 00000532 8A26[0000]          <1> 	mov ah, byte [relocateddata]
   605                              <1> linkdatarelocation try_debugger_amis_multiplex_number
   606 00000536 E86600              <1> 	call plex_check
   607 00000539 7305                <1> 	jnc @F
   608                              <1> 
   609 0000053B B4FF                <1> 	mov ah, 0FFh		; start with multiplex number 0FFh
   610                              <1> .loop_hint:
   611 0000053D E85F00              <1> 	call plex_check
   612                              <1> @@:
   613 00000540 7307                <1> 	jnc .end_hint		; if found --> (NC)
   614 00000542 80EC01              <1> 	sub ah, 1		; search is backward (to find latest installed first), from 0FFh to 00h including
   615 00000545 73F6                <1> 	jnc .loop_hint		; try next if we didn't check all yet -->
   616 00000547 EB20                <1> 	jmp .no_hint
   617                              <1> 
   618                              <1> .end_hint:
   619 00000549 50                  <1> 	push ax
   620 0000054A C446FC              <1> 	les ax, [bp + ?instance]
   621 0000054D BF[A107]            <1> 	mov di, listmsg.hint.offset
   622                              <1> internalcoderelocation
   623 00000550 E8FDFFEB020000      <1> 	extcall hexword
   624 00000557 BB[8007]            <1> 	mov bx, listmsg.hint
   625                              <1> internalcoderelocation
   626 0000055A 368B16[0000]        <1> 	mov dx, [ss:relocateddata]
   627                              <1> linkdatarelocation extseg	; must be 86 Mode segment even in PM
   628 0000055F 58                  <1> 	pop ax
   629 00000560 B040                <1> 	mov al, 40h		; AMIS message display service
   630 00000562 E8FDFFEB020000      <1> 	extcall call_int2D
   631                              <1> .no_hint:
   632                              <1> %endif
   633                              <1> 
   634 00000569 5B                  <1> 	pop bx				; -> our heap data
   635 0000056A 5E                  <1> 	pop si				; -> our command line tail
   636 0000056B 16                  <1> 	 push ss
   637 0000056C 1F                  <1> 	 pop ds
   638 0000056D C47EFC              <1> 	les di, [bp + ?instance]
   639 00000570 268B4502            <1> 	mov ax, word [es:di + eldiEndCode]
   640 00000574 36F606[0100]017409- <1> houdini
   640 0000057C 36F606[0100]017401- <1>
   640 00000584 CC                  <1>
   641 00000585 2D[A002]            <1> 	sub ax, strict word endresident + code
   642                              <1> internalcoderelocation
   643 00000588 26C74502[A002]      <1> 	mov word [es:di + eldiEndCode], endresident + code
   644                              <1> internalcoderelocation
   645 0000058E 2906[0000]          <1> 	sub word [relocateddata], ax
   646                              <1> linkdatarelocation extseg_used
   647                              <1> %if _DATA_SIZE == 0
   648                              <1> 	xor ax, ax
   649                              <1> 	mov word [es:di + eldiStartData], ax
   650                              <1> 	mov word [es:di + eldiEndData], ax
   651                              <1> %endif
   652 00000592 89EC5D              <1> 	lleave code
   653                              <1> 		; INP:	es => ELD code segment
   654                              <1> 		;	ds:si -> command line tail
   655                              <1> 		;	ds:bx -> ELD data block
   656                              <1> 		;	ss:sp -> far return address for current mode
   657                              <1> 		; STT:	ds = ss, UP, EI
   658 00000595 E940FC              <1> 	jmp start
   659                              <1> 
   660                              <1> .error:
   661 00000598 89EC5D              <1> 	lleave
   662 0000059B B8FFFF              <1> 	mov ax, -1
   663 0000059E CB                  <1> 	retf
   664                              <1> 
   665                              <1> 
   666                              <1> %ifnidni _LISTING, ""
   667                              <1> 		; INP:	ah = multiplex number to check
   668                              <1> 		; OUT:	CY if multiplex number unused or no signature match,
   669                              <1> 		;	 bp, ah, ds unmodified
   670                              <1> 		;	NC if match found,
   671                              <1> 		;	 ah = multiplex number (unmodified)
   672                              <1> 		; CHG:	si, di, es, cx, dx
   673                              <1> plex_check:
   674 0000059F 16                  <1> 	push ss
   675 000005A0 1F                  <1> 	pop ds
   676 000005A1 F606[0000]08        <1> 	testopt [relocateddata], 8
   677                              <1> linkdatarelocation internalflags4, -3
   678 000005A6 740B                <1> 	jz @F
   679 000005A8 BE[0000]            <1> 	mov si, relocateddata
   680                              <1> linkdatarelocation amis_multiplex_number, -2, optional
   681 000005AB 85F6                <1> 	test si, si
   682 000005AD 7404                <1> 	jz @F
   683 000005AF 3A24                <1> 	cmp ah, byte [si]
   684 000005B1 7420                <1> 	je .notfound		; do not use our own multiplexer -->
   685                              <1> @@:
   686 000005B3 B000                <1> 	mov al, 00h		; AMIS installation check
   687 000005B5 E8FDFFEB020000      <1> 	extcall call_int2D	; AMIS (or "DOS reserved" = iret if no AMIS present)
   688 000005BC 3CFF                <1> 	cmp al, 0FFh
   689 000005BE 7513                <1> 	jne .notfound
   690 000005C0 0E                  <1> 	push cs
   691 000005C1 1F                  <1> 	pop ds
   692 000005C2 BE[7007]            <1> 	mov si, debuggeramissig	; ds:si -> our AMIS name strings
   693                              <1> internalcoderelocation
   694 000005C5 E8FDFFEB020000      <1> 	extcall setes2dx	; es:di -> name strings of AMIS multiplexer that just answered
   695 000005CC B90800              <1> 	mov cx, 8		; Ignore description, only compare vendor and program name
   696 000005CF F3A7                <1> 	repe cmpsw
   697 000005D1 7401                <1> 	je .checkret		; ZR, NC = match -->
   698                              <1> .notfound:
   699 000005D3 F9                  <1> 	stc			; CY no match
   700                              <1> .checkret:
   701 000005D4 C3                  <1> 	retn
   702                              <1> %endif
   703                              <1> 
   704                              <1> 
   705 000005D5 00<rep 3h>          <1> 	align 4, db 0
   706                              <1> linkercoderelocations:
   707                              <1> %if _ELDCALL_OPTIONAL
   708                              <1> 	dw ELDCALL_CODE_RELOCATIONS_OPTIONAL, 0
   709                              <1> %else
   710 000005D8 2200[A907]A001-     <1> 	dw ELDCALL_CODE_RELOCATIONS, 0, 0
   710 000005DE [B807]A801[C407]B0- <1>
   710 000005E5 01[D007]B801[D907]- <1>
   710 000005EC C001[E007]C801-     <1>
   710 000005F2 [E707]D001[EF07]36- <1>
   710 000005F9 02[D007]2905[2608]- <1>
   710 00000600 5005[FF07]6205-     <1>
   710 00000606 [2F08]B505[2F08]C5- <1>
   710 0000060D 05[3C08]00000000    <1>
   711                              <1> %endif
   712                              <1> 
   713                              <1> %if _ELD_LINKER_PASSES
   714                              <1> linkerlinkercoderelocations:
   715                              <1> %if _ELDCALL_OPTIONAL
   716                              <1> 	dw ELDCALL_LINKER_CODE_RELOCATIONS_OPTIONAL, 0
   717                              <1> %else
   718 00000614 1404[FF07]3004-     <1> 	dw ELDCALL_LINKER_CODE_RELOCATIONS, 0, 0
   718 0000061A [EF07]3904[0908]00- <1>
   718 00000621 000000              <1>
   719                              <1> %endif
   720                              <1> 
   721                              <1> 	align 2, db 0
   722                              <1> linktable:
   723                              <1> 	istruc LINKTABLE
   724                              <1> at ltCodeToCode
   725 00000624 6007                <1> 	dw internallinkercodetocoderelocations - code
   726 00000626 0407                <1> 	dw internalcodetocoderelocations - code
   727                              <1> at ltCodeToData
   728 00000628 6A07                <1> 	dw internallinkercodetodatarelocations - code
   729 0000062A 2607                <1> 	dw internalcodetodatarelocations - code
   730                              <1> at ltDataToCode
   731 0000062C 6C07                <1> 	dw internallinkerdatatocoderelocations - code
   732 0000062E 4807                <1> 	dw internaldatatocoderelocations - code
   733                              <1> at ltDataToData
   734 00000630 6E07                <1> 	dw internallinkerdatatodatarelocations - code
   735 00000632 4A07                <1> 	dw internaldatatodatarelocations - code
   736                              <1> at ltLinkData
   737 00000634 4C07                <1> 	dw linkerlinkerdatarelocations - code
   738 00000636 3C06                <1> 	dw linkerdatarelocations - code
   739                              <1> at ltLinkCode
   740 00000638 1406                <1> 	dw linkerlinkercoderelocations - code
   741 0000063A D805                <1> 	dw linkercoderelocations - code
   742                              <1> 	iend
   743                              <1> %endif
   744                              <1> 
   745                              <1> 	align 2, db 0
   746                              <1> linkerdatarelocations:
   747 0000063C 01004600[4708]0100- <1> 	dw LINK_DATA_RELOCATIONS, 0
   747 00000644 7000[5708]01007900- <1>
   747 0000064C [6208]01008500-     <1>
   747 00000652 [6B08]0100A900-     <1>
   747 00000658 [6B08]0100ED00-     <1>
   747 0000065E [8108]0100F500-     <1>
   747 00000664 [8C08]01010301-     <1>
   747 0000066A [9D08]01002F01-     <1>
   747 00000670 [8108]01003701-     <1>
   747 00000676 [8C08]01014801-     <1>
   747 0000067C [AD08]01005201-     <1>
   747 00000682 [BD08]01016001-     <1>
   747 00000688 [C808]01018801-     <1>
   747 0000068E [DB08]01018B01-     <1>
   747 00000694 [EB08]0100E101-     <1>
   747 0000069A [FA08]01001502-     <1>
   747 000006A0 [8108]01002502-     <1>
   747 000006A6 [0809]01003202-     <1>
   747 000006AC [1609]01004002-     <1>
   747 000006B2 [8108]01004802-     <1>
   747 000006B8 [8C08]01005A02-     <1>
   747 000006BE [0809]01006602-     <1>
   747 000006C4 [1609]01006A02-     <1>
   747 000006CA [6B08]01008502-     <1>
   747 000006D0 [6B08]01008B02-     <1>
   747 000006D6 [8108]01003405-     <1>
   747 000006DC [3609]01005D05-     <1>
   747 000006E2 [6208]01007705-     <1>
   747 000006E8 [8108]01007F05-     <1>
   747 000006EE [8C08]01009005-     <1>
   747 000006F4 [0809]0100A305-     <1>
   747 000006FA [5B09]0101A905-     <1>
   747 00000700 [6C09]0000          <1>
   748                              <1> 
   749                              <1> 	align 2, db 0
   750                              <1> internalcodetocoderelocations:
   751 00000704 8000CD001C02210229- <1> 	dw INTERNAL_CODE_TO_CODE_RELOCATIONS, 0
   751 0000070D 022E02560262026D02- <1>
   751 00000716 800287024E05580586- <1>
   751 0000071F 058C05C3050000      <1>
   752                              <1> 
   753                              <1> 	align 2, db 0
   754                              <1> internalcodetodatarelocations:
   755 00000726 34004E005600D100DC- <1> 	dw INTERNAL_CODE_TO_DATA_RELOCATIONS, 0
   755 0000072F 00FF000A0119011F01- <1>
   755 00000738 43015A019601E901F1- <1>
   755 00000741 01FD0191020000      <1>
   756                              <1> 
   757                              <1> 	align 2, db 0
   758                              <1> internaldatatocoderelocations:
   759 00000748 FFFF                <1> 	dw INTERNAL_DATA_TO_CODE_RELOCATIONS, -1
   760                              <1> 
   761                              <1> 	align 2, db 0
   762                              <1> internaldatatodatarelocations:
   763 0000074A FFFF                <1> 	dw INTERNAL_DATA_TO_DATA_RELOCATIONS, -1
   764                              <1> 
   765                              <1> %if _ELD_LINKER_PASSES
   766                              <1> 	align 2, db 0
   767                              <1> linkerlinkerdatarelocations:
   768 0000074C 0100CD03[8108]0100- <1> 	dw LINK_LINKER_DATA_RELOCATIONS, 0
   768 00000754 0B04[BD08]0100E204- <1>
   768 0000075C [2509]0000          <1>
   769                              <1> 
   770                              <1> 	align 2, db 0
   771                              <1> internallinkercodetocoderelocations:
   772 00000760 D303E203F3031D0400- <1> 	dw INTERNAL_LINKER_CODE_TO_CODE_RELOCATIONS, 0
   772 00000769 00                  <1>
   773                              <1> 
   774                              <1> 	align 2, db 0
   775                              <1> internallinkercodetodatarelocations:
   776 0000076A 0000                <1> 	dw INTERNAL_LINKER_CODE_TO_DATA_RELOCATIONS, 0
   777                              <1> 
   778                              <1> 	align 2, db 0
   779                              <1> internallinkerdatatocoderelocations:
   780 0000076C FFFF                <1> 	dw INTERNAL_LINKER_DATA_TO_CODE_RELOCATIONS, -1
   781                              <1> 
   782                              <1> 	align 2, db 0
   783                              <1> internallinkerdatatodatarelocations:
   784 0000076E FFFF                <1> 	dw INTERNAL_LINKER_DATA_TO_DATA_RELOCATIONS, -1
   785                              <1> %endif
   786                              <1> 
   787                              <1> %ifnidni _LISTING, ""
   788                              <1> 	align 2, db 0
   789                              <1> debuggeramissig:
   790 00000770 65636D20<rep 5h>    <1> 		fill 8, 32, db "ecm"
   791 00000778 6C446562756720-     <1> 		fill 8, 32, db "lDebug"
   791 00000778 <rep 2h>            <1>
   792                              <1> listmsg:
   793 00000780 547261634C6973742D- <1> .hint:		db "TracList-add-offset=",_LISTING,"::"
   793 00000789 6164642D6F66667365- <1>
   793 00000792 743D686973746F7279- <1>
   793 0000079B 2E6C73743A3A        <1>
   794 000007A1 2D2D2D2D680D0A00    <1> .hint.offset:	asciz "----h",13,10
   795                              <1> %endif
   796                              <1> 
   797 000007A9 30CD0C636D64335F6E- <1> 	eldcall_dump_names ELDCALL_CODE_NAMES
   797 000007B2 6F745F657874D55509- <1>
   797 000007BB 736B6970636F6D6D61- <1>
   797 000007C4 03C309697373747269- <1>
   797 000007CD 6E673FDDB90663686B- <1>
   797 000007D6 656F6CBABD04636D64- <1>
   797 000007DF 332890046973706D55- <1>
   797 000007E8 1205707574737A6FA2- <1>
   797 000007F1 0D707574736C696E65- <1>
   797 000007FA 5F63726C6684810768- <1>
   797 00000803 6578776F7264D0BB1A- <1>
   797 0000080C 636F70795F73696E67- <1>
   797 00000815 6C655F636F756E7465- <1>
   797 0000081E 645F737472696E6798- <1>
   797 00000827 6906696E7463686B21- <1>
   797 00000830 300A63616C6C5F696E- <1>
   797 00000839 743244B77408736574- <1>
   797 00000842 6573326478          <1>
   798 00000847 54400D6D73672E756E- <1> 	link_data_dump_names LINK_DATA_NAMES
   798 00000850 696E7374616C6CEB42- <1>
   798 00000859 08657874647373656C- <1>
   798 00000862 D52D06657874736567- <1>
   798 0000086B 97B6136578745F636F- <1>
   798 00000874 6D6D616E645F68616E- <1>
   798 0000087D 646C65725ABC086F70- <1>
   798 00000886 74696F6E7337CD510E- <1>
   798 0000088F 696E7465726E616C66- <1>
   798 00000898 6C616773362AE70D68- <1>
   798 000008A1 6973746F7279666F72- <1>
   798 000008AA 6D617473830D686973- <1>
   798 000008B3 746F72796275666665- <1>
   798 000008BC 7284E3086C696E655F- <1>
   798 000008C5 6F75747D4210686973- <1>
   798 000008CE 746F72792E7365676F- <1>
   798 000008D7 7273656C75AE0D6869- <1>
   798 000008E0 73746F72792E666972- <1>
   798 000008E9 737431AA0C68697374- <1>
   798 000008F2 6F72792E6C6173748D- <1>
   798 000008FB 710B6D73672E696E73- <1>
   798 00000904 74616C6CE7D30B6578- <1>
   798 0000090D 747365675F75736564- <1>
   798 00000916 B2400C657874646174- <1>
   798 0000091F 615F7573656468440E- <1>
   798 00000928 6C696E6B63616C6C5F- <1>
   798 00000931 7461626C65F09E2274- <1>
   798 0000093A 72795F646562756767- <1>
   798 00000943 65725F616D69735F6D- <1>
   798 0000094C 756C7469706C65785F- <1>
   798 00000955 6E756D626572CB510E- <1>
   798 0000095E 696E7465726E616C66- <1>
   798 00000967 6C61677334688C1561- <1>
   798 00000970 6D69735F6D756C7469- <1>
   798 00000979 706C65785F6E756D62- <1>
   798 00000982 6572                <1>
   799                              <1> 
   800                              <1> %if _ELD_LINKER_PASSES
   801                              <1> lmsg:
   802 00000984 214F7074696F6E616C- <1> .warning_data_optional:		counted "Optional data link missing, hash="
   802 0000098D 2064617461206C696E- <1>
   802 00000996 6B206D697373696E67- <1>
   802 0000099F 2C20686173683D      <1>
   803                              <1> %if _ELDCALL_OPTIONAL
   804                              <1> .warning_code_optional:		counted "Optional code link missing, hash="
   805                              <1> %endif
   806 000009A6 1844617461206C696E- <1> .error_data:			counted "Data link missing, hash="
   806 000009AF 6B206D697373696E67- <1>
   806 000009B8 2C20686173683D      <1>
   807 000009BF 18436F6465206C696E- <1> .error_code:			counted "Code link missing, hash="
   807 000009C8 6B206D697373696E67- <1>
   807 000009D1 2C20686173683D      <1>
   808 000009D8 0A682C206C6162656C- <1> .error.2:			counted "h, label ",'"'
   808 000009E1 2022                <1>
   809                              <1> %endif
   810                              <1> 
   811 000009E3 00<rep Dh>          <1> 	align 16, db 0
   476                                  
   477                                  	align 16
   478                                  code_size equ $ - code
