Cross compiled executables, the XTcc record and Dataspace.

Anything QL Software or Programming Related.
User avatar
NormanDunbar
Super Gold Card
Posts: 615
Joined: Tue Dec 14, 2010 9:04 am
Location: Leeds, West Yorkshire, UK
Contact:

Cross compiled executables, the XTcc record and Dataspace.

Postby NormanDunbar » Tue Oct 30, 2018 2:24 pm

As mentioned elsewhere, I'm playing with the xtc68 C compiler, on Linux, to generate executables for QDOSMSQ. It works quite well, so far.

I did need a quick utility to convert the non-executable on QDOSMSQ, to an executable with the correct data space, as taken from the 'XTcc' header at the end of the compiled file. To this end, I quickly knocked up the following:

Code: Select all

1000 REMark A program to extract the XTcc record from the end of a
1010 REMark Cross-compiled executable file and set the dataspace to
1020 REMark the correct value.
1030 :
1040 REMark Norman Dunbar
1050 REMark 30th October 2018.
1060 :
1070 REMark Uses DJToolkit
1080 :
1085 CLS
2000 REPeat file_loop
2010   PRINT #1
2020   INPUT #1, 'Enter the cross-compiled filename please, ENTER to quit: '; f$
2030   IF f$ = '' THEN EXIT file_loop: END IF
2040   IF FILE_TYPE(f$) = 1 THEN
2050     PRINT #1,f$; ' is already an executable file, with dataspace set to ';
2060     PRINT #1,FILE_DATASPACE(f$)
2070     NEXT file_loop
2080   END IF
2090   :
2100   size = FILE_LENGTH(f$)
2110   IF size < 0 THEN
2120     PRINT #1,'Error '; size; ' reading file size for '; f$
2130     NEXT file_loop
2140   END IF
2150   :
2160   addr = RESERVE_HEAP(size)
2170   IF addr < 0 THEN
2180     PRINT #1, 'Error '; addr; ' allocating memory for '; f$
2190     NEXT file_loop
2200   END IF
2210   :
2220   LBYTES f$,addr
2230   xtcc = SEARCH_I(addr + size - 8, 4, 'XTcc')
2240   IF xtcc = 0 THEN
2250     PRINT #1, f$; ' has no XTcc record present. Cannot continue.'
2260     RELEASE_HEAP(addr)
2270     NEXT file_loop
2280   END IF
2290   :
2300   dspace = PEEK_L(xtcc + 4)
2310   PRINT #1, 'XTcc record found. Dataspace is '; dspace
2320   IF dspace < 512 THEN
2330     PRINT #1, 'Dataspace seems a tad small at '; dspace
2340     PRINT #1, 'You might need to increase it. '
2350   END IF
2360   :
2370   SEXEC_O f$, addr, size, dspace
2380   PRINT f$; ' resaved as executable file, with dataspace set to '; dspace; '.'
2390   RELEASE_HEAP(addr)
2400   PRINT 'Press any key to continue....'
2410 END REPeat file_loop


This requires DJToolkit but that's easily available from Dilwyn at http://www.dilwyn.me.uk/tk/djtk.zip.

Cheers,
Norm.


Why do they put lightning conductors on churches?
If at first you don't succeed, don't take up skydiving!
If you think your job is pointless, remember, there's someone in Germany who fits indicators to BMWs.
User avatar
NormanDunbar
Super Gold Card
Posts: 615
Joined: Tue Dec 14, 2010 9:04 am
Location: Leeds, West Yorkshire, UK
Contact:

Re: Cross compiled executables, the XTcc record and Dataspace.

Postby NormanDunbar » Thu Dec 13, 2018 3:47 pm

Regarding the above listing, there will be an article an this very subject in the next, somewhat exciting, instalment of the somewhat irregular Assembly Language eComic.

Watch out for that, coming soon. (For certain values of "soon" that is!) ;)


Cheers,
Norm.


Why do they put lightning conductors on churches?
If at first you don't succeed, don't take up skydiving!
If you think your job is pointless, remember, there's someone in Germany who fits indicators to BMWs.

Return to “Software & Programming”

Who is online

Users browsing this forum: No registered users and 2 guests