Question: Using the LC-3 simulator, you will construct an assembly-level program that prompts the user for a starting address (in hex) and an ending address (in

Using the LC-3 simulator, you will construct an assembly-level program that prompts the user for a starting address (in hex) and an ending address (in hex). Your program will then output the contents of memory (in hex) between the provided ranges (inclusive).

I/O for this routine requires that we develop a routine to enable the input of a 4-digit hex value and a routine for displaying the contents of a 16-bit registers/memory location as a 4-digit hex value. We will implement each of these routines as TRAPs.

Input (Trap x40): A Trap routine (invoked as TRAP x40) that prints an x to the screen as a prompt, reads a 4-digit hex number from the keyboard and returns the value in R0. This trap may call other traps. You will develop this trap routine and locate it in memory at address x4000.

Output (Trap x41): A Trap routine (invoked as TRAP x41) that displays the contents of R0 to the display as a 4-digit hex value. This routine should output exactly 5 characters: a leading x and the 4 hex digits. Do not display a carriage return/line feed/end-of-line as part of the trap call. This trap may also call other traps. You will develop this trap routine and locate it in memory at address x5000.

Develop these TRAP routines and the use them to implement a program to perform memory dumps (using the i/o format provided in the example above).

Turn-in and Grading

The lab will be due in two parts. Part 1 will be due in the week following the lab session in which the lab is assigned. Part 2 will be due the following week. Check the Pilot calendar for the specific due dates for each part.

Part 1

Input Routine (Trap x40)

10 points 4-hex digit input: Your project must include an input routine that reads a 4-hex digit input. It must properly translate the ASCII inputs into a 16-bit value returned in R0.

5 points Error checking: Your input routine should read exactly 4 hexadecimal characters. It should ignore characters other than the digits 0-9 and the letters A-F and not echo them to the screen. (You can earn 2 extra-credit points for correctly accepting either upper or lower case A-F digits.)

5 points TRAP implementation: Your input routine should be implemented as a TRAP. Please locate this routine starting at address x4000 in memory. Please execute this routine as TRAP x40. The TRAP routine should not have any unexpected side-effects!

Turn in:

Your input trap implementation, which should load at address x4000, in a file named input.asm.

A file that, when loaded, initializes the trap vector table so that you can call your input trap from your main routine. The format of this file will be discussed in the lab sessions. This file should be called part1vector.asm.

You may use the following main to test your code but you do not need to turn it in.

Main for Part 1

 .ORIG x3000 ; Print prompt LEA R0, Prompt PUTS ; Read input and store in result TRAP x40 ST R0, Result HALT Result .FILL 0 Prompt .STRINGZ "Enter 4 hex digits:" .END 

Example output for part 1

If you run the provided main with your input trap and type the characters "45AB", after running the address x3005 will be set to x45AB and the console will appear as follows:

Enter 4 hex digits:x45AB

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 Databases Questions!