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 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 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...
To begin, write a program to loop through a string character by character. If the character...
To begin, write a program to loop through a string character by character. If the character is a letter, print a question mark, otherwise print the character. Use the code below for the message string. This will be the first string that you will decode. Use the String class method .charAt(index) and the Character class method .isLetter(char). (You can cut and paste this line into your program.) String msg = "FIG PKWC OIE GJJCDVKLC MCVDFJEHIY BIDRHYO.\n"; String decryptKey = "QWERTYUIOPASDFGHJKLZXCVBNM";...
Write a program in python that reads the elements of a set from the keyboard, stores...
Write a program in python that reads the elements of a set from the keyboard, stores them in a set, and then determines its powerset. Specifically, the program should repeatedly ask the user: Enter one more element ? [Y/N] If the user answers Y then an new element is read from the keyboard: Enter the new element in the set: This cycle continues until the user answers N to the first question. At that point the program shall compute the...
Write a program that prompts the user to input their first name from the keyboard and...
Write a program that prompts the user to input their first name from the keyboard and stores them in the variable "firstName". It does the same for last name and stores it in the variable "lastName". It then uses strcat to merge the two names, separates them by a space and stores the full name into a string variable called "fullName". In the end, the program must print out the string stored within fullName. ANSWER IN C LANGUAGE ! You...
Write a MIPS assembly program to repeatedly read two non-negative integers and print the integer product...
Write a MIPS assembly program to repeatedly read two non-negative integers and print the integer product and quotient without using the multiplication and division instructions. Each input number will be entered on a separate line. Your program will terminate when two zeroes are entered by the user. If only the second number in a pair is zero, then a divide-by-zero error message should be printed for the division operation. Use comments generously in your program. Test your program with the...
Write a MIPS assembly program to repeatedly read two non-negative integers and print the integer product...
Write a MIPS assembly program to repeatedly read two non-negative integers and print the integer product and quotient without using the multiplication and division instructions. Each input number will be entered on a separate line. Your program will terminate when two zeroes are entered by the user. If only the second number in a pair is zero, then a divide-by-zero error message should be printed for the division operation. Use comments generously in your program. Test your program with the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT