Question: Write an LC - 3 assembly language program that does the following: Output a message to the screen that prompts the user to type in

Write an LC-3 assembly language program that does the following:
Output a message to the screen that prompts the user to type in an LC-3 assembly language instruction (like ADD). The user ends their input by pressing Enter/Return.
If the instruction typed by the user is a legal LC-3 assembly language instruction, your program displays the corresponding 4-bit opcode. For example, if the user types "ADD", the program would print out "0001".
If the instruction typed by the user is not a legal LC-3 assembly language instruction (for example, "ADDD"), your program displays an appropriate error message.
After displaying the output, your program loops back to the top, reinitializes anything that needs to be reinitialized, and goes again.
Your program will exit when the user types the string "QUIT" and presses Enter/Return.
Submit your code as a .asm file (a .asm file is just a text file with the extension ".asm").
IMPORTANT NOTES:
Your program must treat input as case insensitive, meaning that the user can type their input in any combination of upper and lower case. For example, "ADD", "add", and "AdD" would all be legal instructions.
As the user types an instruction, your program should echo each typed character to the monitor so they can see what they're typing.
You can process characters as the user enters them or you can store them away and process them after the user hits the Return or Enter key. If you process characters as they are entered, you still have to wait until after the user hits Return/Enter before you give an error response, even if you already know it's not a valid instruction.
The algorithm you use for processing the text has to use a state machine. If the user types an 'A', you move to the A State. In the A State you check to see if the next character is either 'N' or 'D'. Anything else would be an error. If the next characer is an 'N' you move to the AN State. In the AN State you check the next character. If it's a 'D' you move to the AND State, otherwise it's an error. In the AND State, the next character has to be the CR or LF character, otherwise it's an error. Etc., etc. Rinse and repeat for all valid instructions.
For the BR instruction, you only need to handle "BR", not the variants ("BRn","BRz","BRp","BRnz","BRzp","BRnp","BRnzp").
Write your program in a text editor (not a word processor!) and save the file as you go. Every time you need to assemble and load the file inWrite an LC-3 assembly language program that does the following:
Output a message to the screen that prompts the user to type in an LC-3 assembly language instruction (like ADD). The user ends their input by pressing Enter/Return.If the instruction typed by the user is a legal LC-3 assembly language instruction, your program displays the corresponding 4-bit opcode. For example, if the user types "ADD", the program would print out "0001".If the instruction typed by the user is not a legal LC-3 assembly language instruction (for example, "ADDD"), your program displays an appropriate error message.After displaying the output, your program loops back to the top, reinitializes anything that needs to be reinitialized, and goes again.Your program will exit when the user types the string "QUIT" and presses Enter/Return.
Submit your code as a .asm file (a .asm file is just a text file with the extension ".asm").
IMPORTANT NOTES:
Your program must treat input as case insensitive, meaning that the user can type their input in any combination of upper and lower case. For example, "ADD", "add", and "AdD" would all be legal instructions.
As the user types an instruction, your program should echo each typed character to the monitor so they can see what they're typing.
You can process characters as the user enters them or you can store them away and process them after the user hits the Return or Enter key. If you process characters as they are entered, you still have to wait until after the user hits Return/Enter before you give an error response, even if you already know it's not a valid instruction.
The algorithm you use for processing the text has to use a state machine. If the user types an 'A', you move to the A State. In the A State you check to see if the next character is either 'N' or 'D'. Anything else would be an error. If the next characer is an 'N' you move to the AN State. In the AN State you check the next character. If it's a 'D' you move to the AND State, otherwise it's an error. In the AND State, the next character has to be the CR or LF character, otherwise it's an error. Etc., etc. Rinse and repeat for all valid instructions.
For the BR instruction, you only need to handle "BR", not the variants("BRn","BRz","BRp","BRnz","BRzp","BRnp","BRnzp").
Write your program in a text editor (not a word processor!) and save the file as you go. Every time you need to assemble and load the file into the Simulator you can just drag the file onto the assembler. The reason you shouldn't use a word pr

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!