Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In Lc3 assembly language: Write the following subroutine, which captures a user-entered string at run-time, storing it as a null-terminated character array (just like the

In Lc3 assembly language:

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 that .STRINGZ hard-codes the 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 "sentinel"), and has stored it in an array ; of characters starting at (R1); the array is NULL-terminated. ; Return Value (R5): The number of non-sentinel characters read from the user. ; R1 still contains the starting address of the array. ;----------------------------------------------------------------------------------------------------------------- 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 (#0) at the end of the array). The sentinel value itself (i.e. the newline) must not be stored in the array! The subroutine returns in R5 the number of non-sentinel characters entered. REMEMBER: no "ghost writing"! Echo each character as it is received from the user!

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. R1 <- Some address at which to store the array (make sure you have enough free memory starting from this address to store the number of characters likely to be entered). You may hard code this address, and reserve space there using .BLKW 2. Calls the subroutine 3. Immediately calls PUTS (aka Trap x22) to print the string (remember that PUTS needs the starting address of the string in R0)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions