TRC format internals

Hi there,

Did anyone ever try to research the TRC format?

I have been doing this for some weeks in my spare time and already made some progress, although many mysteries and questions remain. I simply create some simple programs and open them in a hex editor and try to make sense out of it and documenting what I think I see. True BASIC green-lighted this research and suggested I'd post about it here.

Regarding TRC containing main programs, at this time I understand a lot of bytes in the header (still some complete byte blocks remain a mystery at this time). Regarding byte blocks in those files that contain the main code, I understand encoding of some constructs like simple PRINT statements, some of the INPUT statements. Also understand how LET works. I also understand some basic things, like how strings, literal numeric values and variables are stored and handled on a low level. Have not really looked at complex expressions yet, but already made some progress there.

I have now turned my interest to loop constructs like DO-LOOP, but have not figured this out yet, although I am making progress. The byte that (most probably) tells where to jump to is a mystery still, but I hope I can beat it one day ;-)

This is a labor of love, I fear that without internal documentation, I will hit unbreakable walls rather sooner than later, though. For example, all main programs that I have seen do some calls to mystery functions (I don't have names, only byte sequences), it will probably be hard to find out what they do, unless I accidentally run across them.

Was wondering if anyone ever attempted something like this before. Since it's an old format, it could be possible.

Comments

I'm just getting started

I have not looked into the workings of the bytecode interpreter, but if you did figure out the format would that mean we could one day chain to DLL files and run their functions from within TrueBASIC?

Have you ever used a language called Euphoria? It makes calling external libraries written in C really easy. True BASIC doesn't have that kind of functionality right?

DLLs from True BASIC

Hi Spintronic,

The (rather expensive IMO, but still powerful) Gold edition of TB supports creating TRC files that in turn call routines from 32-bit DLLs.

This requires some knowledge of the C language, as TB has unusual structs for its datatypes, but I had no real difficulty creating a DLL that I could call from TB in PowerBASIC for Windows (competing BASIC compiler, that since the unfortunate passing of its founder, Bob Zale of Turbo BASIC fame, in 2012 has not seen any new releases, since. The company has been sold recently, however, so who knows what its future holds). See my old forum post https://www.truebasic.com/node/1050 for more info. Also check out the Gold manual from TB's download section.

The biggest trouble I had was finding a language that could generate DLLs that can work with TB, TB requires the CDECL calling style IIRC, but don't quote me on that. I tried some other alternative languages that I would have loved to create some TB-compatible DLLs with, but those languages could not generate DLLs for this calling style.

Personally, I never really liked Win32 API development, I am fully into the JVM these days.

CDECL calling style

I thought you could decide the calling style in your Visual Studio project configuration. GCC also supports CDECL.

At least that's what Wikipedia says.