1
00:00:03,710 --> 00:00:10,810
So to create a loop we have to create a subroutine that always runs in a loop.

2
00:00:11,150 --> 00:00:16,220
And let's just call this light on.

3
00:00:16,320 --> 00:00:27,810
Can just used to be Bill I use men use the cops here it's on like this but this the problem.

4
00:00:27,840 --> 00:00:35,880
If we created this we need we're not we're not guaranteed he was always running Fox would run once and

5
00:00:35,880 --> 00:00:43,510
program would just run once and it would stop in order to make this run over and over again we can label

6
00:00:43,520 --> 00:00:52,810
her we can keep it in a label just for Labor caucus labor.

7
00:00:56,120 --> 00:01:02,830
And then what I'm going to do with this make the program always punched this label like this.

8
00:01:04,090 --> 00:01:08,200
So what happens is it keeps going in a circle around this.

9
00:01:08,210 --> 00:01:15,050
And then when it gets to the end bunch back to the label then when it gets the end it goes back to the

10
00:01:15,060 --> 00:01:17,590
maybe over and over again running this show.

11
00:01:17,660 --> 00:01:24,300
This subroutine known as light on to equality and we have to do now is write out the content of light

12
00:01:24,360 --> 00:01:31,170
on and we'll be set to go to test our board and see our first assembly language come to life.

13
00:01:31,530 --> 00:01:33,430
So let's continue.

14
00:01:34,270 --> 00:01:39,990
So just like we write all of our subroutines stuff like this.

15
00:01:39,990 --> 00:01:43,860
Lights on the school on the name of the 17.

16
00:01:44,280 --> 00:01:49,180
And you know this one is the one that is actually going to turn on and off the light.

17
00:01:49,200 --> 00:01:55,400
And what we need here is the data register the data register is the register about performs the final

18
00:01:55,440 --> 00:01:56,190
trigger.

19
00:01:56,550 --> 00:02:01,270
So when we set a data register the pin of the data register high.

20
00:02:01,650 --> 00:02:04,840
The light turns on and when it goes no it turns off.

21
00:02:04,860 --> 00:02:09,690
So just like we load it right we're going to do the same thing.

22
00:02:11,130 --> 00:02:15,250
So we need to look at the data register.

23
00:02:16,850 --> 00:02:21,930
Cops are out of one.

24
00:02:22,180 --> 00:02:36,920
This one is called Cheat or if you I called the school are and then we moved to finally move to 40 into

25
00:02:36,920 --> 00:02:40,870
it and then we move keep her.

26
00:02:41,800 --> 00:02:43,980
So remember Mike always explained.

27
00:02:43,990 --> 00:02:52,120
We have we have the destination register in one register and the source in another this is this is the

28
00:02:52,120 --> 00:02:52,810
container.

29
00:02:52,810 --> 00:02:55,060
This is where we want to point the container.

30
00:02:55,060 --> 00:02:57,250
Just think of it No way.

31
00:02:57,420 --> 00:02:59,890
So we have our school and the funding.

32
00:02:59,890 --> 00:03:03,920
We want to move this as you can guess.

33
00:03:03,990 --> 00:03:11,940
It's the same father we see with X you add to course this is where the registers I arranged in the same

34
00:03:11,940 --> 00:03:17,910
way it was so that when we checked the data sheet this for much as the same format for the digital and

35
00:03:17,910 --> 00:03:20,780
they were register as well as the data register.

36
00:03:20,790 --> 00:03:29,370
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

37
00:03:29,480 --> 00:03:30,450
we write this.

38
00:03:30,480 --> 00:03:32,780
And then finally install.

39
00:03:32,880 --> 00:03:43,830
We always have to store our source and destinations register like this one excel are retained from the

40
00:03:43,830 --> 00:03:44,730
subroutine.

41
00:03:45,060 --> 00:03:48,940
And finally always online.

42
00:03:49,280 --> 00:03:55,250
And like this and our code is ready.

