So now let's start to write out our code.
I'm going to delete this line here.
It's not needed.
It was for your reference only.
And we're going to stop by right now.
Our directives remember the directives they help the Compiler Compiler the code in a particular way.
We're going to start by hitting four tops.
One two three four.
And I will start with a first directive shall be written in Cobb's area and then tab vertical line dot.
And this directive here makes our code callable from a C code a code written in C and we add the other
directive C or D is tells the compiler to place the following line in the code space which is usually
the wrong comma.
Let's just make it read only safe this way unless our line line it of to.
Now we could tell the compiler that our code is written in thumb to empty thumb.
And then we export our program and export our program
and we're going to call Let's call our program made.
So we export main you know what the export directive does.
It makes this program of this program callable from other other programs.
So this file the content of this file can be caught from other files.
You know the dot text makes it callable to see files by export makes it callable to assembly files and
see files and it takes would not work without the export main.
So now our program is made.
So we export in Maine.
So now let's write out our program.
We start by in Maine the first and we're going to do is initialize our pot and pen and we're going to
do this by writing a subroutine to do that for us.
And remember there to be L is branch 2 subroutine I'm going to use the P L up code to do this and we're
going to call this first subroutine G P i o f in it as the name implies it's going to initialize the
general purpose input output to put s KPI in it.
And remember we want to turn on the red LCD and we realized when we checked into data sheets that it
read LCD is connected to put f pin 1.
So that's the one we have to initialize for our initialization.
We are going to use something known as index an immediate addressing index addressing uses two or requires
two registers one register points to a value and the value pointed to by this first register is then
put into the second register and we do these two steps by using the L T R to load up code image ID address
in uses the move up code to move the value into a register.
So first as we said we have to activate the clock of the pot s here.
Does the first and we have to do it and it said set number three we have to set it direction registers
and then enable.
Remember we're not doing this one here cos we're not using PD 7.
So what we are going to do now is write out the content of our subroutine our subcutaneous code.
Keep you f in it.
So what we're going to do is load load the address of the clock into register 1 and we do this call
in the r r one because system control our CDC keeping who on a school r remember addresses 32 bit large
numbers here.
Load R1 ecosystem control RC TCE TPA or R is pointing to the address I should tell you the name here
system control RC KC TPA or R is a name you could think of it as a name was given to the numeric value
of the address.
Later on we would see how we assign this name to the 32 bits number before now now keep this name and
now explain to you why we use in this long name which underscores rather than getting a simple name
that we can remember.
So let's move on now.
We have our one pointing to the address of the system control register which is the clock register.
Now we have to take the content at this address and put it into our cereal and we do that by invoking
l the r r zero comma square brackets are 1.
So now the content at this address pointed to by R1 is put into our zero.
If you go back to the data sheet you would realize that they reset value of their system control our
C GC GPI register as 0 0 0 0 0 with a series after the X currently.
I'll tell you this value is put into our cereal so our cereal currently has this value in order to enable
put F..
We will have to enable bit 5 in the system control our CTC keep register and we can accomplish this
by using something known as the or operator like this all power are our zero equals zero and number
two zero.
Here we say in our zero course Iris rule or zero x to zero.
To further elaborate this let's take a break from your vision and see how this all operation changes
the bit.