// In-Lab Practice - 2 // // Read characters from the keyboard until the chracter is not a number // // Store the number in decimal into R1 // .ORIG x3000 AND R1, R1, #0 ; Clear R1 LD R2, BIN ; R2 = x-30 -> It's for changing ASCII to Binary // Loop until input value is not a unmber // TOP TRAP x23 ; Prompt an input character => R0 ADD R0, R0, R2 ; Change ASCII to binary // Test whether the input was a number or not // // Finish it If the input is not a number // BRN DONE ; Go to DONE if R0 < 0 ADD R3, R0, #-10 ; Test R0 - 10 >=10 BRZP DONE ; GO to DONE if R0 >= 10 // R1 = R1x10 + R0 // JSR MULT ; Go to MULT subroutine FOR R1 = R1x10 END_MULT ; Back from MULT subroutine ADD R1, R1, R0 ; R1 = R1 + R0 JSR TOP ; go to TOP // END LOOP // DONE halt ; Halt // Multiplier : R1 = R1x10 // // Add 10 R1 times // MULT AND R3, R1, R1 ; R3 = R1 AND R1, R1, #0 ; Clear R1 TOP_MULT ADD R3, R3, #-1 ; R3 = R3 - 1 BRN END_MULT ; Go to END_MULT if R3 < 0 ADD R1, R1, #10 ; R1 = R1 + 10 JSR TOP_MULT ; Go to top_MULT BIN .FILL x-30 .end