// mult.asm // // Create a program that multiplies R0 & R1 and puts the result in R2 // Algorithm is based on repetetive action. // // // okay let's go. // Get R0 // Create a loop based on the number of R0. I.e loop 10 times if R0 is 10. // Everytime around sum of R2 should be incremented by R1 // Need variable @i which is the index. If that reaches 0. Loop end // Variables @i M=1 @R2 M=0 // Check if loop is needed. @R0 D=M @END // Jump to End if R0 is 0. Nothing to add. D;JEQ @R1 D=M @END // Jump to End if R1 is 0. Nothing to add. D;JEQ (LOOP) // get R1 @R1 D=M // Add R1 to R2 @R2 M=D+M // add one to i @i M=M+1 D=M @R0 D=D-M // check if R0 - i is greater or equal than 0 @LOOP D;JLE // Then jump to loop // else just move on (END) // End of Program @END 0;JMP