I had no problem knowing how to initialize R2 for Mult.asm, but I beat my head against a wall for an hour or so, trying to figure out how to input values for R0 and R1. I knew I couldn't hard-code them, because I had no idea what values the test script would be expecting, but I certainly saw no way to get user input, either through the command line or within the program. Finally, I just said the heck with it, and decided to write the code without setting any values for R0 and R1, and guess what...that ultimately turned out to be the right answer! The test script sets the values for R0 and R1 as it evaluates your code, so you don't have to worry about them. In fact, I imagine - though I didn't test it - that if you did
try to initialize R0 and R1 to some logical value like 0 or 1, you'd end up hosing the test script.
Even having decided to take a Taoist attitude toward R0 and R1, I still wasn't sure how to construct an assembly-language program. The only thing I could think of was to deconstruct the only complete assembly language program I could find, Sum.asm from fig. 4.2 in the text, or slide 6 in the Assembler tutorial. I started by typing in the code as written, without the comments. Then I went through the program line by line, and massively over-commented it, explicitly translating every single command into English or pseudo-code. My over-commented version of Sum.asm looks like this:
Then wrote a Python program to meet the specs for Mult.asm (be nice, C++ hackers; I only started programming 8 weeks ago), which turned out to be just 3 lines long. Then, using Sum.asm as a model, I began hacking out a Hack-assembly version of my Python program, over-commenting it line-by-line. My first attempts to assemble and run it turned up a couple of minor syntax errors, but once I found and corrected those, it ran fine and past the test.
One last tip, for anyone who is struggling with Mult.asm: be very careful to keep A and M straight
. It was easy for me to mix them up, which produced a program that the assembler would process without error, but would fail the test script.