Purpose: To write a program in LC-3 machine language starting at memory address
ID: 3592114 • Letter: P
Question
Purpose: To write a program in LC-3 machine language starting at memory address x3000 to convert all lower case characters stored in a null terminated character array to upper case characters, and all upper case letters to lower case. You can assume that no other character will be present in the given array. The characters are stored in bits [7:0], and your converted case characters must also be stored in bits [7:0]. Bits [15:8] in each location must be left intact. The null character at the end of the array must also be copied.
What is given: The character array is stored at memory address starting at x3100. Your program must store the upper case character array starting at address x3200.
Example: See below. Both the original lower case array and the converted upper case array are shown.
Address
Bits[15:8]
Bits[7:0]
x3100
x64
x65
x3101
x74
x4E
x3102
x7A
x67
x3103
x7B
x44
x3104
NULL
NULL
…
…
…
x3200
x64
x45
x3201
x74
x6E
x3202
x7A
x47
x3203
x7B
x64
x3204
NULL
NULL
Notes:
You can assume array’s length is less than 256.
All of the 8 bits of ASCII code for NULL character are zero.
I know that i need to figure out how to test if a character is uppercase or not or even a letter but im not sure how to go about it.
Address
Bits[15:8]
Bits[7:0]
x3100
x64
x65
x3101
x74
x4E
x3102
x7A
x67
x3103
x7B
x44
x3104
NULL
NULL
…
…
…
x3200
x64
x45
x3201
x74
x6E
x3202
x7A
x47
x3203
x7B
x64
x3204
NULL
NULL
Explanation / Answer
Consider the following LC-3 assembly language program. After execution, the output of the program is available in register R0.
Problem 2 (4 points)
The following LC-3 program compares two characters strings of the same length; the source strings are in the .STRINGZ form. The first string starts at memory location x4000, and the second string starts at memory location x4100. If the strings are the same, the program terminates with a value 1 in R5, otherwise R5 is 0. Insert instructions at (a), (b) and (c) that will complete the program
Problem 3 (5 points)
Consider the following LC-3 assembly language program:
Problem 4 (9 points)
In this problem you are to write an assembly program that converts lower case alphabet characters to upper case alphabet characters. The input to the program is from the keyboard and the output is sent to the (display) screen. Make use of the template code provided in q4.zip along with the test scripts.
You have to implement the following functionalities in the program:
Your program should use subroutines for all the major functions.
To run the test for q4, type the following line into the Pennsim command line:
Your test is considered a failure if you see some messages having the FALSE keyword on the output command window when you run the test script. If your program is called something other than q4.asm you should either change its name or edit the script file, but make sure to rename it to q4.asm when you submit it to the Learn@UW DropBox.
The grading scheme for this problem will be as follows:
Problem 5 (9 points)
For problem 5, you have to further modify the GetInput and DisplayChar functionality of problem 4. Now, instead of getting input from the user, you will read a section of the memory from x7000 to x7013 (both inclusive). Instead of displaying the output at the console you will have to only write the uppercase alphabets to memory location starting from x7100. Thus in this part there is no need to check the termination character. In addition, you will need to implement some counters:
To test your code you can use the test script provided in (q5.zip). You can do this by typing the following line into the Pennsim command line:
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.