[CS61C FA20] Lecture 07.4 - RISC-V Intro: RISC-V Immediates — Transcript
Full transcript
- 0:00[Music]
- 0:08welcome back
- 0:09we are continuing to go through our risk
- 0:12five assembly instructions
- 0:14we have covered throwing two
- 0:15instructions so far add and sub
- 0:17that perform addition and subtraction
- 0:20over the contents of the registers
- 0:22inside of a processor we
- 0:25add assembly instructions to a processor
- 0:28to support common cases that we find
- 0:30in higher level languages so one thing
- 0:32that we
- 0:33frequently do in higher level languages
- 0:36like c
- 0:37is we add a constant to a variable
- 0:40so there is a a special instruction that
- 0:43does
- 0:44this addition of a constant to a
- 0:46variable
- 0:48numerical constants in assembly are
- 0:49called immediates
- 0:52they often very they they appear often
- 0:55in the code
- 0:55so it does make sense to have support
- 0:57for them in the assembly language
- 1:00the instruction that risk 5 uses for
- 1:03adding immediates is called
- 1:05adbi which stands for ad immediate
- 1:08it makes sense that it is called that
- 1:10way because in a catalog of the
- 1:11instructions so
- 1:12in in the green card you add immediate
- 1:15is going to be
- 1:16standing right next to the register add
- 1:21its format is also very similar to what
- 1:23we have seen as a format for the add
- 1:25instruction
- 1:27instead of having add destination
- 1:31register
- 1:32source 1 source 2 the format of the add
- 1:35immediate is addi
- 1:37destination register source register and
- 1:40the value of the immediate
- 1:45it looks similar to the add instruction
- 1:48because we do
- 1:48want to reuse actually most of the
- 1:51hardware that we'll be
- 1:52using to build this processor to
- 1:55implement these two instructions
- 1:58a few other interesting things about the
- 2:00risk 5
- 2:01and the immediates although there are
- 2:04separate add and sub instructions
- 2:06because
- 2:07sub instruction you know substitution
- 2:10is not communicated commutative so
- 2:14it makes sense to have a sub instruction
- 2:16there is no sub immediate
- 2:19i'll give you a second to think about
- 2:20why we don't need
- 2:22sub immediate in assembly
- 2:30of course well because we really really
- 2:33don't need it
- 2:35we can implement it we can replace it by
- 2:37using add immediate
- 2:39where that immediate would be a negative
- 2:41value
- 2:42implemented in two's complement in risk
- 2:44five so
- 2:45our instruction that would implement f
- 2:48equals to g minus 10 in c would look
- 2:51like
- 2:52add immediate x 3 x 4 minus 10
- 2:55is to in two's complement in risk five
- 3:00so we don't need it notice though that
- 3:03if we wanted to implement
- 3:04f equals 10 minus g
- 3:08we would need two instructions to do
- 3:10that
- 3:12you can think about how to do that
- 3:16keep in mind that the most common
- 3:18immediate that we are going to encounter
- 3:20in code
- 3:20is zero that's why it makes sense
- 3:24to keep that zero handy inside of a
- 3:26processor
- 3:27by hardwiring one of its registers and
- 3:30in
- 3:30the risk five it is the x zero register
- 3:34so no matter what you do to this x0
- 3:36register it
- 3:37always holds the value of zero because
- 3:40processor does
- 3:40like to have a zero handy at all times
- 3:47so if you do things with x0 keep that in
- 3:50mind
- 3:51for example add x3 x4
- 3:54x0 would simply move the contents of a
- 3:58register x4
- 4:00to register x3 like
- 4:03f equals g and c
- 4:06now we can try to use
- 4:11the the register x0 as a destination
- 4:13register but that
- 4:14doesn't make sense because if we say
- 4:17that add
- 4:19if we write an instruction add x0
- 4:22x3 x4 no matter what the value
- 4:26or what the values are stored in the
- 4:28registers x3 and x4
- 4:31this instruction will not change the the
- 4:33contents of x0
- 4:34x0 is going to stay zero and that's it
- 4:38what we have to say for now
- 4:39about the immediate um now it's a good
- 4:42time to
- 4:43take a little break because we're going
- 4:45to get into
- 4:46slightly more slightly
- 4:50different instructions in the next
- 4:53segment
- 4:54see you then
About this transcript
This page contains the full transcript of [CS61C FA20] Lecture 07.4 - RISC-V Intro: RISC-V Immediates by CS 61C Departmental, generated from the public captions YouTube serves with the video. The transcript has 643 words across 123 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.