‫Hello and welcome.
‫And in this lecture, we are going to actually read from the desk, so before we continue any further,
‫it's about time we make a makefile, I think, which will automatically build our project for us to
‫just create a new file and call it makefile.
‫It needs to be spelt exactly like this capital and the rest, lowercase makefile.
‫And make just allow us to automate the build process of projects, so make is a language in itself.
‫So if you get lost, you're going to have to read a little bit about make online, because this is an
‫operating system.
‫Development costs, not a makefile course, but I'll try to explain it as I go along the best I can.
‫So we're not going to take full advantage of the makefile in this lecture.
‫We're just going to write something fairly simple and basic.
‫So we're just going to go all Kolon.
‫And you need to make sure that your editor has tabs enabled not not houseless spaces, because the make
‫language requires that if you use in visual studio code, then it will know that a makefile uses Tab's
‫instead of spaces.
‫So you can just press tab once.
‫So now here we're just going to go Nazeem Dash have been bootlace dash boot up and right.
‫And we'll put forward sashayed to.
‫OK, so this is very simple makefile.
‫We're not even using rules or anything because we don't need to yet.
‫So let's go up to here and open the terminal in the project folder and just type make.
‫And it'll ask you to install it because we don't have it in this case, so we're going to go pseudo
‫apte and still make.
‫And then they will install.
‫And then we're just going to make and there we go, it's now run this command by default, make fast.
‫We run the first labor, they see all is the label.
‫OK, so we're going to create a text file here.
‫We're going to go to new file and we're just going to call it message.
‫Text.
‫We're just going to type.
‫Hello world.
‫This is my awesome message.
‫Now, if we go back to the Makefile, we're just going to go d f equals dark forward slash message.
‫Dot text.
‫And then we're just going to do these two hours here.
‫Top forward slash boot pin, and we now need to install the Blessed Hex editor.
‫So just go pseudo apte, install Blash and I've already got it, but just go through the prompts and
‫we're now just going to go make.
‫OK, so now go Blair.
‫Step forward.
‫Slash Boot Dobbyn.
‫And this is the machine code for our program, OK, for our bootloader, and you can see our little
‫message at the start of the second sector because remember I said the desk, everything is sectors right
‫when we run.
‫But I've been on an emulator.
‫It sees that file as a hard disk.
‫It is literally a she thinks is a hard disk, is a virtual machine.
‫So it treats this as a hard disk.
‫So on our second sector, we can see our message.
‫So I think you've gathered ball about to do now we're going to load the second sector and print out
‫whatever the message was on the second sector.
‫However, we will fail to load this because the second sector isn't 512 bytes.
‫So we're going to have to do something about that.
‫So close this we're going to go back to the makefile.
‫We're going to go F equals def zero and we're going to do the two hour, two hours again.
‫Talk forward slash boot Dobbyn.
‫But now this time we need to set up some arguments here.
‫So we're going to go back six, five, 12 count equals one.
‫So that'll write one sector just after our message.
‫So obviously, the utility here is responsible for reading all of this stuff in and then we use the
‫to write ours here to pipe it out to the file to append it, because, remember, Butterbean is actually
‫a hard disk of virtual hard disk.
‫So we go back, which I make again, we reopen the file with Blash and there we go.
‫We can see now that there's an extra sector just after our message.
‫Perfect.
‫OK, so we're ready to start writing the code, the loads this sector.
‫So let me go to Firefox and I'm going to go to Ralph Brown's Interop list just to show you guys this
‫stuff so you understand it yourselves.
‫I click interrupt, we're going to go for 13 because that's for hard disk operations.
‫Read sectors into memory.
‫So this is the one we want.
‫OK, so this is what it expects, it expects the age register to have the number to the register, to
‫have the number of sectors to read.
‫She hates to be the low a bit to the center, no S.L to be the sector.
‫No, because this is C for reading, we're reading it as C, E, C, the previous lecture, if you understand
‫what I mean.
‫And the high two bits of the cash register are the high two bits of the cylinder.
‫We're not going to worry about all that stuff.
‫We're not going to stay on C too long because it gets complicated and you know, it is the old way of
‫doing things.
‫So the D is the head.
‫No, these the registers, remember, and DL is the drive number.
‫Now an important note that I need to let you know when the bias loads our boot sector, the DL register
‫is already set to the drive number automatically, so we don't need to set this.
‫It automatically gets set to the drive that were booting from surfable from hard.
‫This one it'll choose that disk from Hardisty will choose that disk.
‫Now modern Bias's have USB emulation and that's the reason why we were able to boot from a USB stick.
‫Bear in mind not all computers support USB emulation.
‫OK, so the data is read into the extra segment and B explain the offset.
‫So obviously it'll be the extra segment multiplied by sixteen plus B X and that's where our data will
‫be loaded to.
‫And then the carry flag is said if there was an error.
‫OK, and the CLARKIE flag is clear if it was successful, so that's all we really need to know.
‫So what I like to do then when I'm doing these things, I copy this.
‫OK, and then I just got about Diesem, and I just paste it in where I'm about to write the code.
‫So first things first before we go any further, let's just remove these intercepts we made last time
‫just to keep the code a bit cleaner so you don't get confused.
‫Make sure to remove the interrupts properly.
‫And we can also remove this printing of the message as well.
‫And scroll down and we're going to remove the message itself to just keep things nice and clean control
‫as to safe.
‫OK, so I'm just going to paste that here just so they just so we can see see it nice and easily as
‫we write this code.
‫So just after we re-enable the interrupts, then we're going to go move ahead to move A-L one because
‫we're reading one sector.
‫OK, um, selling the number can be zero.
‫OK, so the sector number can be two, because we want to reach sector two, they start at one four
‫six, right.
‫This isn't LBA and our head number can be zero and we don't need to set because it's already set up
‫for us.
‫OK, so we need to make a label for our Buffa.
‫We can see the extra segment already points to zero seven zero.
‫So that's good news.
‫OK, so we're going to need a place to load this.
‫So if you just scroll down here, just after about six year, we're going to create another label and
‫we're just going to call it Buffa and we're not going to set anything here, OK?
‫We're just going to use it and we're going to write to it.
‫OK, so that ensure it doesn't overwrite any of our code at all.
‫So now, just by here, we're going to say.
‫Error message.
‫DDB failed to load.
‫Sector, OK, now we can issue and in it 06 13 now, which will invoke the recommend and just before
‫we do that, we need to set backs, remember to the buffer.
‫OK, so I want you to imagine this in memory right now, OK?
‫The bias has only loaded one sector.
‫OK, so if I did something like this hello, we would never, ever even be loaded.
‫OK, you need to realize this is important.
‫However, we can reference it with a label.
‫OK, so then if we reference this, it will reference just past our boot sector.
‫So it will actually write.
‫To address.
‫Seven zero zero if we reference Buffa.
‫OK, just because it's not loaded doesn't mean that the assembly can't reference it as if it was going
‫to be loaded.
‫So that's how we're able to use this in this position as long as we don't bring data into it like this
‫and expect that day to be there.
‫It is absolutely fine.
‫OK, so what we're now going to do is we're going to go and create a new label error.
‫OK, and what I'll do is we'll move essi error message, call friends, OK?
‫And that was if there was an error.
‫OK, and then if everything went fine, we're just going to do a jump by here, OK, Infonet jump.
‫So here we're going to go.
‫Jayce, Jim Carrey.
‫So Jim Carrey error.
‫OK, so if the carry flags said, it'll jump to the error label and print the error message and then
‫do an infinite jump where it is in its current position.
‫Otherwise we won't see any error message and it will just do nothing.
‫And that's how we know it's loaded.
‫So let's test this and we're going to go make.
‫Oh, one thing you need to get rid of this data that I put here, because it is not assembly language
‫and we're going to go make there we go.
‫And then we're going to go Kumu.
‫And we can see nothing, which is great news images, Lodrick successfully secure Kumu dash system Dash
‫86 and Disco 64 and then, you know, just to that command call.
‫All right.
‫So we did successfully loaded.
‫So now less output.
‫The message suggestions are Jazeera, we're going to go move aside, Baffour, call Prince.
‫And now if we save that and we do make again run Kumu.
‫Hello, world.
‫This is my awesome message.
‫Well done.
‫You just did it.
‫Well done.
‫And we go to the message texte.
‫We can change this to whatever we want so we can say I change the message because remember, text files
‫are now terminated.
‫Um, which is why it stops of the null terminated because our little print routine we did in the Hallowell
‫tutorial checks for that.
‫Right.
‫So we go back to the terminal now, make Kumu.
‫I change the message.
‫So welldone guys.
‫So that's how you lo from hard disks when you're writing Col's.
‫There's no such thing as files, it's just blocks of data called sectors.
‫It's exactly the same if you want to write right.
‫In sectors, you don't say, I want to write one byte opposition five eight seven two.
‫No, no, no.
‫You write in sectors.
‫That's how it works.