‫Hello and welcome.
‫And in this lecture, we are going to implement get key.
‫Now, if we just take a look at iodized see, you will see that we've already made a get key colonel
‫command.
‫So all that we need to do is invoke the colonel, like we did a couple lectures ago, will basically
‫invoke the get key command on the colonel.
‫And that will be that that will be the communication, much like we did with the printer in assembly.
‫So what we're going to do then, we're going to create a get killable in assembly and this will be our
‫key function.
‫So we will return an integer and it will take no arguments.
‫So it will look like that.
‫OK, and we're going to push the base point up up the base point.
‫We're going to return and move the stack point to the base pointer and then we're going to set the command
‫to to which, as we know, is that key.
‫We're going to invoke the colonel and after the colonel has been invoked, the register will contain
‫the key that was pressed.
‫And because of the way C compiles into assembly, if the return type in C can fit into four bytes,
‫then it uses the register to return that result.
‫So if you were to disassemble a C function that looked like that, OK, and you returned five or whatever
‫you would see in the disassembly that the X register gets sent to five.
‫OK, so C programmers expect the x rays to continue to contain the return results essentially.
‫OK, so we know in and 680 will set that X register to the return result for us.
‫So we're absolutely happy with that.
‫So, OK, let's go to our start and we're going to just create the prototype and it key, OK?
‫And now if we go to Lanctot C and just by here we're going to say, well, one, I'll tell you inside
‫I will loop.
‫Actually, we're going to say if get key does not equal zero, then print key was pressed, OK?
‫And that's what we're going to do here today.
‫So if we now build the whole thing, we do make clean Belltrees Hajj.
‫And we can see and define reference to get key, that's no problem, go back to us.
‫We just need to make it global like we did here.
‫So global get key function like that, OK?
‫We go back and we build.
‫We can see everything works fine.
‫And we're going to go seed bin Kumu and I'll press the key and you can see he was pressed.
‫So congratulations.
‫We have now ported to get key function into the standard library.