Question: Please submit your code as a . asm file ( a . asm file is just a text file with the extension . asm
Please submit your code as a asm file a asm file is just a text file with the extension asm"
One of the things an assembler has to do is take assembly language instructions like ADD, AND, and JMP and convert those into binary opcodes. Each assembly instruction has a corresponding bit binary opcode. For example, the binary opcode for ADD is for AND it's and for JMP it's
Task
Write an LC assembly language program that does the following:
Output a message to the screen that prompts the user to type in an LC assembly language instruction like ADD The user ends their input by pressing EnterReturn
If the instruction typed by the user is a legal LC assembly language instruction, your program displays the corresponding bit opcode. For example, if the user types "ADD", the program would print out
If the instruction typed by the user is not a legal LC 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 EnterReturn
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 ReturnEnter 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 variantsBRnBRzBRpBRnzBRzpBRnpBRnzp
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 processor like Word is that word processors put a bunch of nonASCII junk into a document file. Plus they do things like smart quotes, which look like regular quotes but have a different underlying value, so the assembler doesn't interpret it correctly.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
