;Multiply a number by 6 .ORIG x3050 ;load program starting at address x3050 in memory Start LD R1, SIX ; R1 is loop counter LD R2, NUMBER ; load number into R2 AND R3, R3, #0 ; clear R3, it will hold the product ; start of loop AGAIN ADD R3, R3, R2 ; add number to current sum (itself 6 times) ADD R1, R1, #-1 ; decrement loop counter by 1 BRp AGAIN ; branch if last ALU operation was positive ; if R1 was positive repeat loop AND R0, R0, #0 ; clear R0 ADD R0, R0, R3 ; copy product to R0 OUT HALT ; else done NUMBER .FILL x0014 ; set memory location aside for NUMBER and ; initialize to decimal 20 SIX .FILL x0006 ; set memory location for SIX and initialize ; location to 6 .END