Clean up x86 assembler.
Rearrange code, add comments, and move tests to another file.