{"id":1251,"date":"2012-01-14T18:34:15","date_gmt":"2012-01-14T16:34:15","guid":{"rendered":"http:\/\/www.kameli.net\/marq\/?p=1251"},"modified":"2012-01-15T19:14:48","modified_gmt":"2012-01-15T17:14:48","slug":"vbcc-for-qdos-proof-of-concept","status":"publish","type":"post","link":"http:\/\/www.kameli.net\/marq\/?p=1251","title":{"rendered":"vbcc for QDOS proof of concept"},"content":{"rendered":"<p>One of these projects that might not be useful for anybody, but it was educational for me at least \ud83d\ude42 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 <a href=\"http:\/\/morloch.hd.free.fr\/qdos\/qdosgcc.html\">GCC hack<\/a>, which can&#8217;t even be compiled these days. The other 68k-friendly alternative is <a href=\"http:\/\/www.compilers.de\/vbcc.html\">vbcc<\/a>, which has support for various related architectures such as Atari ST and Amiga, but no QDOS. Hacking GCC is nothing I&#8217;d love to do in my spare time, so I checked out vbcc instead.<\/p>\n<p>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&#8217;t necessary, since<em> vlink<\/em> supports <em>rawbin1<\/em> 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&#8217;t do much more than call _main. The correct way would be to call libvc&#8217;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 <em>aout<\/em> sections (.text, .data and .bss) wasn&#8217;t that bad after some orientation.<\/p>\n<p>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&#8217;t very useful yet, so next it was time to look into that. To my surprise I found out that <em>libvc<\/em> 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 &#8212; of course excluding i\/o &#8212; so there is no immediate need for a real libvc implementation. A kludge on top of another kludge doesn&#8217;t decrease the overall quality significantly \ud83d\ude1b<\/p>\n<p>The necessary files are here: <a href=\"http:\/\/www.kameli.net\/~marq\/kode\/vbcc-qdos-poc.zip\">vbcc-qdos-poc.zip<\/a>. In order to compile anything, you need to install <em>vbccm68k<\/em>, copy the archive contents to <em>\/usr\/local\/vbcc<\/em>, and then add <em>+qdos<\/em> to the compiler command line. There&#8217;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.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>One of these projects that might not be useful for anybody, but it was educational for me at least \ud83d\ude42 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&#8217;t even be compiled [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[25,15,24],"tags":[],"class_list":["post-1251","post","type-post","status-publish","format-standard","hentry","category-koodi","category-retro","category-softat"],"_links":{"self":[{"href":"http:\/\/www.kameli.net\/marq\/index.php?rest_route=\/wp\/v2\/posts\/1251","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.kameli.net\/marq\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.kameli.net\/marq\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.kameli.net\/marq\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.kameli.net\/marq\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1251"}],"version-history":[{"count":4,"href":"http:\/\/www.kameli.net\/marq\/index.php?rest_route=\/wp\/v2\/posts\/1251\/revisions"}],"predecessor-version":[{"id":1255,"href":"http:\/\/www.kameli.net\/marq\/index.php?rest_route=\/wp\/v2\/posts\/1251\/revisions\/1255"}],"wp:attachment":[{"href":"http:\/\/www.kameli.net\/marq\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1251"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.kameli.net\/marq\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1251"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.kameli.net\/marq\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1251"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}