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


12 bytes, four bytes for each of three integers.

Fields within a Struct

A block of memory for this struct consists of twelve bytes. The first field (age) is located at a displacement of zero into the block. The second field (pay) is located at a displacement of four into the block. The last field (class) is located at a displacement of eight into the block.

  int age;  
  int pay;
  int class;

Warning: C and C++ compilers are free to rearrange the order of items inside a struct and to do other things for optimization or hardware compatibility. Worse yet, different compilers may do different things. Do not write C programs that make assumptions about the internal structure of a struct.


Say that register $s1holds the address of a struct like the above. Fill in the blank so that register $t0 gets the value in the pay field:

lw $t0, (  )    # load the pay