Write an arm subroutine which allocate memory for new string

Assignment Help Programming Languages
Reference no: EM1373160

Write an ARM subroutine which will extract a substring from a string. You will need to use the library routine malloc to allocate memory for the new string.

The subroutine signature is:

            char * mysubstring( char string[], int start, int end ) ;

 

where char string[] is the string to extract the substring from; it is passed into the ARM routine as a pointer in a1 to the first element of the character (byte) array,

int start is the first character to extract from the string to the substring; it is passed into the ARM routine as a value in a2,

int end is the last character to extract from the string to the substring; it is passed into the ARM routine as a value in a3.

The return is a pointer to the new string.

#include <stdio.h>

#include <stdlib.h>

extern char * mysubstring( char string[], intstart, int end ) ;

int main( intargc, char * argv[] )

{

            chartosub[] = "this is the string to substring" ;

            char * result ; /* pointer to new string */

 

            result = mysubstring( tosub, 12, 17 ) ;

            printf( "String: %s\nSubstring: %s\n", tosub, result ) ;

 

            exit( 0 ) ;

}

To use the library routine malloc you need to calculate the number of bytes of memory you are requesting, put that number in a1 and blmalloc. Upon return from the library routine a1 will have a pointer to the allocated memory.

You may assume that the start and end values are within the string and  malloc returns a proper pointer value.

Reference no: EM1373160

Questions Cloud

Capital budgeting decisions and utility rate decisions : If the expected returns for risk free asset and a risky asset are 4 percent and 17 percent respectively, what percentages of your money must be invested in risky asset and risk free asset, respectivel.
Design of the software : Report of the software design and implement the software as per the design, and demonstrate it
Multiple choice question on wacc : Brandon Corporation consists of two divisions of same size, and Brandon is 100% equity financed. Division A cost of equity capital is 9.8%, while Division B cost of equity capital is 14%.
Determine the risk premium and average risk premium : Here are stock market and Treasury bill returns between 1997 and 2001, Determine the risk premium on common stock in each year?
Write an arm subroutine which allocate memory for new string : Prepare an ARM subroutine which will extract a substring from a string and you will need to use the library routine malloc to allocate memory for the new string - CS252 Programming Assignment
Estimating cost of capital : Canyon Corporation has two divisions: Division A makes up 50% of the company, while Division B makes up the other 50%. Canyon's beta is 1.2.
Determine the project irr and cost of capital : Determine the project IRR and the cost of capital for the project? Does the accept reject decision using IRR agree with the decision using NPV?
Finding the arithmetic mean of returns : Assume you know that someone invested $1,500 in the Ec140 mutual fund 10-years ago, Now you learn that their balance in the fund has increase to $9,245.
Question based on expected profit : Suppose you know that there is a 40 percent probability that Microsoft will be selling for $22.50 three months from now and a 60 percent probability that it will be selling for $42.50.

Reviews

Write a Review

Programming Languages Questions & Answers

  Write a haskell program to calculates a balanced partition

Write a program in Haskell which calculates a balanced partition of N items where each item has a value between 0 and K such that the difference b/w the sum of the values of first partition,

  Create an application to run in the amazon ec2 service

In this project you will create an application to run in the Amazon EC2 service and you will also create a client that can run on local machine and access your application.

  Explain the process to develop a web page locally

Explain the process to develop a Web page locally

  Write functions

These 14 questions covers java class, Array, link list , generic class.

  Programming assignment

If the user wants to read the input from a file, then the output will also go into a different file . If the user wants to read the input interactively, then the output will go to the screen .

  Write a prolog program using swi proglog

Write a Prolog program using swi proglog

  Create a custom application using eclipse

Create a custom Application Using Eclipse Android Development

  Create a application using the mvc architecture

create a application using the MVC architecture. No scripting elements are allowed in JSP pages.

  Develops bespoke solutions for the rubber industry

Develops bespoke solutions for the rubber industry

  Design a program that models the worms behavior

Design a program that models the worm's behavior.

  Writing a class

Build a class for a type called Fraction

  Design a program that assigns seats on an airplane

Write a program that allows an instructor to keep a grade book and also design and implement a program that assigns seats on an airplane.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd