summary refs log tree commit diff stats
path: root/blog/asm
diff options
context:
space:
mode:
Diffstat (limited to 'blog/asm')
-rw-r--r--blog/asm/1.html77
1 files changed, 41 insertions, 36 deletions
diff --git a/blog/asm/1.html b/blog/asm/1.html
index c4b0bf6..d46759f 100644
--- a/blog/asm/1.html
+++ b/blog/asm/1.html
@@ -3,7 +3,7 @@
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
 <head>
-<!-- 2024-03-07 Thu 20:54 -->
+<!-- 2024-03-07 Thu 20:55 -->
 <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
 <meta name="viewport" content="width=device-width, initial-scale=1" />
 <title>x86 Assembly from my understanding</title>
@@ -23,9 +23,9 @@
 <p>
 Soooo this article (or maybe even a series of articles, who knows ?) will be about x86 assembly, or rather, what I understood from it and my road from the bottom-up hopefully reaching a good level of understanding
 </p>
-<div id="outline-container-org826f92f" class="outline-2">
-<h2 id="org826f92f">Memory :</h2>
-<div class="outline-text-2" id="text-org826f92f">
+<div id="outline-container-org924bef5" class="outline-2">
+<h2 id="org924bef5">Memory :</h2>
+<div class="outline-text-2" id="text-org924bef5">
 <p>
 Memory is a sequence of octets (Aka 8bits) that each have a unique integer assigned to them called <b>The Effective Address (EA)</b>, in this particular CPU Architecture (the i8086), the octet is designated by a couple (A segment number, and the offset in the segment)
 </p>
@@ -40,9 +40,9 @@ Memory is a sequence of octets (Aka 8bits) that each have a unique integer assig
 The offset and segment are encoded in 16bits, so they take a value between 0 and 65535
 </p>
 </div>
-<div id="outline-container-orgdfce54b" class="outline-4">
-<h4 id="orgdfce54b">Important :</h4>
-<div class="outline-text-4" id="text-orgdfce54b">
+<div id="outline-container-orgdfa99d1" class="outline-4">
+<h4 id="orgdfa99d1">Important :</h4>
+<div class="outline-text-4" id="text-orgdfa99d1">
 <p>
 The relation between the Effective Address and the Segment &amp; Offset is as follow :
 </p>
@@ -52,8 +52,8 @@ The relation between the Effective Address and the Segment &amp; Offset is as fo
 </p>
 </div>
 <ul class="org-ul">
-<li><a id="org3da6d39"></a>Example :<br />
-<div class="outline-text-5" id="text-org3da6d39">
+<li><a id="org8845f88"></a>Example :<br />
+<div class="outline-text-5" id="text-org8845f88">
 <p>
 Let the Physical address (Or Effective Address, these two terms are enterchangeable) <b>12345h</b> (the h refers to Hexadecimal, which can also be written like this <b>0x12345</b>), the register <b>DS = 1230h</b> and the register <b>SI = 0045h</b>, the CPU calculates the physical address by multiplying the content of the segment register <b>DS</b> by 10h (or 16) and adding the content of the register <b>SI</b>. so we get : <b>1230h x 10h + 45h = 12345h</b>
 </p>
@@ -66,16 +66,16 @@ Now if you are a clever one ( I know you are, since you are reading this &lt;3 )
 </li>
 </ul>
 </div>
-<div id="outline-container-org53e7169" class="outline-3">
-<h3 id="org53e7169">Registers</h3>
-<div class="outline-text-3" id="text-org53e7169">
+<div id="outline-container-org16ce372" class="outline-3">
+<h3 id="org16ce372">Registers</h3>
+<div class="outline-text-3" id="text-org16ce372">
 <p>
 The 8086 CPU has 14 registers of 16bits of size. From the POV of the user, the 8086 has 3 groups of 4 registers of 16bits. One state register of 9bits and a counting program of 16bits inaccessible to the user (whatever this means).
 </p>
 </div>
-<div id="outline-container-org052f8dc" class="outline-4">
-<h4 id="org052f8dc">General Registers</h4>
-<div class="outline-text-4" id="text-org052f8dc">
+<div id="outline-container-org8d1541d" class="outline-4">
+<h4 id="org8d1541d">General Registers</h4>
+<div class="outline-text-4" id="text-org8d1541d">
 <p>
 General registers contribute to arithmetic&rsquo;s and logic and addressing too.
 </p>
@@ -126,28 +126,28 @@ Now here are the Registers we can find in this section:
 </div>
 </div>
 </div>
-<div id="outline-container-org2327321" class="outline-3">
-<h3 id="org2327321">Addressing and registers&#x2026;again</h3>
-<div class="outline-text-3" id="text-org2327321">
+<div id="outline-container-orgd61521c" class="outline-3">
+<h3 id="orgd61521c">Addressing and registers&#x2026;again</h3>
+<div class="outline-text-3" id="text-orgd61521c">
 </div>
-<div id="outline-container-orgcab6464" class="outline-4">
-<h4 id="orgcab6464">I realized what I wrote here before was almost gibberish, sooo here we go again I guess ?</h4>
-<div class="outline-text-4" id="text-orgcab6464">
+<div id="outline-container-orgc573bac" class="outline-4">
+<h4 id="orgc573bac">I realized what I wrote here before was almost gibberish, sooo here we go again I guess ?</h4>
+<div class="outline-text-4" id="text-orgc573bac">
 <p>
 Well lets take a step back to the notion of effective addresses VS relative ones.
 </p>
 </div>
 </div>
-<div id="outline-container-orgb2c4683" class="outline-4">
-<h4 id="orgb2c4683">Effective = 10h x Segment + Offset . Part1</h4>
-<div class="outline-text-4" id="text-orgb2c4683">
+<div id="outline-container-org83b616a" class="outline-4">
+<h4 id="org83b616a">Effective = 10h x Segment + Offset . Part1</h4>
+<div class="outline-text-4" id="text-org83b616a">
 <p>
 When trying to access a specific memory space, we use this annotation <b>[Segment:Offset]</b>, so for example, and assuming <b>DS = 0100h</b>. We want to write the value <b>0x0005</b> to the memory space defined by the physical address <b>1234h</b>, what do we do ?
 </p>
 </div>
 <ul class="org-ul">
-<li><a id="orge32ff8e"></a>Answer :<br />
-<div class="outline-text-5" id="text-orge32ff8e">
+<li><a id="orga0fd499"></a>Answer :<br />
+<div class="outline-text-5" id="text-orga0fd499">
 <div class="org-src-container">
 <pre class="src src-asm"><span style="color: #89b4fa;">MOV</span> [DS:0234h], 0x0005
 </pre>
