### Assembly

Course
Time
13 hours 15 minutes
Difficulty
Beginner
CEU/CPE
14

### Video Transcription

00:01
Hello. This is Dr Miller, and this is Episode 12.4 of Assembly.
00:06
Today, we're going to give a floating point Example.
00:10
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.
00:20
So I already got the project set up.
00:24
So we're gonna have a couple of messages here,
00:30
so it'll ask them entered, uh,
00:33
00:46
We will have to scan the number from the user, so used percent f
00:55
and I will print off our result
00:58
area.
01:04
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.
01:15
And they will declare a variable. So we'll declare pie
01:21
and I dont be three.
01:26
That will be
01:29
3.1 for
01:32
15
01:34
nine to
01:37
65
01:41
359 So I'm gonna use a double here, so we get a little bit more accuracy.
01:49
So let's set up our stack. So we got our frame pointer and our link register.
01:55
We'll go ahead and set up the stack.
02:08
Well, sidetrack some for here. Just pick a number.
02:13
Um, when we go to restore, we're going to do so. But SPF p
02:19
the number four because we added So we do a subject.
02:23
So now we'll go ahead and print off our result. LD R zero
02:29
Get our first format
02:35
read in cold print off and here less declare our
02:38
functions that we're going to use
02:45
current events can up. So we printed off our question for the user and then we're going to
02:50
02:53
are one is where we're going to use it.
02:55
It's gonna be our pointer saw frame pointer
02:59
and then minus eight. So the number eight
03:04
So that's where the data is located.
03:06
We'll do. LD R R zero
03:09
format A. Which is our scan f will go ahead and call branch of links can if
03:16
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.
03:25
We'll just pick a register. So I'm gonna pick s 15
03:30
and we're going to get the value at the frame pointer
03:34
minus the number eight. And the way arm does it, you have to put the hashtag care to tell that it's a number.
03:42
So we're going to frame Pointer minus eight,
03:44
and then we'll use V convert
03:47
into a floating 0.64
03:52
from a floating 0.32
03:55
into D seven
03:58
and we're going to use s 15
04:06
all right?
04:10
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
04:17
and go ahead and square that so we can save the mall
04:21
a 64 bit
04:25
floating point.
04:27
You mean to say d seven is d seven times d seven. It's That's an easy way to square something,
04:33
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
04:42
Well, the R D r two
04:46
value at our zero. So again,
04:50
R two and r three are gonna be loaded
04:57
just so we don't forget that and then
05:00
we can convert that into a 64 bit. So again, USVI move
05:09
because they're in our to win our three floating 30.64
05:14
into will use d eight
05:16
and we're gonna load R two and r three Little copy those into that register
05:25
we can now multiply
05:27
are things together. So we got d eight has pie and d seven has the value squared.
05:32
05:36
we're gonna do floating 0.64
05:40
Okay,
05:41
g seven, his arrest or it and we're gonna multiple i d seven times d eight.
05:47
So now they're multiplied in stored in D seven.
05:51
So again we can use v move. And so one of the things to understand is that
05:57
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
06:03
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.
06:14
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.
06:21
Sorry, we're not going to set our one, but we will set our zero.
06:26
The load register are zero. We'll get our format that we want a print, so it's four minute
06:31
be
06:33
and then we'll go ahead and
06:35
called friend F
06:38
06:40
and then we're at the bottom of our function. So let's try this
06:47
and looks like I
06:49
06:55
I miss types can f
06:59
There we go
07:08
when I think I missed type format here.
07:15
All right,
07:16
So far Radius is 10 10 times 10 is 100
07:20
100 times pi is 314.
07:28
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.
07:39
So in the future will talk about us and I m d and then thumb mode and conditional execution.
07:45
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

### Assembly

This course will provide background and information related to programming in assembly. Assembly is the lowest level programming language which is useful in reverse engineering and malware analysis.

### Instructed By

Matthew Miller
Assistant Professor at the University of Nebraska at Kearney
Instructor