The following linked list node is declared in C:
struct node {
double val;
struct node *next;
}
开发者_开发知识库
Suppose that no more than 20 link nodes are needed for a problem. What are MIPS statements to reserve 20-node space for the linked list?
You can do so in C and check the resulting assembly generated by the C compiler. Anyway...
Double-precision floating point -> 64 bits
Pointer -> 32 bits
Total struct size -> 96 bits + 32 bits to align doubles -> 128 bits
20 structs + 1 head list pointer (assuming it's a simple list with only one pointer to the starting element) -> 20 x 128 + 32 = 2592 bits
.space 2592
精彩评论