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

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 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 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...
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...
In Java, write a program that finds the first character to occur 3 times in a...
In Java, write a program that finds the first character to occur 3 times in a given string? EX. Find the character that repeats 3 times in "COOOMMPUTERRRR"
Using the windows32 framework, write a procedure to read a string and shift each character of...
Using the windows32 framework, write a procedure to read a string and shift each character of the string by one. As an example, if your input string is Abcz, your output should be Bcda. Note that you must test your string for non-alphabetic characters (such as numbers and special characters). If there are non-alphabetic characters, you should terminate your program with an appropriate message. You should display your converted string using the output macro. Hint: Let your procedure returns an...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT