1
00:00:00,770 --> 00:00:05,630
Hello, my name is Stephan, and in this video lecture we will delve into the assembly code, which

2
00:00:05,630 --> 00:00:12,380
we will write in calculator, dot, asme file, and this code will demonstrate various arithmetic operations

3
00:00:12,380 --> 00:00:19,760
on numbers using the x86 64 assembly language, and I will also provide comprehensive explanation for

4
00:00:19,760 --> 00:00:26,690
each register and variable used in the code, helping you to understand how the calculations and operations

5
00:00:26,690 --> 00:00:29,130
are carried out step by step.

6
00:00:29,150 --> 00:00:34,580
Now let's open our assembly here and close our previously open terminal.

7
00:00:35,240 --> 00:00:38,930
We will develop it using this and create a new project.

8
00:00:39,530 --> 00:00:41,420
Clear the previous project here.

9
00:00:42,490 --> 00:00:42,690
PM.

10
00:00:42,790 --> 00:00:46,630
I mean the default code here and here.

11
00:00:46,630 --> 00:00:49,420
We will save it on the assembly.

12
00:00:49,420 --> 00:00:54,160
We will create a new folder, let's name it Calculator.

13
00:00:55,780 --> 00:00:57,710
And calculators.

14
00:00:59,470 --> 00:01:00,190
That's it.

15
00:01:01,040 --> 00:01:04,280
Now, let's name it the calculator.

16
00:01:04,310 --> 00:01:05,900
Calculator.

17
00:01:06,290 --> 00:01:06,560
Dot.

18
00:01:07,160 --> 00:01:12,160
We will declare an external function print f for later use.

19
00:01:12,170 --> 00:01:14,510
So external print f.

20
00:01:15,910 --> 00:01:19,420
Actually decrease the brightness a little bit.

21
00:01:19,810 --> 00:01:20,920
Okay, that's better.

22
00:01:20,950 --> 00:01:23,560
Now what we're going to do is we will section.

23
00:01:24,550 --> 00:01:25,180
Section.

24
00:01:25,180 --> 00:01:26,320
We will cut the section data.

25
00:01:26,320 --> 00:01:26,830
Here.

26
00:01:26,830 --> 00:01:32,740
We will define a 64 bit floating point number with a value of one.

27
00:01:33,420 --> 00:01:34,290
To right.

28
00:01:35,040 --> 00:01:37,380
And number one.

29
00:01:40,170 --> 00:01:43,080
BC for creating floating point numbers.

30
00:01:43,080 --> 00:01:47,070
And we will, uh, give it the value.

31
00:01:47,220 --> 00:01:49,830
One 128.

32
00:01:49,860 --> 00:01:54,030
Number two is going to be, uh, 19 as well.

33
00:01:54,030 --> 00:01:59,640
We will define another 64 bit floating point number with the value of 19.

34
00:02:01,660 --> 00:02:08,770
And we will define a signed 64 bit integer with the value of -12.

35
00:02:09,880 --> 00:02:11,740
Negative number.

36
00:02:13,270 --> 00:02:14,500
So let's make it.

37
00:02:15,360 --> 00:02:19,050
Here, so a negative number DQ as well.

38
00:02:19,050 --> 00:02:19,830
So.

39
00:02:28,970 --> 00:02:29,990
And 12.

40
00:02:32,770 --> 00:02:37,900
And also keep in mind that these are not necessarily floating point numbers.

41
00:02:37,900 --> 00:02:41,950
So you can you can also they can also behave like integers here.

42
00:02:42,220 --> 00:02:46,480
And this is the first number for arithmetic operations.

43
00:02:46,480 --> 00:02:48,790
This is the second number for arithmetic operations.

44
00:02:48,790 --> 00:02:54,130
And this is a negative number to demonstrate sign extension.

45
00:02:54,730 --> 00:02:56,340
And it can also be positive.

46
00:02:56,350 --> 00:03:03,220
We just name it just nick number and we will format the strings for printf function as well.

47
00:03:03,220 --> 00:03:07,450
So we will define fmt DB.

48
00:03:12,060 --> 00:03:16,440
And here the numbers are old.

49
00:03:18,040 --> 00:03:20,080
And here.

50
00:03:22,060 --> 00:03:26,340
Ten zero and we will use fmt int.

51
00:03:26,380 --> 00:03:27,940
I will explain all of this.

52
00:03:28,780 --> 00:03:31,750
After completing this section here.

53
00:03:32,890 --> 00:03:34,240
Like the code section.

54
00:03:34,360 --> 00:03:37,300
I will explain after writing this code.

55
00:03:37,420 --> 00:03:41,290
So s d here again.

56
00:03:42,560 --> 00:03:44,090
And zero.

57
00:03:44,800 --> 00:03:46,090
So me here.

58
00:03:47,300 --> 00:03:49,010
The be here.

59
00:03:49,220 --> 00:03:50,990
The sum is.

60
00:03:55,920 --> 00:03:56,850
And TV.

61
00:04:00,330 --> 00:04:03,660
They pay the difference?

62
00:04:06,800 --> 00:04:08,600
Null terminated strings here.

63
00:04:08,690 --> 00:04:11,600
These are all the null terminated strings.

64
00:04:12,840 --> 00:04:15,280
And I see.

65
00:04:15,290 --> 00:04:15,600
I.

66
00:04:18,660 --> 00:04:19,740
So here.

67
00:04:20,480 --> 00:04:23,960
Number one, incremented.

68
00:04:26,790 --> 00:04:28,230
Null termination.

69
00:04:30,410 --> 00:04:30,950
E.

70
00:04:30,950 --> 00:04:33,440
A c i.

71
00:04:35,040 --> 00:04:35,490
Keep.

72
00:04:37,860 --> 00:04:42,150
Number one incremented here.

73
00:04:45,970 --> 00:04:47,050
Zero as well.

74
00:04:48,040 --> 00:04:49,030
Sally.

75
00:04:50,590 --> 00:04:51,250
EB.

76
00:04:53,140 --> 00:04:55,990
Number one shift.

77
00:04:56,620 --> 00:04:57,280
Left.

78
00:04:58,430 --> 00:05:00,630
Shifts left to here.

79
00:05:00,980 --> 00:05:01,700
X four.

80
00:05:08,390 --> 00:05:09,500
Zero again.

81
00:05:10,490 --> 00:05:12,450
S s a r.

82
00:05:13,650 --> 00:05:14,610
A here.

83
00:05:18,310 --> 00:05:21,970
Number one shift, right?

84
00:05:24,480 --> 00:05:26,250
Right to.

85
00:05:27,220 --> 00:05:30,790
Which is divide by 2 or 4.

86
00:05:36,610 --> 00:05:42,790
Zero and s a r i.

87
00:05:43,120 --> 00:05:43,870
X.

88
00:05:47,220 --> 00:05:48,660
Number one.

89
00:05:49,900 --> 00:05:51,550
Shift, right?

90
00:05:52,390 --> 00:05:57,580
But this one will be shifted with the sign expression.

91
00:05:59,920 --> 00:06:01,540
Us with.

92
00:06:03,360 --> 00:06:05,660
So in the expression here.

93
00:06:12,020 --> 00:06:13,730
Let's add a termination.

94
00:06:15,080 --> 00:06:15,880
Add multi.

95
00:06:15,890 --> 00:06:22,100
We just need to write three lines of code and after that I will explain registers and everything here.

96
00:06:23,550 --> 00:06:24,270
Here.

97
00:06:24,360 --> 00:06:24,870
TB.

98
00:06:26,130 --> 00:06:28,440
This is the the product.

99
00:06:35,580 --> 00:06:41,910
And here this is the integer coefficient.

100
00:06:47,140 --> 00:06:48,610
The integer.

101
00:06:50,320 --> 00:06:51,970
And as.

102
00:06:55,530 --> 00:06:58,800
And lastly, we have the Remy here.

103
00:07:00,640 --> 00:07:04,030
The be here the modulo.

104
00:07:05,620 --> 00:07:06,430
Is.

105
00:07:08,320 --> 00:07:08,790
Zero.

106
00:07:08,800 --> 00:07:12,280
Now that's it with our code for now.

107
00:07:12,280 --> 00:07:16,180
Here we will add also, we will also add more codes here.

108
00:07:16,540 --> 00:07:19,140
Here we just developed a section data here.

109
00:07:19,150 --> 00:07:28,990
Now the the registers, um, like the general purpose registers are used to hold data and perform arithmetic

110
00:07:28,990 --> 00:07:31,870
operation, which we will learn that in next lecture.

111
00:07:31,870 --> 00:07:39,400
But firstly, what we're going to sing here is at the second line of our program here we are declaring

112
00:07:39,400 --> 00:07:48,190
an external function printf that is used in another module like C library, and this allows the assembly

113
00:07:48,190 --> 00:07:52,750
code to call the printf function for output.

114
00:07:52,750 --> 00:07:58,660
And in this data here we are declaring a section of memory where initialized data is stored.

115
00:07:58,690 --> 00:08:06,430
The number one, number two and the negative number are initialized with a specific values for arithmetic

116
00:08:06,430 --> 00:08:07,360
operations.

117
00:08:08,160 --> 00:08:08,940
And.

118
00:08:10,050 --> 00:08:12,210
And we also have the format strings here.

119
00:08:14,430 --> 00:08:21,920
And here the first format string does that here, this fmt here.

120
00:08:21,930 --> 00:08:28,480
So this format string is used to display the values of two long integers.

121
00:08:28,500 --> 00:08:32,270
The LD and the LD here, as you can see.

122
00:08:32,280 --> 00:08:39,570
So LD is a placeholder that will be placed with the actual values of the long integers.

123
00:08:40,560 --> 00:08:49,020
And ten here represents the Ascii code for a new line character like the new line character.

124
00:08:49,020 --> 00:08:49,980
This here.

125
00:08:50,880 --> 00:08:57,990
And after that, so we have the new line and this is the zero indicates the end of the string, which

126
00:08:57,990 --> 00:09:03,090
is a null terminated string here to mark its completion.

127
00:09:05,130 --> 00:09:09,660
And also we have here is let me actually fix this mask.

128
00:09:10,050 --> 00:09:14,790
Also, we have here the fmt, uh, integer here.

129
00:09:16,800 --> 00:09:23,010
So the this form of string is used to display a string followed by a long integer.

130
00:09:23,010 --> 00:09:25,020
As you can see here, this is a string.

131
00:09:25,020 --> 00:09:29,610
This is a long integer and the S is a placeholder for a string.

132
00:09:29,610 --> 00:09:33,450
And the L is a placeholder for a long integer.

133
00:09:33,450 --> 00:09:38,120
And ten here represents the Ascii code for a new line character as well.

134
00:09:38,130 --> 00:09:42,000
The this is the new line character and.

135
00:09:43,100 --> 00:09:47,330
This will cause the new line to be printed after this value.

136
00:09:47,690 --> 00:09:51,200
And this zero here indicates the end of a string.

137
00:09:51,470 --> 00:09:54,440
It's also called the null terminated string.

138
00:09:54,440 --> 00:09:58,220
And we also have the Sumi here as.

139
00:09:58,990 --> 00:10:00,700
You, am I?

140
00:10:01,150 --> 00:10:07,600
So this format string is a message to be printed before displaying the sum of two numbers.

141
00:10:07,720 --> 00:10:14,650
The string simply states the sum is and zero here indicates the end of the string, which is a null

142
00:10:14,650 --> 00:10:15,540
terminated string.

143
00:10:15,550 --> 00:10:22,870
And we also have d here d i f i.

144
00:10:23,440 --> 00:10:24,520
Similar to the previous one.

145
00:10:24,520 --> 00:10:29,680
The this format string is a message to be printed before displaying the difference.

146
00:10:30,130 --> 00:10:33,030
Uh, with the difference of two numbers.

147
00:10:33,040 --> 00:10:39,040
The string states, the the differences and zero indicates the end of the string.

148
00:10:39,070 --> 00:10:48,280
And also we have a i n i this is the format string message is to be printed before displaying the increment

149
00:10:48,280 --> 00:10:49,450
value of the first one.

150
00:10:49,450 --> 00:10:55,630
The string just simply states number one incremented and zero indicates the end of the string.

151
00:10:55,660 --> 00:10:56,710
So.

152
00:10:57,990 --> 00:11:00,390
We have the same here.

153
00:11:00,390 --> 00:11:02,430
And that's it.

154
00:11:03,330 --> 00:11:06,300
And yeah, that they are basically the same here.

155
00:11:06,300 --> 00:11:10,920
They are just a string we are attaching to this variable names and so on.

156
00:11:10,920 --> 00:11:17,250
So this format strings are essential for presenting clear and informative output messages when performing

157
00:11:17,250 --> 00:11:24,000
arithmetic operations and manipulations on the provided numbers so the placeholders within the format

158
00:11:24,000 --> 00:11:29,160
string will be replaced with the actual values like these placeholders.

159
00:11:29,160 --> 00:11:31,260
Here's LD and so on.

160
00:11:32,970 --> 00:11:39,960
Uh, so they will they will be replaced with the actual values during the printf function called the

161
00:11:39,960 --> 00:11:49,110
null termination at the end of every string here is crucial for proper string handling in C and other

162
00:11:49,110 --> 00:11:52,290
low level languages, like in assembly language as well.

163
00:11:52,290 --> 00:12:00,900
So this code essentially sets, but actually so you don't add the null terminated string characters

164
00:12:01,470 --> 00:12:04,530
manually just handles it automatically.

165
00:12:05,750 --> 00:12:13,160
Now, this code here essentially sets sets up data values for my strings and external function declarations

166
00:12:13,160 --> 00:12:18,710
for performing arithmetic operations on the provided numbers and demonstrating various manipulations.

167
00:12:18,710 --> 00:12:25,610
So the format strings are used with the printf function to display the messages and computed results.

168
00:12:25,820 --> 00:12:33,650
So the x86 64 assembly registers are key elements in executing the arithmetic, operations and manipulations

169
00:12:33,650 --> 00:12:36,320
outlined in this code.

170
00:12:36,650 --> 00:12:39,920
I'm awaiting you in next lecture for continuing our project.