[CS61C FA20] Lecture 09.2 - RISC-V Decisions II: A Bit About Machine Program — Transcript
Full transcript
- 0:00[Music]
- 0:09welcome back
- 0:10we're still talking about 365 assembly
- 0:13language but we're going to take
- 0:14a bit of a detour to see what is
- 0:16happening with that assembly program
- 0:18once it is written so say that we have
- 0:22two pieces of assembly code food.s and
- 0:24bar.tests which are our assembler source
- 0:27files which are written in plain text
- 0:30we're going to pass them through the
- 0:32assembler which will produce machine
- 0:35code object files
- 0:37food.o and bar.toe
- 0:41those are you know those er ex
- 0:44extensions dot o stand for the object
- 0:48files
- 0:49we may have uh pre-built object file
- 0:51libraries like lib.o
- 0:53that may contain some commonly used
- 0:55functions like for example a
- 0:57division linker will take our object
- 1:00files
- 1:01and the library files and link them
- 1:04together
- 1:05now what is linking them together will
- 1:08place the addresses in appropriate
- 1:09spaces
- 1:10and put everything together such that it
- 1:12looks like one
- 1:13piece of a program the output is a dot
- 1:16out
- 1:16which is machine code executable file so
- 1:19where does that machine code executable
- 1:21file
- 1:22live it is not small enough
- 1:25to fit in the register so therefore it
- 1:27has to live in the memory
- 1:29remember our memory is big and cons
- 1:32is byte addressable however these bytes
- 1:35are put together to form
- 1:3732-bit words we'll have a section of
- 1:40memory where the data will live
- 1:43and then there will be a section of a
- 1:45memory where the program will
- 1:47all reside those are typically
- 1:52kept separate from each other with an
- 1:54exception in 61c
- 1:56exams where data tends to run
- 2:00on top of a program and causes
- 2:02interesting effects over there
- 2:04but in practice that usually doesn't
- 2:06happen so
- 2:08we got a pretty good idea of how does
- 2:10the program look like now
- 2:12it is essentially a sequence of bricks
- 2:14five instructions
- 2:15where each of these five instruction
- 2:17instructions is
- 2:1832 bits wide and we will be executing
- 2:22them
- 2:23typically in order until we run into
- 2:26one of those that corresponds to a
- 2:27branch or a jump
- 2:29and then we are going to perhaps jump to
- 2:32another
- 2:32place in memory to a different address
- 2:35in memory
- 2:36what does the processor do with this
- 2:38program
- 2:40well this is a picture that we hopefully
- 2:43have
- 2:44have had tattooed already
- 2:48so our processor to the left has
- 2:51a control unit and a data path and then
- 2:54memory is to the right
- 2:57inside the processor inside the data
- 3:00path there is one very special register
- 3:03which is called the program counter
- 3:05product counter
- 3:06is internal to the processor and it
- 3:09holds the byte address of the next
- 3:11instruction that is going to be executed
- 3:15so it is something that is really
- 3:17important
- 3:18a control unit is going to use the
- 3:21program counter
- 3:22to producing the to fetch the
- 3:25instruction
- 3:26from the memory take a look at what is
- 3:28that instruction
- 3:29and execute it by using the data path
- 3:32and the memory system and then
- 3:36we'll update the program counter to
- 3:39point to the next instruction that is
- 3:40going to be executed
- 3:42most commonly that will be the next
- 3:44instruction in sequence
- 3:46but sometimes it may be a branch the
- 3:48next instruction in sequence
- 3:50is four bytes away you have to keep that
- 3:52in mind
- 3:53it is one word away but that is four
- 3:56bytes
- 3:57so in order to point to the next address
- 4:00we need to increment the program counter
- 4:03by
- 4:03four bytes or to load
- 4:06into a program counter a new address
- 4:09if it is a branch
- 4:13hopefully you get now a reasonable
- 4:15picture
- 4:16of how does the processor execute the
- 4:18program it may be
- 4:19helpful understanding what comes next
- 4:24in the meantime a few other interesting
- 4:27things that will help us or helpful
- 4:28things that will
- 4:29help us understand how to um
- 4:32work through the functions later on um
- 4:36first there are there is something there
- 4:39called
- 4:39symbolic register names there are 32
- 4:43registers in risk 5 architecture
- 4:45the first one is reserved to to be a
- 4:47zero but the
- 4:49other 31 are assignable but some of them
- 4:52are going to have very special purposes
- 4:54and it will be kind of hard to remember
- 4:56which one does which out of 31 of them
- 4:59so we give them
- 5:00symbolic names for example
- 5:03physical registers x10 to x17
- 5:08are have symbolic names a to a zero to a
- 5:11seven
- 5:12for argument registers for function
- 5:15calls
- 5:16or zero is spelled out as a
- 5:20as a symbolic name for a register x
- 5:23naught
- 5:26there is another useful thing which are
- 5:29pseudo instructions
- 5:30remember risk 5 does not have
- 5:35many instructions and some of them you
- 5:38know look
- 5:39fairly cryptic although you know we can
- 5:41do things in just a simple
- 5:42one instruction it looks cryptic for
- 5:44example if we want to copy a value of
- 5:46one
- 5:47register to another we have to do
- 5:50add immediate this of
- 5:54a source to a destination register with
- 5:57an immediate value of zero other
- 6:00processors may have an instruction
- 6:02move so in this case
- 6:05move instruction is a symbolic
- 6:07instruction that corresponds to add
- 6:09immediate with a zero
- 6:11so move the destination register source
- 6:14register
- 6:15is the same as add immediate destination
- 6:18register source register zero
- 6:19it copies the the contents of a source
- 6:22register
- 6:23to the destination register the other
- 6:25one that is
- 6:26also that will find user useful is
- 6:29load immediate although it does not work
- 6:31with the memory it simply
- 6:33loads an immediate value into a register
- 6:37if it is a short immediate that can fit
- 6:40as
- 6:43as an argument of an ad immediate and
- 6:48finally
- 6:48a common instruction that we will run
- 6:52frequently in in the code is no
- 6:54operation or it stands as not
- 6:56that's when processor needs to wait for
- 6:58something for example for a datum to
- 6:59come from the memory
- 7:01it is spinning around and doing nothing
- 7:02that's a knob well
- 7:04knob is anything that uses x0 as the
- 7:07destination register
- 7:08so x0x0 add the mediatek 0x00
- 7:13is a good knob
- 7:17these instructions don't change anything
- 7:19in the way how they're being
- 7:21executed they just make the code
- 7:24more readable so instead of trying to
- 7:26figure out what
- 7:27does add immediate our destination our
- 7:29source zero do
- 7:31we just write a move that's it for now
- 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.