One introduction to qhasm is the following short talk that I gave: 2005.02.21, "Have any challenges for qhasm?" The online notes for my Fall 2006 course on high-speed cryptography included a much more detailed example of using qhasm to write software for a serious cryptographic application.
WARNING WARNING WARNING: qhasm is in prototype form. The existing qhasm tools and interfaces have produced high-speed professional-quality software for several applications, but they are not themselves professional-quality tools; they have many known deficiencies and many sharp corners. Each of the qhasm tools has at least one complete rewrite planned. The .q language is not stable; if you write .q files then you should plan on having to modify them extensively for future qhasm releases. The machine-description language has a stable structure but is still undergoing tweaks; I can incorporate machine descriptions into qhasm and keep them up to date, but I won't promise that non-incorporated descriptions will continue to work. The prototypes of qhasm's cycle counter, range analyzer, and scheduler are several generations behind the current .q language and, as a practical matter, aren't usable right now.
Not scared? Okay. Here's how to download and compile the current prototypes of qhasm's instruction decoder, register allocator, x86-floating-point-stack handler, and assembler:
wget https://cr.yp.to/qhasm/qhasm-20070207.tar.gz gunzip < qhasm-20070207.tar.gz | tar -xf - cd qhasm-20070207 ./doNo installation script at this point. To process .q files you'll need to be inside the qhasm compilation directory to run ./qhasm-x86 etc.
Here are some examples of .q files (in some cases needing updates for the latest qhasm prototype!) and the resulting .s files: