go to previous page   go to home page   go to next page hear noise


Usually not.

Allocating Memory for an Object

Object one is built out of dynamically allocated memory. Here is the start of the program that allocates the memory for one object. The address of the newly allocated memory is saved at object1. (this is roughly equivalent to a reference variable in Java.)

          .globl   main
main:                                 # object1 = new object(); 
          li       $v0,           #   allocate 32 bytes
          li       $a0,           #  
          syscall                        #   $v0 = address
          sw       $v0,           #

          . . . . . .

object1:  .word    0
object2:  .word    0


Fill in the blanks. (Hint: the code for the dynamic memory allocation service is 9).