YouTube2Text

[CS61C FA20] Lecture 13.2 - Compilation, Assembly, Linking, Loading: Compiler — Transcript

by CS 61C Departmental · 1,110 words · 176 segments · language en · Watch on YouTube

Full transcript

  1. 0:00and welcome back now we're going to see
  2. 0:02the first and that call
  3. 0:04the compiler so this is the beautiful
  4. 0:07picture look at this beautiful beautiful
  5. 0:09picture that shows you the
  6. 0:10pretty complicated step to go from a c
  7. 0:12program to a running program
  8. 0:15we're going to see this over and over as
  9. 0:16we kind of poke at the different pieces
  10. 0:18of this
  11. 0:19but let's kind of take a look here so
  12. 0:20we're going to look at the compiler
  13. 0:21stage here
  14. 0:22but we're going to see overall the big
  15. 0:24picture is
  16. 0:25a compiler compiles the code from so
  17. 0:28what's the input in the output of that
  18. 0:29box
  19. 0:30that's a c program and the output is a
  20. 0:32dot s program
  21. 0:33in fact that normally is hidden you can
  22. 0:35say compile and the
  23. 0:36output is a a dot out so this whole
  24. 0:38thing typically is when you're done when
  25. 0:40you say gcc
  26. 0:41this whole thing is done and you you
  27. 0:44often don't see those pieces
  28. 0:46but work you could actually stop the
  29. 0:47pieces and say oh that's when that
  30. 0:49happens that's what happened that
  31. 0:50happens
  32. 0:50and so one of the features is for gcc if
  33. 0:53you say dash s
  34. 0:54it'll actually generate the dot s file
  35. 0:56and that's the output of the compiler
  36. 0:58and dot s is the input to the assembler
  37. 1:00so we'll talk about what each of these
  38. 1:01do
  39. 1:02in the next series of lectures just want
  40. 1:03to make sure i get the big picture here
  41. 1:05in this first lecture
  42. 1:09assembler takes the dot s produces a dot
  43. 1:11o we'll see this again in more detail
  44. 1:13the dot o
  45. 1:14the linker takes the dot o and other dot
  46. 1:16o files maybe from libraries
  47. 1:17and includes them to make a running
  48. 1:19program and the loader is
  49. 1:21the operating system and the loader is
  50. 1:22the guy that takes a run it takes a
  51. 1:24program a dot out on disk
  52. 1:25loads it into memory and sets up
  53. 1:27everything needs to set up a lot of
  54. 1:28complicated things need to set up
  55. 1:30and then runs the program okay so that's
  56. 1:32the big picture and again if you want to
  57. 1:33see the output of a dot
  58. 1:35of the compiler you type in dash capital
  59. 1:37s to that
  60. 1:38to make that work so this is the only
  61. 1:41slide on this
  62. 1:42the big picture is you're taking a dot c
  63. 1:44you put out a dot s and here's the key
  64. 1:46thing that you might not have understood
  65. 1:49you're looking at this c code and you're
  66. 1:51deciding as a compiler what to do and
  67. 1:53you're producing assembler level code
  68. 1:54you've already learned about risk 5
  69. 1:55assembler that's what you produce that's
  70. 1:57what the compiler has been doing all
  71. 1:58along
  72. 1:59dot s can be produced by two ways a
  73. 2:01compiler can do it
  74. 2:02you can turn optimization on and that
  75. 2:04changes what the compiler is doing so
  76. 2:05lots of ways you can feed things into
  77. 2:07the compiler to change
  78. 2:08those settings you could also hand
  79. 2:11author.s files you could hand off the
  80. 2:13risk 5 code
  81. 2:14in fact we give you venus so you can
  82. 2:15play with hand authoring it to
  83. 2:17understand what it
  84. 2:18is that it takes to translate hand
  85. 2:20translate c
  86. 2:22to dot s files it's not on you it's not
  87. 2:24unheard of that we give you some c
  88. 2:25code and ask you to do that on an exam
  89. 2:27so make sure you're fluent enough with
  90. 2:29the risk five not just oh okay that's
  91. 2:31how it works on a wall
  92. 2:32i was sitting back with my arms crossed
  93. 2:34learning the whole time never did it
  94. 2:35yourself no get your hands dirty
  95. 2:36get in venus play with it so you
  96. 2:38understand what it is and then
  97. 2:40grab some really small c programs
  98. 2:41compile them down and see how your hand
  99. 2:43translation compares with how they
  100. 2:44actually do it in fact at the end of
  101. 2:45this lecture
  102. 2:46we're going to hand translate a little
  103. 2:47hello world just to show you how it all
  104. 2:49works a little bit more complicated than
  105. 2:50just
  106. 2:51because there's some more things going
  107. 2:52on but you'll see it we'll see by the
  108. 2:54end of this for this lecture
  109. 2:56here's the important thing there's an
  110. 2:57idea of allowing for
  111. 3:00a squishier that's squishy may not be
  112. 3:04the word
  113. 3:04but allowing for what we call pseudo
  114. 3:06instructions and what that is
  115. 3:08is you know what let's make it easier
  116. 3:10for you to write
  117. 3:11risk five code so we add these pseudo
  118. 3:14instructions
  119. 3:14that the assembler needs to then work
  120. 3:16with later that
  121. 3:18make it much easier to think about
  122. 3:20writing assembler level programs for so
  123. 3:22for example here's an example
  124. 3:23a great example that we show you here so
  125. 3:26move t1 t2 what this does is take the
  126. 3:29value of two this is like t1 equals t2
  127. 3:32in c code it says take the value of t2
  128. 3:34and stuff it right in that register and
  129. 3:36stuff it in the register t1
  130. 3:38well it's really nice to think about
  131. 3:40that and by the way i don't like move i
  132. 3:41think move is a terrible name this
  133. 3:43should be copy
  134. 3:44because t1 is t2's value doesn't go away
  135. 3:47it's really copy in the unix sense it's
  136. 3:48really copy
  137. 3:49uh in fact the order is opposite you
  138. 3:51usually copy from this to that
  139. 3:53so here you know it goes it goes from
  140. 3:55the order of function goes
  141. 3:57from t2 into t1 but
  142. 4:00the point is i think this should be copy
  143. 4:01not move my point of all of this is that
  144. 4:04it's easier to say move than is to say
  145. 4:07at
  146. 4:07i t 1 t 2 0.
  147. 4:10yeah that works too i get it t 2 plus
  148. 4:13the
  149. 4:13immediate zero goes into t1 therefore t1
  150. 4:16gets the value of t2
  151. 4:18so i could always be thinking at eyes
  152. 4:20but isn't it easier just to write move
  153. 4:22so we've added say we mean the assembler
  154. 4:24community have added
  155. 4:25pseudo instructions to make it easier to
  156. 4:27write risk five assembly code that's
  157. 4:29been true for all the assemblers that
  158. 4:30i've been
  159. 4:31you know familiar with uh mips risk
  160. 4:34all of these allows for you to have
  161. 4:37these pseudo instructions which just
  162. 4:38make it easier to write in that assembly
  163. 4:40level
  164. 4:40okay that's it so again the compiler
  165. 4:43takes.c code
  166. 4:44produces.s assembler code that that s
  167. 4:47file could contain
  168. 4:48by the way that could also be hand
  169. 4:49authored compiler or you
  170. 4:51hand author at the end of the day you've
  171. 4:52got s code and that could contain
  172. 4:55pseudo-instructions and these sort of
  173. 4:56pseudo-instructions just make it easier
  174. 4:58to write that assembler all right
  175. 4:59see the next lecture we learned about
  176. 5:00the assembler take care

About this transcript

This page contains the full transcript of [CS61C FA20] Lecture 13.2 - Compilation, Assembly, Linking, Loading: Compiler by CS 61C Departmental, generated from the public captions YouTube serves with the video. The transcript has 1,110 words across 176 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.