[CS61C FA20] Lecture 11.4 - RISC-V Instruction Formats I: Loads — Transcript
Full transcript
- 0:00[Music]
- 0:10hi
- 0:11welcome back to risk five instruction
- 0:12formats we have covered
- 0:14two types of instructions so far the r
- 0:17type uses the r format with
- 0:20the two source registers and destination
- 0:23register
- 0:24and is used for arithmetic and logic
- 0:28register to register instructions
- 0:32the i type uses the i format
- 0:35that has one source register one
- 0:37destination register
- 0:38and the immediate value and it is used
- 0:40for immediate
- 0:41arithmetic and logic instructions so
- 0:44what do we need
- 0:45to support the loads in risk five
- 0:48there is only one type of a load that
- 0:50there is or one
- 0:52you know multiple load instructions but
- 0:55of all one type all of them are of one
- 0:58type
- 0:59and that type specifies the base
- 1:01register
- 1:02and offset with respect to that base
- 1:04register which is an immediate value
- 1:07and that points to memory location
- 1:10and we get a the datum from that memory
- 1:13opera
- 1:14location and place in a destination
- 1:16register
- 1:17so we have the instruction format that
- 1:20has rom
- 1:21for one source register a destination
- 1:23register
- 1:25and an immediate we've just covered that
- 1:28that's our i type or i format
- 1:32so we don't need a new instruction
- 1:35format to support the load
- 1:37we can just use the i type
- 1:40so here is how how loads look like
- 1:44they do get a new op code because
- 1:47they're not really
- 1:48immediate arithmetic instructions
- 1:51they are loads we also have used we have
- 1:54fully populated the the space to
- 1:58encode instructions of the immediate
- 2:01type
- 2:02so we definitely don't need a new op
- 2:05code
- 2:06besides the opcode we need to
- 2:09specify the destination register the
- 2:12base register
- 2:14the same opposite as we have had before
- 2:16of 12 bits
- 2:17and the functory sets the type
- 2:21of load that we are going to do
- 2:24remember we have different kinds of
- 2:26loads we may be loading a word
- 2:28or a byte and that byte load may be
- 2:31unsigned we'll come back to that in a
- 2:34sec
- 2:36but essentially it does what it's
- 2:38supposed to do
- 2:39so the 12-bit sign immediate is added
- 2:42to the value of the base register and
- 2:45then
- 2:45it points to the memory address the
- 2:48contents of that memory address is
- 2:50stored in destination register
- 2:52so it is the same instruction format
- 2:55but the operation is very different than
- 2:58what we had in
- 2:59um immediate arithmetic
- 3:04let's take a look at an example here is
- 3:06a risk 5 assembly instruction
- 3:08that is load word x14
- 3:128 with an offset
- 3:15base pointer is x2 with an offset of 8.
- 3:18so the op code here is going to be the
- 3:21op code that corresponds to
- 3:23the load which is in this case decimal 3
- 3:26binary 1 1 that is different than
- 3:29the ones that we had for the immediates
- 3:32we need to specify
- 3:34the base register here which is 2 so we
- 3:36encode the value
- 3:38of 2 and the
- 3:41destination register which is 14 that
- 3:43corresponds to the
- 3:45x14 that we had in the instruction and
- 3:47then
- 3:48we add the immediate value which is plus
- 3:51eight and the instruction type is
- 3:54load word zero one zero from the green
- 3:58sheet
- 3:58is a load word
- 4:02as we have seen there are different
- 4:04types of loads that
- 4:06we should fit in this format they are
- 4:09covering
- 4:10loading bytes loading words and loading
- 4:13half words
- 4:14what are our words well we know that the
- 4:17word
- 4:18is 32 bits a byte is quarter of a word
- 4:22it's 8 bits so what is
- 4:26a half word well it's 16 bits not that
- 4:29hard to
- 4:30to to guess and then we have
- 4:34unsigned versions of load
- 4:38byte and load half word we don't have an
- 4:40unsigned
- 4:41version of load word because we are
- 4:44taking 32 bits
- 4:45from a memory location and placing them
- 4:47into 32 bits
- 4:49of a register there is nothing to be
- 4:51extended
- 4:52um remember how the load bytes work
- 4:56we take any byte from a memory location
- 4:59that is in memory
- 5:00and place it in the least significant
- 5:03position
- 5:04and in our register
- 5:07and then extend its most significant bit
- 5:11to perform the sign extension
- 5:15loading half words works exactly the
- 5:17same way we
- 5:18place a half word into the lower part of
- 5:21the
- 5:22of the of the register and sign extended
- 5:26load byte unsigned and load half
- 5:29word unsigned do not perform the
- 5:34the sign extension and finally one thing
- 5:37to notice here
- 5:39um sign extension is an important
- 5:42thing to notice that we need to do so it
- 5:46got its separate bit designated bit
- 5:49in the functory field that's all what we
- 5:53need to know about
- 5:54loads this was relatively easy so we're
- 5:57gonna move on to the next
- 6:00instruction type in a bit see you there
About this transcript
This page contains the full transcript of [CS61C FA20] Lecture 11.4 - RISC-V Instruction Formats I: Loads by CS 61C Departmental, generated from the public captions YouTube serves with the video. The transcript has 789 words across 145 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.
What you can do with it
Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to translate the transcript into 100+ languages.
Free YouTube transcript tool
YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, translation to 100+ languages, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.