diff options
author | Crystal <crystal@wizard.tower> | 2024-03-07 20:52:05 +0100 |
---|---|---|
committer | Crystal <crystal@wizard.tower> | 2024-03-07 20:52:05 +0100 |
commit | 84a8ce16ea2a8d285723bdde2ae071f6439baea1 (patch) | |
tree | c99ec042c140de86aebf1e9f639f6dd1cc39de1b | |
parent | 2461686f0e37055df3dc9a3b5ce85076c98f51cb (diff) | |
download | www-84a8ce16ea2a8d285723bdde2ae071f6439baea1.tar.gz |
Add stuff
-rw-r--r-- | blog/asm/1.html | 72 | ||||
-rw-r--r-- | src/org/blog/assembly/1.org | 2 |
2 files changed, 37 insertions, 37 deletions
diff --git a/blog/asm/1.html b/blog/asm/1.html index 702bc47..0221da4 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:48 --> +<!-- 2024-03-07 Thu 20:51 --> <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-orgf540874" class="outline-2"> -<h2 id="orgf540874">Memory :</h2> -<div class="outline-text-2" id="text-orgf540874"> +<div id="outline-container-orgbee531b" class="outline-2"> +<h2 id="orgbee531b">Memory :</h2> +<div class="outline-text-2" id="text-orgbee531b"> <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-orgdfb155c" class="outline-4"> -<h4 id="orgdfb155c">Important :</h4> -<div class="outline-text-4" id="text-orgdfb155c"> +<div id="outline-container-org3db3907" class="outline-4"> +<h4 id="org3db3907">Important :</h4> +<div class="outline-text-4" id="text-org3db3907"> <p> The relation between the Effective Address and the Segment & Offset is as follow : </p> @@ -52,8 +52,8 @@ The relation between the Effective Address and the Segment & Offset is as fo </p> </div> <ul class="org-ul"> -<li><a id="org1aab4ca"></a>Example :<br /> -<div class="outline-text-5" id="text-org1aab4ca"> +<li><a id="org37b19f8"></a>Example :<br /> +<div class="outline-text-5" id="text-org37b19f8"> <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 <3 ) </li> </ul> </div> -<div id="outline-container-org86f9b8f" class="outline-3"> -<h3 id="org86f9b8f">Registers</h3> -<div class="outline-text-3" id="text-org86f9b8f"> +<div id="outline-container-org9bc1004" class="outline-3"> +<h3 id="org9bc1004">Registers</h3> +<div class="outline-text-3" id="text-org9bc1004"> <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-org9fb78cf" class="outline-4"> -<h4 id="org9fb78cf">General Registers</h4> -<div class="outline-text-4" id="text-org9fb78cf"> +<div id="outline-container-org9277a22" class="outline-4"> +<h4 id="org9277a22">General Registers</h4> +<div class="outline-text-4" id="text-org9277a22"> <p> General registers contribute to arithmetic’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-orgbdc7488" class="outline-3"> -<h3 id="orgbdc7488">Addressing and registers…again</h3> -<div class="outline-text-3" id="text-orgbdc7488"> +<div id="outline-container-org2702b3c" class="outline-3"> +<h3 id="org2702b3c">Addressing and registers…again</h3> +<div class="outline-text-3" id="text-org2702b3c"> </div> -<div id="outline-container-org81d6e8a" class="outline-4"> -<h4 id="org81d6e8a">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-org81d6e8a"> +<div id="outline-container-orgef839da" class="outline-4"> +<h4 id="orgef839da">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-orgef839da"> <p> Well lets take a step back to the notion of effective addresses VS relative ones. </p> </div> </div> -<div id="outline-container-org7dee427" class="outline-4"> -<h4 id="org7dee427">Effective = 10h x Segment + Offset . Part1</h4> -<div class="outline-text-4" id="text-org7dee427"> +<div id="outline-container-orgad7af48" class="outline-4"> +<h4 id="orgad7af48">Effective = 10h x Segment + Offset . Part1</h4> +<div class="outline-text-4" id="text-orgad7af48"> <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="org0f12415"></a>Answer :<br /> -<div class="outline-text-5" id="text-org0f12415"> +<li><a id="org0b2c15e"></a>Answer :<br /> +<div class="outline-text-5" id="text-org0b2c15e"> <div class="org-src-container"> <pre class="src src-asm"><span style="color: #89b4fa;">MOV</span> [DS:0234h], 0x0005 </pre> @@ -155,7 +155,7 @@ When trying to access a specific memory space, we use this annotation <b>[Segmen <p> Why ? Let’s break it down : -<img src="../../../gifs/lain-dance.gif" alt="lain-dance.gif" /> +<img src="../../gifs/lain-dance.gif" alt="lain-dance.gif" /> </p> @@ -172,9 +172,9 @@ Simple, right ?, now for another example </li> </ul> </div> -<div id="outline-container-org757ac64" class="outline-4"> -<h4 id="org757ac64">Another example :</h4> -<div class="outline-text-4" id="text-org757ac64"> +<div id="outline-container-org0b9e5e9" class="outline-4"> +<h4 id="org0b9e5e9">Another example :</h4> +<div class="outline-text-4" id="text-org0b9e5e9"> <p> What if we now have this instruction ? </p> @@ -187,9 +187,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-org2f959c2" class="outline-4"> -<h4 id="org2f959c2">Segment + Register <3</h4> -<div class="outline-text-4" id="text-org2f959c2"> +<div id="outline-container-orge060532" class="outline-4"> +<h4 id="orge060532">Segment + Register <3</h4> +<div class="outline-text-4" id="text-orge060532"> <p> Consider <b>DS = 0100h</b> and <b>BX = BP = 0234h</b> and this code snippet: </p> @@ -225,8 +225,8 @@ The General rule of thumb is as follows : </ul> </div> <ul class="org-ul"> -<li><a id="org0e8010b"></a>Note<br /> -<div class="outline-text-5" id="text-org0e8010b"> +<li><a id="orgc97f34f"></a>Note<br /> +<div class="outline-text-5" id="text-orgc97f34f"> <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’t write directly into the DS or CS segment registers, so something like </p> @@ -244,7 +244,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:48</p> +<p class="date">Created: 2024-03-07 Thu 20:51</p> </div> </body> </html> diff --git a/src/org/blog/assembly/1.org b/src/org/blog/assembly/1.org index fa77e49..ac05e07 100644 --- a/src/org/blog/assembly/1.org +++ b/src/org/blog/assembly/1.org @@ -80,7 +80,7 @@ MOV [DS:0234h], 0x0005 #+END_SRC Why ? Let's break it down : -[[../../../gifs/lain-dance.gif]] +[[../../gifs/lain-dance.gif]] |