<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>add instruction Archives - NeuralLantern.com</title>
	<atom:link href="https://www.NeuralLantern.com/tag/add-instruction/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.NeuralLantern.com/tag/add-instruction/</link>
	<description></description>
	<lastBuildDate>Sun, 02 Nov 2025 12:20:25 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.2</generator>

<image>
	<url>https://www.NeuralLantern.com/wp-content/uploads/2025/04/cropped-2025-04-04-Lantern-03-32x32.png</url>
	<title>add instruction Archives - NeuralLantern.com</title>
	<link>https://www.NeuralLantern.com/tag/add-instruction/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Yasm x86-64 Assembly: Instruction Formats, Operands, MOV, ADD, Memory &#038; Registers Explained</title>
		<link>https://www.NeuralLantern.com/yasm-x86-64-assembly-instruction-formats-operands-mov-add-memory-registers-explained/</link>
					<comments>https://www.NeuralLantern.com/yasm-x86-64-assembly-instruction-formats-operands-mov-add-memory-registers-explained/#respond</comments>
		
		<dc:creator><![CDATA[mike]]></dc:creator>
		<pubDate>Sun, 02 Nov 2025 12:20:23 +0000</pubDate>
				<category><![CDATA[Assembly Language]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[Videos]]></category>
		<category><![CDATA[add instruction]]></category>
		<category><![CDATA[asm programming]]></category>
		<category><![CDATA[assembly crash course]]></category>
		<category><![CDATA[assembly language tutorial]]></category>
		<category><![CDATA[assembly operands]]></category>
		<category><![CDATA[assembly registers]]></category>
		<category><![CDATA[inc rax]]></category>
		<category><![CDATA[low level programming]]></category>
		<category><![CDATA[memory dereference]]></category>
		<category><![CDATA[mov instruction]]></category>
		<category><![CDATA[qword byte size]]></category>
		<category><![CDATA[reverse engineering]]></category>
		<category><![CDATA[ubuntu assembly book]]></category>
		<category><![CDATA[x86-64 assembly]]></category>
		<category><![CDATA[Yasm assembly]]></category>
		<guid isPermaLink="false">https://www.NeuralLantern.com/?p=245</guid>

					<description><![CDATA[<p>Yasm assembly tutorial: decode instruction formats, operands, mov, add, memory sizes &#038; registers. Fix common crashes. Code-along x86-64 guide for beginners.</p>
<p>The post <a href="https://www.NeuralLantern.com/yasm-x86-64-assembly-instruction-formats-operands-mov-add-memory-registers-explained/">Yasm x86-64 Assembly: Instruction Formats, Operands, MOV, ADD, Memory &amp; Registers Explained</a> appeared first on <a href="https://www.NeuralLantern.com">NeuralLantern.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe title="Yasm x86-64 Assembly: Instruction Formats, Operands, MOV, ADD, Memory &amp; Registers Explained" width="1380" height="776" src="https://www.youtube.com/embed/dXQQh_ppqPU?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
</div></figure>



<p class="wp-block-paragraph">Ever stared at &#8220;mov rdi, rsi&#8221; and wondered WHO goes WHERE?<br>This 18-minute crash course turns confusion into confidence.</p>



<p class="wp-block-paragraph">We start with the world’s simplest instruction (inc rax) and level-up to:</p>



<ul class="wp-block-list">
<li>Zero, one, two, and three-operand formats</li>



<li>Why &#8220;mov rdi, 89&#8221; and “mov rdi, [someVar]” are NOT the same</li>



<li>Brackets = dereference, no brackets = pointer</li>



<li>When ADD destroys your register (and how to stop it)</li>



<li>The memory-size trap that crashes 90% of beginners</li>



<li>Byte / word / dword / qword prefixes that save your life</li>



<li>Pro tip: keep everything in registers until the last microsecond</li>
</ul>



<p class="wp-block-paragraph">Code is shown live in Yasm, every line explained like you’re sitting next to me.<br>No fluff, no 2-hour theory—just the exact mental model you need to read and write assembly tomorrow.</p>



<p class="wp-block-paragraph">Grab the free PDF cheat-sheet (link in first comment) and code along.<br>Hit Subscribe—next video we build a complete program from scratch.</p>



<h1 class="wp-block-heading">Assembly #x86_64 #Yasm #LowLevel</h1>



<p class="wp-block-paragraph">Introduction to Instruction Formats 00:00:00<br>Simple INC Example 00:00:28<br>Instruction and Operand Basics 00:00:47<br>Zero to Three Operands 00:01:14<br>MOV Instruction Explained 00:02:02<br>Immediates and Registers 00:02:44<br>Memory Variables and Pointers 00:03:16<br>Dereferencing with Brackets 00:05:08<br>ADD with Two Operands 00:05:32<br>ADD with Three Operands 00:06:55<br>Consulting the Ubuntu Book 00:07:45<br>MOV Source vs Destination 00:08:52<br>Memory Size Matters 00:09:07<br>Specifying Data Size 00:11:40<br>INC on Memory Locations 00:13:19<br>Why Size Prefixes Prevent Bugs 00:14:08<br>Performance Tip &#8211; Use Registers 00:15:12<br>Book Recommendation Wrap-up 00:16:04</p>



<p class="wp-block-paragraph">Thanks for watching!</p>



<p class="wp-block-paragraph">Find us on other social media here:</p>



<ul class="wp-block-list">
<li>https://www.NeuralLantern.com/social</li>
</ul>



<p class="wp-block-paragraph">Please help support us!</p>



<ul class="wp-block-list">
<li>Subscribing + Sharing on Social Media</li>



<li>Leaving a comment or suggestion</li>



<li>Subscribing to our Blog</li>



<li>Watching the main &#8220;pinned&#8221; video of this channel for offers and extras</li>
</ul>



<p class="wp-block-paragraph">Hey there! Let&#8217;s talk about instruction formats in Yasm Assembly.</p>



<p class="wp-block-paragraph">So what am I talking about? Well, if we&#8217;re in Yasm Assembly and we&#8217;re going to learn how to</p>



<p class="wp-block-paragraph">use lots and lots of instructions, it&#8217;s probably a pretty good idea to understand the general idea</p>



<p class="wp-block-paragraph">of an instruction and its operands and the things that you can do to it. So the first thing I want</p>



<p class="wp-block-paragraph">show you is a really simple instruction called inc and we&#8217;ll put it we&#8217;ll put a</p>



<p class="wp-block-paragraph">register there we&#8217;ll say RAX we want to take whatever value is inside of the RAX</p>



<p class="wp-block-paragraph">register and just increase it by one simple enough but it&#8217;s important to</p>



<p class="wp-block-paragraph">understand that this is this follows a specific format the first thing that we</p>



<p class="wp-block-paragraph">put is the name of the instruction that we want to execute second thing we put</p>



<p class="wp-block-paragraph">is an operand you know what thing do we want to increase we could actually put</p>



<p class="wp-block-paragraph">We could actually put other types of operands there.</p>



<p class="wp-block-paragraph">We couldn&#8217;t put an immediate number, like just a hard-coded number,</p>



<p class="wp-block-paragraph">but we could put a memory location if we wanted to, and we were careful about it.</p>



<p class="wp-block-paragraph">So think about instructions as following this sort of format.</p>



<p class="wp-block-paragraph">Let&#8217;s see, INST, and then a space, and then, you know,</p>



<p class="wp-block-paragraph">sometimes instructions have zero operands, like there&#8217;s an instruction called CQO, I think,</p>



<p class="wp-block-paragraph">and it just takes two registers and sort of like lays them out against each other.</p>



<p class="wp-block-paragraph">against each other but for now we&#8217;ll just assume we&#8217;re going to write instructions that</p>



<p class="wp-block-paragraph">actually do something to named registers or memory locations or whatever.</p>



<p class="wp-block-paragraph">So the name of the instruction comes first and then we have an operand.</p>



<p class="wp-block-paragraph">One or more operands up to three actually.</p>



<p class="wp-block-paragraph">So basically the operands are separated by commas so we&#8217;ll say operand one, operand two,</p>



<p class="wp-block-paragraph">operand three and most instructions will follow this format.</p>



<p class="wp-block-paragraph">do what the operands are for it&#8217;s easy to tell that the first operand is the</p>



<p class="wp-block-paragraph">thing that will be increased in the increase operand but what about the move</p>



<p class="wp-block-paragraph">instruction what if we wanted to move you know one register to another let&#8217;s</p>



<p class="wp-block-paragraph">say RDI to RSI or sorry RDI from RSI or vice versa I mean how would you know</p>



<p class="wp-block-paragraph">remember this is the instruction and this is the first operand and then this</p>



<p class="wp-block-paragraph">And then this is the second operand.</p>



<p class="wp-block-paragraph">There&#8217;s not three operands in this instruction.</p>



<p class="wp-block-paragraph">Other instructions have three operands.</p>



<p class="wp-block-paragraph">The way it works with the move instruction,</p>



<p class="wp-block-paragraph">I hope you understand already at this point,</p>



<p class="wp-block-paragraph">is that operand two gets placed into operand one.</p>



<p class="wp-block-paragraph">So when this instruction is finished,</p>



<p class="wp-block-paragraph">then whatever value was inside of RSI is going to be inside of RDI.</p>



<p class="wp-block-paragraph">So they&#8217;re actually going to end up being copies of each other.</p>



<p class="wp-block-paragraph">Some instructions allow you to put immediates,</p>



<p class="wp-block-paragraph">like I could just put the number 89 right here and the number 89 will get loaded into RDI so I</p>



<p class="wp-block-paragraph">don&#8217;t really even need to use a register. Some instructions this one in particular also will</p>



<p class="wp-block-paragraph">allow you to place the name of some variable in brackets as the second operand and then what&#8217;ll</p>



<p class="wp-block-paragraph">happen is if you if you recall hopefully let me let me let me improve this a little bit.</p>



<p class="wp-block-paragraph">you have a data section and you have a text section.</p>



<p class="wp-block-paragraph">The text section is for your instructions.</p>



<p class="wp-block-paragraph">In the data section, we could say some variable</p>



<p class="wp-block-paragraph">and we could define this as data quad word, I guess,</p>



<p class="wp-block-paragraph">and put like a big giant number inside of there.</p>



<p class="wp-block-paragraph">And so now we have a variable, a global variable to that module</p>



<p class="wp-block-paragraph">that is sitting in memory somewhere and it&#8217;s got this value.</p>



<p class="wp-block-paragraph">So then what we can do is basically say,</p>



<p class="wp-block-paragraph">take the name of that variable, stick it inside of brackets,</p>



<p class="wp-block-paragraph">and then the move instruction will go grab that number, grab the value associated with that</p>



<p class="wp-block-paragraph">variable and then load that into RDI. What if we didn&#8217;t put brackets? What if we just said load and</p>



<p class="wp-block-paragraph">then some variable? This is how you place a pointer inside of a register. Remember all these registers,</p>



<p class="wp-block-paragraph">at least the general purpose registers with this R format, are 64-bit registers and in the 64-bit</p>



<p class="wp-block-paragraph">use that means you could hold a memory location in the register so it&#8217;s pretty convenient when</p>



<p class="wp-block-paragraph">when you define a variable up top here what you&#8217;re really doing is you&#8217;re saying i would like to</p>



<p class="wp-block-paragraph">allocate eight bytes for a quad word and i would like to fill it up with this data</p>



<p class="wp-block-paragraph">you know like let&#8217;s take eight bytes reserve it for us then we&#8217;ll convert all the ones and zeros</p>



<p class="wp-block-paragraph">appropriately so that it ends up equaling that value then when we&#8217;re done it&#8217;ll give us a pointer</p>



<p class="wp-block-paragraph">a normal variable that you usually would think of in C++ where it&#8217;s just like the variable is the</p>



<p class="wp-block-paragraph">variable and not a pointer to something. All these are actually just pointers. So if I load some</p>



<p class="wp-block-paragraph">variable into RDI I&#8217;m actually loading a pointer to RDI which by the way would make it pretty easy</p>



<p class="wp-block-paragraph">for you to pass a pointer into another function just by loading up RDI with some pointer to you</p>



<p class="wp-block-paragraph">know some of your data somewhere. But the moment I put the brackets around it it will dereference</p>



<p class="wp-block-paragraph">it will dereference the pointer for me</p>



<p class="wp-block-paragraph">and take the value and then send the value into that.</p>



<p class="wp-block-paragraph">Hopefully that makes sense.</p>



<p class="wp-block-paragraph">Okay, so we got pointers, dereference pointers,</p>



<p class="wp-block-paragraph">immediates and registers.</p>



<p class="wp-block-paragraph">That actually went by pretty fast.</p>



<p class="wp-block-paragraph">I thought this was gonna be a long video.</p>



<p class="wp-block-paragraph">Well, let&#8217;s look at my favorite book here,</p>



<p class="wp-block-paragraph">the Ubuntu coding book.</p>



<p class="wp-block-paragraph">Let&#8217;s see.</p>



<p class="wp-block-paragraph">Oh, maybe first let&#8217;s look at the add instruction</p>



<p class="wp-block-paragraph">because I wanted to get something with three operands.</p>



<p class="wp-block-paragraph">So let&#8217;s do an instruction with three operands.</p>



<p class="wp-block-paragraph">I&#8217;ll say INST and we&#8217;ll do operand one, operand two, operand three.</p>



<p class="wp-block-paragraph">So we have this add instruction here where we can just add two integers together.</p>



<p class="wp-block-paragraph">I could say let&#8217;s load the value of, you know what, let&#8217;s do this first with only two.</p>



<p class="wp-block-paragraph">Yeah, because that&#8217;ll be more fun.</p>



<p class="wp-block-paragraph">Let&#8217;s do RDI and RSI.</p>



<p class="wp-block-paragraph">Okay, so this is legal.</p>



<p class="wp-block-paragraph">You can have an instruction named add that uses either two or three operands.</p>



<p class="wp-block-paragraph">A lot of instructions do that.</p>



<p class="wp-block-paragraph">Usually in the two operand format, what they&#8217;re saying is,</p>



<p class="wp-block-paragraph">let&#8217;s do something with both of these values and then store the result</p>



<p class="wp-block-paragraph">of doing something in the first register.</p>



<p class="wp-block-paragraph">So for example, it&#8217;s going to take RDI and add it with RSI,</p>



<p class="wp-block-paragraph">assuming two&#8217;s complement integers.</p>



<p class="wp-block-paragraph">store the result of that addition inside of RDI. So if you think about it, it&#8217;s faster to type,</p>



<p class="wp-block-paragraph">but sometimes it might destroy data if you didn&#8217;t actually expect to modify RDI.</p>



<p class="wp-block-paragraph">If you wanted to store the result somewhere else, but still add RDI and RSI somewhere,</p>



<p class="wp-block-paragraph">then that wouldn&#8217;t work. So let&#8217;s do the three operand format, operand two, operand three.</p>



<p class="wp-block-paragraph">So now let&#8217;s say that we wanted to store in some other register without destroying</p>



<p class="wp-block-paragraph">RDI after we do the addition. So we can use the three operand format. Maybe I&#8217;ll</p>



<p class="wp-block-paragraph">hit space here a couple times just to make it a little more interesting. I</p>



<p class="wp-block-paragraph">guess I probably should have formatted the comment. Let me try to… No I guess I</p>



<p class="wp-block-paragraph">can&#8217;t. I don&#8217;t need to space it out. Well I could. I could anyway. So we&#8217;ll use the</p>



<p class="wp-block-paragraph">add instruction which is totally valid to use for three operands in addition to</p>



<p class="wp-block-paragraph">two operands. And what will happen now is it&#8217;ll take RDI and add it to RSI</p>



<p class="wp-block-paragraph">and add it to RSI and store the result in R11 in case you wanted to preserve the value of RDI and</p>



<p class="wp-block-paragraph">RSI. Lots and lots of different instructions with lots and lots of different things that you can do.</p>



<p class="wp-block-paragraph">Of course, we could put a memory location there. We could put like an immediate somewhere.</p>



<p class="wp-block-paragraph">But let me go to my favorite book here. Whoops, I already have it highlighted on the right section.</p>



<p class="wp-block-paragraph">x86 64 assembly language programming with Ubuntu by a brilliant doctor and I</p>



<p class="wp-block-paragraph">use his book all the time I&#8217;m not gonna say his name because I don&#8217;t want to</p>



<p class="wp-block-paragraph">accidentally mispronounce it I&#8217;m pretty sure I know how but I don&#8217;t even want to</p>



<p class="wp-block-paragraph">try because I suck at pronouncing things I&#8217;ve pronounced my own name wrong on</p>



<p class="wp-block-paragraph">many occasion so let&#8217;s see I&#8217;m gonna click on section 7 the instruction set</p>



<p class="wp-block-paragraph">the instruction set overview and basically you know it kind of goes over the fact that oh you</p>



<p class="wp-block-paragraph">know we can put registers as operands and we can do some certain things like if you see this</p>



<p class="wp-block-paragraph">notation it means you can put a register as an operand if you see this notation it means that&#8217;s</p>



<p class="wp-block-paragraph">going to be the source operand if you put if you see this notation it means you can put an immediate</p>



<p class="wp-block-paragraph">at that spot so the book just kind of tells you what to expect in terms of notation then if you</p>



<p class="wp-block-paragraph">go down it starts explaining a bunch of different instructions for example the move instruction</p>



<p class="wp-block-paragraph">instructions. For example, the move instruction that we&#8217;ve just been working with. Notice how it</p>



<p class="wp-block-paragraph">tells you the source is on the right, the destination is on the left. And if we are taking</p>



<p class="wp-block-paragraph">from a memory location, which I probably should have mentioned, let me see, did I mention that?</p>



<p class="wp-block-paragraph">No, I don&#8217;t think I did. If we&#8217;re taking from a memory location, it&#8217;s important to understand that</p>



<p class="wp-block-paragraph">the data size of the memory locations data and the register might actually be different. See,</p>



<p class="wp-block-paragraph">different. See here we kind of made a bad assumption. We made the assumption that RDI</p>



<p class="wp-block-paragraph">was a 64-bit register. That&#8217;s a good assumption. But then we also made the assumption that sitting</p>



<p class="wp-block-paragraph">at that pointer is eight bytes of memory. That&#8217;s a bad assumption. Up at the top, we know that</p>



<p class="wp-block-paragraph">when we put DQ for data quad word, then eight bytes are going to get allocated. But by the time we</p>



<p class="wp-block-paragraph">But by the time we get down to this instruction, you know assembly is not very smart.</p>



<p class="wp-block-paragraph">By the time we get down to this instruction, we can&#8217;t be sure if that pointer refers to</p>



<p class="wp-block-paragraph">something that is 8 bytes or 4 bytes or 2 bytes.</p>



<p class="wp-block-paragraph">We should be able to support loading a number.</p>



<p class="wp-block-paragraph">Like just as an example, I could lower this number, like let&#8217;s say with the number 25,</p>



<p class="wp-block-paragraph">but you know that the number 25 will fit into just a single byte.</p>



<p class="wp-block-paragraph">It&#8217;ll also fit into a word, 2 bytes.</p>



<p class="wp-block-paragraph">32 bit number, a D word, you know, four bytes.</p>



<p class="wp-block-paragraph">It&#8217;ll also fit into a quad word, 64 bits, eight bytes.</p>



<p class="wp-block-paragraph">So it&#8217;ll fit in different sizes of data.</p>



<p class="wp-block-paragraph">So what if you have a memory allocation,</p>



<p class="wp-block-paragraph">like instead of putting DQ,</p>



<p class="wp-block-paragraph">what if we put DB for just data byte?</p>



<p class="wp-block-paragraph">So just like one byte of memory to put that 25 in,</p>



<p class="wp-block-paragraph">that should work.</p>



<p class="wp-block-paragraph">But the point is this part of the code</p>



<p class="wp-block-paragraph">doesn&#8217;t actually know how big the memory location is.</p>



<p class="wp-block-paragraph">So it doesn&#8217;t know how many bytes to grab.</p>



<p class="wp-block-paragraph">many bytes to grab like what if we what if it just assumed that because we used a 64-bit register</p>



<p class="wp-block-paragraph">actually let&#8217;s go back up here let&#8217;s change this to a byte data byte so we know that the 25 occupies</p>



<p class="wp-block-paragraph">only one byte but here if we were unlucky then the assembler might assume oh they want to load</p>



<p class="wp-block-paragraph">eight bytes of memory interpreted as a number and then put that into a 64-bit register an eight</p>



<p class="wp-block-paragraph">But that probably wouldn&#8217;t work because we only actually modified one byte to make that 25.</p>



<p class="wp-block-paragraph">So there&#8217;s going to be seven other bytes of junk data.</p>



<p class="wp-block-paragraph">So now we just loaded RDI with some sort of a nonsense value.</p>



<p class="wp-block-paragraph">And even if it does work, it might not work on every run of the program.</p>



<p class="wp-block-paragraph">So then you have something which is probably undefined behavior,</p>



<p class="wp-block-paragraph">where it&#8217;s just like you made a bad mistake and your program&#8217;s going to work sometimes</p>



<p class="wp-block-paragraph">and maybe some other times not work.</p>



<p class="wp-block-paragraph">So how do we fix this?</p>



<p class="wp-block-paragraph">So how do we fix this? We just specify the size of the memory location or of</p>



<p class="wp-block-paragraph">the bytes that we&#8217;re going to grab at that memory location. So if I just put</p>



<p class="wp-block-paragraph">the word byte in front, now the assembler knows that I only want to grab</p>



<p class="wp-block-paragraph">one byte and interpret that as a number and then put that into RDI rather than</p>



<p class="wp-block-paragraph">all the extra junk data. So if I want to make sure that it understands that I want</p>



<p class="wp-block-paragraph">eight bytes and also to prevent it from refusing to compile, which it&#8217;s probably</p>



<p class="wp-block-paragraph">going to do if i don&#8217;t specify the size i&#8217;ll put q word to say yeah this 25 it&#8217;s uh it&#8217;s actually</p>



<p class="wp-block-paragraph">a q word it occupies eight bytes so i want you to load up eight bytes in ram and interpret all</p>



<p class="wp-block-paragraph">those bytes as just you know whatever numbers inside of them pretty sweet i love going to this</p>



<p class="wp-block-paragraph">book because i was going to forget to say that anyway just so you know there&#8217;s a bunch of</p>



<p class="wp-block-paragraph">instructions that you can look up i&#8217;m not going to go through all of them but um you know typically</p>



<p class="wp-block-paragraph">Leftmost operand in some sort of a modifying instruction is going to be the destination</p>



<p class="wp-block-paragraph">register or memory location.</p>



<p class="wp-block-paragraph">And if you have a two operand instruction, it&#8217;s probably going to take both operands</p>



<p class="wp-block-paragraph">and do something with them and then stick the result in the first operand.</p>



<p class="wp-block-paragraph">And then if you have a three operand instruction, it&#8217;s probably going to take the rightmost</p>



<p class="wp-block-paragraph">two operands, do something with them, store the result in the leftmost operand.</p>



<p class="wp-block-paragraph">wonderful, wonderful book will tell you exactly what to expect for every type of instruction.</p>



<p class="wp-block-paragraph">So there&#8217;s like move here, integer arithmetic. Oh yeah, there&#8217;s the add function or sorry,</p>



<p class="wp-block-paragraph">the add instruction. And then here&#8217;s like a bunch of sample code, which is awesome.</p>



<p class="wp-block-paragraph">And notice how here, if we want to increase something that is located at a memory location,</p>



<p class="wp-block-paragraph">we got to specify the size of the memory. Again, same problem that we just talked about up above.</p>



<p class="wp-block-paragraph">Did we do that at the beginning?</p>



<p class="wp-block-paragraph">I don&#8217;t remember if we did that.</p>



<p class="wp-block-paragraph">You know, if we have something where it&#8217;s like,</p>



<p class="wp-block-paragraph">if we said increase the RAX register,</p>



<p class="wp-block-paragraph">the computer knows that RAX is a 64-bit register</p>



<p class="wp-block-paragraph">because the way we typed it, RAX, that implies 64 bits.</p>



<p class="wp-block-paragraph">If we meant to only use 32 bits of the register,</p>



<p class="wp-block-paragraph">we would type a different, you know,</p>



<p class="wp-block-paragraph">set of letters to represent that register.</p>



<p class="wp-block-paragraph">But if we say, I would like you to increase</p>



<p class="wp-block-paragraph">the value sitting in memory at some variable,</p>



<p class="wp-block-paragraph">sitting in memory at some variable dereferenced, well then whoops,</p>



<p class="wp-block-paragraph">it doesn&#8217;t actually know how many bytes.</p>



<p class="wp-block-paragraph">If you increase a small</p>



<p class="wp-block-paragraph">value, like if it&#8217;s if you have one byte and you try to increase it,</p>



<p class="wp-block-paragraph">what if it overflows?</p>



<p class="wp-block-paragraph">Like, for example, if we had a one byte, if we had one byte of data here</p>



<p class="wp-block-paragraph">and we had the number, let&#8217;s say 255 already, that&#8217;s the highest value that a</p>



<p class="wp-block-paragraph">So if we then say let&#8217;s increase that,</p>



<p class="wp-block-paragraph">the computer is going to, you know, like overflow back down to just zero or not.</p>



<p class="wp-block-paragraph">What if it actually was a quad word?</p>



<p class="wp-block-paragraph">The computer didn&#8217;t understand whether it&#8217;s supposed to overflow or not overflow.</p>



<p class="wp-block-paragraph">Do you see what I&#8217;m saying?</p>



<p class="wp-block-paragraph">There&#8217;s lots of problems that can happen if you don&#8217;t know the size.</p>



<p class="wp-block-paragraph">So that just means we have to specify the size.</p>



<p class="wp-block-paragraph">Anytime we&#8217;re dealing with memory, we&#8217;ll say we&#8217;ll increase a keyword sitting at some</p>



<p class="wp-block-paragraph">variable. And of course, if you&#8217;re going to</p>



<p class="wp-block-paragraph">and of course if you&#8217;re gonna i don&#8217;t know why you&#8217;d want to do this but if you wanted to well</p>



<p class="wp-block-paragraph">i guess if you&#8217;re running through a string if you wanted to increase a pointer value uh then i think</p>



<p class="wp-block-paragraph">you don&#8217;t have to specify the data size although i&#8217;m not actually sure if you can change the value</p>



<p class="wp-block-paragraph">of that pointer i don&#8217;t know if it&#8217;s hard coded usually what i do is i would just move you know</p>



<p class="wp-block-paragraph">some kind of a i would move the pointer if we&#8217;re if we&#8217;re using a running pointer to run through</p>



<p class="wp-block-paragraph">I would load the pointers value into a register and then I would just start increasing the</p>



<p class="wp-block-paragraph">register just to make things a little bit easier because as I usually try to say it&#8217;s</p>



<p class="wp-block-paragraph">way slower to constantly be hitting memory.</p>



<p class="wp-block-paragraph">Anytime you can possibly keep all of your calculations and algorithms and stuff inside</p>



<p class="wp-block-paragraph">of only registers as long as possible, then your program will be way, way faster.</p>



<p class="wp-block-paragraph">So if you&#8217;re going to run through a bunch of data with a pointer, probably want to load</p>



<p class="wp-block-paragraph">it up into a register first and then keep increasing the register.</p>



<p class="wp-block-paragraph">When you finally figure out, you know, everything that&#8217;s calculated and finished,</p>



<p class="wp-block-paragraph">then go ahead and save it back to memory at the very end.</p>



<p class="wp-block-paragraph">But just to let you know, we&#8217;ve got lots of stuff.</p>



<p class="wp-block-paragraph">Okay, so there&#8217;s the add function.</p>



<p class="wp-block-paragraph">This is the two op version.</p>



<p class="wp-block-paragraph">You can see at the top there.</p>



<p class="wp-block-paragraph">Let&#8217;s see, where&#8217;s the three op version?</p>



<p class="wp-block-paragraph">Here&#8217;s somebody honking the horn outside.</p>



<p class="wp-block-paragraph">Someone&#8217;s upset with someone else.</p>



<p class="wp-block-paragraph">Someone&#8217;s upset.</p>



<p class="wp-block-paragraph">Someone&#8217;s upset. Do you ever honk the horn not angry, but just so that the other driver will think you&#8217;re angry and</p>



<p class="wp-block-paragraph">Then possibly be a good driver or a better driver later on in their life. I don&#8217;t know if that actually works. I have tried it</p>



<p class="wp-block-paragraph">And you do your eyebrows like this</p>



<p class="wp-block-paragraph">Even though you&#8217;re not upset</p>



<p class="wp-block-paragraph">I wonder if they just go home laughing and they&#8217;re like, yeah, you&#8217;re right. I was ridiculous</p>



<p class="wp-block-paragraph">Okay, so I guess I&#8217;m gonna stop scrolling</p>



<p class="wp-block-paragraph">a</p>



<p class="wp-block-paragraph">A good coder always reads the documentation and studies ahead and things like that</p>



<p class="wp-block-paragraph">I know you were hoping for me to tell you everything in this video, but there&#8217;s just not enough time or energy to do that</p>



<p class="wp-block-paragraph">I just wanted you to understand</p>



<p class="wp-block-paragraph">How how to how to interpret instruction formats?</p>



<p class="wp-block-paragraph">I wanted to make that part easy for you</p>



<p class="wp-block-paragraph">but all the different instructions that are available to you to multiply to add to increase values to do all this stuff</p>



<p class="wp-block-paragraph">It&#8217;s all in this nice wonderful book</p>



<p class="wp-block-paragraph">okay anyway I think I&#8217;m gonna cut the video I hope you enjoyed what you have</p>



<p class="wp-block-paragraph">learned I hope you have learned a lot of stuff and had a little bit of fun there</p>



<p class="wp-block-paragraph">and I&#8217;ll see you in the next video hey everybody thanks for watching this video</p>



<p class="wp-block-paragraph">again from the bottom of my heart I really appreciate it I do hope you did</p>



<p class="wp-block-paragraph">learn something and have some fun if you could do me a please a small little</p>



<p class="wp-block-paragraph">favor could you please subscribe and follow this channel or these videos or</p>



<p class="wp-block-paragraph">or whatever it is you do on the current social media website that you&#8217;re looking at right now.</p>



<p class="wp-block-paragraph">It would really mean the world to me and it&#8217;ll help make more videos and grow this community.</p>



<p class="wp-block-paragraph">So we&#8217;ll be able to do more videos, longer videos, better videos,</p>



<p class="wp-block-paragraph">or just I&#8217;ll be able to keep making videos in general.</p>



<p class="wp-block-paragraph">So please do me a kindness and subscribe.</p>



<p class="wp-block-paragraph">You know, sometimes I&#8217;m sleeping in the middle of the night</p>



<p class="wp-block-paragraph">and I just wake up because I know somebody subscribed or followed.</p>



<p class="wp-block-paragraph">It just wakes me up and I get filled with joy.</p>



<p class="wp-block-paragraph">That&#8217;s exactly what happens every single time.</p>



<p class="wp-block-paragraph">every single time so you could do it as a nice favor to me or you could you control me if you</p>



<p class="wp-block-paragraph">want to just wake me up in the middle of the night just subscribe and then i&#8217;ll i&#8217;ll just wake up i</p>



<p class="wp-block-paragraph">promise that&#8217;s what will happen also uh if you look at the middle of the screen right now you</p>



<p class="wp-block-paragraph">should see a qr code which you can scan in order to go to the website which i think is also named</p>



<p class="wp-block-paragraph">somewhere at the bottom of this video and it&#8217;ll take you to my main website where you can just</p>



<p class="wp-block-paragraph">kind of like see all the videos i published and the services and tutorials and things that i offer</p>



<p class="wp-block-paragraph">all that good stuff and uh if you have a suggestion for uh uh clarifications or errata or just future</p>



<p class="wp-block-paragraph">videos that you want to see please leave a comment or if you just want to say hey what&#8217;s up what&#8217;s</p>



<p class="wp-block-paragraph">going on you know just send me a comment whatever i also wake up for those in the middle of the</p>



<p class="wp-block-paragraph">night i get i wake up in a cold sweat and i&#8217;m like it would really it really mean the world to me i</p>



<p class="wp-block-paragraph">and enjoy the cool music as I fade into the darkness which is coming for us all.</p>



<p class="wp-block-paragraph">Thank you.</p>
<p>The post <a href="https://www.NeuralLantern.com/yasm-x86-64-assembly-instruction-formats-operands-mov-add-memory-registers-explained/">Yasm x86-64 Assembly: Instruction Formats, Operands, MOV, ADD, Memory &amp; Registers Explained</a> appeared first on <a href="https://www.NeuralLantern.com">NeuralLantern.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.NeuralLantern.com/yasm-x86-64-assembly-instruction-formats-operands-mov-add-memory-registers-explained/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
