Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In LC3, can you assemble three separate programs with comments. Exercise 1 Write the following subroutine, which captures a user-entered string at run-time, storing it
In LC3, can you assemble three separate programs with comments.
Exercise 1 Write the following subroutine, which captures a user-entered string at run-time, storing it as a null-terminated character array (just like the. STRINGZ pseudo-op, with the big difference that .STRINGZ requires a hard-coded character array at compile-time). ; Subroutine: SUB_GET_STRING ; Parameter (R1): The starting address of the character array ; Postcondition: The subroutine has prompted the user to input a string, terminated by the [ENTER] key (the "sentine1"), and has stored the received characters in an array of characters starting at (R1). the array is NULL-terminated; the sentinel character is NOT stored. Return value (R5): The number of non-sentinel chars read from the user. R1 contains the starting address of the array unchanged. This subroutine should prompt the user to enter in a string of text, ending with the [ENTER] key. The string of text will be stored starting at whatever address is specified by (R1) and will be NULL-terminated (i.e. the subroutine will store zero (x0000=#0=\0) as a sentinel at the end of the array). The entry sentinel value itself (i.e. the newline) must not be stored in the array! The subroutine returns in RS the number of non-sentinel characters entered. REMEMBER: no "ghost writing"! Echo each character as it is received from the user! Example: If the user enters: "This is really hard!", followed by [ENTER], then the array will look like this: Where the initial ' T ' is stored in the address specified by R1 (this value will not be altered by the subroutine); R5 will hold the value 14=H20 (count the characters to confirmI) Test Harness: Now write a test harness (i.e. a program that tests your subroutine to make sure it works) that does the following: 1. R1Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started