43
00:03:55,440 --> 00:04:01,970
So let's compile and see the compiler would tell us whether we did a good job or not.

44
00:04:02,220 --> 00:04:05,560
Now one area we almost did it when I see say

45
00:04:10,800 --> 00:04:16,080
on expected operator equal to or equivalent length to

46
00:04:19,990 --> 00:04:21,060
the policy.

47
00:04:22,480 --> 00:04:26,690
Okay so you know we gave symbolic moves here.

48
00:04:28,370 --> 00:04:37,470
You gave these symbolic names the Archbishop Tutu or the and was not actually uttered the meaning of

49
00:04:37,470 --> 00:04:39,680
the names on the stand.

50
00:04:39,750 --> 00:04:45,960
So we have to define that as sort of like using a variable with not defined yet.

51
00:04:46,020 --> 00:04:52,100
So what we have to do is come up with and give the final result.

52
00:04:52,800 --> 00:05:02,720
And I'm going to just copy and paste them should I get what I'm doing for that geeky move to give symbolic

53
00:05:02,720 --> 00:05:08,440
names to you and then the funding of this issue.

54
00:05:08,530 --> 00:05:16,740
X I copy this value from the data sheet with shoulder to x six to eight.

55
00:05:16,760 --> 00:05:18,190
So that's the base across.

56
00:05:18,230 --> 00:05:21,240
Plus the offset on this one.

57
00:05:23,380 --> 00:05:25,930
We compare the quarter.

58
00:05:26,930 --> 00:05:30,400
And you can use this to give symbolic names.

59
00:05:31,050 --> 00:05:47,460
And the base across plus the offset uses to X seer x for this user to fund for serious here and is the

60
00:05:47,470 --> 00:05:49,150
T R show.

61
00:05:49,200 --> 00:05:59,540
Let's do that in two and gives this key.

62
00:05:59,570 --> 00:06:00,010
Sure.

63
00:06:00,010 --> 00:06:06,990
X fortune here shoe size 3.

64
00:06:09,930 --> 00:06:15,070
See little calves.

65
00:06:15,130 --> 00:06:24,230
And then finally we tough to declare what we have to give the name the days to register.

66
00:06:24,510 --> 00:06:24,900
So

67
00:06:34,540 --> 00:06:39,250
likewise those can commit to X

68
00:06:43,400 --> 00:07:02,110
fortunes here to to slice through to five through FC this one headed in register slider 2 5 5 1.

69
00:07:02,170 --> 00:07:02,580
See

70
00:07:05,290 --> 00:07:05,950
this.

71
00:07:06,000 --> 00:07:08,390
And she was set to go.

72
00:07:08,650 --> 00:07:09,010
Yeah.

73
00:07:09,340 --> 00:07:09,800
Yes.

74
00:07:09,800 --> 00:07:16,930
And finally when we write in comments in assembly code we don't use this.

75
00:07:16,920 --> 00:07:20,770
This one here or this one.

76
00:07:20,770 --> 00:07:21,760
This one here.

77
00:07:21,880 --> 00:07:27,910
Using this as a C standard in assembly semicolon gives us a comment.

78
00:07:27,930 --> 00:07:30,640
That's what is given this this last error.

79
00:07:30,940 --> 00:07:31,900
So let's just.

80
00:07:31,910 --> 00:07:33,090
Or a semicolon.

81
00:07:33,760 --> 00:07:35,510
Everything should be fine.

82
00:07:35,720 --> 00:07:38,740
As we can see hooray we have zero errors.

83
00:07:38,740 --> 00:07:39,940
Two warnings.

84
00:07:39,980 --> 00:07:46,870
So what we have to do now is know that onto our board sit down and enjoy.

85
00:07:46,870 --> 00:07:49,510
To do that let's verify our settings.

86
00:07:50,050 --> 00:07:50,470
Okay.

87
00:07:50,470 --> 00:07:59,770
We have had we have sixteen megahertz that's the frequency of our board AC debug and I have this two

88
00:07:59,790 --> 00:08:01,850
letters I see either.

