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

  Program a maze-type game using assembly language

Project requires you to program a maze-type game using Assembly Language, it is not acceptable to use any other programming language for this project

  Write liberty basic to make payment of current balance

Makes a payment equal to 5 percent of current balance suppose the customer makes no new purchases. Must be written in Liberty Basic.

  Create the logic for a program which merges two files

Create the logic for a program which merges the two files into one file containing list of all students in district, maintaining student id number order.

  Calculate and display total fees and discount

Write a program to select type of student using an option button and capture total credit hours using a text box. Calculate and display total fees, discount (if any) and net total fees (after discount).

  Write bash script to copy file from one location to another

Write a bash script called mycopy that copies a file from one location to another. An example of running the script is given below.

  Write and implement generic set class with attributes

Write and implement the generic Set class with attributes you find essential and with the following methods. Set class has nonduplicate elements.

  Identify all the pure-strategy nash equilibria of game

Identify all of the pure-strategy Nash Equilibria of this game. Identify at least one mixed-strategy Nash Equilibrium, and show that it is a Nash Equilibrium.

  Creating form which analyzes poker hand entered by user

To observe behavior of Sub Procedures, draw a Form which analyzes a poker hand entered by user and displays the type of hand.

  Write program to accept a list of student-s name

Write a program that will accepts a list of student's name, individual scores for quiz1, quiz2 and quiz3. Your program should then compute for the average of 3 quizzes.

  Create logic for program which contains housekeeping

Create logic for program in pseudocode or flowchart which contains housekeeping, detail loop, and end-of-job modules, and which computes service charge and the original check amount customers owe for writing bad check.

  Create a multi-threaded competition

Create a multi-threaded competition

  Write class to represent temperatures in degree and celsius

Write a Temperature class that represents temperatures in degrees in Celsius, Fahrenheit and Kelvin. Use a floating-point number for the temperature and a character (type char) for the scale.

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