YouTube2Text

[CS61C FA20] Lecture 09.2 - RISC-V Decisions II: A Bit About Machine Program — Transcript

by CS 61C Departmental · 1,048 words · 196 segments · language en · Watch on YouTube

Full transcript

  1. 0:00[Music]
  2. 0:09welcome back
  3. 0:10we're still talking about 365 assembly
  4. 0:13language but we're going to take
  5. 0:14a bit of a detour to see what is
  6. 0:16happening with that assembly program
  7. 0:18once it is written so say that we have
  8. 0:22two pieces of assembly code food.s and
  9. 0:24bar.tests which are our assembler source
  10. 0:27files which are written in plain text
  11. 0:30we're going to pass them through the
  12. 0:32assembler which will produce machine
  13. 0:35code object files
  14. 0:37food.o and bar.toe
  15. 0:41those are you know those er ex
  16. 0:44extensions dot o stand for the object
  17. 0:48files
  18. 0:49we may have uh pre-built object file
  19. 0:51libraries like lib.o
  20. 0:53that may contain some commonly used
  21. 0:55functions like for example a
  22. 0:57division linker will take our object
  23. 1:00files
  24. 1:01and the library files and link them
  25. 1:04together
  26. 1:05now what is linking them together will
  27. 1:08place the addresses in appropriate
  28. 1:09spaces
  29. 1:10and put everything together such that it
  30. 1:12looks like one
  31. 1:13piece of a program the output is a dot
  32. 1:16out
  33. 1:16which is machine code executable file so
  34. 1:19where does that machine code executable
  35. 1:21file
  36. 1:22live it is not small enough
  37. 1:25to fit in the register so therefore it
  38. 1:27has to live in the memory
  39. 1:29remember our memory is big and cons
  40. 1:32is byte addressable however these bytes
  41. 1:35are put together to form
  42. 1:3732-bit words we'll have a section of
  43. 1:40memory where the data will live
  44. 1:43and then there will be a section of a
  45. 1:45memory where the program will
  46. 1:47all reside those are typically
  47. 1:52kept separate from each other with an
  48. 1:54exception in 61c
  49. 1:56exams where data tends to run
  50. 2:00on top of a program and causes
  51. 2:02interesting effects over there
  52. 2:04but in practice that usually doesn't
  53. 2:06happen so
  54. 2:08we got a pretty good idea of how does
  55. 2:10the program look like now
  56. 2:12it is essentially a sequence of bricks
  57. 2:14five instructions
  58. 2:15where each of these five instruction
  59. 2:17instructions is
  60. 2:1832 bits wide and we will be executing
  61. 2:22them
  62. 2:23typically in order until we run into
  63. 2:26one of those that corresponds to a
  64. 2:27branch or a jump
  65. 2:29and then we are going to perhaps jump to
  66. 2:32another
  67. 2:32place in memory to a different address
  68. 2:35in memory
  69. 2:36what does the processor do with this
  70. 2:38program
  71. 2:40well this is a picture that we hopefully
  72. 2:43have
  73. 2:44have had tattooed already
  74. 2:48so our processor to the left has
  75. 2:51a control unit and a data path and then
  76. 2:54memory is to the right
  77. 2:57inside the processor inside the data
  78. 3:00path there is one very special register
  79. 3:03which is called the program counter
  80. 3:05product counter
  81. 3:06is internal to the processor and it
  82. 3:09holds the byte address of the next
  83. 3:11instruction that is going to be executed
  84. 3:15so it is something that is really
  85. 3:17important
  86. 3:18a control unit is going to use the
  87. 3:21program counter
  88. 3:22to producing the to fetch the
  89. 3:25instruction
  90. 3:26from the memory take a look at what is
  91. 3:28that instruction
  92. 3:29and execute it by using the data path
  93. 3:32and the memory system and then
  94. 3:36we'll update the program counter to
  95. 3:39point to the next instruction that is
  96. 3:40going to be executed
  97. 3:42most commonly that will be the next
  98. 3:44instruction in sequence
  99. 3:46but sometimes it may be a branch the
  100. 3:48next instruction in sequence
  101. 3:50is four bytes away you have to keep that
  102. 3:52in mind
  103. 3:53it is one word away but that is four
  104. 3:56bytes
  105. 3:57so in order to point to the next address
  106. 4:00we need to increment the program counter
  107. 4:03by
  108. 4:03four bytes or to load
  109. 4:06into a program counter a new address
  110. 4:09if it is a branch
  111. 4:13hopefully you get now a reasonable
  112. 4:15picture
  113. 4:16of how does the processor execute the
  114. 4:18program it may be
  115. 4:19helpful understanding what comes next
  116. 4:24in the meantime a few other interesting
  117. 4:27things that will help us or helpful
  118. 4:28things that will
  119. 4:29help us understand how to um
  120. 4:32work through the functions later on um
  121. 4:36first there are there is something there
  122. 4:39called
  123. 4:39symbolic register names there are 32
  124. 4:43registers in risk 5 architecture
  125. 4:45the first one is reserved to to be a
  126. 4:47zero but the
  127. 4:49other 31 are assignable but some of them
  128. 4:52are going to have very special purposes
  129. 4:54and it will be kind of hard to remember
  130. 4:56which one does which out of 31 of them
  131. 4:59so we give them
  132. 5:00symbolic names for example
  133. 5:03physical registers x10 to x17
  134. 5:08are have symbolic names a to a zero to a
  135. 5:11seven
  136. 5:12for argument registers for function
  137. 5:15calls
  138. 5:16or zero is spelled out as a
  139. 5:20as a symbolic name for a register x
  140. 5:23naught
  141. 5:26there is another useful thing which are
  142. 5:29pseudo instructions
  143. 5:30remember risk 5 does not have
  144. 5:35many instructions and some of them you
  145. 5:38know look
  146. 5:39fairly cryptic although you know we can
  147. 5:41do things in just a simple
  148. 5:42one instruction it looks cryptic for
  149. 5:44example if we want to copy a value of
  150. 5:46one
  151. 5:47register to another we have to do
  152. 5:50add immediate this of
  153. 5:54a source to a destination register with
  154. 5:57an immediate value of zero other
  155. 6:00processors may have an instruction
  156. 6:02move so in this case
  157. 6:05move instruction is a symbolic
  158. 6:07instruction that corresponds to add
  159. 6:09immediate with a zero
  160. 6:11so move the destination register source
  161. 6:14register
  162. 6:15is the same as add immediate destination
  163. 6:18register source register zero
  164. 6:19it copies the the contents of a source
  165. 6:22register
  166. 6:23to the destination register the other
  167. 6:25one that is
  168. 6:26also that will find user useful is
  169. 6:29load immediate although it does not work
  170. 6:31with the memory it simply
  171. 6:33loads an immediate value into a register
  172. 6:37if it is a short immediate that can fit
  173. 6:40as
  174. 6:43as an argument of an ad immediate and
  175. 6:48finally
  176. 6:48a common instruction that we will run
  177. 6:52frequently in in the code is no
  178. 6:54operation or it stands as not
  179. 6:56that's when processor needs to wait for
  180. 6:58something for example for a datum to
  181. 6:59come from the memory
  182. 7:01it is spinning around and doing nothing
  183. 7:02that's a knob well
  184. 7:04knob is anything that uses x0 as the
  185. 7:07destination register
  186. 7:08so x0x0 add the mediatek 0x00
  187. 7:13is a good knob
  188. 7:17these instructions don't change anything
  189. 7:19in the way how they're being
  190. 7:21executed they just make the code
  191. 7:24more readable so instead of trying to
  192. 7:26figure out what
  193. 7:27does add immediate our destination our
  194. 7:29source zero do
  195. 7:31we just write a move that's it for now
  196. 7:34see you in a bit

About this transcript

This page contains the full transcript of [CS61C FA20] Lecture 09.2 - RISC-V Decisions II: A Bit About Machine Program by CS 61C Departmental, generated from the public captions YouTube serves with the video. The transcript has 1,048 words across 196 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.