Hello. This is Dr Miller, and this is upside 12.13 of assembly
today. We're going to give a thumb conditional execution example using I t blocks.
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.
So first will define a couple of different messages here.
which is gonna ask us to enter our numbers,
and then we're gonna have be
and we'll put a percent d there
All right, so the first thing we need to do is print our first prompt someone load register. Are zero
and then we're gonna do branch with Link read,
that'll have our result in R zero. And then we're gonna go ahead and
copy R, zero intar seven.
We'll go ahead and copy two lines.
Read it again and copy it into our eight,
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.
So we're gonna be writing a thumb function. So they've branch with Link Exchange, max.
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
are zero, which is our result.
Um, load register are zero. We're going to copy into it the value of B,
and then I wouldn't call Brent death.
All right, so now our function again, this is gonna be a thumb function.
Um, So I think here, I need a dot and funk here.
two tells us this is gonna line on to buy boundaries and then dot from
All right, so this is going to be
So I hadn't push our link register
at the end. Will do pop of our program counter.
Okay, so we'll do a compare of r seven and r eight. So these are two of our numbers,
and then we'll do an if then
because we're trying to find Max,
so I'll do a move. Right? So it's greater than so I could do a move greater than
are zero r seven. So seven is bigger. So I'll go ahead and do that. And then we go
less than or equal to. So anything else are zero or seven.
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
and then we'll just do an if then
less than or equal to, you know, move. Ellie,
No, but our nine is bigger.
Our eight is bigger.
Our seven is bigger. And so we got our three cases for that.
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.
In addition to doing our if them blocks, we also have gotta tell it that we're going to use unified syntax.
This will allow us to use our if them blocks inside of there.
so we got enter three numbers, one Teoh, three
you know, go through and work.
So then we can easily add a minimum function. So here I'm going to,
um change Be to say,
Instead of calling Max, I'll go ahead and call men
and then I'm gonna copy everything from here down
so we can dio Yangpu
Yank, Or why 200 yank and it'll copy all of our lines, and then I can go ahead and put those in
so we're gonna call the men function,
and so we basically just need to
invert all of our conditions here. So instead of saying
if then else greater than we can go ahead and say
if then else less than
change this to less than and this to greater than or equal to
And then here instead of Ellie Weaken say g t
So now we have changed our
max function into a min function.
I guess I can change these here.
so now when I run at an or three numbers one to you, three
312 it gives us the right number.
So today we created Botham in and a max function
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.
Um, in future lectures will look at the comparison of conditional execution vs Branching and then we'll look at Indian nous.
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.