89
00:08:01,940 --> 00:08:03,410
That's what I'm looking for.

90
00:08:03,410 --> 00:08:07,190
Okay so all I have to do is click here to download

91
00:08:09,760 --> 00:08:11,990
and press to restart.

92
00:08:12,490 --> 00:08:13,830
And mine is working.

93
00:08:13,840 --> 00:08:19,830
I hope this is work and this is good show.

94
00:08:19,870 --> 00:08:21,030
Thank you very much.

95
00:08:21,040 --> 00:08:22,910
Thanks for your patience.

96
00:08:23,000 --> 00:08:30,130
We should be very proud of you so congratulations you've done what most embedded developers cannot do.

97
00:08:30,130 --> 00:08:31,900
This is very rare.

98
00:08:31,930 --> 00:08:34,630
You've just written a code in assembly.

99
00:08:34,630 --> 00:08:36,750
So thank you.

100
00:08:36,790 --> 00:08:38,220
And see the next lesson.

101
00:08:40,470 --> 00:08:42,510
So one last thing.

102
00:08:42,570 --> 00:08:49,290
If your program is not work and if you keep getting one error it's probably because you forgot to change

103
00:08:49,290 --> 00:08:52,620
the name of the starting point of the program.

104
00:08:52,650 --> 00:08:59,730
You know this main export main here and main here is where the program starts and we have to tell the

105
00:09:00,780 --> 00:09:04,570
reset handler that this is where the program starts.

106
00:09:04,590 --> 00:09:10,140
So if we don't do the our program once run you've probably experienced that too.

107
00:09:10,200 --> 00:09:12,250
Or you have to do is come over here.

108
00:09:12,300 --> 00:09:16,650
Startup on the score T M one two three dot s..

109
00:09:16,740 --> 00:09:22,680
Double click and then went to file opens were you looking for voice to reset.

110
00:09:22,680 --> 00:09:29,420
Handler and for those of you who took part in the introduction to cortex and we spoke about the reset.

111
00:09:29,430 --> 00:09:32,550
HANDLER We said the program starts from the reset.

112
00:09:32,550 --> 00:09:34,770
HANDLER There was a main function.

113
00:09:35,730 --> 00:09:42,570
All you have to do is find it all you do is control F to open the door you wish and find dialog box

114
00:09:42,660 --> 00:09:44,970
and then you type and reset

115
00:09:47,830 --> 00:09:48,980
just type in research.

116
00:09:49,770 --> 00:09:55,440
And then not this one not this one not this one.

117
00:09:55,440 --> 00:10:03,790
This is for you looking for the Reset handler here and all you have to do is change this import here.

118
00:10:03,930 --> 00:10:04,890
I have changed mine.

119
00:10:04,890 --> 00:10:11,190
That's why it looks like this what you would see in yours would probably be underscore name and it's

120
00:10:11,190 --> 00:10:12,960
a man with a lower case.

121
00:10:12,970 --> 00:10:18,890
And I have changed mine and you have to chain decide to to the main.

122
00:10:18,890 --> 00:10:22,860
Basically you have to change it to the name you give to your program.

123
00:10:23,220 --> 00:10:29,310
The starting points of your program the reason why by default it is this.

124
00:10:29,610 --> 00:10:35,130
As you know when we go to the disassembly view we see that this is where the problem starts when we

125
00:10:35,130 --> 00:10:36,660
run the seed code.

126
00:10:36,660 --> 00:10:41,910
The secret goes through this to start the program but the assembly code hasn't got this.

127
00:10:41,940 --> 00:10:44,730
We have to give it our own main starting point.

128
00:10:44,730 --> 00:10:46,830
The C could always starts from main.

129
00:10:46,860 --> 00:10:50,070
That's why by default it is like this.

130
00:10:50,070 --> 00:10:57,510
So we have to give it the name main and we're doing that because we give it main here and we actually

131
00:10:57,510 --> 00:11:04,950
export in main so it should work now and enjoy and get ready for Project Number 2.
