Question

in mip assembly language Memory/Heap Management Software: Write a ‘malloc’ service that takes a piece of...

in mip assembly language

Memory/Heap Management Software: Write a ‘malloc’ service that takes a piece of memory (that you preallocate using the .space directive) and offers a malloc function that allows a user to specify the number of bytes of memory he/she wishes to allocate and returns the memory address of a block of memory that is at least that number of bytes large. You service should also have functions to free memory and keep track of which memory is available and which memory is being used.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

MIP, similar to C, actually has three different ways of sharing memory.

Consider the following code C:

int arr [2]; // global variable, provided in the data section

int main () {
int arr2 [2]; // local dynamics, provided by the station
int * arr3 = malloc (sizeof (int) * 2); // local variables, given over the bulk
}
The MIP meeting supports all these types of data.

Assigning the current list to a portion of the data you can use:

.data

arr: .word 0, 0 #nough space for two words, made to 0, set points for the first item
Assigning a list of services to the stack you can use:

#sindisa $ ra
addi $ sp $ sp -4 #give 4 bytes on the stove to keep the frame connector
sw $ fp 0 ($ sp) #find the old input independently
move $ fp $ sp #modify frame and stack indicators
addi $ sp $ sp -12 #lit 12 bytes of storage, 4 by $ ra and 8 by our list
sw $ ra -4 ($ fp)

# currently has a set of edits at address -8 ($ fp)
To allocate space over the bulk, a system call is required. In the spim simulator this is the 9th program:

li $ a0 8 #good space for two prices
$ v0 9 #syscall 9 (sbrk)
system
# The current address address is now $ v0

Add a comment
Know the answer?
Add Answer to:
in mip assembly language Memory/Heap Management Software: Write a ‘malloc’ service that takes a piece of...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a program in assembly language that loads register R2 with the word in memory location...

    Write a program in assembly language that loads register R2 with the word in memory location which is 10 bytes above the address in R0; and loads register R3 with the word in memory location which is 10 bytes below the address in R1. Your program must compare the two numbers in R2 and R3. If number in R2 is less than or equal to the number in R3 it must add the two numbers and save the result in...

  • In this assignment, you will implement a Memory Management System(MMS). Using C Programming Language..... MAKE SURE...

    In this assignment, you will implement a Memory Management System(MMS). Using C Programming Language..... MAKE SURE YOU USE C PROGRAMMING Your MMS will handle all requests of allocation of memory space by different users (one thread per user) …. HINT(You will use Pthreads and Semaphores). Your MMS will provide the user with an interface for making memory requests and also for freeing up memory that is no longer needed by the user. One of the jobs of your memory management...

  • Write the code to dynamically allocate ONE integer variable using calloc (contiguous allocation) or malloc (memory...

    Write the code to dynamically allocate ONE integer variable using calloc (contiguous allocation) or malloc (memory allocation) and have it pointed to by a pointer (of type int * ) named ptr_1. Use ptr_1 to assign the number 7 to that dynamically allocated integer, and in another line use printf to output the contents of that dynamically allocated integer variable. Write the code to dynamically allocate an integer array of length 5 using calloc or malloc and have it pointed...

  • Write a MIPS assembly language program that uses dynamic memory allocation to create and manage a...

    Write a MIPS assembly language program that uses dynamic memory allocation to create and manage a linked list data structure. Gives the user the following options:                         1. To create and add the first node to a linked list.          2. To add a single node to the pre-existing linked list.             The list must already exist before a new node can be added.            The nodes should be maintained in ascending order based on the data value within the nodes...

  • I've posted 3 classes after the instruction that were given at start You will implement and...

    I've posted 3 classes after the instruction that were given at start You will implement and test a PriorityQueue class, where the items of the priority queue are stored on a linked list. The material from Ch1 ~ 8 of the textbook can help you tremendously. You can get a lot of good information about implementing this assignment from chapter 8. There are couple notes about this assignment. 1. Using structure Node with a pointer point to Node structure to...

  • Read this article. Then write a 250 word response on two of the programs you like...

    Read this article. Then write a 250 word response on two of the programs you like the most. Open source business intelligence software 1. BIRT BIRT is an open source BI program that CloudTweaks says is often viewed as the industry standard. BIRT boasts “over 12 million downloads and over 2.5 million developers across 157 countries.” Its users include heavyweights such as Cisco, S1, and IBM (which is also a BIRT sponsor). They also have maturity going for them, as...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT