Multiplication and reading input with the LC-3 Simulator

A place to discuss the implementation and style of computer programs.

Moderators: phlip, Moderators General, Prelates

Multiplication and reading input with the LC-3 Simulator

Postby urza4315 » Sun May 06, 2012 1:37 am UTC

I have to write a program using the LC-3 simulator that reads in an multiplicand and a multiplier (the bigger the range, the better) and multiplies them and prints out the result.

First question: How can I obtain an integer value (up to 3 digits) from the user after asking for a string input?
So far I've tried adding each individual character to itself several times to simulate the shift-left operation depending on the number of integers put in, e.g. If user inputs "123" then I add "1" to itself 99 times to get 100, add "2" to itself 19 times to get 20, then add 3 to get 123, but I feel like there's probably a more efficient solution.

Second question: To get the maximum marks for an assignment the range of both the multiplicand and the multiplier has to be greater than 0-511 (this can extend into negative numbers too). Hence I have to be able to store a number as big as sqr(512)=262,144, but if I'm not mistaken the biggest value a memory location in LC-3 can hold is 2^15-1=32,767 right? So how would I be able to compute/store such a huge number?
urza4315
 
Posts: 39
Joined: Thu Aug 25, 2011 9:49 am UTC

Return to Coding

Who is online

Users browsing this forum: No registered users and 7 guests