So to create a loop we have to create a subroutine that always runs in a loop.
And let's just call this light on.
Can just used to be Bill I use men use the cops here it's on like this but this the problem.
If we created this we need we're not we're not guaranteed he was always running Fox would run once and
program would just run once and it would stop in order to make this run over and over again we can label
her we can keep it in a label just for Labor caucus labor.
And then what I'm going to do with this make the program always punched this label like this.
So what happens is it keeps going in a circle around this.
And then when it gets to the end bunch back to the label then when it gets the end it goes back to the
maybe over and over again running this show.
This subroutine known as light on to equality and we have to do now is write out the content of light
on and we'll be set to go to test our board and see our first assembly language come to life.
So let's continue.
So just like we write all of our subroutines stuff like this.
Lights on the school on the name of the 17.
And you know this one is the one that is actually going to turn on and off the light.
And what we need here is the data register the data register is the register about performs the final
trigger.
So when we set a data register the pin of the data register high.
The light turns on and when it goes no it turns off.
So just like we load it right we're going to do the same thing.
So we need to look at the data register.
Cops are out of one.
This one is called Cheat or if you I called the school are and then we moved to finally move to 40 into
it and then we move keep her.
So remember Mike always explained.
We have we have the destination register in one register and the source in another this is this is the
container.
This is where we want to point the container.
Just think of it No way.
So we have our school and the funding.
We want to move this as you can guess.
It's the same father we see with X you add to course this is where the registers I arranged in the same
way it was so that when we checked the data sheet this for much as the same format for the digital and
they were register as well as the data register.
So when we do this we access and P F one or the time which is the pin for the red and the beads show
we write this.
And then finally install.
We always have to store our source and destinations register like this one excel are retained from the
subroutine.
And finally always online.
And like this and our code is ready.
So let's compile and see the compiler would tell us whether we did a good job or not.
Now one area we almost did it when I see say
on expected operator equal to or equivalent length to
the policy.
Okay so you know we gave symbolic moves here.
You gave these symbolic names the Archbishop Tutu or the and was not actually uttered the meaning of
the names on the stand.
So we have to define that as sort of like using a variable with not defined yet.
So what we have to do is come up with and give the final result.
And I'm going to just copy and paste them should I get what I'm doing for that geeky move to give symbolic
names to you and then the funding of this issue.
X I copy this value from the data sheet with shoulder to x six to eight.
So that's the base across.
Plus the offset on this one.
We compare the quarter.
And you can use this to give symbolic names.
And the base across plus the offset uses to X seer x for this user to fund for serious here and is the
T R show.
Let's do that in two and gives this key.
Sure.
X fortune here shoe size 3.
See little calves.
And then finally we tough to declare what we have to give the name the days to register.
So
likewise those can commit to X
fortunes here to to slice through to five through FC this one headed in register slider 2 5 5 1.
See
this.
And she was set to go.
Yeah.
Yes.
And finally when we write in comments in assembly code we don't use this.
This one here or this one.
This one here.
Using this as a C standard in assembly semicolon gives us a comment.
That's what is given this this last error.
So let's just.
Or a semicolon.
Everything should be fine.
As we can see hooray we have zero errors.
Two warnings.
So what we have to do now is know that onto our board sit down and enjoy.
To do that let's verify our settings.
Okay.
We have had we have sixteen megahertz that's the frequency of our board AC debug and I have this two
letters I see either.
That's what I'm looking for.
Okay so all I have to do is click here to download
and press to restart.
And mine is working.
I hope this is work and this is good show.
Thank you very much.
Thanks for your patience.
We should be very proud of you so congratulations you've done what most embedded developers cannot do.
This is very rare.
You've just written a code in assembly.
So thank you.
And see the next lesson.
So one last thing.
If your program is not work and if you keep getting one error it's probably because you forgot to change
the name of the starting point of the program.
You know this main export main here and main here is where the program starts and we have to tell the
reset handler that this is where the program starts.
So if we don't do the our program once run you've probably experienced that too.
Or you have to do is come over here.
Startup on the score T M one two three dot s..
Double click and then went to file opens were you looking for voice to reset.
Handler and for those of you who took part in the introduction to cortex and we spoke about the reset.
HANDLER We said the program starts from the reset.
HANDLER There was a main function.
All you have to do is find it all you do is control F to open the door you wish and find dialog box
and then you type and reset
just type in research.
And then not this one not this one not this one.
This is for you looking for the Reset handler here and all you have to do is change this import here.
I have changed mine.
That's why it looks like this what you would see in yours would probably be underscore name and it's
a man with a lower case.
And I have changed mine and you have to chain decide to to the main.
Basically you have to change it to the name you give to your program.
The starting points of your program the reason why by default it is this.
As you know when we go to the disassembly view we see that this is where the problem starts when we
run the seed code.
The secret goes through this to start the program but the assembly code hasn't got this.
We have to give it our own main starting point.
The C could always starts from main.
That's why by default it is like this.
So we have to give it the name main and we're doing that because we give it main here and we actually
export in main so it should work now and enjoy and get ready for Project Number 2.