PageRenderTime 242ms CodeModel.GetById 80ms app.highlight 2ms RepoModel.GetById 159ms app.codeStats 0ms

/4/mult/Mult.asm

http://github.com/happy4crazy/elements_of_computing_systems
Assembly | 26 lines | 20 code | 6 blank | 0 comment | 0 complexity | ac89e1029d6786065c12860f96432248 MD5 | raw file
 1// multiplies R0 and R1
 2
 3// simple implementation of a*b = a + a*(b-1) = ...
 4
 5@R2
 6M=0
 7
 8(LOOP)
 9  @R0
10  D=M
11  @END
12  D;JEQ
13
14  @R1
15  D=M
16  @R2
17  M=M+D // R2 = R2 + R1
18
19  @R0
20  M=M-1 // decrement R0
21
22  @LOOP
23  0;JMP
24(END)
25@END
260;JMP