Question about lb instruction

55 views
Skip to first unread message

Ryan Tio

unread,
Sep 21, 2020, 6:15:13 PM9/21/20
to cmpt-295-sfu
# Lecture Question
Week : 3
Slide deck name: L06 - Instructions
Question: On the final slide of the instructions video, I'm not sure what the 3(x11) in lb x10, 3(x11) means. Is it moving 3 bytes from the starting point of x11, or is it meaning to copy the lowest 3 bytes of x11? I'm actually quite iffy on the whole lb sb concept as a whole.

We pass the src parameter as a memory address, and it will only copy the single byte at that address then sign extend to fill the rest of the register?

Arrvindh Shriraman

unread,
Sep 22, 2020, 12:39:54 PM9/22/20
to cmpt-295-sfu
I'm not sure what the 3(x11) in lb x10, 3(x11) means. Is it moving 3 bytes from the starting point of x11, or is it meaning to copy the lowest 3 bytes of x11?

Neither :)

There are 3 parts to the instruction. 
lb - I want to load a byte from memory
x10 - When I read the byte from memory which register should I copy the value to
x11 - Base pointer
3 - An immediate value that is added to x11. 
     Immediate means the binary representation of number is included as part of the instruction itself. 
     
It means treat x11 as a pointer. Add 3 to the pointer address. E.g., lets say x11 is 0x10. The new pointer address would be 0x13.
Read 1 byte starting from 0x13 in memory and copy it to x10.

x10 = mem[x11+3]


includes more details (however it also included discussion on instruction encoding which is discussed only in Week 4).




On Monday, September 21, 2020 at 3:15:13 PM UTC-7, Ryan Tio wrote:
# Lecture Question
Week : 3
Slide deck name: L06 - Instructions
Question: On the final slide of the instructions video,  I'm actually quite iffy on the whole lb sb concept as a whole.
Reply all
Reply to author
Forward
0 new messages