@@ -39,6 +39,9 @@ procedure Write_PubDefRecords(var F : File; BaseGroupIndex: byte; BaseSegmentInd
39
39
Function CreateTPObj (infile,outfile,publicname : string) : word;
40
40
Function CreateTPObj (infile,outfile,publicname,publicsizename : string) : word;
41
41
42
+ Function CreateTMTObj (infile,outfile,publicname : string) : word;
43
+ Function CreateTMTObj (infile,outfile,publicname,publicsizename : string) : word;
44
+
42
45
Function CreateTCObj (infile,outfile,publicname,segname,classname : string;UseFswitch : Boolean) : word;
43
46
Function CreateTCObj (infile,outfile,publicname,publicsizename,segname,classname : string;UseFswitch : Boolean) : word;
44
47
@@ -489,7 +492,7 @@ procedure Write_LeData32(var F : File;SegmentIndex : Byte;EnumeratedDataOffset :
489
492
FreeMem(recordPtr, dataLength + 5 );
490
493
end ;
491
494
492
- procedure Write_SegmentData32 (var F : File ; SegmentIndex: byte; EnumeratedDataOffset: longword; dataBytes : PByte; dataLength: word );
495
+ procedure Write_SegmentData32 (var F : File ; SegmentIndex: byte; EnumeratedDataOffset: longword; dataBytes : PByte; dataLength: longword );
493
496
begin
494
497
while (dataLength > 1024 ) do
495
498
begin
@@ -515,6 +518,19 @@ function GetFileSize(filename : string) : longword;
515
518
{ $I+}
516
519
end ;
517
520
521
+ function GetFileSize32 (filename : string) : longword;
522
+ var
523
+ F : File ;
524
+ begin
525
+ Assign(F,filename);
526
+ { $I-}
527
+ Reset(F,1 );
528
+ result:=FileSize(F);
529
+ close(F);
530
+ { $I+}
531
+ end ;
532
+
533
+
518
534
Procedure Write_FileContents (var F : File ;filename : string;segIdx: byte; dataOffset: word);
519
535
var
520
536
size : longword;
@@ -603,6 +619,26 @@ function GetFileSize(filename : string) : longword;
603
619
end ;
604
620
605
621
622
+ procedure ChangePubDefStr (index : byte;var data; PublicName : string; PublicOffset : word; typeindex : byte);
623
+ var
624
+ DataA : array [1 ..255 ] of TPubDefStrRec absolute data;
625
+ begin
626
+ dataA[index].StringLength:=length(publicname);
627
+ dataA[index].PubLicName:=publicname;
628
+ dataA[index].PublicOffset:=publicoffset;
629
+ dataA[index].TypeIndex:=typeindex;
630
+ end ;
631
+
632
+ procedure ChangePubDefStr32 (index : byte;var data; PublicName : string; PublicOffset : longword; typeindex : byte);
633
+ var
634
+ DataA : array [1 ..255 ] of TPubDefStrRec32 absolute data;
635
+ begin
636
+ dataA[index].StringLength:=length(publicname);
637
+ dataA[index].PubLicName:=publicname;
638
+ dataA[index].PublicOffset:=publicoffset;
639
+ dataA[index].TypeIndex:=typeindex;
640
+ end ;
641
+
606
642
607
643
// create Turbo Pascal Compatile BINOBJ output exactly to the byte level
608
644
Function CreateTPObj (infile,outfile,publicname : string) : word;
@@ -625,51 +661,86 @@ function GetFileSize(filename : string) : longword;
625
661
result:=IORESULT;
626
662
end ;
627
663
628
- procedure ChangePubDefStr (index : byte;var data; PublicName : string; PublicOffset : word; typeindex : byte);
664
+
665
+ Function CreateTPObj (infile,outfile,publicname,publicsizename : string) : word;
629
666
var
630
- DataA : array [1 ..255 ] of TPubDefStrRec absolute data;
667
+ size : word;
668
+ F : File ;
669
+ data : array [1 ..2 ] of TPubDefStrRec;
631
670
begin
632
- dataA[index].StringLength:=length(publicname);
633
- dataA[index].PubLicName:=publicname;
634
- dataA[index].PublicOffset:=publicoffset;
635
- dataA[index].TypeIndex:=typeindex;
671
+ size:=WORD(GetFileSize(infile));
672
+ { $I-}
673
+ assign(F,outfile);
674
+ rewrite(F,1 );
675
+ Write_THeadr(F,#$3a#$3a);
676
+ Write_LNames(F,' #CODE##' );
677
+ Write_SegDef(F,$28 ,size+2 ,2 ,1 ,1 ); // +2 is the addtional bytes we will need to include the size information
678
+
679
+ ChangePubDefStr(1 ,data,publicname,0 ,0 );
680
+ ChangePubDefStr(2 ,data,publicsizename,size,0 );
681
+ Write_PubDefRecords(F,0 ,1 ,data,2 );
682
+
683
+ Write_FileContentsAndSize(F,infile,1 ,0 );
684
+ Write_ModEnd(F);
685
+ close(F);
686
+ { $I+}
687
+ result:=IORESULT;
636
688
end ;
637
689
638
- procedure ChangePubDefStr32 (index : byte;var data; PublicName : string; PublicOffset : longword; typeindex : byte);
690
+
691
+
692
+
693
+ Function CreateTMTObj (infile,outfile,publicname : string) : word;
639
694
var
640
- DataA : array [1 ..255 ] of TPubDefStrRec32 absolute data;
695
+ size : longword;
696
+ F : File ;
641
697
begin
642
- dataA[index].StringLength:=length(publicname);
643
- dataA[index].PubLicName:=publicname;
644
- dataA[index].PublicOffset:=publicoffset;
645
- dataA[index].TypeIndex:=typeindex;
698
+ size:=GetFileSize32(infile);
699
+ { $I-}
700
+ assign(F,outfile);
701
+ rewrite(F,1 );
702
+ Write_THeadr(F,#$3a#$3a);
703
+ Write_LNames(F,' #CODE##' );
704
+ Write_SegDef32(F,$28 ,size,2 ,1 ,1 );
705
+ Write_PubDef(F,0 ,1 ,publicname,0 ,0 );
706
+ Write_FileContents32(F,infile,1 ,0 );
707
+ Write_ModEnd(F);
708
+ close(F);
709
+ { $I+}
710
+ result:=IORESULT;
646
711
end ;
647
712
648
- Function CreateTPObj (infile,outfile,publicname,publicsizename : string) : word;
713
+
714
+ // public size name will not work TMT Pascal. we can only store 2 bytes for size instead of 4
715
+ // tmt compiler would need to understand option 91h
716
+ Function CreateTMTObj (infile,outfile,publicname,publicsizename : string) : word;
649
717
var
650
- size : word ;
718
+ size : longword ;
651
719
F : File ;
652
720
data : array [1 ..2 ] of TPubDefStrRec;
653
721
begin
654
- size:=WORD(GetFileSize( infile) );
722
+ size:=GetFileSize32( infile);
655
723
{ $I-}
656
724
assign(F,outfile);
657
725
rewrite(F,1 );
658
726
Write_THeadr(F,#$3a#$3a);
659
727
Write_LNames(F,' #CODE##' );
660
- Write_SegDef (F,$28 ,size+2 ,2 ,1 ,1 ); // +2 is the addtional bytes we will need to include the size information
728
+ Write_SegDef32 (F,$28 ,size+4 ,2 ,1 ,1 ); // +4 is the addtional bytes we will need to include the size information
661
729
662
730
ChangePubDefStr(1 ,data,publicname,0 ,0 );
663
- ChangePubDefStr(2 ,data,publicsizename,size,0 );
731
+ ChangePubDefStr(2 ,data,publicsizename,size,0 ); // <---we are doomed here
664
732
Write_PubDefRecords(F,0 ,1 ,data,2 );
665
733
666
- Write_FileContentsAndSize (F,infile,1 ,0 );
734
+ Write_FileContentsAndSize32 (F,infile,1 ,0 );
667
735
Write_ModEnd(F);
668
736
close(F);
669
737
{ $I+}
670
738
result:=IORESULT;
671
739
end ;
672
740
741
+
742
+
743
+
673
744
// Turbo C's BGIOBJ /F switch inserts another LName that is the same as the public name
674
745
// eg default is _TEXT CODE, if public name is _IMAGE, LName section becomes IMAGE_TEXT CODE
675
746
// /F switch has not used when segname is provided
0 commit comments