Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00.05 --> 00:00:02.06
- [Instructor] Computers of all shapes and sizes
2
00:00:02.06 --> 00:00:04.04
achieve their computational tasks
3
00:00:04.04 --> 00:00:07.07
by manipulating binary data, zeros and ones,
4
00:00:07.07 --> 00:00:09.00
using a set of instructions,
5
00:00:09.00 --> 00:00:12.04
built into the hardware of their chip sets.
6
00:00:12.04 --> 00:00:13.09
These instructions themselves
7
00:00:13.09 --> 00:00:16.01
are represented as zeros and ones
8
00:00:16.01 --> 00:00:18.05
in what's known as machine code.
9
00:00:18.05 --> 00:00:20.08
For as humans it's a bit mind numbing
10
00:00:20.08 --> 00:00:23.02
looking at just zeros and ones.
11
00:00:23.02 --> 00:00:25.04
So we aggregate them into sets of four bits
12
00:00:25.04 --> 00:00:27.02
and call them hexadecimal.
13
00:00:27.02 --> 00:00:29.06
Represented by the numbers no to nine,
14
00:00:29.06 --> 00:00:34.07
and the letters A to F 16 possible values in total.
15
00:00:34.07 --> 00:00:36.06
Chip manufacturers will have their own set
16
00:00:36.06 --> 00:00:39.04
of instructions for their chips.
17
00:00:39.04 --> 00:00:41.02
The most popular instruction set
18
00:00:41.02 --> 00:00:44.05
is that used with the Intel x86 chip.
19
00:00:44.05 --> 00:00:47.06
Two of the commonly seen chip sets are they ARM chip
20
00:00:47.06 --> 00:00:50.01
which is the most popular mobile phone chip,
21
00:00:50.01 --> 00:00:51.05
and the Atmel chip,
22
00:00:51.05 --> 00:00:55.01
which appears in many small IoT type devices.
23
00:00:55.01 --> 00:00:56.03
For the purposes of this course,
24
00:00:56.03 --> 00:00:59.08
we'll be focusing on the x86 chip set.
25
00:00:59.08 --> 00:01:01.07
Instructions are executed in what's known as
26
00:01:01.07 --> 00:01:03.07
the central processing unit of the chip
27
00:01:03.07 --> 00:01:06.01
using a set of registers.
28
00:01:06.01 --> 00:01:07.04
Special areas of the chip,
29
00:01:07.04 --> 00:01:10.01
which are able to manipulate bits.
30
00:01:10.01 --> 00:01:12.01
We'll look at what these registers are shortly
31
00:01:12.01 --> 00:01:14.04
but as an example, the instruction
32
00:01:14.04 --> 00:01:17.09
to add 28 to a register called ESP
33
00:01:17.09 --> 00:01:22.09
will be coded in machine language as 83 C4 1C.
34
00:01:22.09 --> 00:01:24.09
Even this is a bit tricky for us.
35
00:01:24.09 --> 00:01:26.04
Although many low level programs
36
00:01:26.04 --> 00:01:29.00
can write machine code directly.
37
00:01:29.00 --> 00:01:31.04
It's more common however, to use mnemonics
38
00:01:31.04 --> 00:01:34.05
to represent the various parts of the instruction.
39
00:01:34.05 --> 00:01:37.08
And this is what's known as assembly language.
40
00:01:37.08 --> 00:01:39.02
So we'd code this instruction
41
00:01:39.02 --> 00:01:43.09
in assembly language as ADD ESP, 1C.
42
00:01:43.09 --> 00:01:46.03
And then we'd use a program called an assembler
43
00:01:46.03 --> 00:01:49.04
to convert this mnemonic form back to machine code
44
00:01:49.04 --> 00:01:52.09
ready for the computer to execute it.
45
00:01:52.09 --> 00:01:55.05
The general model that we can keep in the back of our minds
46
00:01:55.05 --> 00:01:59.06
as we program in assembler starts with the processing unit.
47
00:01:59.06 --> 00:02:01.00
This works most effectively
48
00:02:01.00 --> 00:02:03.06
with its set of high performance registers.
49
00:02:03.06 --> 00:02:05.02
However, we often need more
50
00:02:05.02 --> 00:02:08.00
than just what can be stored in registers.
51
00:02:08.00 --> 00:02:10.00
So we need to have a memory area
52
00:02:10.00 --> 00:02:12.04
which can be used to store our data
53
00:02:12.04 --> 00:02:14.06
and our program instructions.
54
00:02:14.06 --> 00:02:16.04
We want to interact with the program.
55
00:02:16.04 --> 00:02:18.08
So we need an input and output device
56
00:02:18.08 --> 00:02:21.03
usually a screen and keyboard.
57
00:02:21.03 --> 00:02:23.02
Of course, we also have other devices
58
00:02:23.02 --> 00:02:27.02
such as track pads and the mouse and then embedded products,
59
00:02:27.02 --> 00:02:29.08
we may display to an LED.
60
00:02:29.08 --> 00:02:33.04
However these are just variations on the general theme.
61
00:02:33.04 --> 00:02:35.03
While the internal memory of a computer
62
00:02:35.03 --> 00:02:38.07
gives us what we need to operate, we need more.
63
00:02:38.07 --> 00:02:40.03
While internal memory doesn't need to be
64
00:02:40.03 --> 00:02:42.01
as fast as registers.
65
00:02:42.01 --> 00:02:44.01
It needs to be fast enough.
66
00:02:44.01 --> 00:02:45.04
This means it's volatile.
67
00:02:45.04 --> 00:02:48.07
So its contents disappear when power is removed.
68
00:02:48.07 --> 00:02:51.02
Consequently, we need to also have access
69
00:02:51.02 --> 00:02:53.02
to backing storage of some sort.
70
00:02:53.02 --> 00:02:58.00
Typically a solid state or magnetic surface hard disk.
71
00:02:58.00 --> 00:03:00.09
The size of the instruction does matter.
72
00:03:00.09 --> 00:03:03.09
For X 86 much of the assembler code we see
73
00:03:03.09 --> 00:03:06.02
is written in 32 bit code.
74
00:03:06.02 --> 00:03:09.03
However with the advent of 64 bit processes
75
00:03:09.03 --> 00:03:11.05
more extensive instructions have been included
76
00:03:11.05 --> 00:03:15.00
in the 64 bit versions of the assembler tools.
77
00:03:15.00 --> 00:03:19.01
We'll cover both 32 and 64 bit instructions.
78
00:03:19.01 --> 00:03:23.00
Microsoft includes both 32 bit and 64 bit assemblers
79
00:03:23.00 --> 00:03:26.08
called ml.exe and ml64.exe
80
00:03:26.08 --> 00:03:29.03
in their software development kits.
81
00:03:29.03 --> 00:03:32.03
These tools can be accessed via visual studio
82
00:03:32.03 --> 00:03:35.01
by including them in a C ++ project
83
00:03:35.01 --> 00:03:37.09
or run directly in the command line.
84
00:03:37.09 --> 00:03:41.02
The MASM32 SDK is project developed
85
00:03:41.02 --> 00:03:43.09
around the Microsoft MASM32 product.
86
00:03:43.09 --> 00:03:46.04
Intended as a simpler and easier introduction
87
00:03:46.04 --> 00:03:50.06
to the Microsoft MASM32 bit programming environment.
88
00:03:50.06 --> 00:03:53.06
And it comes with a simple IDE.
89
00:03:53.06 --> 00:03:56.00
GoAsm is a very easy to use set of tools,
90
00:03:56.00 --> 00:03:58.00
providing assembly and linking
91
00:03:58.00 --> 00:04:01.04
of both 32 and 64 bits assembler programs.
92
00:04:01.04 --> 00:04:03.01
We'll be focusing on GoASM
93
00:04:03.01 --> 00:04:06.06
as our assembler of choice in this course.
94
00:04:06.06 --> 00:04:09.00
We've described a basic architecture
95
00:04:09.00 --> 00:04:12.07
with which we can process instructions that work on data.
96
00:04:12.07 --> 00:04:16.00
Let's look at the general classes of instructions.
97
00:04:16.00 --> 00:04:17.05
The first category of instructions
98
00:04:17.05 --> 00:04:19.02
is the load and store instructions,
99
00:04:19.02 --> 00:04:23.03
which move data between registers and memory locations.
100
00:04:23.03 --> 00:04:25.06
These include basic move and store instructions
101
00:04:25.06 --> 00:04:27.05
as well as some more esoteric instructions
102
00:04:27.05 --> 00:04:32.07
such as sign extensions and data exchange instructions.
103
00:04:32.07 --> 00:04:35.04
The second category is the set of instructions
104
00:04:35.04 --> 00:04:39.08
used to add, subtract, multiply, and divide.
105
00:04:39.08 --> 00:04:43.02
Which provide the computational capability of the chip.
106
00:04:43.02 --> 00:04:46.01
These include signed and unsigned operations
107
00:04:46.01 --> 00:04:50.01
Packed Decimal Format operations, floating point operations
108
00:04:50.01 --> 00:04:53.03
and increment and decrement operations.
109
00:04:53.03 --> 00:04:57.08
The third major category is bit wise or logical operations.
110
00:04:57.08 --> 00:05:00.04
These are special forms of manipulation at the bit level
111
00:05:00.04 --> 00:05:03.07
such as shifting, adding or calling and so on.
112
00:05:03.07 --> 00:05:06.01
And they are used for a variety of purposes
113
00:05:06.01 --> 00:05:08.08
including extracting parts of a memory location
114
00:05:08.08 --> 00:05:11.05
a process known as masking.
115
00:05:11.05 --> 00:05:13.09
The next category is that involving instructions
116
00:05:13.09 --> 00:05:17.04
which change the flow of execution of the program.
117
00:05:17.04 --> 00:05:20.05
The most basic form of coding is to perform an instruction
118
00:05:20.05 --> 00:05:23.00
move to the next sequential instruction location
119
00:05:23.00 --> 00:05:26.01
and perform that instruction and so on.
120
00:05:26.01 --> 00:05:28.08
However, we also need to make decisions
121
00:05:28.08 --> 00:05:31.02
on whether to move to the next instruction
122
00:05:31.02 --> 00:05:33.07
or to take an alternative path.
123
00:05:33.07 --> 00:05:35.05
We do this using a set of instructions
124
00:05:35.05 --> 00:05:37.08
which change the Control flow.
125
00:05:37.08 --> 00:05:40.02
This includes if statements,
126
00:05:40.02 --> 00:05:44.03
looping instructions and sub program calls.
127
00:05:44.03 --> 00:05:47.00
There's also a number of advanced capabilities of the chip
128
00:05:47.00 --> 00:05:50.01
including AES hardware capability.
129
00:05:50.01 --> 00:05:53.02
Packed decimal 128 bit instructions
130
00:05:53.02 --> 00:05:57.07
and 256 and larger vector instructions.
131
00:05:57.07 --> 00:06:00.09
We'll cover some of this advanced material in this course
132
00:06:00.09 --> 00:06:03.06
but after the course, you might want to check the full range
133
00:06:03.06 --> 00:06:06.07
of advanced instructions yourself.
134
00:06:06.07 --> 00:06:08.07
With that as an introduction
135
00:06:08.07 --> 00:06:11.06
let's get into learning how to write assembly code.
10983
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.