I'm working on Mult.asm, but I'm still having trouble implementing and understanding the machine language, especially on what to do in multiplication. I read the chapter, and the power point, and my instructor also added new instructions such as "left bit shift" (<) to the mult.asm file. I was wondering if there is a reference out there with more explanation provided? I have an exam soon too, and my instructor will include more of implementation of it, and I really wanna get this. I understand D, M, A for instance:
...but how do I use this to add, multiply, divide, etc. Thank you!
The Mult.asm program is intended to have you learn the basics of accessing data and conditional looping in Hack assembly. It is not intended that you write a sophisticated multiply algorithm. You can simple compute x=a*b by adding a together b times.
x = 0
while a > 0
x = x+b
a = a-1
You will not need to write division in assembly language for the n2t course.
I do not understand "added left shift to the mult.asm file." The only commands the n2t tools understand are the documented A-commands and C-commands.
Thanks for the introduction document, I'll defiantly look into it.
My professor created a div.asm file where we compute division of R0 and R1 in result it into R2.
He rearranged the tools(Added a new altered Compiler.jar and Hack.jar) so we can include the left bit shift operators (<) to use for Mult.asm file. He says "for multiplication: using shift bit & add,
for division: using subtraction"