‫Welcome.
‫So now that you've installed Immunity 86, we're going to actually create a hello program, as you always
‫do when you use a new language.
‫So what I wanted to do, I want you to press new buy here and we'll just go with the comtemplate and
‫just press.
‫OK, now you'll see this.
‫And this is a bit confusing, right?
‫For a beginner, essentially, this emulator is kind of running like its own version of MSDOS and it
‫will load the program right here into memory, address one hundred hacks and then it'll start executing
‫from there.
‫So when we do ÓG 100 Hajjaj What we're basically saying here is that the program we're writing now will
‫be loaded into this address and then when we assemble, it helps make sure that we offset correctly.
‫And that's why we have to do this by doing all 100 page.
‫We're telling the assembler we're always going to be loaded into this address and because we're going
‫to be loaded into this address, it should make sure that everything's offset to that address.
‫So that's what that does.
‫It isn't actually an assembly instruction.
‫It just tells the assembly we're going to offset from the this little rat by here means we're returning
‫from a subroutine.
‫Now, essentially, we can get more on this later, but I'll just explain a little bit.
‫The MSDOS calls us when it loads us.
‫And then by doing that, we return Control Domestos.
‫But I'll explain a lot more about how this works later on, because it's a bit confusing to understand,
‫right, for a beginner.
‫So what we're going to do then, we're just going to first output a character to the screen.
‫Just one character, Sasho.
‫How to do that?
‫I want you to go and this is going to be really confusing.
‫You won't get it at all.
‫But just follow what I'm doing because you've got to start somewhere just to move a movie.
‫El-Hage, comma zero.
‫E.H. now press enter and then I want you to do move and a and then finally do integer.
‫I mean, IMT 10.
‫So if we just press emulate at the top here now and you run that and just press one and you'll see that
‫a as I put it to the screen.
‫So if you want to type Halliwell's here, nothing would happen.
‫It would fail.
‫It would not work.
‫So just don't try it and I'll explain why in a minute.
‫Now, this movie means we're moving some data to some memory or to some register of some kind.
‫Now, just briefly explain this, because it'll be explained much more in depth as we go along.
‫Registers are essentially storage units in the processor itself, and they can store like a certain
‫amount of data.
‫For example, a Hadash can store one byte and Alkon store one byte.
‫However, you can reference them both together using X, but more will be explained by that later on.
‫So in the process, we have an eight register here and I will register here and there, basically just
‫one by memory units in the process itself.
‫This is not rame.
‫This is this is in the processor itself.
‫So what we do is we move 063 into A.H. So hexadecimal Zeri into A.H. and then we move the character
‫AI into A-L and remember this.
‫Remember when you, when you do, when you do a quote like this quote a quote, it gets converted to
‫the binary binary equivalent.
‫I says the same as saying decimal sixty five and whatever, whatever the binary equivalent is of decimal
‫sixty five.
‫So now for now for imt imt means interrupt and again here we do 10 hajee.
‫So hopefully if called on by now that the Hajj at the end of here means that we're using hexadecimal.
‫So zero zero zero we you know, hexadecimal zero now IMT 10 Hajj is basically saying let's call interrupting
‫Hajj and.
‫Ten Hajj is basically responsible for outputting to the screen.
‫Now, how this works is we'll explain much more about this later on because there's so much to explain.
‫That's why it's taken me so long to even get through a hello world.
‫But don't worry, you just need to follow this through and you'll understand when we go in t10 Hajj,
‫we're saying calling trip 10 Hajj.
‫Now you register interrupts in memory, but we'll get on to that later on 10.
‫Hajj is a pious routine.
‫So you know you're bias, right?
‫You probably don't know much about it.
‫Right.
‫Because it does a lot more than you realize.
‫The bias has its own kernel that can only be used when you're in something known as real mode, which
‫is a compatibility mode.
‫And basically, when you're when you're when you first put your computer, your computer is in a compatibility
‫mode until until until there's some code that tells it to go go to the go to the modern architecture.
‫So whilst you're in this compatibility mode, you can do you can run all code like 16 bit code for the
‫old internal processes from the 1980s where and that's exactly what we're doing here.
‫This is what Ammu eighty, eighty six.
‫It's it's an old processor.
‫Right.
‫So in the biosphere's kernel, Interop 10, which is responsible for outputting to the screen.
‫So when we go and do interrupt 10 Hajj, it goes in, calls that byas routine and in the BIOS will actually
‫deal with the hardware of getting this on the screen here.
‫And it basically just puts it into video memory.
‫But more on that later, because this is quite a mouthful for a hello.
‫Right.
‫I mean, there is a lot to learn, so I don't expect you to understand all of this straight away.
‫It will take us a while to go through it all.
‫And that's how you pronounce a to the screen.
‫OK, so now let's make a program that outputs Hello World.
‫OK, so what we're going to do to do that, then I want you to go up here at the very top here.
‫I want you to do Main Kolon and we're just going to table this just to make it clear.
‫So Main is a label.
‫This is how you create labels in assembly.
‫You may have the label name and then a column and you can reference labels all throughout your program,
‫essentially in assembly.
‫Everything runs down.
‫Like even if I put some data here, it would start executing that data, like the processor runs down
‫downwards.
‫Right.
‫If you write it like this without using sections and so on, that that's how it works.
‫So what we need to do then here we create main here, which which we're going to use.
‫And at the very top here, I just wanted to say message Kolon DB Hello, world explanation Mark quote.
‫And I want you to do comma zero for the Terminator, right.
‫To end the string.
‫Now if you run this, this isn't going to work very well.
‫Now let me explain why.
‫If you press emulate here and you try to run that, you can see unknown code skipped decimal sixty five
‫now decimal sixty five is the ASCII equivalent of the character.
‫No I think it's a character actually.
‫Now the e it's one of them anyway.
‫The important thing to know is the the emulator has tried to run this data which is a problem.
‫So this is what I mean by that.
‫It runs downwards, it's gone in here.
‫It's MSDOS is loaded up program.
‫It start executing a stage and it's tried to run a message label as actual code.
‫Now, this isn't a variable.
‫Do not make that mistake.
‫When I was first learning assembly, I thought this was a variable.
‫Like writing like this was a variable is not the case.
‫This is no different than our main label.
‫By here, the only thing you need to be focused on is DB.
‫DB here means data bytes and it allows us to specify like allows us to specify a number of characters.
‫Right.
‫So we can say hello world here.
‫And that'll literally be put in memory as Hello World right at one hundred Hageman slowed down.
‫So how do we get around this then.
‫How do we stop it from running our little message here.
‫Well you use something called a jump.
‫You just to jump, man.
‫And if you just press that now, you can see it works as usual again, because what we do is we jump
‫over message here because we jump to the main label.
‫OK, so enough of that.
‫Now we can carry on and make our print routine.
‫So down here just to print, OK?
‫And up here, we're going to go print on the scroll chart.
‫OK, good.
‫So by here than in our print, I want you to move aside message and size.
‫Just another register by the way, but more will be explained on this later.
‫I'm just trying to give you a taste of how it works.
‫Then I want you to go move H zero E.H..
‫All right, cool.
‫Now, what I want you to do is, is I want to just say a lot and then I want you to go copy at zero
‫and I want you to go g dot.
‫Done, OK.
‫And then if done is cold, then we will actually return here.
‫OK, so then I want you to make a new label above here and just call it.
‫To underscore LUB or I guess you don't need to underscore just to yeah, I guess you do actually do
‫an underscore here underscore loop and then we're going to say and the JADOT done, we're going to go
‫jump, jump start, Lou.
‫OK, so let me explain this then.
‫One one print is called We Move our message, the address of our message, I should say, the address
‫of our message where the address because when you reference these labels, it gets the address.
‫Right.
‫That's what it's doing is getting the address.
‫So this would be, what, about one hundred and two hech I think because of all little jump construction,
‫maybe about one hundred and three.
‫I think anyway that that would be the address of message.
‫Right.
‫So we move on to the ESSI register.
‫OK, we move to a church again which remember is a print print character routine and then we go into
‫loopier lot.
‫Espie basically loads the first character from Message and then increments the S I buy here.
‫OK, so what that does is it load the load the bike from the bike from from the message, which is Ilinka
‫and S.I.
‫So then the next time comes around is pointing at E!
‫So make sense.
‫OK, so a lot SB it loads into the register.
‫I should have said that, so it'll read the character and load into the Arrow Register, which is one
‫byte in size.
‫So then we say compare the register to zero if it is zero.
‫Done so then we J.E. means jump.
‫So if at zero jump to done we're done, let's leave.
‫And then here we jump back to our loop to carry on.
‫So all I want you to do here then I want you to say this by here.
‫Copy this, OK, we can get rid of our print shop.
‫And by the way, we won't need that anymore.
‫Just paste that in there and get rid of these two.
‫And that is that that should work fine.
‫So rather than do rather than do this the way I've done this right, you would go call prints.
‫But obviously print print itself specifies the message.
‫So what we'll do instead if we take this out of here and we put that there instead.
‫OK, so what we're now saying is, is move, move message to the ESSI register.
‫And then then when we call print, then it will then move into a register.
‫And Zeray, by the way, is I don't know if I've said this already is the command to the BIOS.
‫So when we call when we call like interrupt ten is for video routines and stuff.
‫Right.
‫So zero is the function number that the bios will look for when we call interrupt.
‫And in this case, zero means to just print one character to the screen.
‫Anyway, let's run that now by pressing when we press run and you can see hello, world outputted,
‫nice and easy.
‫OK, so that's what it looks like.
‫So make sure you get that exactly right.
‫OK, so I understand that you're probably very confused because this is not like high level programming.
‫And when I first started assembly, I, I used to think these were variables like then things like this,
‫as I've said already.
‫But the most important thing about learning assembly is first understanding this one crucial point,
‫and that is the code runs down.
‫Right.
‫It doesn't care if you have data in the way it'll run it.
‫It'll run it unless you're unless you're compiling with sections and stuff.
‫But doing it like this, that's how it works.
‫So without this Jumpman, the the process, it will come in and it will try to execute Hech as an instruction
‫and then they'll try to execute E as an instruction.
‫All right.
‫By putting the jump there, this will jump to Main down here, skipping over our data, skipping over
‫our print function, because this is all in order, by the way, all of it is in order.
‫And then when we call here, then we can just move the message to the SC, register the address of the
‫message, not the message itself, the address in memory, which is like one hundred and three h.
‫I think based on the look of this and then we Kokorin, it'll jump up here, it'll output our message.
‫What it's done, we call Recht, which puts us on line twenty five here because we return back back
‫to the collar of the subroutine.
‫Right.
‫And then finally we call Rec which passes control back to MSDOS, which ends our program because I know,
‫I know you probably really confused.
‫Probably makes no sense at all.
‫But don't worry, this is the hello world, right.
‫When you understand this you will do anything.
‫So in the following lectures, we're going to discuss a lot of these individual components in depth.
‫And I'll be using the Hello World as a reference to try and explain that how it applies to this hello
‫program as we go along.
‫So by the end of the course, you'll definitely understand this Hello World Program and you'll probably
‫be able to do a lot more with assembly.
‫You'll understand how it all works internally.
‫OK, so thanks for watching.