My graduation work (1987) was to define the macroexpansion for Prolog and test its possible benefits. My target was the WAM. I had the source code of WAM in DEC-10 assembly language, but unfortunately I had no DEC-10 (neither physical nor emulated), so I had to implement a compiler from the WAM language to TurboPascal v3 as a side work. As far as I remember, my implementation was not complete, but enough for what I had to do. I'd be surprised if, almost five years after having posted this question, you found this contribution (so small, so late) useful; however, if you do, just post an answer and I'll gladly send you my source code. I wrote it, I can gladly donate my rights to the public domain.