%if 0

Extensions for lDebug macros

Copyright (C) 2008-2025 E. C. Masloch

Usage of the works is permitted provided that this
instrument is retained with the works, so that any entity
that uses the works is notified of this instrument.

DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.

%endif

%ifndef ELD_MAC
%define ELD_MAC 1

%include "lmacros3.mac"

		; ELD executable header
	struc ELD_HEADER
eldhSignature:		resb 4	; "ELD1"
			resb 3	; reserved
			resb 1	; 26 (Ctrl-Z)
eldhCodeOffset:		resd 1	; position displacement from eldhSignature
eldhCodeImageLength:	resw 1	; amount bytes, at least 32
eldhCodeAllocLength:	resw 1	; amount bytes, added to prior. sum < 64 KiB
eldhDataOffset:		resd 1
eldhDataImageLength:	resw 1	; (zero allowed)
eldhDataAllocLength:	resw 1	; (zero allowed)
eldhCodeEntrypoint:	resw 1	; within code section, used as displacement
eldhReserved:		resb 4	; reserved
eldhExtensionSize:	resw 1	; from eldhSignature, -> past eldhx fields in use
	endstruc
	endarea ELD_HEADER, 1

	struc ELD_HEADERX
eldhxHeader:		resb ELD_HEADER_size
eldhxDescriptionOffset:	resd 1	; zero if none, from eldhxHeader. <= 128 Bytes
eldhxHelpOffset:	resd 1	; zero if none, from eldhxHeader
eldhxLibTable:		resd 1	; zero if none, from eldhxHeader
eldhxDateTimeOffset:	resd 1	; zero if none, from eldhxHeader
	alignb 16
	endstruc

	struc ELD_TRAILER_HEADER
eldthSignature:		resb 8	; "ELD1TAIL"
eldthHeaderOffset:	resd 1	; negative displacement from eldthSignature,
				;  add this dword to the seek offset
eldthReserved:		resw 1	; reserved, must be initialised to zero
eldthChecksum:		resw 1	; sum of all words in trailer header = 0
	endstruc
	endarea ELD_TRAILER_HEADER, 1

	struc ELD_LIBTABLE
eldltFormat:		resw 1
	; 0 = uncompressed
	; 2 = heatshrink compressed
	; 3 = lzexedat -4 compressed
	; 4 = lzexedat -4 -l compressed
eldltAmount:		resw 1
eldltOffset:		resd 1	; from eldhxHeader
eldltCompressedLength:		; (dword, only present if format 2, 3, or 4)
	endstruc
	endarea ELD_LIBTABLE, 1

		; ELD instance header
	struc ELD_INSTANCE
eldiStartCode:		resw 1	; -> this structure itself (para aligned)
eldiEndCode:		resw 1	; -> behind memory used by instance (para aligned)
eldiStartData:		resw 1	; -> data in data entry section (para aligned), or 0
eldiEndData:		resw 1	; -> behind data (para aligned), or 0
eldiIdentifier:		resb 8	; blank-filled text
eldiFlags:		resw 1	; flags
eldiListing_size equ 14
eldiListing:		resb eldiListing_size
				; ASCIZ listing file name
	endstruc
		; flags for eldiFlags:
eldifResident:		equ 1

		; ELD link info header
	struc ELD_LINKINFO
eldlSignature:		resw 1	; 0E1D1h
eldlReserved:		resw 2
eldlUseLinkHash:	resw 1
eldlDataAmount:		resw 1
eldlDataPrefixes:	resw 1
eldlDataEntries:	resw 1
eldlDataAddresses:	resw 1
eldlCodeAmount:		resw 1
eldlCodePrefixes:	resw 1
eldlCodeEntries:	resw 1
eldlCodeAddresses:	resw 1
	endstruc

	numdef ELD_CODE_VSTART, 9001h
	numdef ELD_DATA_VSTART, 8000h
	numdef ELD_RELOC_VSTART, 8000h

	numdef ELD_RECLAIM_HINT, 0
	strdef ELD_LISTING, ""
	numdef ELD_DATETIME, 0

%if _ELD_DATETIME
 %define PUT_ELDHX_DATETIME_OFFSET at eldhxDateTimeOffset, dd DATAOFFSET + datetime - datastart
 %macro PUT_ELD_DATETIME 0.nolist
datetime:	asciz __UTC_DATE__,'T',__UTC_TIME__,'Z'
		asciz		; for future extension
 %endmacro
%else
 %define PUT_ELDHX_DATETIME_OFFSET
 %define PUT_ELD_DATETIME
%endif

%endif
