Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Write an ARM assembly function that takes a string and two characters and returns a pointer to a new modified string. The first character is the character to replace and the second is the character to replace it with. The C program below changes the character 'i' to an 'X'

The C language program is:

#include

extern newsubst( char * string, char this, char that ) ;

void main( int argc, char * argv[] )

{

            char * result ;

            char this = 'i' ;

            char that = 'X' ;

            char string[] = "Another string to modify" ;

 

            result = newsubst( string, this, that ) ;

            printf( "Original: %s\nModified: %s\n", string, result ) ;

}

The input to the ARM assembly language function is a pointer to the first element of the string in register a1. The character to look for is in a2 as a byte in the low part of the register and the character to replace it with is in a3 as a byte in the low part of the register. Remember a character is 1 byte long. A string in C is terminated with a null byte (one equal to zero).

To determine the length of the string you can use the library subroutine strlen. The input to this subroutine is a pointer to the string in a1. The subroutine returns the length of the string not counting the terminating null byte in a1.

To obtain space for the new string you can use the library subroutine malloc. The input to this subroutine is a number of bytes of space to obtain in a1. The subroutine returns a pointer to the allocated space in a1.

 

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M9885582

Have any Question?


Related Questions in Computer Engineering

Taylor found that 8 of the recipients of loans form a

Taylor found that 8% of the recipients of loans form a particular mortgage lender default within 3 years. If he takes a random sample of 736 customers who received loans 3 years ago, what is the average number of custome ...

Quality management plan it should includea short statement

Quality Management Plan. It should include: A short statement that reflects your team's philosophy or objective for ensuring that you deliver a quality system to your client. Develop and describe the following that your ...

Question what is the relationship between programming and

Question : What is the relationship between programming and networking, and do you think that the United States has lost some of its economic advantage in these fields to other parts of the world?

Can someone please help me with this pleasetaskthe purpose

Can Someone please help me with this please: Task: The purpose of this assignment is to empirically measure attributes for binary search trees. Steps: Create a program that will build a binary search tree (BST) by adding ...

1 what would be the purpose for a user to protect a

1. What would be the purpose for a user to protect a file from "read" or "write" access by other users? 2. Is there a reason why it would be safer for administrators to use two different accounts when working with a comp ...

Segmentationassume virtual memory hardware that uses

SEGMENTATION Assume virtual memory hardware that uses segmentation, and divides the address space in two by using the top bit of the virtual address. Each segment is thus relocated independently. What we'll be drawing in ...

Given a variable electionresults that is associated with a

Given a variable, election_results, that is associated with a dictionary that maps candidate names to votes received, associate the name of the candidate with the most votes with the variable winner.

Assume a normal distribution for n 300 how many cases

Assume a normal distribution for N = 300. How many cases would one expect to find between +1 and -1 standard deviations around the mean?

Question suppose that in addition to edge capacities a flow

Question : Suppose that, in addition to edge capacities, a flow network has vertex capacities. That is each vertex v has a limit l(v) on how much flow can pass through v. Show how to transform a flow network G = (V, E) w ...

Respond to the followingin a bst what is the complexity

Respond to the following: In a BST, what is the complexity required to remove the minimum element? In a BST, what is the complexity required to find (but not remove) the minimum element? In a heap, what is the complexity ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As