Hello, this is Dr. Miller, and this
is absurd, 12 13 of assembly
today, we're going to give a thumb
conditional execution example using
it blocks
so our thumb conditional execution
example.
So what we're going to do is we're
going to create a min
max function using it
blocks.
So, first of all, define a couple of
different messages here,
so we got a.
Which is going to ask us to
enter our numbers.
And then we're going to have be.
The max
is
and we'll put a D there
and a new line.
All right, so the first thing we
need to do is print our first
prompt.
So we're going to load register our
zero the address
of a
branch with link to
print F.
And then we're going to do branch
with Link read
into that, I'll have
our result in our zero
and then we're going to go ahead and
move. Our seven
copy are zero in to seven.
Go ahead and copy two lines,
reading it again and copy it into
our eight.
And then copy it into
our nine, so we got our numbers are
in our seven or eight and our
nine, the read from the user.
So we're going to be writing a thumb
function. So the branch with link
exchange, Max,
and then when we're all done, we'll
go ahead and print off our number.
So we're going to do move into our
one hour zero,
which is our result
load register our zero
and we're going to copy into it the
value of B and
then we go ahead and call
Brint F.
All right. So now our function
again, this is going to be a thumb
function.
So I think here I need it and
found here.
So dot a
line
to tells us this is going to line
on to by boundaries and then dot
some.
Function,
all right, so this is going to be
Amax function,
so go ahead and push
our link register.
At the end, we'll do pop
of our program counter.
OK, so we'll do a compare
of our seven
or eight, so these are two
of our numbers.
And then we'll do an if
then else
greater than because
we're trying to find Max,
so I'll do a move, right.
So it's greater than so I can do a
move greater than
our zero hour seven.
So seven is bigger.
So I'll go ahead and do that.
And then we go move
less than or equal to.
So anything else are
zero or seven.
Sorry. All right.
All right. So now we are zero has
the bigger of our seven and our
eight and then we can do
compar of our zero
and our nine
and then we'll just do an if then
less than or equal to
move L.E.
or zero or nine
and we'll put our nine is
bigger.
Our eight is
bigger.
Our seven is bigger,
so we've 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 then
blocks, we also have got to tell it
that we're going to use Unified
Syntex.
This will allow us to use our if
then blocks inside of their.
All right, so
we've got two or three numbers, one
to three
or three to one.
Or one
thirty three to.
You go through and work,
so then we can easily add a minimum
function, so here I'm going to
change be to say,
Oh.
The man
is.
And instead of calling Max, I'll go
ahead and call Min.
And then I'm going to copy
everything from here down.
So we can do
Yank,
Yank or why two hundred
yank and it'll copy all of our lines
and then I can go ahead and put
those in.
So we're going to call the
MIN 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.
We can change this to a less than
and this to greater than or equal
to and then
here instead of L.E., we can say
G.T.
you
got.
So now we've changed our
max function into a main function,
and I guess I can change these here.
OK.
So now when I run it into three
numbers, one, two, three,
three, two, one,
three, one, two.
It gives us the right number.
So today, we created both of them in
an emacs function
using conditional execution, and we
use it blocks for
thumb mode because that's the only
way that you can do it inside of
thumb mode
in future lectures will look
at the comparison of conditional
execution versus branching, and then
we'll look at Indianness.
If you have questions, you can email
me, you indicate to
you and you can find me on Twitter
at Millhauser 30.