3, (20%) Consider the below RISC-V code snippet: Line I: lui 6, 0sDAOB Line 2: a
ID: 3749245 • Letter: 3
Question
3, (20%) Consider the below RISC-V code snippet: Line I: lui 6, 0sDAOB Line 2: addi x6, x6,0x123 Line 3: sd x6, 0Xx0) Line 4: lb x6, 2(x0) Last name: First name: abc123: (1). (4%) What's the value of x6 after line 1? (2), (496) what's the value of x6 after line 2? (3). (4%) in a little-endian machine, what are the byte values at memory addresses 0x0 to 0x7 after line 3? Byte value at address OxD: Byte value at address OxI Byte value at address Ox2 Byte value at address Ox3: Byte value at address Ox4: Byte value at address Ox5: Byte value at address Ox6: Byte value at address Ox7: (4). (4%) In a big-endian machine, what are the byte values at memory addresses 0x0 to 0x7 after line 3? Byte value at address OD: Byte value at address Oxl Byte value at address 0x2 Byte value at address 0x3: Byte value at address Ox4: Byte value at address Ox5: Byte value at address 0x6: Byte value at address Ox7 (5), (4%) What's the value of x6 after line 4 in a RISC-V computer?Explanation / Answer
3. Solution is provided below, please comment if any doubts:
1.
Answer: 00 00 00 00 0A 0B F0 00
Explanation:
The operation performed by “lui” instruction:
2.
Answer: 00 00 00 00 0A 0B F1 23
Explanation:
The operation performed by “addi” instruction:
3.
The third line save the register “x6” value to the memory address x0.
In little-endian format the most significant bit will be stored towards the end.
Thus the values stored will be
Byte value at address 0x0: 23
Byte value at address 0x1: F1
Byte value at address 0x2: 0B
Byte value at address 0x3: 0A
Byte value at address 0x4: 00
Byte value at address 0x5: 00
Byte value at address 0x6: 00
Byte value at address 0x7: 00
4.
The third line save the register “x6” value to the memory address x0.
In big-endian format the most significant bit will be stored towards starting of the memory where it has to be saved.
Thus the values stored will be
Byte value at address 0x0: 00
Byte value at address 0x1: 00
Byte value at address 0x2: 00
Byte value at address 0x3: 00
Byte value at address 0x4: 0A
Byte value at address 0x5: 0B
Byte value at address 0x6: F1
Byte value at address 0x7: 23
5.
The byte value after the 0x2 address will be loaded into the register x6.
Here the little-endian or big-endian format followed will be criteria.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.