‫Hello and welcome, everybody, and this lecture we're going to make use a program, talk with the colonel
‫command that we created in the last lecture.
‫So before we do that, there was a slight bug I noticed.
‫So I'm going to tell you guys that now and we'll fix it so we don't run into any problems.
‫Just go to Colonel Diesem.
‫You'll see that we've set the colonel registers here to decimal ten.
‫It's supposed to be hexadecimal 10.
‫So if you keep that as decimal ten, there's going to be an exception thrown and the entire pantalla
‫will be invoked to for us to handle that error.
‫We don't want that.
‫Right.
‫So make sure that six, 10 and not decimal 10 in the kernel registers.
‫OK, once you've done that, scroll up.
‫We're going to go to our Blank Toryism program and get rid of the label and we're going to make an infinite
‫jump to itself so it will constantly jump on itself now.
‫OK, making this program never end and we're just going to go.
‫Movistar zero in it.
‫Zaydi So why it why are we moving Ziu into the X register?
‫Because remember, X is used for commands, for command codes to tell the colonel which command we want
‫to run.
‫And zero is the one that we bind it here.
‫If you go to ISO DH, we binded command zero.
‫So this Isaw LDH command zero sum function.
‫So what'll happen is now we use the language will invoke the colonel, which will invoke this and return
‫zero to us.
‫OK, now don't forget, use the land is ring three.
‫So if we try to do any colonel stuff in here, it's going to panic the system.
‫We can't use any hardware instructions, anything like that.
‫We can invoke the colonel, which will put the processor back into a restricted state.
‫OK, so we're now going to try this.
‫So we're going to go make clean bill to the S.H..
‫And we're going to ask Kevin GDB to launch the debugger at Simbel File builds kind of the Xbox One one,
‫two, three, four, five, five zeros.
‫And yes, we do want them to add the symbol table.
‫And now we're just going to go break askaris you x 400000.
‫So four, one, two, three, four, five, hexadecimal 400000.
‫This address we want to break on Y because that's the entry point for user programs.
‫We want to break one way and use a line right when we're running the process so we can debug the process
‫to make sure it works properly.
‫So now we're going to go target remote and we're going to pipe that to Kumu.
‫OK.
‫So it needs to be exactly like this guy's enter and now we just proceed to continue.
‫Now we've just broken on the USA program.
‫Now that we're running an address here, 400000, we're going to go lay ITSM, which will show us an
‫assembly view.
‫OK, so we just we can go step through this, which will run its construction press, enter to run the
‫last instruction, which is step by in this case.
‫And you can see we now been taken to our assembly and SREP handler and just press enter again, press
‫enter and then present.
‫And now here we now see function.
‫Izadi Handler.
‫That's a key function.
‫So just go layout prev, which will take us to the previous layer, which is the code view.
‫And now we can just go next, next, next.
‫So we can see where in the kernel page now type next again.
‫So the tasks, the task state is now safe.
‫So if we was to go print's task current and well print asterisk task current I should say you can see
‫that print out all the registers for us.
‫We can see everything is is saved.
‫Essentially the task now contains everything that was saved to the stack when the insured was invoked.
‫So all of the registers of that time, the base points the IP of the task, basically where the program
‫is running in memory, where it's currently paused, all of that is saved.
‫So by setting the process back to all those registers, we essentially caused the program to run again
‫so that it's that simple.
‫That's why we saved the state, so that if we ever were to implement multitasking, we could easily
‫flip between the different registers changing which programs running.
‫And if we do this fast enough, it gives the illusion of multitasking, even if we're only using one
‫process, a call.
‫So, OK, now I've showed you that on line one, two, three here.
‫We're just going to step back just to step, not step by step, instruction to step.
‫And now we're going to go next and we can see we're in the ISI, the handle command function now.
‫So we can see here that it has the command function, if we go print, come on funk, you can see that
‫points to ISIS command zero sum.
‫So all we do now is we do step.
‫And look at that, colonel is now running command zero, and that's about to return zero to just to
‫step again, OK, and adjust your step and now we're setting the task page again.
‫So we're just going to go next this time.
‫So now we switch the page directory back to points back so that it points to the tasks page tables,
‫not the colonels.
‫OK, and now it's going to return the results.
‫So we're going to go back to the assembly view now.
‫So we're going to go layout as we're going to go step by, step by step by.
‫And now we're back in the assembly handle by here.
‫Let me show you we're back in this handle now, the assembly version, and we're just going to step
‫through that.
‫So we're going to step by step by step II.
‫And this is now restoring from the temp respirable back into the reg.
‫Just so we're going to step by and I finally I rhett's, which takes us back to the user program to
‫the infinite jump.
‫And I if we print X we see the result zero.
‫So that worked guys.
‫That was exactly what we wanted.
‫Now obviously that doesn't do much.
‫Let's make it actually some.
‫But in order to do that we need to access the tasks stack.
‫So that will be in the next lecture.