qhasm: tools to help write high-speed software D. J. Bernstein
Computer hardware

Writing high-speed software

What is a portable assembly language?
Does a free swap turn a stack into a traditional register set?
Some relevant literature
There's a mailing list for discussions among potential qhasm users ("How could I do this with qhasm?"), actual qhasm users ("Here's a .q file I wrote"), potential users of software produced by qhasm ("Can you qhasm people speed up this time-critical function for me?"), and qhasm contributors ("Here's a new machine description"). To subscribe, send an empty message to qhasm-subscribe@list.cr.yp.to.

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
     ./do
No 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: