1
00:00:00,460 --> 00:00:05,130
All right boys and girls we are back for two more commands.

2
00:00:05,130 --> 00:00:09,880
Today we're going to be looking at return and temporary end.

3
00:00:10,080 --> 00:00:15,790
So without further ado let's go ahead and get everything up and running.

4
00:00:15,790 --> 00:00:18,800
Our S links emulate.

5
00:00:19,140 --> 00:00:23,690
We're going to load this thing up and that's going to be our return temporary.

6
00:00:23,770 --> 00:00:29,550
And so when you have all your sample programs if you want to go through this that's what you're looking

7
00:00:29,550 --> 00:00:30,580
for.

8
00:00:30,630 --> 00:00:35,660
Set that station up to 1 and let's get this thing running.

9
00:00:37,730 --> 00:00:46,450
And once we're running Let's go ahead and go on line with emulate we are connected.

10
00:00:46,700 --> 00:00:49,090
Let's make those bigger so we can see.

11
00:00:49,100 --> 00:00:51,490
And let's start going through this.

12
00:00:51,650 --> 00:00:53,060
OK this looks bigger.

13
00:00:53,090 --> 00:00:54,930
This looks more complicated.

14
00:00:55,130 --> 00:01:01,640
And I've even created a subroutine here which looks more complicated and all of that is just to demonstrate

15
00:01:01,780 --> 00:01:03,680
to instructions.

16
00:01:03,680 --> 00:01:04,110
OK.

17
00:01:04,129 --> 00:01:05,830
Right now you're thinking bummer.

18
00:01:05,870 --> 00:01:07,740
There's a lot going on here.

19
00:01:07,850 --> 00:01:10,790
Really this isn't as bad as it looks.

20
00:01:10,790 --> 00:01:11,560
Don't worry.

21
00:01:11,570 --> 00:01:15,450
Let me explain how this thing is for starters.

22
00:01:15,620 --> 00:01:19,200
We've got these two less than competitors.

23
00:01:19,310 --> 00:01:25,190
Don't worry about these the values we're looking at here in seven one and in seven to.

24
00:01:25,190 --> 00:01:29,720
Those are just going to be storing results of our test.

25
00:01:29,720 --> 00:01:34,610
So we're going a store in 7:1 at the beginning of our execution.

26
00:01:34,610 --> 00:01:38,990
We're going to store in 7:2 at the end of our execution.

27
00:01:38,990 --> 00:01:42,270
And these are always going to be less than ninety nine ninety nine.

28
00:01:42,440 --> 00:01:49,140
So the only reason these two instructions are here is just to show us what in seven one in in seven

29
00:01:49,140 --> 00:01:54,940
to our without having to come down here and go through data tables and things like that.

30
00:01:54,950 --> 00:02:01,580
So these are just here's a convenience and this action really doesn't need to be here but it's really

31
00:02:01,580 --> 00:02:09,530
just resetting in seven zero back to zero value which is where we wanted pretty much all the time.

32
00:02:09,530 --> 00:02:13,960
Now we're going to be doing three different tests.

33
00:02:14,030 --> 00:02:17,230
We're going to be testing the routine all the way through.

34
00:02:17,480 --> 00:02:21,160
We're going to be testing the routine using a return.

35
00:02:21,440 --> 00:02:28,640
And then we're going to be testing the routine using a temporary end and each of these is on one shot

36
00:02:28,640 --> 00:02:35,960
because whenever we toggle one of these switches we only want the routine to execute one time not two

37
00:02:35,960 --> 00:02:40,850
or three or four one time then we've got our trigger bits over here.

38
00:02:40,850 --> 00:02:49,040
These are what's going to carry our one shot actions over into this point where we actually execute

39
00:02:49,130 --> 00:02:53,340
our set routine which is this ladder three right here.

40
00:02:53,780 --> 00:02:59,360
And it's also where we're going to store our start of execution value.

41
00:02:59,630 --> 00:03:04,870
So in 7 0 at the start of execution should always be zero.

42
00:03:04,880 --> 00:03:10,650
So we're always going to have zero stored in in 7:1 but in in 7:02.

43
00:03:10,700 --> 00:03:17,090
At the end of execution we should have different values depending on how our cycle works.

44
00:03:17,090 --> 00:03:22,430
So the subroutine is what's going to be modifying the 7:2 value.

45
00:03:22,610 --> 00:03:26,330
So let's check it out and see what's happening in there.

46
00:03:26,840 --> 00:03:33,570
When we come into the subroutine we are seeing this is the common operation we're doing in here.

47
00:03:33,570 --> 00:03:41,490
We're going to be moving some source value whether it's 100 or 200 or 300.

48
00:03:41,570 --> 00:03:50,700
We're going to be moving that to in 7 0 and then we're going to be copying or moving in 7 0 2 7 2.

49
00:03:50,900 --> 00:03:57,080
And remember in 7:2 is what we're looking at at the end of execution because we want to see what it

50
00:03:57,140 --> 00:03:58,880
ends up at.

51
00:03:58,880 --> 00:04:09,020
So what this program what the set routine tries to do is move 100 to in 7 0 and then store that into

52
00:04:09,030 --> 00:04:10,600
in 7:02.

53
00:04:10,790 --> 00:04:19,730
Then when it comes down to rank 2 it wants to move 200 into in 7 0 and then store that to in 7:2 and

54
00:04:19,730 --> 00:04:21,640
then we come down here.

55
00:04:21,740 --> 00:04:27,910
It wants to move 300 into in 7 0 and store that in 7:02.

56
00:04:28,190 --> 00:04:30,020
That's the end of the routine.

57
00:04:30,050 --> 00:04:37,200
So if we run this routine what we should end up with is 300 in in 7:02.

58
00:04:37,550 --> 00:04:39,630
So let's find out if that happens.

59
00:04:39,800 --> 00:04:47,990
I'm going to toggle this to test complete routine and as soon as i do we can see at the start of execution

60
00:04:48,110 --> 00:04:53,370
in 7:01 was stored at 0 that came from in 7 0.

61
00:04:53,870 --> 00:05:00,040
And sure enough there are three hundred in in 7:2 at the end of execution.

62
00:05:00,320 --> 00:05:10,540
So we effectively moved the values 100 200 and 300 respectively into in 7 0 and then stored that into

63
00:05:10,550 --> 00:05:11,960
in 7:02.

64
00:05:12,050 --> 00:05:16,910
And as we expected at the end it wasn't 100 it wasn't 200.

65
00:05:16,910 --> 00:05:18,800
It was 300.

66
00:05:19,310 --> 00:05:26,820
But now we've got a couple of different instructions which can change the way that a program executes.

67
00:05:26,930 --> 00:05:30,100
The first one we're going to look at is this return.

68
00:05:30,140 --> 00:05:39,080
So when we go back into Ladder 3 if we happen to start this routine with the test return trigger then

69
00:05:39,350 --> 00:05:48,390
what's going to happen is from rung 3 it should return to the subroutine which called this one.

70
00:05:48,390 --> 00:05:54,310
So in this case we used our GSR and ladder 2.

71
00:05:54,510 --> 00:06:03,900
So when we use a return from Ladder 3 when we come back we're going to come back to this next run which

72
00:06:03,900 --> 00:06:05,220
is the end.

73
00:06:05,220 --> 00:06:14,610
But if we had nested subroutines let's say we used the GSR and ladder two to jump to Ladder 5 then we

74
00:06:14,610 --> 00:06:18,300
jumped to Ladder 7 and then we jumped to Ladder 3.

75
00:06:18,420 --> 00:06:24,410
When we return we're going to go back to 7 because that's the one that actually called Ladder 3.

76
00:06:24,630 --> 00:06:30,430
But in this case our GSR is on rung 4 and ladder 2.

77
00:06:30,570 --> 00:06:35,750
So we're going to be returning with rung five on ladder too.

78
00:06:35,760 --> 00:06:44,490
So anyway when we return from here we notice there's still another line there still another rung beneath

79
00:06:44,640 --> 00:06:45,930
our return.

80
00:06:45,930 --> 00:06:48,760
And that's where we set the value to three hundred.

81
00:06:48,960 --> 00:06:55,400
So presumably if we test return we should come into this routine.

82
00:06:55,410 --> 00:06:58,490
We should move 100 into an 7:02.

83
00:06:58,620 --> 00:07:03,800
We should move 202 in 7:02 but we should never see 300.

84
00:07:04,020 --> 00:07:08,150
So at the end we would expect to see 200.

85
00:07:08,760 --> 00:07:10,170
And let's try that.

86
00:07:10,170 --> 00:07:14,460
I'm going to go ahead and reset our end value.

87
00:07:14,880 --> 00:07:21,380
And in seven zeros always kept the zero our start values should always be zero.

88
00:07:21,600 --> 00:07:23,530
Let's test that return.

89
00:07:24,150 --> 00:07:33,720
And sure enough we ended up with 200 because we got here and returned so we never got to execute this

90
00:07:33,720 --> 00:07:34,600
300.

91
00:07:34,830 --> 00:07:39,790
Well one last thing we want to test in this program is this temporary end.

92
00:07:40,080 --> 00:07:49,750
This guy is different from our return because return just goes back to the subroutine that called it.

93
00:07:49,770 --> 00:07:52,110
It goes right back to the GSR.

94
00:07:52,110 --> 00:07:54,600
That led us here in the first place.

95
00:07:54,690 --> 00:08:01,380
T n d on the other hand completely terminates that scan of the program.

96
00:08:01,380 --> 00:08:11,970
So it doesn't matter if we come back into ladder 2 it doesn't matter if after here there were 10 different

97
00:08:11,970 --> 00:08:19,450
rungs with other jump to subroutines it doesn't matter that there was a whole giant mountain of program.

98
00:08:19,530 --> 00:08:27,990
Once we hit a T and D we go back to ladder to rungs 0 and we start back from there.

99
00:08:27,990 --> 00:08:31,270
So it completely terminates the scan.

100
00:08:31,680 --> 00:08:40,659
And if we do this if we TMD here we expect we will never see 200 we'll never see 300.

101
00:08:40,860 --> 00:08:44,890
We should end up with 100 as our final value.

102
00:08:45,210 --> 00:08:52,680
So again let's reset everything and let's go ahead and test our TNT.

103
00:08:53,250 --> 00:08:56,180
And sure enough we ended with 100.

104
00:08:56,430 --> 00:08:57,870
So we got in here.

105
00:08:57,960 --> 00:09:00,050
We set the value to 100.

106
00:09:00,240 --> 00:09:04,000
We hit TNT and then the show is over.

107
00:09:04,050 --> 00:09:07,080
We never executed anything else here.

108
00:09:07,170 --> 00:09:11,280
We if there were more lines here we wouldn't have looked at those lines.

109
00:09:11,370 --> 00:09:15,790
We would have just come back to here and tried to start a new scan.

110
00:09:16,080 --> 00:09:23,010
And this program unless you have one of these toggled for one scan it doesn't do anything so right now

111
00:09:23,010 --> 00:09:28,110
it's basically just scanning this over and over again and waiting for me to do something to tell it

112
00:09:28,110 --> 00:09:29,470
to take an action.

113
00:09:29,790 --> 00:09:40,830
But that's how ARYEETEY return and T and the temporary end work return goes back to the GSR that called

114
00:09:40,950 --> 00:09:51,900
the subroutine containing return temporary end ends the whole scan brings it to an abrupt halt and returns

115
00:09:51,960 --> 00:09:57,970
back to latter to run zero to begin the next scan.

116
00:09:58,020 --> 00:09:59,240
So that's it.

117
00:09:59,250 --> 00:10:06,650
Two more intermediate level commands that you can use and work with and incorporate into your own programs

118
00:10:06,660 --> 00:10:07,630
going forward.

119
00:10:07,830 --> 00:10:09,010
See you next lecture.


