{"id":1215,"date":"2012-04-15T00:55:54","date_gmt":"2012-04-14T22:55:54","guid":{"rendered":"http:\/\/blog.benny-baumann.de\/?p=1215"},"modified":"2012-04-15T00:55:54","modified_gmt":"2012-04-14T22:55:54","slug":"dcpu-16-highlighting","status":"publish","type":"post","link":"https:\/\/blog.benny-baumann.de\/?p=1215","title":{"rendered":"DCPU-16 highlighting"},"content":{"rendered":"<p>Not quite 0x0001 0000 0000 0000 years since the last post in this category but still long enough to justify emitting a new sign that there&#8217;s still some developement going on with GeSHi. And it&#8217;s quite a coincidence that Markus &#8222;Notch&#8220; Persson is <a href=\"https:\/\/github.com\/blog\/1098-take-over-the-galaxy-with-github\">taking over GitHub<\/a> with its own new language now being highlighted. And since most assembly languages are quite easy to highlight it&#8217;s only natural to add support for highlighting of this new language for GeSHi.<\/p>\n<p>So there it is: After only about 10 minutes <a href=\"http:\/\/0x10c.com\/doc\/dcpu-16.txt\">looking at the language specs<\/a> the basic structure looked simple enough and since GeSHi already supported a bunch of different assembly languages it&#8217;s only natural to use another one of them as the template. In this case I decided go for Z80 assembly as the ZiLOG Z80 instruction set is quite simple and still the language file was elaborate enough to support all the features required by Notch&#8217;s new assembly language. Actually: I even could remove some features not required to properly highlight DCPU-16.<\/p>\n<p>After a short clean-up of the language file &#8211; removing all the old instructions, registers and directives &#8211; it took only few more steps to fill in the list of supported instructions: In the case of the DCPU-16 instruction set this is a quite small set of only 16 instructions, 11 registers and 3 &#8222;memory shortcuts&#8220;. Thus there was not that much to copy from the specs, althoug the example given there looks quite nice when rendered with this new language file:<\/p>\n<pre lang=\"dcpu16\" escaped=\"true\">\r\n; Try some basic stuff\r\n              SET A, 0x30              ; 7c01 0030\r\n              SET [0x1000], 0x20       ; 7de1 1000 0020\r\n              SUB A, [0x1000]          ; 7803 1000\r\n              IFN A, 0x10              ; c00d \r\n                 SET PC, crash         ; 7dc1 001a [*]\r\n              \r\n; Do a loopy thing\r\n              SET I, 10                ; a861\r\n              SET A, 0x2000            ; 7c01 2000\r\n:loop         SET [0x2000+I], [A]      ; 2161 2000\r\n              SUB I, 1                 ; 8463\r\n              IFN I, 0                 ; 806d\r\n                 SET PC, loop          ; 7dc1 000d [*]\r\n\r\n; Call a subroutine\r\n              SET X, 0x4               ; 9031\r\n              JSR testsub              ; 7c10 0018 [*]\r\n              SET PC, crash            ; 7dc1 001a [*]\r\n\r\n:testsub      SHL X, 4                 ; 9037\r\n              SET PC, POP              ; 61c1\r\n                \r\n; Hang forever. X should now be 0x40 if everything went right.\r\n:crash        SET PC, crash            ; 7dc1 001a [*]\r\n\r\n; [*]: Note that these can be one word shorter and one cycle faster by using the short form (0x00-0x1f) of literals,\r\n;      but my assembler doesn't support short form labels yet.     \r\n<\/pre>\n<p>There were no major problems, except for some trouble with two regular expressions which broke rendering; but since those weren&#8217;t needed I could just simply remove them.<\/p>\n<p>If you like to try out the language file for yourself just <a href=\"http:\/\/qbnz.com\/highlighter\/\">visit the main GeSHi site<\/a> or grab a copy of the language file <a href=\"http:\/\/geshi.svn.sf.net\/svnroot\/geshi\/trunk\/\">directly from the SVN trunk<\/a>.<\/p>\n<p class=\"wp-flattr-button\"><a href=\"https:\/\/blog.benny-baumann.de\/?flattrss_redirect&amp;id=1215&amp;md5=2dbbbe3e76c2712b381b840493a4e649\" title=\"Flattr\" target=\"_blank\"><img src=\"http:\/\/blog.benny-baumann.de\/wp-content\/plugins\/flattr\/img\/flattr-badge-large.png\" srcset=\"http:\/\/blog.benny-baumann.de\/wp-content\/plugins\/flattr\/img\/flattr-badge-large.png\" alt=\"Flattr this!\"\/><\/a><\/p>","protected":false},"excerpt":{"rendered":"<p>Not quite 0x0001 0000 0000 0000 years since the last post in this category but still long enough to justify emitting a new sign that there&#8217;s still some developement going on with GeSHi. And it&#8217;s quite a coincidence that Markus &#8222;Notch&#8220; Persson is taking over GitHub with its own new language now being highlighted. And [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0,"footnotes":""},"categories":[3],"tags":[98,347,345,7],"class_list":["post-1215","post","type-post","status-publish","format-standard","hentry","category-geshi","tag-developement","tag-fun","tag-geshi","tag-links"],"_links":{"self":[{"href":"https:\/\/blog.benny-baumann.de\/index.php?rest_route=\/wp\/v2\/posts\/1215","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.benny-baumann.de\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.benny-baumann.de\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.benny-baumann.de\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.benny-baumann.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1215"}],"version-history":[{"count":2,"href":"https:\/\/blog.benny-baumann.de\/index.php?rest_route=\/wp\/v2\/posts\/1215\/revisions"}],"predecessor-version":[{"id":1217,"href":"https:\/\/blog.benny-baumann.de\/index.php?rest_route=\/wp\/v2\/posts\/1215\/revisions\/1217"}],"wp:attachment":[{"href":"https:\/\/blog.benny-baumann.de\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1215"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.benny-baumann.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1215"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.benny-baumann.de\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1215"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}