MIPS - Memory allocation(Array of Structure Pointers)
Posted on 2006-05-09
Consider the following C-style struct to represent a date:
Use the same date structure as the preceding exercises.
In the static data section of your program declare space for an array of up to 25 addresses:
size: .word 0
dates: .space 25*4
You might not use all of the potential addresses. The field size starts at zero because to start, none of the addresses are used.
Write a program that asks the user for how many dates are needed. Set size to that amount. Now a counting loop executes for that many times. Each execution of the loop allocates space for one data, puts the address of that date in the array of addresses, asks the user for values for that data, and finally, fills the date with those values.
At the end of the program, write out the values in the dates. Do this by scanning through the array of addresses to access each date. (Probably the dates will be in order in a contiguous block of memory, but a real-world program can not count on this being true.)