@@ -155,11 +155,16 @@ When trying to access a specific memory space, we use this annotation <b>[Segmen
 
 <p>
 Why ? Let&rsquo;s break it down :
-<img src="../../src/gifs/lain-dance.gif" alt="lain-dance.gif" />
 </p>
 
 
 
+<div id="orge5d4a33" class="figure">
+<p><img src="../../src/gifs/lain-dance.gif" alt="lain-dance.gif" />
+</p>
+</div>
+
+
 <p>
 We Already know that <b>Effective = 10h x Segment + Offset</b>, So here we have : <b>1234h = 10h x DS + Offset</b>, we already know that <b>DS = 0100h</b>, we end up with this simple equation <b>1234h = 1000h + Offset</b>, therefor the Offset is <b>0234h</b>
 </p>
@@ -172,9 +177,9 @@ Simple, right ?, now for another example
 </li>
 </ul>
 </div>
-<div id="outline-container-orga49169d" class="outline-4">
-<h4 id="orga49169d">Another example :</h4>
-<div class="outline-text-4" id="text-orga49169d">
+<div id="outline-container-org93b46d0" class="outline-4">
+<h4 id="org93b46d0">Another example :</h4>
+<div class="outline-text-4" id="text-org93b46d0">
 <p>
 What if we now have this instruction ?
 </p>
@@ -187,9 +192,9 @@ What does it do ? You might or might not be surprised that it does the exact sam
 </p>
 </div>
 </div>
-<div id="outline-container-org901ecc2" class="outline-4">
-<h4 id="org901ecc2">Segment + Register &lt;3</h4>
-<div class="outline-text-4" id="text-org901ecc2">
+<div id="outline-container-orgcba10b0" class="outline-4">
+<h4 id="orgcba10b0">Segment + Register &lt;3</h4>
+<div class="outline-text-4" id="text-orgcba10b0">
 <p>
 Consider <b>DS = 0100h</b> and <b>BX = BP = 0234h</b> and this code snippet:
 </p>
@@ -225,8 +230,8 @@ The General rule of thumb is as follows :
 </ul>
 </div>
 <ul class="org-ul">
-<li><a id="org6cd6bc8"></a>Note<br />
-<div class="outline-text-5" id="text-org6cd6bc8">
+<li><a id="orgf6c5f3b"></a>Note<br />
+<div class="outline-text-5" id="text-orgf6c5f3b">
 <p>
 The values of the registers CS DS and SS are automatically initialized by the OS when launching the program. So these segments are implicit. AKA : If we want to access a specific data in memory, we just need to specify its offset. Also you can&rsquo;t write directly into the DS or CS segment registers, so something like
 </p>
@@ -244,7 +249,7 @@ The values of the registers CS DS and SS are automatically initialized by the OS
 </div>
 <div id="postamble" class="status">
 <p class="author">Author: Crystal</p>
-<p class="date">Created: 2024-03-07 Thu 20:54</p>
+<p class="date">Created: 2024-03-07 Thu 20:55</p>
 </div>
 </body>
 </html>
'>33352536 ^
6a7eaa81 ^

f04fdc8e ^







33352536 ^
f04fdc8e ^
33352536 ^

f04fdc8e ^


6a7eaa81 ^
7a583220 ^
33352536 ^

71eb22a5 ^
6a7eaa81 ^

33352536 ^
71eb22a5 ^
6a7eaa81 ^

33352536 ^
6a7eaa81 ^


33352536 ^

6a7eaa81 ^
d7622824 ^
6a7eaa81 ^
33352536 ^
6a7eaa81 ^


33352536 ^
6a7eaa81 ^

d7622824 ^
6a7eaa81 ^
33352536 ^
6a7eaa81 ^


33352536 ^
7a583220 ^
33352536 ^

6a7eaa81 ^

f04fdc8e ^
7a583220 ^
33352536 ^

71eb22a5 ^
6a7eaa81 ^

33352536 ^
71eb22a5 ^
6a7eaa81 ^

33352536 ^
6a7eaa81 ^


33352536 ^

6a7eaa81 ^


33352536 ^
6a7eaa81 ^


33352536 ^
6a7eaa81 ^


d7622824 ^
6a7eaa81 ^
33352536 ^
6a7eaa81 ^


33352536 ^
7a583220 ^
33352536 ^

6a7eaa81 ^

bc20cc3d ^
71eb22a5 ^
7a583220 ^
33352536 ^

bc20cc3d ^
33352536 ^

bc20cc3d ^
33352536 ^

bc20cc3d ^


33352536 ^


6070c23e ^
bc20cc3d ^
33352536 ^







bc20cc3d ^
33352536 ^
7a583220 ^
33352536 ^

bc20cc3d ^

aff782c4 ^





bc20cc3d ^


3a044623 ^
bc20cc3d ^



33352536 ^
bc20cc3d ^
33352536 ^

bc20cc3d ^


6a7eaa81 ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237