Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Multiplies R0 and R1 and stores the result in R2.
- // (R0, R1, R2 refer to RAM[0], RAM[1], and RAM[2], respectively.)
- // Put your code here.
- @2 // load result
- M=0 // zeroing result
- @3 // R[3] is the counter
- M=1 // set the counter to 1
- (LOOP)
- @3 // load counter
- D=M // store the counter in the data reg
- @1 // load 2nd factor
- D=D-M // data = data - counter
- @END // load end location
- D;JGT // if data - counter > 0 goto END
- @0 // load 1st factor
- D=M // store 1st factor in data reg
- @2 // load result
- M=M+D // store result
- @3
- M=M+1 // increase the counter
- @LOOP
- 0;JMP // unconditionate jump to LOOP
- (END)
- @END
- 0;JMP // infinte loop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement