[CS61C FA20] Lecture 13.2 - Compilation, Assembly, Linking, Loading: Compiler — Transcript
Full transcript
- 0:00and welcome back now we're going to see
- 0:02the first and that call
- 0:04the compiler so this is the beautiful
- 0:07picture look at this beautiful beautiful
- 0:09picture that shows you the
- 0:10pretty complicated step to go from a c
- 0:12program to a running program
- 0:15we're going to see this over and over as
- 0:16we kind of poke at the different pieces
- 0:18of this
- 0:19but let's kind of take a look here so
- 0:20we're going to look at the compiler
- 0:21stage here
- 0:22but we're going to see overall the big
- 0:24picture is
- 0:25a compiler compiles the code from so
- 0:28what's the input in the output of that
- 0:29box
- 0:30that's a c program and the output is a
- 0:32dot s program
- 0:33in fact that normally is hidden you can
- 0:35say compile and the
- 0:36output is a a dot out so this whole
- 0:38thing typically is when you're done when
- 0:40you say gcc
- 0:41this whole thing is done and you you
- 0:44often don't see those pieces
- 0:46but work you could actually stop the
- 0:47pieces and say oh that's when that
- 0:49happens that's what happened that
- 0:50happens
- 0:50and so one of the features is for gcc if
- 0:53you say dash s
- 0:54it'll actually generate the dot s file
- 0:56and that's the output of the compiler
- 0:58and dot s is the input to the assembler
- 1:00so we'll talk about what each of these
- 1:01do
- 1:02in the next series of lectures just want
- 1:03to make sure i get the big picture here
- 1:05in this first lecture
- 1:09assembler takes the dot s produces a dot
- 1:11o we'll see this again in more detail
- 1:13the dot o
- 1:14the linker takes the dot o and other dot
- 1:16o files maybe from libraries
- 1:17and includes them to make a running
- 1:19program and the loader is
- 1:21the operating system and the loader is
- 1:22the guy that takes a run it takes a
- 1:24program a dot out on disk
- 1:25loads it into memory and sets up
- 1:27everything needs to set up a lot of
- 1:28complicated things need to set up
- 1:30and then runs the program okay so that's
- 1:32the big picture and again if you want to
- 1:33see the output of a dot
- 1:35of the compiler you type in dash capital
- 1:37s to that
- 1:38to make that work so this is the only
- 1:41slide on this
- 1:42the big picture is you're taking a dot c
- 1:44you put out a dot s and here's the key
- 1:46thing that you might not have understood
- 1:49you're looking at this c code and you're
- 1:51deciding as a compiler what to do and
- 1:53you're producing assembler level code
- 1:54you've already learned about risk 5
- 1:55assembler that's what you produce that's
- 1:57what the compiler has been doing all
- 1:58along
- 1:59dot s can be produced by two ways a
- 2:01compiler can do it
- 2:02you can turn optimization on and that
- 2:04changes what the compiler is doing so
- 2:05lots of ways you can feed things into
- 2:07the compiler to change
- 2:08those settings you could also hand
- 2:11author.s files you could hand off the
- 2:13risk 5 code
- 2:14in fact we give you venus so you can
- 2:15play with hand authoring it to
- 2:17understand what it
- 2:18is that it takes to translate hand
- 2:20translate c
- 2:22to dot s files it's not on you it's not
- 2:24unheard of that we give you some c
- 2:25code and ask you to do that on an exam
- 2:27so make sure you're fluent enough with
- 2:29the risk five not just oh okay that's
- 2:31how it works on a wall
- 2:32i was sitting back with my arms crossed
- 2:34learning the whole time never did it
- 2:35yourself no get your hands dirty
- 2:36get in venus play with it so you
- 2:38understand what it is and then
- 2:40grab some really small c programs
- 2:41compile them down and see how your hand
- 2:43translation compares with how they
- 2:44actually do it in fact at the end of
- 2:45this lecture
- 2:46we're going to hand translate a little
- 2:47hello world just to show you how it all
- 2:49works a little bit more complicated than
- 2:50just
- 2:51because there's some more things going
- 2:52on but you'll see it we'll see by the
- 2:54end of this for this lecture
- 2:56here's the important thing there's an
- 2:57idea of allowing for
- 3:00a squishier that's squishy may not be
- 3:04the word
- 3:04but allowing for what we call pseudo
- 3:06instructions and what that is
- 3:08is you know what let's make it easier
- 3:10for you to write
- 3:11risk five code so we add these pseudo
- 3:14instructions
- 3:14that the assembler needs to then work
- 3:16with later that
- 3:18make it much easier to think about
- 3:20writing assembler level programs for so
- 3:22for example here's an example
- 3:23a great example that we show you here so
- 3:26move t1 t2 what this does is take the
- 3:29value of two this is like t1 equals t2
- 3:32in c code it says take the value of t2
- 3:34and stuff it right in that register and
- 3:36stuff it in the register t1
- 3:38well it's really nice to think about
- 3:40that and by the way i don't like move i
- 3:41think move is a terrible name this
- 3:43should be copy
- 3:44because t1 is t2's value doesn't go away
- 3:47it's really copy in the unix sense it's
- 3:48really copy
- 3:49uh in fact the order is opposite you
- 3:51usually copy from this to that
- 3:53so here you know it goes it goes from
- 3:55the order of function goes
- 3:57from t2 into t1 but
- 4:00the point is i think this should be copy
- 4:01not move my point of all of this is that
- 4:04it's easier to say move than is to say
- 4:07at
- 4:07i t 1 t 2 0.
- 4:10yeah that works too i get it t 2 plus
- 4:13the
- 4:13immediate zero goes into t1 therefore t1
- 4:16gets the value of t2
- 4:18so i could always be thinking at eyes
- 4:20but isn't it easier just to write move
- 4:22so we've added say we mean the assembler
- 4:24community have added
- 4:25pseudo instructions to make it easier to
- 4:27write risk five assembly code that's
- 4:29been true for all the assemblers that
- 4:30i've been
- 4:31you know familiar with uh mips risk
- 4:34all of these allows for you to have
- 4:37these pseudo instructions which just
- 4:38make it easier to write in that assembly
- 4:40level
- 4:40okay that's it so again the compiler
- 4:43takes.c code
- 4:44produces.s assembler code that that s
- 4:47file could contain
- 4:48by the way that could also be hand
- 4:49authored compiler or you
- 4:51hand author at the end of the day you've
- 4:52got s code and that could contain
- 4:55pseudo-instructions and these sort of
- 4:56pseudo-instructions just make it easier
- 4:58to write that assembler all right
- 4:59see the next lecture we learned about
- 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.