Am 09/10/2022 10:32 PM, Lawrence Nelson schrieb:
> On Saturday, August 20, 2022 at 10:55:14 AM UTC-4, Martin wrote:
>> A TDL Relocatable Object Code Loader.
>>
>> Simple, stupid, and dangerous!
>> It can overwrite your system, if you say so :-)
>>
>> I tried to pack all details directly into comments.
>> Just assemble with the CP/M asm/load.
>>
>> Here is the source, hope someone can use it.
>> Martin
>>
>>
> I also made a CP/M version of TDLoader.
I'll try to compare our two versions of the code.
Been a while since I used it mainly for making a CP/M version of TDL Basic.
>
> Lars
>
It all began with /ENTERPRS/CPM/UTILS/S/Z80MAC.ZIP
on the CP/M CD-ROM.
I realized, it likely is based on an older version of
TASMIO (CP/M-UG #16) and my reverse engineering interest
was awake... :-)
Soon I was analysing the CP/M binaries floating around
and relate them with the existing CP/M adapters, like
MAC4.ASM, MAC6.AZM and TASMIO.MAC (CP/M-UG #8, #36 and #16).
Couldn't believe that there is absolutely no small CP/M loader
for the TDL RELOCATABLE OBJECT format in the CP/M archives.
So I wrote this patchwork, tried to reuse working code and
to keep the memory footprint small.
The first version was hardcoded to always prefill with 0FFH.
But in the meantime, I realized the need to a prefill with 000H,
so the following small modification was made.
It allows you to prepend a prefill value starting with a '/'.
This allowes to overlay TDL code by means of running the loader
multiple times. For now, just erase the intermediate BIN files.
NOTE: I fixed one *SEVERE BUG* of this loader!
The default relocation type of the record was ignored.
All bytes without explicit relocation info were relocated
relative to the ".CODE." segment.
Look in the code after this line:
; FIX: SET THE RELOCATION BASE FOR THE RECORD
Use this "unified diff", or hand-apply the diffs to the source.
Have fun!
Martin
==== 8< ====
--- tdlloadO.asm
+++ tdlload.asm
@@ -17,8 +17,10 @@
; Command syntax:
; tdlload
; filename.ext
-; [<loading bias>[,<rel base 1>[,<rel base 2>]]]
+; [/<filler>,][<loading bias>[,<rel base 1>[,<rel base 2>]]]
;
+; /<filler>
+; if specified, prefill memory with filler
; <loading bias>
; is an optional bias, which will be added to
; the load address
@@ -83,23 +85,6 @@
;
FILE INFILE,DSKI,,1,
;
- LXI H,BUFFERS+@NXTB ;FREE MEMORY
- XCHG
- LHLD BDOS+1 ;TOP OF MEMORY
- XRA A ;PAGE BOUNDARY
- SUB E
- MOV C,A
- MOV A,H
- SBB D
- MOV B,A
- XCHG
-INIMEM: MVI M,0FFH ;WHATEVER
- INX H
- DCX B
- MOV A,B
- ORA C
- JNZ INIMEM
-;
LXI H,0 ;INIT MIN/MAX
SHLD MMAX
DCX H
@@ -121,7 +106,37 @@
DAD B
MVI M,CR
;
- CALL READ ;TDL RELOCATABLE OBJECT LOADER
+ MOV A,C
+ ORA A
+ JZ L5
+ LDAX D
+ CPI '/'
+ JNZ L5 ;NO FILLER BYTE
+ INX D
+ CALL EXPR ;GET FILLER BYTE
+ POP H
+ PUSH D ;SAVE PARAMETER
+ PUSH H ;SAVE FILLER
+ LXI H,BUFFERS+@NXTB ;FREE MEMORY
+ XCHG
+ LHLD BDOS+1 ;TOP OF MEMORY
+ XRA A ;PAGE BOUNDARY
+ SUB E
+ MOV C,A
+ MOV A,H
+ SBB D
+ MOV B,A
+ XCHG
+ POP D ;GET FILLER
+INIMEM: MOV M,E
+ INX H
+ DCX B
+ MOV A,B
+ ORA C
+ JNZ INIMEM
+ POP D ;GET PARAMETER
+;
+L5: CALL READ ;TDL RELOCATABLE OBJECT LOADER
;
FINIS DSKI
;
==== 8< ====