13 hours 15 minutes
Hello. This is Dr Miller, and this is Episode 12.4 of Assembly.
Today, we're going to give a floating point Example.
So what's our problem? To be solved. So we're going to read it radius from the user, and then we'll go ahead and calculate and print the area. And what we'll do is we'll end up using neon instructions for that.
So I already got the project set up.
So we're gonna have a couple of messages here,
so it'll ask them entered, uh,
We will have to scan the number from the user, so used percent f
and I will print off our result
I will put a new line in here, so it's nice for the user. So up here, we won't put a new line because usual type something and then the light enter. So we might as well make it look nice.
And they will declare a variable. So we'll declare pie
and I dont be three.
That will be
359 So I'm gonna use a double here, so we get a little bit more accuracy.
So let's set up our stack. So we got our frame pointer and our link register.
We'll go ahead and set up the stack.
Well, sidetrack some for here. Just pick a number.
Um, when we go to restore, we're going to do so. But SPF p
the number four because we added So we do a subject.
So now we'll go ahead and print off our result. LD R zero
Get our first format
read in cold print off and here less declare our
functions that we're going to use
current events can up. So we printed off our question for the user and then we're going to
go ahead and load it. So sub
are one is where we're going to use it.
It's gonna be our pointer saw frame pointer
and then minus eight. So the number eight
So that's where the data is located.
We'll do. LD R R zero
format A. Which is our scan f will go ahead and call branch of links can if
and then So now we've got our result in there. And so what we want to do is we want to copy it out. So vector L d r.
We'll just pick a register. So I'm gonna pick s 15
and we're going to get the value at the frame pointer
minus the number eight. And the way arm does it, you have to put the hashtag care to tell that it's a number.
So we're going to frame Pointer minus eight,
and then we'll use V convert
into a floating 0.64
from a floating 0.32
into D seven
and we're going to use s 15
And then what we want to do is we're gonna have to do our multiplication. So that's going to give us our Radius, which is in d seven
and go ahead and square that so we can save the mall
a 64 bit
You mean to say d seven is d seven times d seven. It's That's an easy way to square something,
and then we're gonna want to go ahead and load our value for pi in so LD r r. Zero The address of pie
Well, the R D r two
value at our zero. So again,
R two and r three are gonna be loaded
just so we don't forget that and then
we can convert that into a 64 bit. So again, USVI move
because they're in our to win our three floating 30.64
into will use d eight
and we're gonna load R two and r three Little copy those into that register
we can now multiply
are things together. So we got d eight has pie and d seven has the value squared.
So instead of the more
we're gonna do floating 0.64
g seven, his arrest or it and we're gonna multiple i d seven times d eight.
So now they're multiplied in stored in D seven.
So again we can use v move. And so one of the things to understand is that
when print off is gonna print it, it's gonna actually just use r two and R three, and we won't use our one because our first value is a
ah double, and so it's not going to use it. So when we do RV move, we're going to move our two into r two and R three.
The value that's in d seven, slot a copy it to those two registers. We're not going to set our zero, but we will say are one.
Sorry, we're not going to set our one, but we will set our zero.
The load register are zero. We'll get our format that we want a print, so it's four minute
and then we'll go ahead and
called friend F
So branch of link
and then we're at the bottom of our function. So let's try this
and looks like I
had a typo which nobody could tell me about. So
I miss types can f
There we go
when I think I missed type format here.
So far Radius is 10 10 times 10 is 100
100 times pi is 314.
All right, so we gave an example using floating point. So we did some loading of registers. We did some reading from scan half and we also did some printing with Brent F.
So in the future will talk about us and I m d and then thumb mode and conditional execution.
If you have questions, you can email me Miller MJ at you and Kate I e to you. And you can find me on Twitter at no house. 30
How to Use GDB (BSWJ)
The GNU Debugger (GDB) is one of the most commonly-used debugging tools in the world. ...
Certificate of Completion Offered
How to Use IDA (BSWJ)
The IDA is used throughout the IT and cybersecurity industries by exploit developers, vulnerability analysts, ...
Certificate of Completion Offered