Write the instruction necessary to allocate 24 bytes from the stack:
addi sp, sp, -24
Given the following code:
1
2
3
4
5
6
7
8
9
10
struct MyStruct {
int i;
long j;
short k;
};
int main() {
MyStruct ms[20];
long value = ms[10].j;
}
What byte offset would you use to load ms[10].j?
248
What is the largest addressable unit in RISC-V (in bits)?
64
What is the smallest addressable unit in RISC-V (in bits)?
8
Given the following C++ code:
1
2
3
int get_value(const unsigned short *data) {
return data[12];
}
Write the assembly instruction that loads data[12] into the proper register to return as shown in the C++ code above:
lhu a0, 24(a0)
Given the following code:
1
2
3
4
5
6
7
8
9
10
struct MyStruct {
int i;
long j;
short k;
};
int main() {
MyStruct ms[20];
long value = ms[3].k;
}
What byte offset would you use to load ms[3].k?
88
All of the stack space allocated to a specific function, such as int main, defines a range from top to bottom. This range is better known as a/an stack frame
Given the following structure,
1
2
3
4
5
struct MyStruct {
char i;
int j;
long k;
};
What is the offset of int j?
4
Given the following code:
1
2
3
4
5
6
7
8
9
struct MyStruct {
int i;
int j;
int k;
};
int main() {
MyStruct ms[200];
int value = ms[94].k;
}
Assuming ms is in memory at 79,361 (base 10), what memory address would be loaded for ms[94].k? Give your answer in base 10.
80,497
Which of the following is the invariant used to determine the offset of a field?
offset % size == 0
Given the following code:
1
2
3
int main(int argc, char *argv[]) {
return argv[30];
}
What is the byte offset of argv[30]?
IDK MIGHT BE 8?
Given the following code:
1
2
3
int val = 0xcafefeed;
unsigned char *p = (unsigned char *)&val;
printf("%x", *p);
What is printed to the screen?
ed
Architectures that store the least-significant byte first in multibyte words are said to be which type of machine?
little-endian