‫Hello and welcome.
‫And in this lecture, we're going to take a blanket RASM program, we're going to turn it into a sea
‫program, and we're also going to create a start library that is responsible for calling our sea our
‫sea main function, essentially, OK, because we can't have the main function as the entry point because,
‫well, if you if you look at the disassembly, it just doesn't work properly.
‫OK, you know, the main function expects and Agfa and things like that.
‫Right.
‫We need a stop routine in assembly that calls the main function.
‫OK, that's how it should be done.
‫So what we're going to do then we're going to go to our programs here blank and we're going to create
‫a new file called Blank Tazi.
‫And this is just going to have a main function.
‫And all this is going to do is return zero.
‫This is a program, it's as simple as that.
‫So I want you to write that and then we're going to compile this file.
‫OK, so let's go to our Col's makefile, because there's going to be things in here that we care about.
‫Just copy and paste, any command, anything, anyone.
‫It doesn't matter which one and go back to blank dot.
‫Well, the blank program, I was just going to paste that in here just like that.
‫OK, and we can get rid of the includes there.
‫We don't care about that.
‫We can make the include here to the local directory only and we want to just compile a blank tazi into
‫blank Dotto and we can get rid of the old Nazeem thing up here as well.
‫I can go now for the time being and yeah, that looks okay to me.
‫Let's just make clean that and build that SHC if everything Keppel's.
‫And you can see here, no input files, OK, that's because this command here needs to be above this
‫one, OK?
‫Because we need to compile it above that one and then we'll link it down here.
‫So now run, run, build the research again.
‫I can see that compiles absolutely fine now.
‫No problem.
‫OK, so you can see from where we compiled it, it says undefined start symbol default into 06 400000.
‫The start symbol will be written in assembly and it will be in charge of calling our main function.
‫OK, so we'll make that later.
‫Let's just clean this makefile up a bit first.
‫OK, so we're going to have includes equals this the very first thing.
‫And just above here we're going to have philes equals and we're going to go build Lanctot.
‫Oh, OK.
‫Now we're now going to take this command blank tauto and we're just going to go build blank dotto top
‫forward slash blank dot c OK.
‫And now we're just going to paste that in there.
‫Makes you put a space by there as well.
‫Keep it clean and we're going to go Dashi.
‫No, not Dashi.
‫We're going to go includes like this.
‫OK, and then that'll include our includes here so that our compiler blanked out C to blank todo and
‫all command should depend on files.
‫OK, so that's perfect.
‫And we can just delete here all of the object files and then finally we'll delete the blank file.
‫OK, so if we now try to compile that make clean builder S.H..
‫We can see that Kampala's absolutely fine, even with our blanket at sea fowl.
‫OK, so that's all perfect.
‫And if we go into programs and we go into the blank and then we go read of Dash a blank drouth, you'll
‫see our main symbol here, our main function.
‫Okay.
‫So we can see that that was compiled and linked successfully and that because it's in the symbol table.
‫OK, perfect.
‫Now go to blank Dadaism and we're going to rename this to Start Diesem, OK?
‫And we will be moving this fall once once we're done with this routine.
‫Now get rid of all of this stuff because we don't need it anymore.
‫We need section doraiswamy, however, and we're just going to make our start label now.
‫So all of our star label will do is it?
‫We'll call the main function and return.
‫That's all it will do for now.
‫OK, and we're going to go global.
‫Uh, start extern main OK.
‫And that's all our little star routine will do now it will just call the main function.
‫OK, you can push arguments here if you want.
‫So we push here and there's aragvi, we pushier.
‫There's a proxy.
‫OK, so yeah we can do that if you wanted as well.
‫However, we'll just call the main function for now.
‫We're not going to focus on passing any arguments to the top.
‫So back to Makefile then we're going to go build start up.
‫Oh and we're going to go build start Dotto.
‫Uh, start today.
‫Awesome.
‫OK, get rid of the extra kolon there and here we're going to go Nazeem F lf, uh, start today.
‫Is that show start Dotto.
‫OK, well build build start although I should say.
‫OK, so now if we now compile that again with make clean builder S.H..
‫We can see that compiles perfectly fine and we can still see it's complaining about the no start symbol.
‫That's because during the linkage here, we're still only providing blanket, although this can be removed
‫now and we can just pass in files, OK?
‫And that will ensure that that gets replaced with both object files here at the top.
‫So that's our link.
‫Come and remember where we're linking it with the link scripts to build again, and we can now see that
‫it linked them successfully.
‫OK, and if you wanted to go see these programs redials
‫dash a blank dot.
‫Lf you can now see both the start symbol and the function.
‫OK, and if we scroll up, we can see that the entry point address is now zero x 400 1000, OK, so
‫that's why in persistance C, we have to care about the entry point because there's no guarantee it's
‫going to be at zero x 400000, OK.
‫That's why the entry point is specified in the file.
‫OK, so yeah, we can, we can carry on now and we can make a new program while the program dependancy,
‫I should say, called Stanlib, and that will contain our start routine along with other stuff like
‫some string routines, basically everything in the C standard library plus our own little stuff for
‫communicating with our with our colonel.
‫OK, so just in programs, we're going to create a new folder and we're going to call this STD lab.
‫OK, we're going to click and drag stop diesem to STD lab.
‫So so moves it.
‫OK, we're going to just go and then delete the object file, start Dotto And now in here we're going
‫to create a new makefile, we're going to create a build directory.
‫And you could make Soss directory here if you wanted as well.
‫But we're not going to worry too much about that right now.
‫You guys understand what's going on.
‫It's no problem.
‫We're going to remove this label we created here for stop and remove the dependency at the top as well,
‫guys.
‫OK, now we're going to go to the Makefile.
‫We're going to paste that in, OK?
‫The one that we just remove, we're going to paste that in.
‫So it looks like that.
‫And now we're going to just create the source directory instead.
‫So it's clean and we're going to click and drag start Dadaism in the.
‫OK, and now obviously we're compiling saw Saturday.
‫OK.
‫Perfect.
‫Now go back to the Makefile in the blank program, we're going to copy and paste the top here files
‫it includes.
‫And just copy and paste that back, because it's very much the same, you know, we're going to change
‫this to start tomorrow and we're going to go back to the Makefile and I copy and paste the clean label
‫here just like that.
‫And we're going to remove the file, which we haven't created yet, when I were going to create an all
‫command here, which will which will depend on all the object files.
‫And then we're going to go ice six, eight, six f load elde, I should say dash m lf I threw eight
‫six relocate.
‫Abo Relocatable and we're going to compile the files, we'll link the files, I should say, and then
‫we're going to output's to start out.
‫So we're creating a relocatable file.
‫And the reason we're doing that is, is because state tourism relies on Maine.
‫However, Maine doesn't exist yet.
‫You know, when we compare Lesce live, we don't know where Maine is.
‫All of the programs are going to link with our S.G. live to el-Fadl.
‫So by setting it is relocatable, it kind of acts like a static library type of thing, OK?
‫So it will be linked one blank one.
‫Our blank program links links itself.
‫It will link with S.G. liberals resolving those symbols during link time.
‫OK, so then the final file has everything it needs.
‫Now let's just go to the main make by here and we're going to scroll down and just use the programs.
‫We're going to build the actual S.G. lab.
‫And that should be at the very top guys, because obviously all the programs depend on a steady lab.
‫OK, just copy and paste the commands and just change them, you know?
‫So we're going to make clean the study lab and make all the study lab.
‫And that's just make clean here.
‫And you'll see no cannot remove the live that doesn't exist.
‫That's fine.
‫Just build LSH.
‫And we can see that has compiled them all successfully, we can see that we see our error again, that
‫we can make this go away right now, just go to the make follow the blank program.
‫And all that we need to do is link with our estie lived out our fall.
‫So just by here, we're going to go forward, slash AEG Live city leapt out of so that we'll link with
‫blank, which is specified in the files, and AEG Live dot elf.
‫OK, and wanted links to that still lived out.
‫Elphick resolves that dependency for the start symbol.
‫So let's try that again.
‫We're going to go build the research and we can see that that now works as expected.
‫And if we was to go see these programs, CD blank, read OAuth dash a blank dot.
‫Lf we can see that it has our start symbol and our function, so we can see that it's it's linked successfully
‫with AEG Live.
‫Gelfond combined the all of the symbols to produce blank.
‫So OK, we've successfully abstracted that out.
‫Let's test our C program and see if it works as expected.
‫So we're just going to go and do make clean build that, S.H..
‫CD Ben GDB Brake asked Chris Cox for one, two, three, four, five, OK, Target remote kumu.
‫System high three eight six oh stop being Dash s, capital S. That's GDB studio press enter.
‫And you'll see that it's done that again, sometimes that happens when that happens.
‫Just try it again until it's gone.
‫OK, there we are.
‫See to continue now.
‫We're going to go lay out assume OK, so we can see our C programming memory while it's compiled version.
‫So we can see you push the base point.
‫We move the stack point to the base point, we move zero to X, which is how you return instead of sized
‫values.
‫And see you just set the X register.
‫Well, that's what the C compiler does and then we pop the base point in return.
‫Now, if we just go step by step by step by step onto return, we can see the next instruction.
‫Xerox Fondren, one thousand five.
‫OK, now, if we can stop that, I assume that is the right instruction on line ten here.
‫OK, so let's create a new window here, terminal window.
‫And I'm going to explain this to you.
‫We're going to go see these programs, CD blank and we're going to go down pelf note and read f dash
‫a blank.
‫And what do we see here?
‫The start symbol is on Xerox Fondren 1000.
‫The main function is on Xerox 400000.
‫So because we broke on Xerox 400000, that's why we saw the main the main function compiled and not
‫the star symbol.
‫OK, because that's on Xerox Fonua one thousand.
‫So, yeah, we can see we've debug the program.
‫We confirmed that this works as expected.
‫So going forward we would write up Lanctot C program in complete C code and we would call functions
‫in the lab so we might make some assembly functions here and talk, talk to them in C essentially.
‫OK, so, you know, it's pretty handy.
‫So now we're ready to start writing programs and see congratulations.