开发者

MIPS struct node

开发者 https://www.devze.com 2023-04-13 09:00 出处:网络
The following linked list node is declared in C: struct node {  double val; struct node *next; } 开发者_开发知识库

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
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号