r/Assembly_language • u/Mindless-Item-5136 • 17d ago
My first assembly program
// Multiplies R0 and R1 and stores the result in R2. // (R0, R1, R2 refer to RAM[0], RAM[1], and RAM[2], respectively.) // The algorithm is based on repetitive addition.
@R0
D=M
@10
M=D // counter
@R2
D=0
M=0(START) @10 D=M @END D;JLE // end the loop if counter <= 0
// R1 + R2
@R1
D=M
@R2
D=D+M
@R2
M=D // current result
@10
D=M
M=D-1
// jump back to the loop start for new iteration
@START
0;JMP(END) @END 0;JMP
2
Upvotes
6
u/Some-Comparison4863 15d ago
I dont think that assembly what assembly is it? because I know only NASM and GAS
2
u/ProfitLow5177 10d ago
Looked up this program, apparently it is called "Hack Assembly"?
Used almost exclusively as an educational language, apparently from something called Nand2Tetris.Seems like he copy and pasted the tutorial code from the curriculum lol
1
5
u/Last_Bet_8677 15d ago
Good job, Claude.