Question: write two functionsin ARM assembly thatcan be called (using a branch and linkinstruction). To describe these,I am going to present you witha couple ofwhat looklike
write two functionsin ARM assembly thatcan be called (using a branch and linkinstruction). To describe these,I am going to present you witha couple ofwhat looklike Cfunction prototypes. But remember, weare not writing this in C.
void expand( const char hex[], char binstring[] );
Thisfunction takes anarray of 40 hex characters any letters in the string will be upper case and converts it into an array of 160 characters that are either 0 or 1.The address in memory of the variable hexwill be given to you in R0, and the location to put the output binstringwill be givento you in R1. So R0 has the input string and R1 will be the address of the output string.For example, and I will color this so that it is clear, suppose the input string starts with
A47B6...
then the output string you create would be
10100100011110110110...
Now, I put in the ...(thats called an ellipsisif you didn'tknow that)to say theres more after this but I did not bother. The input will have 40 characters in hex and the output will have 160 characters that will be characters 0and 1. Next, please write a function as follows:
char byte_at( int position, const char binstring[] );

How is this table constructed? The dataarewritten in a 5-bit scheme, which includes one bit for parity and then fourbits for the data. This scheme allows for sixteen characters, 0-9 and (:, ;, , ?) or, in hex, 0x30 to 0x3F. The parity bit is infront and is used to make sure that the number of 1s in a 5-bit character is odd. So, for example,consider 10110. The first bit is the parity bit so lets look at just the 0110part. If we converted the string version to an actual numberit would be 6, and adding 0x30 gives the character 6. The number of one bits is three so the parity is correct three is an odd number.
Your function byte_attakes the starting position and the long array and returns the character representation of the five bits at that location. The return value goes into R0. For example,lets take the data from above:
10100100011110110110...
And suppose the position is 4. I have highlighted it in yellow above so you can see. This is 01000and the function shouldreturn the character 8in R0. If the position was 15(highlighted in gray) the result in R0 is 6.
This function takes two parameters. The position is an integer from 0 to 155. This parameter will be in RO. The second parameter is the same array we created above, binstring, which is 160 characters. We are considering characters in groups of five binary characters. You can use the following table: Pattern 10000 00001 00010 10011 00100 10101 Character 0 1 2 3 4 5 1 6 7 8 9 : 10110 00111 01000 11001 11010 01011 11100 01101 01110 11111 : VII > ? Note please that I did not put quote marks in the table but everything is characters. So 10110 is five bytes long, and generates a byte which is the character 6. This function takes two parameters. The position is an integer from 0 to 155. This parameter will be in RO. The second parameter is the same array we created above, binstring, which is 160 characters. We are considering characters in groups of five binary characters. You can use the following table: Pattern 10000 00001 00010 10011 00100 10101 Character 0 1 2 3 4 5 1 6 7 8 9 : 10110 00111 01000 11001 11010 01011 11100 01101 01110 11111 : VII > ? Note please that I did not put quote marks in the table but everything is characters. So 10110 is five bytes long, and generates a byte which is the character 6
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
