Assembly

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

Video Transcription

00:01
Hello. This is Dr Miller, and this is upside 12.13 of assembly
00:06
today. We're going to give a thumb conditional execution example using I t blocks.
00:12
So our thumb conditional execution example. So what we're gonna do is we're going to create a min slash max function using I t blocks.
00:24
So first will define a couple of different messages here.
00:28
So we got a
00:36
which is gonna ask us to enter our numbers,
00:47
and then we're gonna have be
00:51
the max is,
00:56
and we'll put a percent d there
00:58
on a new line.
01:02
All right, so the first thing we need to do is print our first prompt someone load register. Are zero
01:08
the address of a
01:11
branch with link
01:14
to print, two f
01:17
and then we're gonna do branch with Link read,
01:22
and
01:23
that'll have our result in R zero. And then we're gonna go ahead and
01:27
move. Are seven
01:30
copy R, zero intar seven.
01:34
We'll go ahead and copy two lines.
01:38
Read it again and copy it into our eight,
01:46
and then copy it into our nine. So we got our numbers are in our seven r eight and are 93 bread from the user.
01:55
So we're gonna be writing a thumb function. So they've branch with Link Exchange, max.
02:02
And then when we're all done, we'll go ahead and print off our number. So we're gonna do move into our one
02:09
are zero, which is our result.
02:12
Um, load register are zero. We're going to copy into it the value of B,
02:19
and then I wouldn't call Brent death.
02:23
All right, so now our function again, this is gonna be a thumb function.
02:28
Um, So I think here, I need a dot and funk here.
02:32
So dot
02:35
a line
02:37
two tells us this is gonna line on to buy boundaries and then dot from
02:45
function.
02:46
All right, so this is going to be
02:49
our max function,
02:52
So I hadn't push our link register
02:58
at the end. Will do pop of our program counter.
03:04
Okay, so we'll do a compare of r seven and r eight. So these are two of our numbers,
03:17
and then we'll do an if then
03:22
else
03:23
greater than
03:25
because we're trying to find Max,
03:29
so I'll do a move. Right? So it's greater than so I could do a move greater than
03:35
are zero r seven. So seven is bigger. So I'll go ahead and do that. And then we go
03:40
move
03:43
less than or equal to. So anything else are zero or seven.
03:50
Sorry. Are eight.
03:52
All right. So now we know are zero has the bigger of r seven and R eight, and then we can do a compare of r zero
04:00
and our nine,
04:02
and then we'll just do an if then
04:04
less than or equal to, you know, move. Ellie,
04:10
are zero R nine?
04:14
No, but our nine is bigger.
04:19
Our eight is bigger.
04:25
Our seven is bigger. And so we got our three cases for that.
04:30
And you can see in here we don't have any branches. And so our execution just is going to go ahead and just run right through.
04:40
In addition to doing our if them blocks, we also have gotta tell it that we're going to use unified syntax.
04:51
This will allow us to use our if them blocks inside of there.
04:59
All right,
05:00
so we got enter three numbers, one Teoh, three
05:04
or 3 to 1.
05:08
Or one
05:11
33 to,
05:14
you know, go through and work.
05:17
So then we can easily add a minimum function. So here I'm going to,
05:21
um change Be to say,
05:26
Oh,
05:29
the
05:30
men is
05:32
Instead of calling Max, I'll go ahead and call men
05:38
and then I'm gonna copy everything from here down
05:44
so we can dio Yangpu
05:47
Yank, Or why 200 yank and it'll copy all of our lines, and then I can go ahead and put those in
05:56
so we're gonna call the men function,
06:00
and so we basically just need to
06:02
invert all of our conditions here. So instead of saying
06:08
if then else greater than we can go ahead and say
06:11
if then else less than
06:14
change this to less than and this to greater than or equal to
06:19
And then here instead of Ellie Weaken say g t
06:25
she you
06:28
gt
06:29
So now we have changed our
06:31
max function into a min function.
06:34
I guess I can change these here.
06:46
Okay,
06:48
so now when I run at an or three numbers one to you, three
06:54
to the 21
06:57
312 it gives us the right number.
07:03
So today we created Botham in and a max function
07:08
using conditional execution, and we use I t blocks for thumb mode because that's the only way that you can do it inside of thumb mode.
07:16
Um, in future lectures will look at the comparison of conditional execution vs Branching and then we'll look at Indian nous.
07:26
If you have questions, you can email me Miller MJ at U N k that you to you and you can find me on Twitter at Milhouse 30.

Up Next

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

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