Answered step by step
Verified Expert Solution
Link Copied!

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 1
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 R0 and R1. 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 R0), and
the address of an array of values (in R1) to interpolate into the format string.
Some hints for completing this exercise:
The address of the format string is specified in R0, the address of the values is specified in R1
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, 01-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 0), unless the character is a percent (%) character
Your program should stop looping when it reaches a null character in the format string, (i.e.
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 #0.
The format string is made up of characters that are one byte long. The values are all 32-bits (four
bytes) long.
If your program encounters a conversion specifier, (i.e. 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 (i.e. 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 4 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 0, SWI 3, SWI 4 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, e.g. 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, e.g. 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

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

Step: 3

blur-text-image

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

Databases Illuminated

Authors: Catherine M. Ricardo, Susan D. Urban, Karen C. Davis

4th Edition

1284231585, 978-1284231588

More Books

Students also viewed these Databases questions

Question

Explain the meaning of b^ 1 in the sample regression equation.

Answered: 1 week ago

Question

Define orientation, and explain the purposes of orientation.

Answered: 1 week ago

Question

What are the various career paths that individuals may use?

Answered: 1 week ago