‫Hello, everybody.
‫We assume to implement printf you all know what printf is obviously, however, printf relies on a few
‫other functions.
‫It relies on functions for processing float's, which we're going to ignore for now, and it relies
‫on functions for processing images which we won't ignore.
‫And we're making that in this lecture.
‫We're making the it's a function which will take an integer and returns a string equivalent of that
‫integer.
‫So this function is a little tricky to write.
‫So just copy what I'm doing.
‫And if you really want to try to understand it, you can pause the video and go through it slowly,
‫although you don't really need to worry about understanding it because it's not really a part of our
‫operating system development, really.
‫OK, so what I want us to do is, is I want us to go to, uh, actually laptop, see, and we're going
‫to create the eye to a function.
‫So just go chaar it toet and that's going to accept an integer value.
‫And I we're going to have a static char text variable.
‫Now here's a question for you.
‫Is this variable on the stack or in global data?
‫If you said on the stack, you're wrong because we put the static keyword here.
‫This data is not declared on the stack and this data will be exactly the same.
‫Every time someone calls this function, it doesn't change and it's not on the stack, which means we
‫can safely return the address of this and it can be accessed through the functions.
‫No big deal.
‫OK, so now that you know that we can continue, so we're going to go in it.
‫Lock equals 11 and now we're going to go text lock.
‫No, no, no.
‫Text 11 equals zero.
‫Char neg equals one.
‫If I above all equals zero.
‫Then egg equals zero equals minus I OK, and then we're going to say, well, I.
‫Text minus minus log equals Charr zero, minus I, modulars ten, and then we're going to go, I divide
‫or equal ten, I mean divide equal ten.
‫So it'll basically take I and divide it by ten.
‫OK, and so the result now and then we're going to say if luck is equal to 11, text minus minus Locke
‫equals zero.
‫If neg then text minus minus Locke equals minus.
‫And then we're just going to return the address of text location.
‫And this should give us the any number we pass in here as a string.
‫OK, now this same text variable here is used every time you call it a function.
‫So you will obviously have to copy that into another buffer if you plan to call this function multiple
‫times.
‫Just something to point out.
‫OK, so we're going to copy and paste the Etowah function into S.G. Liberdade Hajjaj just like that.
‫So we're now ready to test it here as a function.
‫Just go to blank, Tazi and just under the print.
‫Hello, how are you?
‫We're just going to go print it away and we're just going to just type in a number eight, seven, six,
‫three.
‫Why not?
‫And we're going to compile that top build that S.H. and then we're going to run it.
‫Kumu.
‫And there we are.
‫Hello, hello, how are you?
‫Eight, seven, six, three.
‫So there we go.
‫We can now get numbers, essentially, which is really handy and a very important step towards implementing
‫print F our print F will be fairly basic guys.
‫It'll print strings and encourages.
‫We don't need to go over the top and print our hexadecimal floats because that's kind of a little outside
‫the OS.
‫Dev, you know, I want to keep it on topic.
‫Obviously, if you want to implement hexadecimal floats later on in our print, our function, we're
‫going to make you could take the skills you've learned when we implement print F and apply those to
‫be able to print hexadecimal and also floats.
‫So thanks so much for watching this lecture.
‫You now have the ability to convert integers to strings.
‫Congratulations.