183k views
0 votes
His LC-3 assembly language program will have the user input a number between (0) and (49). The program will only accept a valid number. All other input is ignored. The program will then print star characters ‘*’to the console to match the number entered. The program lets the user know when it is done counting. The program repeats until 'q' is inputted.

The program must start at address x3000. Here is how the program must behave:

1. The program sends 2 newline characters to the console and prints "Enter a number (0-49): ", which serves as a prompt to tell the user that the program is waiting for input. The prompt string has a single space after the colon.

2. The user then types a one- or two-digit number (0-49) on the keyboard. As the numbers are typed on the keyboard they should be echoed onto the console window. Any illegal input values are ignored. Numerical digits (0-9), ‘q’, and linefeed (‘\\’) are all legal inputs. Everything else is ignored. The linefeed is the only legal input that is not echoed. 2 The program should recognize the entry as complete if it sees: [a] 1 valid digit plus a return, or [b] 2 valid digits, with the return not being used for case [b].

3. If the user types the character ‘q’ at any time during step 2, the program should display two newlines and the string "Goodbye!!!" followed by two more newlines and then Halt.

4. The program now converts the user-entered ASCII numbers to binary. For example, a user input of ‘3’ and ‘6’ is converted to binary 36. This value is compared to decimal 49 to ensure that the value is within the range. This comparison must be made using binary values, not ASCII. If the number is not within the numerical range (0-49), the program prints a newline then the string "Invalid input, try again!", with no newlines after it. The program then returns back to step 1. If the number is within range, the program advances to step 5.

5. The program now prints two newlines to the console, then the string "I see stars!", followed by one more newline. The program will then print the number of stars chosen by the binary number from above.

6. After the stars are complete, the program sends a message, 2 newlines, then "All Done". 7. The program returns to step 1.

User Shakeena
by
7.7k points

1 Answer

3 votes

Final answer:

The question pertains to creating an LC-3 assembly language program that accepts numbers between 0 and 49, prints stars corresponding to the entered number, and quits upon 'q'. It involves input validation, binary conversion, and user communication throughout the program's execution.

Step-by-step explanation:

The subject of your question is in the field of Computers and Technology, specifically dealing with assembly language programming for the LC-3 microprocessor. The task is to write a program starting at memory address x3000 that takes user input and prints a corresponding number of stars while handling invalid input and quitting upon the user entering 'q'. The program follows a multi-step process that includes input validation, ASCII to binary conversion, a loop for accepting continuous inputs, and proper messaging to the user.

The program must be capable of echoing valid inputs, ignoring invalid inputs, and recognizing when a complete number has been entered according to the defined criteria. Upon valid input within the specified range, the program will advance to printing stars and informing the user that the action is completed, then will return to the initial step to await further input or termination of the program with 'q'.

User Zachary Dale
by
8.2k points