Question: This is the hack assembly code for multiplication. How would I implement division such as, @i M-1 (LOOP) @i D-M GR1 D-D-M //variable to run
@i M-1 (LOOP) @i D-M GR1 D-D-M //variable to run the loop //set the inital value of i as 1 //to perform the repeated addition //take the value stored at i //take the value from R1 and decrement with ? //that is compute R1-i //end the loop execution if /stay in loop if D >0 //take the value of RO END D: JGT GRO D-M GR2 M-M+D Gi M-M+1 LOOP 0: JMP (END) END 0: JMP //update the result //increment the counter //repeat the loop
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
