YouTube2Text

[CS61C FA20] Lecture 07.4 - RISC-V Intro: RISC-V Immediates — Transcript

by CS 61C Departmental · 643 words · 123 segments · language en · Watch on YouTube

Full transcript

  1. 0:00[Music]
  2. 0:08welcome back
  3. 0:09we are continuing to go through our risk
  4. 0:12five assembly instructions
  5. 0:14we have covered throwing two
  6. 0:15instructions so far add and sub
  7. 0:17that perform addition and subtraction
  8. 0:20over the contents of the registers
  9. 0:22inside of a processor we
  10. 0:25add assembly instructions to a processor
  11. 0:28to support common cases that we find
  12. 0:30in higher level languages so one thing
  13. 0:32that we
  14. 0:33frequently do in higher level languages
  15. 0:36like c
  16. 0:37is we add a constant to a variable
  17. 0:40so there is a a special instruction that
  18. 0:43does
  19. 0:44this addition of a constant to a
  20. 0:46variable
  21. 0:48numerical constants in assembly are
  22. 0:49called immediates
  23. 0:52they often very they they appear often
  24. 0:55in the code
  25. 0:55so it does make sense to have support
  26. 0:57for them in the assembly language
  27. 1:00the instruction that risk 5 uses for
  28. 1:03adding immediates is called
  29. 1:05adbi which stands for ad immediate
  30. 1:08it makes sense that it is called that
  31. 1:10way because in a catalog of the
  32. 1:11instructions so
  33. 1:12in in the green card you add immediate
  34. 1:15is going to be
  35. 1:16standing right next to the register add
  36. 1:21its format is also very similar to what
  37. 1:23we have seen as a format for the add
  38. 1:25instruction
  39. 1:27instead of having add destination
  40. 1:31register
  41. 1:32source 1 source 2 the format of the add
  42. 1:35immediate is addi
  43. 1:37destination register source register and
  44. 1:40the value of the immediate
  45. 1:45it looks similar to the add instruction
  46. 1:48because we do
  47. 1:48want to reuse actually most of the
  48. 1:51hardware that we'll be
  49. 1:52using to build this processor to
  50. 1:55implement these two instructions
  51. 1:58a few other interesting things about the
  52. 2:00risk 5
  53. 2:01and the immediates although there are
  54. 2:04separate add and sub instructions
  55. 2:06because
  56. 2:07sub instruction you know substitution
  57. 2:10is not communicated commutative so
  58. 2:14it makes sense to have a sub instruction
  59. 2:16there is no sub immediate
  60. 2:19i'll give you a second to think about
  61. 2:20why we don't need
  62. 2:22sub immediate in assembly
  63. 2:30of course well because we really really
  64. 2:33don't need it
  65. 2:35we can implement it we can replace it by
  66. 2:37using add immediate
  67. 2:39where that immediate would be a negative
  68. 2:41value
  69. 2:42implemented in two's complement in risk
  70. 2:44five so
  71. 2:45our instruction that would implement f
  72. 2:48equals to g minus 10 in c would look
  73. 2:51like
  74. 2:52add immediate x 3 x 4 minus 10
  75. 2:55is to in two's complement in risk five
  76. 3:00so we don't need it notice though that
  77. 3:03if we wanted to implement
  78. 3:04f equals 10 minus g
  79. 3:08we would need two instructions to do
  80. 3:10that
  81. 3:12you can think about how to do that
  82. 3:16keep in mind that the most common
  83. 3:18immediate that we are going to encounter
  84. 3:20in code
  85. 3:20is zero that's why it makes sense
  86. 3:24to keep that zero handy inside of a
  87. 3:26processor
  88. 3:27by hardwiring one of its registers and
  89. 3:30in
  90. 3:30the risk five it is the x zero register
  91. 3:34so no matter what you do to this x0
  92. 3:36register it
  93. 3:37always holds the value of zero because
  94. 3:40processor does
  95. 3:40like to have a zero handy at all times
  96. 3:47so if you do things with x0 keep that in
  97. 3:50mind
  98. 3:51for example add x3 x4
  99. 3:54x0 would simply move the contents of a
  100. 3:58register x4
  101. 4:00to register x3 like
  102. 4:03f equals g and c
  103. 4:06now we can try to use
  104. 4:11the the register x0 as a destination
  105. 4:13register but that
  106. 4:14doesn't make sense because if we say
  107. 4:17that add
  108. 4:19if we write an instruction add x0
  109. 4:22x3 x4 no matter what the value
  110. 4:26or what the values are stored in the
  111. 4:28registers x3 and x4
  112. 4:31this instruction will not change the the
  113. 4:33contents of x0
  114. 4:34x0 is going to stay zero and that's it
  115. 4:38what we have to say for now
  116. 4:39about the immediate um now it's a good
  117. 4:42time to
  118. 4:43take a little break because we're going
  119. 4:45to get into
  120. 4:46slightly more slightly
  121. 4:50different instructions in the next
  122. 4:53segment
  123. 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.