Question: Exercise #2: String transformation [30 pts] Write an assembly program called hw3_ex2, with source in file hw3_ex2.asm, that prompts the user for a 2character string

 Exercise \#2: String transformation [30 pts] Write an assembly program called

Exercise \#2: String transformation [30 pts] Write an assembly program called hw3_ex2, with source in file hw3_ex2.asm, that prompts the user for a 2character string s1 and then for a 3-character string s2. The program then prints the following 6-character string: s2[0] s1[1] s2[2] s1[0] s2[3] '!'. For instance, if s1= " xy " and s2= "ABC", the output should be "AyBxCz!" Below are program invocation examples ('\%' is the command-line prompt), and your program should match that output format exactly: ./hw3_ex2 Enter a 2-character string: xy Enter a 3-character string: ABC The output is: AyBxC! %./hw3_ex2 Enter a 2-character string: XS Enter a 3-character string: 123 The output is: 1S23 ! You may assume that the user will always type exactly 2 characters for the first string followed by a carriage return (linefeed) and 3 characters for the second string followed by a carriage return (linefeed). Even with our very limited knowledge of assembly, there are quite a few ways to write this program. And yes, because we can't do loops yet, sections of code will have to be cut-and-pasted (which is very bad practice but unavoidable for now). Hints: - Reading a character from the keyboard is done via the read_char macro (see page 17 of the textbook for a description). So you'll have to call this macro 3 times (two times to get the 2 characters in s1 and a third time to consume the linefeed) and then 4 times ( 3 times to get the 3 characters in s 2 and a 4th time to consume the linefeed). - Remember that when you print a string it should be null-terminated, meaning that it should have an extra byte with value zero at the end. EXTRA CREDIT: - 4 points of extra credit if the program uses no more than 3 calls to print_string and no call to print_char

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!