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.08
- [Narrator] In the early days of microcomputers,
2
00:00:02.08 --> 00:00:05.03
processors such as the Intel 8080 chip
3
00:00:05.03 --> 00:00:07.04
supported 8-bit computing.
4
00:00:07.04 --> 00:00:09.06
Computers have evolved a lot since then,
5
00:00:09.06 --> 00:00:11.02
progressing through 16-bit
6
00:00:11.02 --> 00:00:14.00
and then 32-bit processors has being used,
7
00:00:14.00 --> 00:00:16.09
through to the Intel 486 chip.
8
00:00:16.09 --> 00:00:19.02
The Microsoft Macro Assembler, MASM,
9
00:00:19.02 --> 00:00:21.09
was originally developed as a 32-bit assembler,
10
00:00:21.09 --> 00:00:25.02
and exists today in the Microsoft software development kits,
11
00:00:25.02 --> 00:00:27.02
as ml.exe.
12
00:00:27.02 --> 00:00:33.02
The MASM32 project supports the Microsoft 32-bit, ml.exe.
13
00:00:33.02 --> 00:00:36.08
Intel introduced 64-bit processing in the Pentium chip.
14
00:00:36.08 --> 00:00:40.01
And this is now the standard used in modern computers.
15
00:00:40.01 --> 00:00:42.05
A new version of MASM for 64-bits
16
00:00:42.05 --> 00:00:47.09
is now shipped with the SDKs and is called ml64.exe.
17
00:00:47.09 --> 00:00:51.01
However, much of the MASM code that we come across
18
00:00:51.01 --> 00:00:53.09
is legacy 32-bit.
19
00:00:53.09 --> 00:00:57.05
Registers are the primary data areas used by the processor,
20
00:00:57.05 --> 00:01:00.00
and they reflect the processing size.
21
00:01:00.00 --> 00:01:03.04
So earlier processes worked on 32-bit registers,
22
00:01:03.04 --> 00:01:07.04
but modern systems work on 64-bit registers.
23
00:01:07.04 --> 00:01:11.06
Fortunately, the X86 chips provide backwards compatibility,
24
00:01:11.06 --> 00:01:15.05
and can still use the 32-bit portions of the registers.
25
00:01:15.05 --> 00:01:17.08
The term Word Size is sometimes used to refer
26
00:01:17.08 --> 00:01:21.07
to the processor size, which is nowadays 64-bits.
27
00:01:21.07 --> 00:01:25.00
However, to retain consistency with early terminology,
28
00:01:25.00 --> 00:01:28.08
the Windows API continues to use the term "word"
29
00:01:28.08 --> 00:01:31.01
to be a 16-bit value.
30
00:01:31.01 --> 00:01:33.07
So 32-bits is a double word,
31
00:01:33.07 --> 00:01:37.04
and 64-bits is a quad word.
32
00:01:37.04 --> 00:01:40.00
There are also extended registers available
33
00:01:40.00 --> 00:01:42.09
in some of the more recent X64 chips.
34
00:01:42.09 --> 00:01:45.01
These are known as the XMM registers
35
00:01:45.01 --> 00:01:49.02
and allow operations using 128-bits.
36
00:01:49.02 --> 00:01:52.02
We'll take a look at the XMM registers later on.
37
00:01:52.02 --> 00:01:54.01
There's also YMM registers,
38
00:01:54.01 --> 00:01:58.04
which allow 256-bit operation and beyond.
39
00:01:58.04 --> 00:02:02.08
The 64-bit X86 architecture provides a set of 16 registers,
40
00:02:02.08 --> 00:02:07.01
which can be accessed to 64 bits, 32 bits, 16 bits,
41
00:02:07.01 --> 00:02:11.09
or in some cases 8-bits using the mnemonic shown.
42
00:02:11.09 --> 00:02:13.09
Racks can be used as a general purpose register,
43
00:02:13.09 --> 00:02:16.05
but is also typically used as the register
44
00:02:16.05 --> 00:02:19.01
for the return value from functions.
45
00:02:19.01 --> 00:02:21.09
RSP is used as the stack pointer.
46
00:02:21.09 --> 00:02:26.00
The processor also maintains an RIP or EIP register,
47
00:02:26.00 --> 00:02:29.00
which is the next instruction pointer.
48
00:02:29.00 --> 00:02:32.00
A typical sequence of events when coding an assembler,
49
00:02:32.00 --> 00:02:33.01
is to load a register with
50
00:02:33.01 --> 00:02:35.02
the contents of a memory location,
51
00:02:35.02 --> 00:02:38.05
process it and store it back into memory.
52
00:02:38.05 --> 00:02:39.08
Let's see how we code that
53
00:02:39.08 --> 00:02:42.05
in the 32-bit MASM assembly language.
54
00:02:42.05 --> 00:02:44.02
I've set up a new project
55
00:02:44.02 --> 00:02:47.04
and here we see the skeleton MASM console code.
56
00:02:47.04 --> 00:02:49.08
In the constant section at line two,
57
00:02:49.08 --> 00:02:54.02
I'll set a hexadecimal value of A-B-A-D-D-E-E-D,
58
00:02:54.02 --> 00:02:56.09
for the variable trouble.
59
00:02:56.09 --> 00:03:06.09
Trouble equals 0 A-B-A-D-D-E-E-D,
60
00:03:06.09 --> 00:03:10.08
and H to show that this is a hexadecimal constant.
61
00:03:10.08 --> 00:03:13.09
In the dissection at line eight, let's set up a string,
62
00:03:13.09 --> 00:03:16.06
which is stored as an array of bytes,
63
00:03:16.06 --> 00:03:21.09
a 16-bit word and a double word value.
64
00:03:21.09 --> 00:03:25.02
Buffer DB,
65
00:03:25.02 --> 00:03:37.01
A-B-C-D-E-F-G-H-I-J-K-L-M-N-O-P-Q-R-S-T-U-V-W-X-Y-Z,
66
00:03:37.01 --> 00:03:41.06
bword and the mnemonic for this is dw,
67
00:03:41.06 --> 00:03:46.00
and we'll set it to a value, 25.
68
00:03:46.00 --> 00:03:51.05
And bdouble, and the mnemonic for that is dd.
69
00:03:51.05 --> 00:04:03.06
And we'll set that to a hexadecimal string DEADBEEF.
70
00:04:03.06 --> 00:04:05.07
Now let's add some code starting at line 20
71
00:04:05.07 --> 00:04:08.09
to move these values into the racks register
72
00:04:08.09 --> 00:04:12.00
being careful to ensure we match the register mnemonic
73
00:04:12.00 --> 00:04:15.05
with the data size
74
00:04:15.05 --> 00:04:18.01
move, al
75
00:04:18.01 --> 00:04:19.09
and we put the contents of the first character
76
00:04:19.09 --> 00:04:22.01
in the buffer,
77
00:04:22.01 --> 00:04:22.09
and then we'll follow
78
00:04:22.09 --> 00:04:25.02
that by moving again into al
79
00:04:25.02 --> 00:04:30.05
and replacing the value with the second entry
80
00:04:30.05 --> 00:04:32.04
in the string buffer.
81
00:04:32.04 --> 00:04:40.08
We'll move the word bword into AX
82
00:04:40.08 --> 00:04:46.00
and we'll move into EAX the double word,
83
00:04:46.00 --> 00:04:54.01
bdouble we'll, then move into EAX trouble
84
00:04:54.01 --> 00:04:58.01
and we'll use the move instruction again
85
00:04:58.01 --> 00:05:03.00
to store back into bdouble the value in EAX.
86
00:05:03.00 --> 00:05:08.01
Okay we'll build, build project one dot EXE,
87
00:05:08.01 --> 00:05:10.02
and we can see we have no errors.
88
00:05:10.02 --> 00:05:11.07
Let's see what this looks like.
89
00:05:11.07 --> 00:05:14.04
As we step through it by selecting,
90
00:05:14.04 --> 00:05:17.07
build debug project 1,
91
00:05:17.07 --> 00:05:22.03
we're in the debugger and we'll press run to use a code
92
00:05:22.03 --> 00:05:28.00
and then we'll press F7 to get down to our code.
93
00:05:28.00 --> 00:05:30.05
Okay we can see the code that we wrote,
94
00:05:30.05 --> 00:05:33.09
I'll go to the memory map tab,
95
00:05:33.09 --> 00:05:38.02
and I'll double click the data section
96
00:05:38.02 --> 00:05:42.05
at the bottom left we can see the data values that we set.
97
00:05:42.05 --> 00:05:48.03
Let's step to the first move using F8,
98
00:05:48.03 --> 00:05:55.04
the two instructions at 40101C and 401021
99
00:05:55.04 --> 00:06:02.04
I move AL by pointer data segment 404.004
100
00:06:02.04 --> 00:06:07.05
and move al by pointer data segment 404005,
101
00:06:07.05 --> 00:06:18.00
and the machine code is 0044400-00540400
102
00:06:18.00 --> 00:06:19.03
we can say the bottom left.
103
00:06:19.03 --> 00:06:21.02
The address of the first bit in the buffer
104
00:06:21.02 --> 00:06:24.05
is indeed 404 power 4
105
00:06:24.05 --> 00:06:25.03
and we can see that
106
00:06:25.03 --> 00:06:27.06
the four bits of the machine code address
107
00:06:27.06 --> 00:06:29.04
are in little Indian form
108
00:06:29.04 --> 00:06:33.05
which means they're held in reverse order bit wise.
109
00:06:33.05 --> 00:06:35.06
Okay let's start with first instruction
110
00:06:35.06 --> 00:06:40.04
and watch the value of EAX in the top right panel.
111
00:06:40.04 --> 00:06:44.03
We can see the bottom bit of EAX has changed to 41.
112
00:06:44.03 --> 00:06:46.02
The value from our buffer
113
00:06:46.02 --> 00:06:48.01
let's step again,
114
00:06:48.01 --> 00:06:48.09
And we can see
115
00:06:48.09 --> 00:06:50.09
that the bottom bit is now 42,
116
00:06:50.09 --> 00:06:53.00
the hexadecimal value of B,
117
00:06:53.00 --> 00:06:55.08
the next bit from our character string.
118
00:06:55.08 --> 00:06:59.06
The next instruction has an address 40401E
119
00:06:59.06 --> 00:07:03.03
which we can see at the bottom left contains 19
120
00:07:03.03 --> 00:07:05.07
followed by zero zero.
121
00:07:05.07 --> 00:07:07.02
As we step over this,
122
00:07:07.02 --> 00:07:09.04
we can see the last two bits of EAX
123
00:07:09.04 --> 00:07:12.01
become 0019.
124
00:07:12.01 --> 00:07:15.06
The hexadecimal value for 25,
125
00:07:15.06 --> 00:07:19.00
the next instruction points to 404020
126
00:07:19.00 --> 00:07:25.00
and we can see the four bytes, E-F-B-E-A-D-D-E.
127
00:07:25.00 --> 00:07:31.06
As we step over it, we see EAX turn into DEADBEEF.
128
00:07:31.06 --> 00:07:36.09
We can now load EAX with the constant trouble,
129
00:07:36.09 --> 00:07:41.00
and we can see EX has become a bad deed,
130
00:07:41.00 --> 00:07:44.01
and when we, again, step, we can see the data
131
00:07:44.01 --> 00:07:48.03
at the bottom left at 404020,
132
00:07:48.03 --> 00:07:53.02
has become E-D-D-E-8D-8B.
133
00:07:53.02 --> 00:07:54.05
So we've now load the data
134
00:07:54.05 --> 00:07:57.00
from memory into a 32 bit register,
135
00:07:57.00 --> 00:07:59.02
and also at 16 and eight big forms
136
00:07:59.02 --> 00:08:02.03
loaded a constant value into a register
137
00:08:02.03 --> 00:08:05.00
and stored a register back into memory.
10853
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.