What is the code?
String Processing Subroutines
Note: you may need to add code to the test program based on the subroutine you are testing! Use PUTS to output a string to the console (the string's address must be in R0).
- Write a subroutine charplus1 that takes a string address in R0 and returns nothing. It should process the string and modify each character of the string (in memory!) to the next character in the alphabet (e.g., 'a' becomes 'b', etc.). Do not worry about what happens to 'z', 'Z', spaces, or punctuation. Just add 1 to each character. Make sure that to not process past the end of the string in memory!
- Write a subroutine strrev that takes a string address in R0, and returns nothing. It should reverse all of the characters in the string; for example, if it is passed “cat”, the string would be “tac” after it returned.
LEA R0, STR1 ; gets a pointer to a test string
PUTS ; outputs the test string before processing
JSR MYSUB ; assumes MYSUB processes string pointer in R0
PUTS ; …and does not corrupt R0
DONE BR START ; repeat forever
; any test program data you need to create goes below here…
STR1 .STRINGZ “abcd TEST”
; Subroutine: MYSUB
; subroutine code and data goes here