vbcc for QDOS proof of concept

January 14th, 2012

One of these projects that might not be useful for anybody, but it was educational for me at least 🙂 For some time I had been looking for a bit nicer and easier way to code for Sinclair QL than just pure asm. There used to be a GCC hack, which can’t even be compiled these days. The other 68k-friendly alternative is vbcc, which has support for various related architectures such as Atari ST and Amiga, but no QDOS. Hacking GCC is nothing I’d love to do in my spare time, so I checked out vbcc instead.

The aim was simple enough: get compiled C code to run on QL at an absolute address (0x30000 in this case, right after the video ram). Dealing with nasty stuff such as executable headers wasn’t necessary, since vlink supports rawbin1 output, which is just good clean binary code and data. In addition to that there was a need for a trivial startup routine, which doesn’t do much more than call _main. The correct way would be to call libvc’s __main, which initializes the stack, the heap and the C library, but since the implementation here is so incomplete anyway, I decided to omit that at this point. The biggest challenge was to create the needed linker script to join different object files and sections to a coherent executable. The example scripts can bring tears to your eyes with their complexity, but to join the three required aout sections (.text, .data and .bss) wasn’t that bad after some orientation.

So, with about five hours of work I got to the point where I could compile and run C code on the QL using my own little Arduino-based transfer cable and software. Plain C without any standard stuff such as includes, stdlib and math isn’t very useful yet, so next it was time to look into that. To my surprise I found out that libvc is not part of the distribution at all. Fortunately, the TOS includes seemed to be almost generic, and since the libs are in aout format as well, I gave them a go as-is. Everything I tried seems to work just fine — of course excluding i/o — so there is no immediate need for a real libvc implementation. A kludge on top of another kludge doesn’t decrease the overall quality significantly 😛

The necessary files are here: vbcc-qdos-poc.zip. In order to compile anything, you need to install vbccm68k, copy the archive contents to /usr/local/vbcc, and then add +qdos to the compiler command line. There’s a lot of broken stuff, questionable hacks and so on, which is why I call it a proof of concept. Anyone willing to take the work further is most welcome to do so. This is enough for my humble purposes, probably coupled with a few additions to deal with the keyboard, screen mode etc.

Filed under: koodi,retro,softat

Kommentin kirjoitus

You must be logged in to post a comment.

RSS feed for comments on this post.


Kommenttien virta

Aiheet