Question

In: Electrical Engineering

Write an LC-3 program that will repeatedly read a character from the keyboard. For each character...

Write an LC-3 program that will repeatedly read a character from the keyboard. For each character read in, your program will print a neat message that echoes the input value, and the ASCII character code of the input character in hexadecimal. It will run forever: no HALT or End of processing is required.

For example:

Please press a key:

You pressed 'z' which is x7A

Please press a key:

You pressed '@' which is x40

Please press a key:

You pressed 'O' which is x4F

Please press a key:

You pressed '2' which is x32

Please press a key:

You pressed ' ' which is x20

..

Solutions

Expert Solution

Given Data:

Please press a key:

You pressed 'z' which is x7A

Please press a key:
You pressed '@' which is x40
Please press a key:
You pressed 'O' which is x4F
Please press a key:
You pressed '2' which is x32
Please press a key:
You pressed ' ' which is x20

Program:

.ORIG   x3000

        LD R1, NEG     ; Load negative of count to R1

POLL1 (a)LDI R2, KSR    ; Read Keyboard status register into R2

      (b)BRzp POLL1     ; If "ready bit" not set, branch to POLL1

      (c)LDI R0, KDR    ; Read input character from Keyboard data register to R0

       

POLL2 (d)LDI R2, DSR    ; Read Display status register into R2

      (e)BRzp POLL2     ; If "ready bit" not set, branch to POLL2

      (f)STI R0, DDR    ; Write output character from R0 to Display data register

       

        ADD R0, R0, #1 ; Increment the charater

        ADD R1, R1, #1 ; Increment count

        BRn POLL2

        HALT

NEG     .FILL   xFFF6   ; -x000A

KSR     .FILL   xFE00   ; Keyboard status register location

KDR     .FILL   xFE02   ; Keyboard data register location

DSR     .FILL   xFE04   ; Display status register location

DDR     .FILL   xFE06   ; Display data register location

        .END


Related Solutions

Write a C++ program to read characters from the keyboard until a '#' character is read....
Write a C++ program to read characters from the keyboard until a '#' character is read. Then the program will find and print the number of uppercase letters read from the keyboard.
In C++, The following program reads one character from the keyboard and will display the character...
In C++, The following program reads one character from the keyboard and will display the character in uppercase if it is lowercase and does the opposite when the character is in uppercase. If the character is a digit, it displays a message with the digit. Modify the program below such that if one of the whitespaces is entered, it displays a message and tells what the character was. // This program reads one character from the keyboard and will //...
Write a C++ program to read in a list of 10 integers from the keyboard. Place...
Write a C++ program to read in a list of 10 integers from the keyboard. Place the even numbers into an array called even, the odd numbers into an array called odd, and the negative numbers into an array called negative. Keep track of the number of values read into each array. Print all three arrays after all the numbers have been read. Print only the valid elements (elements that have been assigned a value). a. Use main( ) as...
Write a java program to read a string from the keyboard, and count number of digits,...
Write a java program to read a string from the keyboard, and count number of digits, letters, and whitespaces on the entered string. You should name this project as Lab5B. This program asks user to enter string which contains following characters: letters or digits, or whitespaces. The length of the string should be more than 8. You should use nextLine() method to read string from keyboard. You need to extract each character, and check whether the character is a letter...
Write a C program that allows: Three integer values to be entered (read) from the keyboard,...
Write a C program that allows: Three integer values to be entered (read) from the keyboard, Display the sum of the three values on the computer screen as follows: The integers that you have entered are: a b c The sum of a , b & c is ______ Thank you! C Code: Output screen:
Write a program in C++ to read 10 numbers from keyboard and find their sum, average,...
Write a program in C++ to read 10 numbers from keyboard and find their sum, average, maximum and minimum
Write a C++ program that takes input from the keyboard of the 3 dimensions of a...
Write a C++ program that takes input from the keyboard of the 3 dimensions of a room (W,L,H in feet) and calculates the area (square footage) needed to paint the walls only. Use function overloading in your program to pass variables of type int and double. You should have two functions: one that accepts int datatypes and one that accepts double datatypes. Also assume a default value of 8 if the height parameter is omitted when calling the functions.
Write a C program that will read a character string and then encrypt the string based...
Write a C program that will read a character string and then encrypt the string based on one of the 3 different encryption methods. The type of encryption is to be selected by the user. Encryption method 1: Swapping by position. Characters in the array are swapped with the opposite characters based on their position in the string. Example: Input string – apple. Encrypted string – elppa Method: The first character ‘a’ and the last character ‘e’ – swap their...
Create a SPIM program that asks the user for a character string and a number. Repeatedly...
Create a SPIM program that asks the user for a character string and a number. Repeatedly display the string on the console for the number of times specified by the user. Format your assembly program to make it easier to read by including appropriate comments and formatting using appropriate white space. When ending your program call system call code 10. Example Output: Please enter a string: I will not repeat myself Please enter the integer number of times to repeat:...
A. Open/create the file bank.txt for writing "w". Enter a character from the keyboard and write...
A. Open/create the file bank.txt for writing "w". Enter a character from the keyboard and write it to the file. Close the file. In the same program open the file for reading "r" and read the character from the file and print it on screen.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT