Afrikaans
Akan
Albanian
Amharic
Arabic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Hungarian
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranรฎ)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
1
- [Narrator] In the early days of microcomputers,
2
processors such as the Intel 8080 chip
3
supported 8-bit computing.
4
Computers have evolved a lot since then,
5
progressing through 16-bit
6
and then 32-bit processors has being used,
7
through to the Intel 486 chip.
8
The Microsoft Macro Assembler, MASM,
9
was originally developed as a 32-bit assembler,
10
and exists today in the Microsoft software development kits,
11
as ml.exe.
12
The MASM32 project supports the Microsoft 32-bit, ml.exe.
13
Intel introduced 64-bit processing in the Pentium chip.
14
And this is now the standard used in modern computers.
15
A new version of MASM for 64-bits
16
is now shipped with the SDKs and is called ml64.exe.
17
However, much of the MASM code that we come across
18
is legacy 32-bit.
19
Registers are the primary data areas used by the processor,
20
and they reflect the processing size.
21
So earlier processes worked on 32-bit registers,
22
but modern systems work on 64-bit registers.
23
Fortunately, the X86 chips provide backwards compatibility,
24
and can still use the 32-bit portions of the registers.
25
The term Word Size is sometimes used to refer
26
to the processor size, which is nowadays 64-bits.
27
However, to retain consistency with early terminology,
28
the Windows API continues to use the term "word"
29
to be a 16-bit value.
30
So 32-bits is a double word,
31
and 64-bits is a quad word.
32
There are also extended registers available
33
in some of the more recent X64 chips.
34
These are known as the XMM registers
35
and allow operations using 128-bits.
36
We'll take a look at the XMM registers later on.
37
There's also YMM registers,
38
which allow 256-bit operation and beyond.
39
The 64-bit X86 architecture provides a set of 16 registers,
40
which can be accessed to 64 bits, 32 bits, 16 bits,
41
or in some cases 8-bits using the mnemonic shown.
42
Racks can be used as a general purpose register,
43
but is also typically used as the register
44
for the return value from functions.
45
RSP is used as the stack pointer.
46
The processor also maintains an RIP or EIP register,
47
which is the next instruction pointer.
48
A typical sequence of events when coding an assembler,
49
is to load a register with
50
the contents of a memory location,
51
process it and store it back into memory.
52
Let's see how we code that
53
in the 32-bit MASM assembly language.
54
I've set up a new project
55
and here we see the skeleton MASM console code.
56
In the constant section at line two,
57
I'll set a hexadecimal value of A-B-A-D-D-E-E-D,
58
for the variable trouble.
59
Trouble equals 0 A-B-A-D-D-E-E-D,
60
and H to show that this is a hexadecimal constant.
61
In the dissection at line eight, let's set up a string,
62
which is stored as an array of bytes,
63
a 16-bit word and a double word value.
64
Buffer DB,
65
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
bword and the mnemonic for this is dw,
67
and we'll set it to a value, 25.
68
And bdouble, and the mnemonic for that is dd.
69
And we'll set that to a hexadecimal string DEADBEEF.
70
Now let's add some code starting at line 20
71
to move these values into the racks register
72
being careful to ensure we match the register mnemonic
73
with the data size
74
move, al
75
and we put the contents of the first character
76
in the buffer,
77
and then we'll follow
78
that by moving again into al
79
and replacing the value with the second entry
80
in the string buffer.
81
We'll move the word bword into AX
82
and we'll move into EAX the double word,
83
bdouble we'll, then move into EAX trouble
84
and we'll use the move instruction again
85
to store back into bdouble the value in EAX.
86
Okay we'll build, build project one dot EXE,
87
and we can see we have no errors.
88
Let's see what this looks like.
89
As we step through it by selecting,
90
build debug project 1,
91
we're in the debugger and we'll press run to use a code
92
and then we'll press F7 to get down to our code.
93
Okay we can see the code that we wrote,
94
I'll go to the memory map tab,
95
and I'll double click the data section
96
at the bottom left we can see the data values that we set.
97
Let's step to the first move using F8,
98
the two instructions at 40101C and 401021
99
I move AL by pointer data segment 404.004
100
and move al by pointer data segment 404005,
101
and the machine code is 0044400-00540400
102
we can say the bottom left.
103
The address of the first bit in the buffer
104
is indeed 404 power 4
105
and we can see that
106
the four bits of the machine code address
107
are in little Indian form
108
which means they're held in reverse order bit wise.
109
Okay let's start with first instruction
110
and watch the value of EAX in the top right panel.
111
We can see the bottom bit of EAX has changed to 41.
112
The value from our buffer
113
let's step again,
114
And we can see
115
that the bottom bit is now 42,
116
the hexadecimal value of B,
117
the next bit from our character string.
118
The next instruction has an address 40401E
119
which we can see at the bottom left contains 19
120
followed by zero zero.
121
As we step over this,
122
we can see the last two bits of EAX
123
become 0019.
124
The hexadecimal value for 25,
125
the next instruction points to 404020
126
and we can see the four bytes, E-F-B-E-A-D-D-E.
127
As we step over it, we see EAX turn into DEADBEEF.
128
We can now load EAX with the constant trouble,
129
and we can see EX has become a bad deed,
130
and when we, again, step, we can see the data
131
at the bottom left at 404020,
132
has become E-D-D-E-8D-8B.
133
So we've now load the data
134
from memory into a 32 bit register,
135
and also at 16 and eight big forms
136
loaded a constant value into a register
137
and stored a register back into memory.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.