Answered step by step
Verified Expert Solution
Question
1 Approved Answer
you will write an ARM assembler function that provides similar functionality to 1 printf ( ) in C . Please ensure you read this document
you will write an ARM assembler function that provides similar functionality to printf in C Please ensure you read this document thoroughly so you know what is expected of your solution. printf: Your printf function will follow the ARM Procedure Call Standard and so take its arguments via the registers R and R Your program must use the registers listed for input. The arguments to your function are: the address of a format string to print out in R and the address of an array of values in R to interpolate into the format string. Some hints for completing this exercise: The address of the format string is specified in R the address of the values is specified in R if you use other registers, your program will fail in the pipeline. Likewise, you must not add in code before the label printf in the skeleton file, printf.s or your program will not execute correctly. As well as using the various test scripts, you may however and probably should modify the format strings and sequence of values to ensure your program works correctly with different input. Your program will need to loop through every character of the format string, and print out the characters using SWI unless the character is a percent character Your program should stop looping when it reaches a null character in the format string, ie when the byte read from memory has the literal value of zero not the ASCII code for the character representing the digit zero You can find this by comparing with # The format string is made up of characters that are one byte long. The values are all bits four bytes long. If your program encounters a conversion specifier, ie you read a character from the format string then your program will need to examine the following characters in the format string, and use them to interpolate ie print the value from the array as appropriate. You can find a list of the conversion specifiers expected to be supported and the expected output below. Each value in the array of values is stored as a byte value even characters You will need to step through the values in the array as you process each conversion specifier. You can use SWI SWI SWI etc. to help here as necessary... It can be helpful to consider breaking this problem down into various related parts and then working out how to implement each section, eg one part might step through the characters in the format string, another might handle printing numbers, another printing strings etc. Id suggest working on each part of the program separately, eg first get your program stepping through the format string printing out each character, then when you are confident that part is working, move onto writing the code to handle the conversion specifiers one by one. And then, start adding support for the finer details of each specifier.
you will write an ARM assembler function that provides similar functionality to
printf in C Please ensure you read this document thoroughly so you know what is expected
of your solution.
printf:
Your printf function will follow the ARM Procedure Call Standard and so take its arguments
via the registers R and R Your program must use the registers listed for input. The arguments to
your function are:
the address of a format string to print out in R and
the address of an array of values in R to interpolate into the format string.
Some hints for completing this exercise:
The address of the format string is specified in R the address of the values is specified in R
if you use other registers, your program will fail in the pipeline. Likewise, you must not add in
code before the label printf in the skeleton file, printf.s or your program will not
execute correctly. As well as using the various test scripts, you may however and probably
should modify the format strings and sequence of values to ensure your program works
correctly with different input.
Your program will need to loop through every character of the format string, and print out the
characters using SWI unless the character is a percent character
Your program should stop looping when it reaches a null character in the format string, ie
when the byte read from memory has the literal value of zero not the ASCII code for the
character representing the digit zero You can find this by comparing with #
The format string is made up of characters that are one byte long. The values are all bits four
bytes long.
If your program encounters a conversion specifier, ie you read a character from the format
string then your program will need to examine the following characters in the format string,
and use them to interpolate ie print the value from the array as appropriate. You can find a list
of the conversion specifiers expected to be supported and the expected output below.
Each value in the array of values is stored as a byte value even characters You will need to
step through the values in the array as you process each conversion specifier.
You can use SWI SWI SWI etc. to help here as necessary...
It can be helpful to consider breaking this problem down into various related parts and then
working out how to implement each section, eg one part might step through the characters in
the format string, another might handle printing numbers, another printing strings etc.
Id suggest working on each part of the program separately, eg first get your program stepping
through the format string printing out each character, then when you are confident that part is
working, move onto writing the code to handle the conversion specifiers one by one. And then,
start adding support for the finer details of each specifier.
Step 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