T
hanks to a comment I saw recently, I went down the rabbit hole that is HQ9+.
From Simple English Wikipedia:
"HQ9+ is a joke programming language made by Cliff L. Biffle in 2001.[1] It has four "operations":
H: print "Hello, world!"Q: print the program's source code (sometimes called a quine)
9: print the lyrics to 99 Bottles of Beer
+: add one to the accumulator (the value of the accumulator cannot be accessed)"
My first goal was to run this on my RC2014. Rosetta Code has a version for 8080 to run on CP/M. The 8080 is a predecessor of the Z80. The Z80 is backwardly-compatible, but in order to assemble the program, many of the instructions must be altered*. Perhaps there are tools to do this, but I enjoyed doing it by hand. My Z80 version is here.
I expected this to work in direct mode, ie type H and see Hello, world. I may alter this program so that it works that way.
However, as it stands, hq9+.com is called from the command line and takes the name of a source file as a parameter. Maybe the Quine command makes more sense this way.
For example, your source file may be called test.hq and contain two bytes, HQ.
D>
D>hq9+ test.hq
Hello, world!
HQ
D>
The documentation for the 8080 version says that the accumulator can be read at memory location 0252h. This may or may not be the case with my translation, it would rely on my program being the same length as the original. I haven't yet checked. Note that if you do access the memory location of the accum: label, this isn't the z80 accumulator or a copy of it, but a variable in memory. Reading it after running the program would seem to go against the original principles of the language.
It's very cool passing in a source file consisting of a single byte:
* The instructions are equivalent, it's their mnemonics in the assembly source file that must be altered.
Comments
Post a Comment