Write a simplified printf subroutine that takes a variable amount of arguments. The first ar- gument for
Question:
Hints To get started you may divide the work in a number of steps. Note that these are just hints, you do not have to follow these steps to finish this assignment. 1. Write a subroutine that prints a string character by character, for example by using putchar. 19 2. Modify the subroutine to recognize format specifiers in the format string. Initially, you can discard the format specifiers rather than process them. Characters that are not part of a format specifier can be printed as before. 3. Implement the various format specifiers. It may help to implement %u before %d. 4. It may help to store all input argument registers on the stack at the start of your function, even if you don’t end up using them. Bonus points: support flags and width fields (+250 points) Extend your printf function to support the flags and width fields on a format specifier. You can find a comprehensive definition in any C standard library reference
(e.g., https://www. cplusplus.com/reference/cstdio/printf/) or on Wikipedia at https://en.wikipedia.org/ wiki/Printf_format_string. To get the bonus points, you must support all of the following for the %d, %u, and %s format specifiers: 1. the minus (on %d and %u), plus (on %d and %u), space, and zero flags, including any combination of flags; 2. the width field given as an integer in the format string; and 3. the width field given as an argument to printf, indicated by an asterisk in the format string.