Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The following program is to be created in LC-3 without using JSR subroutines. Th

ID: 3807215 • Letter: T

Question

The following program is to be created in LC-3 without using JSR subroutines.

The program must start at address x3000. Here's how the program must behave: The program prints "> ", which serves as a prompt to tell the user that the program is waiting for input. The prompt string is a greater-than symbol, followed by a single space. The user types a character on the keyboard. The user does not hit after the character is typed. The user character is printed on the console^1 followed by a linefeed character. The program a string that shows the 8-bit binary representation of the ASCII code for the character. The string must follow exactly the format shown below, where X is replaced by the user's character and bbbbbbbb is replaced by the ASCII code: The ASCII code for 'X' is bbbbbbbb A linefeed is printed at the end of the string. (Your code will not print in boldface, of course; that's just used for emphasis here.) The program halts.

Explanation / Answer

enter code here .ORIG x3000 LEA R0, PROMPT ;Prompt for input TRAP x22 LD R0, STRING ;Input a character string JSR GETSTR LD R0, NEWLIN ;Start a new output line TRAP x21 LD R0, STRING ;Display the input string TRAP x22 JSR PAKSTR ;Pack the character string LD R0, NEWLIN ;Start a new output line TRAP x21 LD R0, STRING TRAP x24 ;Display the packed string LD R0, NEWLIN TRAP x21 TRAP x25 ;Halt ;Data NEWLIN .FILL x0A STRING .FILL x3100 PROMPT .STRINGZ "Enter a character string, hit ENTER> " ;------------------------------------------------------------ GETSTR ;Input a character string from the keyboard to memory ;Each input character is echoed at the console ;End of input is signalled by NEWLN (Enter key) x0A ;The end of the string in memory is marked by x0000 ;Parameters - R0 : address of the string ST R7, GET_7 JUMP ADD R2, R0,0 ADD R2, R2, 1 TRAP x20 BRnp JUMP TRAP x21 LD R7, GET_7 RET GET_7 .BLKW 1 ;--------------------------------------------------------------------- PAKSTR ;Create a packed string from a 0-terminated character string ;The packed string overwrites the original string in memory ;The format of a packed string is described in Table A.2, p543 ;Parameters - R0 : address of the string ST R7, PAK_7 BACK ADD R0, R0, R0 TRAP x24 BRnp BACK LD R7, PAK_7 RET PAK_7 .BLKW 1 .END