<?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>stack alignment assembly Archives - NeuralLantern.com</title>
	<atom:link href="https://www.NeuralLantern.com/tag/stack-alignment-assembly/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.NeuralLantern.com/tag/stack-alignment-assembly/</link>
	<description></description>
	<lastBuildDate>Sun, 22 Feb 2026 03:21:33 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://www.NeuralLantern.com/wp-content/uploads/2025/04/cropped-2025-04-04-Lantern-03-32x32.png</url>
	<title>stack alignment assembly Archives - NeuralLantern.com</title>
	<link>https://www.NeuralLantern.com/tag/stack-alignment-assembly/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>x86-64 Assembly Pointers &#038; Dereferencing Explained &#8211; Hybrid C++/YASM Example</title>
		<link>https://www.NeuralLantern.com/x86-64-assembly-pointers-dereferencing-explained-hybrid-c-yasm-example/</link>
					<comments>https://www.NeuralLantern.com/x86-64-assembly-pointers-dereferencing-explained-hybrid-c-yasm-example/#respond</comments>
		
		<dc:creator><![CDATA[mike]]></dc:creator>
		<pubDate>Sun, 22 Feb 2026 03:21:32 +0000</pubDate>
				<category><![CDATA[Assembly Language]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[Videos]]></category>
		<category><![CDATA[assembly C++ interop]]></category>
		<category><![CDATA[assembly data section]]></category>
		<category><![CDATA[assembly memory addresses]]></category>
		<category><![CDATA[assembly pointers]]></category>
		<category><![CDATA[assembly tutorial]]></category>
		<category><![CDATA[dereferencing assembly]]></category>
		<category><![CDATA[extern C assembly]]></category>
		<category><![CDATA[hybrid C++ assembly]]></category>
		<category><![CDATA[low level programming]]></category>
		<category><![CDATA[passing pointers assembly]]></category>
		<category><![CDATA[stack alignment assembly]]></category>
		<category><![CDATA[systems programming]]></category>
		<category><![CDATA[x86 assembly tutorial]]></category>
		<category><![CDATA[x86-64 assembly]]></category>
		<category><![CDATA[x86-64 calling convention]]></category>
		<category><![CDATA[x86-64 pointers]]></category>
		<category><![CDATA[Yasm assembly]]></category>
		<category><![CDATA[Yasm tutorial]]></category>
		<guid isPermaLink="false">https://www.NeuralLantern.com/?p=305</guid>

					<description><![CDATA[<p>This video explains pointers and dereferencing in x86-64 YASM assembly and demonstrates passing pointers between assembly and C++ in a hybrid program. We show how to read a C string from assembly, modify a long via pointer dereference so the change is visible in C++, and send assembly-owned data (string, long, double) back to C++ using pointers.</p>
<p>The post <a href="https://www.NeuralLantern.com/x86-64-assembly-pointers-dereferencing-explained-hybrid-c-yasm-example/">x86-64 Assembly Pointers &amp; Dereferencing Explained &#8211; Hybrid C++/YASM Example</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="x86-64 Assembly Pointers &amp; Dereferencing Explained - Hybrid C++/YASM Example" width="1380" height="776" src="https://www.youtube.com/embed/jzj0iqC-XJI?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>Learn pointers &amp; dereferencing in x86-64 YASM assembly and how to pass them correctly between assembly and C++ in a hybrid program. We build a small working example that sends strings, longs, and doubles both directions using pointers, modifies values across module boundaries, and explains why pointer-to-double still uses general-purpose registers. Includes a quick demo of stack misalignment crash + fix.</p>



<p>Great for assembly beginners moving to real programs, systems programming students, or anyone curious how low-level code talks to C/C++.</p>



<p>00:00 Introduction to Pointers and Dereferencing in x86-64 Assembly<br>00:28 Pointers explained in C++<br>01:02 Changing values via pointers in C++<br>01:43 Pointers in assembly basics<br>02:09 Defining variables and pointers in YASM data section<br>03:23 Pointers are always integers even to doubles<br>04:20 Function arguments are pointers treated as 64-bit integers<br>05:00 Driver C++ code overview<br>05:58 Marking extern &#8220;C&#8221; functions<br>06:40 Local stack variables and passing pointers<br>07:51 Stack lifetime warning<br>08:34 Assembly data section strings and numbers<br>09:39 Print null-terminated string helper functions<br>10:38 External symbols and hey_driver_print_this<br>11:29 Point function prologue and stack alignment<br>13:04 Extra push for 16-byte alignment<br>14:20 Printing welcome message from assembly<br>16:00 Driver sees initial long value<br>16:58 Printing received string from C++<br>18:20 Using received char pointer without dereference<br>20:21 Modifying incoming long via dereference<br>21:46 Driver sees modified long value 101<br>22:43 Calling back to C++ to print assembly-owned data<br>23:48 Passing pointers to assembly string long and double<br>25:08 Driver prints assembly-owned values and addresses<br>26:14 Summary of pointer passing between modules<br>26:36 Stack alignment crash demonstration<br>27:39 Adding extra push/pop fixes segfault<br>28:00 Closing remarks and call to subscribe</p>



<p>=-=-=-=-=-=-=-=-=</p>



<p>Thanks for watching!</p>



<p>Find us on other social media here:</p>



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



<li>Twitter / X: https://x.com/NeuralLantern</li>



<li>Rumble: https://rumble.com/c/c-3696939</li>



<li>BitChute: https://www.bitchute.com/channel/pg1Pvv5dN4Gt</li>



<li>Daily Motion: https://www.dailymotion.com/neurallantern</li>



<li>Minds: https://www.minds.com/neurallantern/</li>



<li>Odysee: https://odysee.com/@NeuralLantern:5</li>
</ul>



<p>Please show your support!</p>



<ul class="wp-block-list">
<li>Buy me a coffee: https://ko-fi.com/neurallantern</li>



<li>Subscribe + Sharing on Social Media</li>



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



<li>Subscribe to Blog: https://www.NeuralLantern.com</li>



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



<p>Hey there! In this video we&#8217;re going to talk about pointers and dereferencing in a YASM x8664</p>



<p>assembly program, also as a hybrid program so that assembly and C++ can talk to each other</p>



<p>and send each other pointers and send each other data and things like that.</p>



<p>for what pointers are.</p>



<p>I&#8217;m going to write in C++ for a second.</p>



<p>Suppose you have a pointer for an integer.</p>



<p>We&#8217;ll call it P.</p>



<p>Suppose you have an integer by itself.</p>



<p>We&#8217;ll call it A.</p>



<p>Let&#8217;s say that the value of A is 5.</p>



<p>And if you wanted to say that P points to A,</p>



<p>you could say P equals the address of A.</p>



<p>I&#8217;ll put C++ at the top here.</p>



<p>And so now if I set A to 6</p>



<p>then I print P a dereference of P this is not like a full pointers tutorial</p>



<p>but basically by changing a I&#8217;m changing what P thinks it sees as a value</p>



<p>assuming ID reference it I could also let me do a print 6 here I could also</p>



<p>just change the value through P I could say dereference P and I could say equals</p>



<p>would actually print a seven right so you know you can have regular variables global variables</p>



<p>whatever kind of you know memory stuff on the stack and to get a pointer to it you really just</p>



<p>need to get its memory location in c++ it&#8217;s kind of easy syntactically you can see what&#8217;s happening</p>



<p>in assembly you really just need the memory location stored somewhere you could store that</p>



<p>variable that just simply stored the memory location of some other variable.</p>



<p>You could have a 64-bit register store the value of a variable.</p>



<p>Let&#8217;s say we have like a, I don&#8217;t know, my whatever, my number let&#8217;s say inside of assembly.</p>



<p>I&#8217;ll do ASM here and we say it&#8217;s a quad word and it starts off as this number or whatever.</p>



<p>So if you haven&#8217;t seen my previous videos, go see them for the basics of assembly and</p>



<p>of assembly and linking and make files and all that stuff but you know if you</p>



<p>have an assembly program and you have a data section and you define a global</p>



<p>variable like this what you&#8217;re basically saying is I want to take this giant</p>



<p>number and I want to write it into eight bytes that&#8217;s the DQ it says data quad</p>



<p>word I want to write that giant number across eight bytes and then I want to</p>



<p>get a pointer to it stored in the my number symbol so my number is not</p>



<p>actually the value it&#8217;s a pointer to the value so you know later if you want to</p>



<p>you know later if you want to move you know something into a register if you did this</p>



<p>that would move the pointer into rax but if you did this</p>



<p>with deref symbols after it or around it then you would move</p>



<p>maybe i&#8217;ll put that into rex you&#8217;d move that actual number that we specified into rex</p>



<p>into Rx. It&#8217;s important to understand also that pointers are integers even when we&#8217;re pointing to</p>



<p>doubles. So for example sometimes people make this mistake they&#8217;ll say you know my double</p>



<p>and they&#8217;ll say it&#8217;s a quad word meaning this is going to be a 64-bit double precision floating</p>



<p>point number and they&#8217;ll do like 44.55 or whatever. So that is a double and it is in memory</p>



<p>you know what is the symbol of my double remember it&#8217;s supposed to be just a</p>



<p>pointer right it can&#8217;t be an actual double because a memory location is not</p>



<p>a double a memory location is an integer so that means if you wanted to move a</p>



<p>pointer into a register you would only be able to move the pointer into a</p>



<p>regular general purpose register not a floating point register and you should</p>



<p>use the regular movement instructions for just regular general purpose</p>



<p>So keep that in mind if you see a signature like this like let&#8217;s say function F and we have</p>



<p>You know, let&#8217;s say long a and long B and actually let&#8217;s do pointers</p>



<p>Let&#8217;s say long pointer a and long pointer</p>



<p>B and double pointer C all three of those arguments are actually 64 bit integers</p>



<p>Because they&#8217;re all pointers even if one of the pointers points to adult a double</p>



<p>double why did I say dull pointers aren&#8217;t dull they&#8217;re exciting okay so I&#8217;m gonna open up some</p>



<p>code here real fast so usually I don&#8217;t explain my uh my driver I&#8217;m gonna explain it to you this time</p>



<p>because it&#8217;s kind of doing a little bit more than my other videos um again if you don&#8217;t have uh the</p>



<p>knowledge of how to make a make file see my other videos because that&#8217;s explained there for now I&#8217;m</p>



<p>what we really need to do is write a driver and an assembly module for a</p>



<p>hybrid program again hybrid programs covered in other videos so the driver is</p>



<p>pretty easy I&#8217;m just going to copy paste it honestly here and then just kind of</p>



<p>explain it to you the driver is pretty easy we&#8217;re going to do I O stream so we</p>



<p>can print stuff we&#8217;re going to mark an external function called point as extern</p>



<p>C so that just disables name mangling which means the C++ module will be able</p>



<p>will be able to call on this function called point and it won&#8217;t expect that</p>



<p>the point function has its name mangled like C++ does the reason being is that</p>



<p>point is actually going to be in a side it&#8217;s going to be inside assembly where</p>



<p>its name will not be mangled this disables the ability to overload but</p>



<p>that&#8217;s okay we don&#8217;t care it&#8217;s going to take two pointers a pointer to a character</p>



<p>and a pointer to a long since both of those are pointers they&#8217;re both</p>



<p>64-bit integers even the character pointer and then we have a function that is internal to this</p>



<p>module called hey driver print this remember we&#8217;re inside of the driver program right now</p>



<p>so if you look at the bottom it&#8217;s just a function that takes in some pointers</p>



<p>and then prints some stuff so it&#8217;s going to print like it&#8217;s going to print what the string is</p>



<p>it&#8217;s going to print what the long is my dog&#8217;s growling at me i&#8217;m going to ignore him because</p>



<p>i literally just let him pee and poop at this point now he&#8217;s harassing me for treats</p>



<p>now he&#8217;s harassing me for treats he always does this okay so uh the string the long the double</p>



<p>this function expects to receive three pointers to different data types it&#8217;s just going to print</p>



<p>all of them and the point get it the point of this function is we&#8217;re going to go inside of</p>



<p>the assembly module and then have the assembly module call on this function so that we can we</p>



<p>can prove that we can have stuff sent from assembly to c plus plus or c using pointers</p>



<p>using pointers we can have data sent over so anyway that&#8217;s why both of these</p>



<p>are in here the point needs to be marked as no name mangling because point is</p>



<p>inside of assembly which will not name mangle and then hey driver print this</p>



<p>that needs to have name mangling disabled also so that the assembly</p>



<p>module can call on this other than that we&#8217;re just basically inside of a main</p>



<p>saying hey this is the c string we&#8217;re making a c string inside of the main function notice how</p>



<p>this is a local variable so that c string is going to show up on the stack it&#8217;s going to show up in</p>



<p>the area that is owned by main for main stack area same thing for my long that&#8217;s a local variable on</p>



<p>the stack um and but then we can actually send pointers to those pieces of data to another</p>



<p>function in another module you don&#8217;t have to only transport globals or stuff on the heap</p>



<p>or stuff on the heap, you can transport pointers to local variables. Just make sure that by the</p>



<p>time this function finishes, then nowhere else is actually using that data because,</p>



<p>well, being on the stack, once main function or once any function finishes, then its portion of</p>



<p>the stack will be cleaned up and removed and it&#8217;ll be junk data. You&#8217;ll probably get a seg fault.</p>



<p>But for now, we&#8217;re not going to use anything on the stack. We&#8217;re not going to use these local</p>



<p>just going to use them quickly on this call to point and then we&#8217;re going to return to the</p>



<p>operating system and finish the program. So that&#8217;s the driver. Now the hard part. Let&#8217;s do this in</p>



<p>assembly. So for starters, I&#8217;m going to make a data section and just explain it to you very,</p>



<p>very quickly. Again, if you don&#8217;t understand the basics of YASM x86-64 assembly, did I mention</p>



<p>that that&#8217;s what this language is at the beginning of the video? I guess I should put that in the</p>



<p>put that in the description or record an announcement that I can tack on at the beginning</p>



<p>or something. Anyway, so if you don&#8217;t understand how to do this, see my other videos, but basically</p>



<p>we&#8217;re going to make a data section. We&#8217;re going to define some strings. Here&#8217;s like an announcement.</p>



<p>Oh, we&#8217;re inside of, you know, the module now, the assembly module. And now we&#8217;re going to print</p>



<p>the received string. And then we&#8217;re going to make a string that is owned by assembly, which we can</p>



<p>into C++ when we call the function inside of the driver.</p>



<p>So this string is owned by the assembly module.</p>



<p>Notice how these are null terminated strings.</p>



<p>I just have like a comma zero there,</p>



<p>which means I have some extra functions</p>



<p>I&#8217;m gonna paste in that we&#8217;re not really gonna talk about</p>



<p>because they&#8217;ve been discussed in other videos</p>



<p>just so that we can print null terminated strings.</p>



<p>Then I&#8217;ve got a new line here,</p>



<p>you know, carriage return line feed.</p>



<p>And then I&#8217;ve just got some numbers</p>



<p>that are owned by the assembly module.</p>



<p>Then I&#8217;ve got a system write call,</p>



<p>call code one for the system call writes and file descriptor standard output so I</p>



<p>can print just to the terminal again if you don&#8217;t understand this see my other</p>



<p>videos so now let&#8217;s start the actual text section so this is where our</p>



<p>instructions start so we got the text section here and we&#8217;re going to use some</p>



<p>external symbols don&#8217;t worry about these I&#8217;m just using my own little library to</p>



<p>and input integers if you have access to this library use it if you don&#8217;t if you&#8217;re watching</p>



<p>at home and you don&#8217;t have this library then that&#8217;s fine you can use you know printf or</p>



<p>scanf or something like that to get and print floats from and to the user</p>



<p>but yeah I&#8217;m just using that and then I&#8217;m marking an external function here called hey driver print</p>



<p>this if you recall the driver module has a function called hey driver print this so</p>



<p>just allows my assembly code to call on that external function. Okay now next</p>



<p>piece of code. This is going to be… actually I&#8217;m going to paste the print</p>



<p>null terminated string function and related code because it&#8217;s just like a</p>



<p>big giant mess and we&#8217;re mostly going to ignore it. So just to show you what I&#8217;m</p>



<p>doing here I have a function called print null terminated string so that I</p>



<p>can print these strings up here and then I have it rely on a function called</p>



<p>string length that I have implemented up here and all it does is just</p>



<p>implemented up here and all it does just calculates the length of the string and</p>



<p>then a crlf function so I can just call that so that&#8217;s all explained in other</p>



<p>videos don&#8217;t worry about it for now we&#8217;re going to start the actual entry</p>



<p>point remember the driver was just gonna call point right so now we just have to</p>



<p>implement point in the assembly module so that&#8217;s gonna be like down here our</p>



<p>our entry point so the signature for this function is going to be character</p>



<p>pointer and then a long pointer and it doesn&#8217;t return anything and remember</p>



<p>that if we look back at the driver that should match the signature right it&#8217;s a</p>



<p>character pointer and a long pointer and of course this is just a comment that</p>



<p>reminds me of what to do in assembly you don&#8217;t really have a signature you just</p>



<p>sort of use registers but I&#8217;m reminding myself that RDI is going to be a</p>



<p>character pointer and RSI is going to be a long pointer.</p>



<p>Here&#8217;s a note to myself that I&#8217;m going to use R12 and R13, which means</p>



<p>the first thing that I should do, well actually before I even do that, I should</p>



<p>return from this function because it is a function. I marked it as global</p>



<p>so that the other module could call it, the driver module could call it. Again,</p>



<p>see my other videos for hybrid programs.</p>



<p>But so now the, you know, if the driver calls this function, then now we&#8217;re inside of</p>



<p>and there&#8217;s a return statement so it&#8217;s a valid function I should preserve the</p>



<p>registers that I&#8217;m going to use that are marked as Kali saved for the ABI so I&#8217;m</p>



<p>going to go prologue and then an epilogue and I&#8217;m going to say push r12 and push</p>



<p>r13 and then I&#8217;m going to pop r13 pop r12 they should be in reverse order if</p>



<p>you&#8217;ve seen my other videos you&#8217;ll know this and the the thing about this</p>



<p>the thing about this particular program is we&#8217;re going to run into stack alignment issues</p>



<p>so uh if you don&#8217;t know about stack alignment and how it can crash your program without you</p>



<p>realizing what&#8217;s wrong see my other videos but for now we&#8217;ll assume you know that and uh i i</p>



<p>already know from running this program in advance that it&#8217;s going to be out of alignment by eight</p>



<p>bytes so i&#8217;m just going to push an extra register onto the stack and that&#8217;s going to put it back</p>



<p>I know it looks weird, but this is going to work.</p>



<p>Let me get rid of this here.</p>



<p>Okay, so.</p>



<p>And then maybe if I can remember at the end of the video,</p>



<p>I can just remove that extra push-pop pair,</p>



<p>and you&#8217;ll see the program starts crashing.</p>



<p>But at home, you can do it just to double check.</p>



<p>So the first thing I really want to do is,</p>



<p>after I push and pop,</p>



<p>is save our incoming arguments.</p>



<p>Remember, the first integer argument</p>



<p>and the second integer argument,</p>



<p>argument they come in as RDI and RSI in assembly per the ABI if both of these</p>



<p>things are pointers it doesn&#8217;t matter what the data type is it could be</p>



<p>pointing to anything including a double and these would still be considered</p>



<p>integer arguments because well RDI and RSI are just going to be loaded up with</p>



<p>memory locations which which are integers so I&#8217;m going to save our</p>



<p>arguments to R12 and R13 now justifying our push and pop pair then I&#8217;m going to</p>



<p>little welcome message so print a little welcome message again you don&#8217;t need to know about this</p>



<p>function but it&#8217;s explained in other videos that I&#8217;ve already published we&#8217;re going to print our</p>



<p>hello beginning message I&#8217;m getting nervous he needs to take a second poop sometimes it&#8217;s poopoo</p>



<p>number two time for him and he&#8217;s not really just lying about a treat but he did go pee and poop</p>



<p>But he did go pee and poop already.</p>



<p>Okay, he just left and walked away.</p>



<p>Okay, if he comes back, I&#8217;m letting him out this time.</p>



<p>I&#8217;ll pause the video if he does it again.</p>



<p>Okay, I&#8217;m pausing the video.</p>



<p>No pee lied.</p>



<p>He went outside, lifted up his little leg, and a couple of drops of pee came out.</p>



<p>Now he&#8217;s staring at me like he deserves a treat.</p>



<p>Sorry, buddy.</p>



<p>I wish I could eat constantly all day long, too.</p>



<p>But life isn&#8217;t always fair.</p>



<p>isn&#8217;t always fair anyway let&#8217;s see I might even lined up on the camera</p>



<p>anymore I don&#8217;t even know so we&#8217;re looking at this code here is going to</p>



<p>print a welcome message let&#8217;s see if that actually works so I&#8217;m gonna do make</p>



<p>run again make files are whoops what did I do loader dot asm what did I do what</p>



<p>did I do I somehow copy pasted the wrong make file</p>



<p>What&#8217;s the name of my source code file?</p>



<p>It&#8217;s point.</p>



<p>I guess I&#8217;ll just change it, and then it&#8217;ll probably work.</p>



<p>It&#8217;s still in assembly module.</p>



<p>Hopefully that didn&#8217;t mess it up too bad by copy-pasting the wrong source code.</p>



<p>Okay.</p>



<p>What is going on here?</p>



<p>Floater.</p>



<p>Oh, I need to change that.</p>



<p>Hang on.</p>



<p>Let me fix this.</p>



<p>I don&#8217;t know if I&#8217;m going to edit this out.</p>



<p>out. It&#8217;s fun to watch me struggle sometimes. There we go.</p>



<p>Point.</p>



<p>Alright, let&#8217;s give it another try.</p>



<p>Oh no, star dot so no such file a directory. Dang it.</p>



<p>Okay, now this seems to work. I may or may not have edited</p>



<p>that out. I copy pasted the wrong source code into my make</p>



<p>file. So I had to manually adjust it. Then I forgot to</p>



<p>copy paste my library file into the build directory. So I had</p>



<p>The driver sees my long as whatever.</p>



<p>What&#8217;s going on?</p>



<p>Print an alternate string begin.</p>



<p>Oh, the driver is printing a bunch of stuff.</p>



<p>Okay.</p>



<p>I started to think, why does it look like the program has a lot of stuff going on?</p>



<p>Oh, that&#8217;s the driver.</p>



<p>Okay.</p>



<p>So the driver says it sees its long as 100.</p>



<p>And then now we&#8217;re inside of the point module.</p>



<p>So that&#8217;s the only thing we&#8217;ve done in assembly so far.</p>



<p>so far then the driver has regained control maybe I should add a couple of</p>



<p>new lines in there so I don&#8217;t get confused again we will do a C out and L</p>



<p>and we&#8217;ll do two of those run the program again and then I won&#8217;t get</p>



<p>confused about the messages okay so now we&#8217;re inside of the point module and</p>



<p>nothing is happening so points let me get rid of the make file here and</p>



<p>and we&#8217;re just printing a welcome message nothing else so now let&#8217;s print</p>



<p>the received string so what am I talking about so we&#8217;re gonna print a prefix</p>



<p>basically saying hey we received the following string right so if you look at</p>



<p>the symbol message received string it&#8217;s just gonna say we&#8217;re now printing the</p>



<p>received string and then it&#8217;ll print it so what are we actually printing we&#8217;re</p>



<p>What is R12? R12 is a character pointer to the print me string. And so basically this</p>



<p>function print null terminated string, it takes a character pointer. So we&#8217;re giving it a character</p>



<p>pointer that we received. When point was called by the driver, notice how it gave a pointer to</p>



<p>the C string. You know, all arrays are basically pointers. They&#8217;re just different syntactically</p>



<p>just different syntactically sometimes so if i declare an array of some length and i give the</p>



<p>symbol somewhere that symbol is really a character pointer so um by calling point with my c string</p>



<p>i&#8217;m calling point inside of the assembly module with this character pointer so that means even</p>



<p>though this c string is owned by the driver by the c plus plus module the assembly module has access</p>



<p>So that means we should be able to print it right now already.</p>



<p>So just the rest of it is just like giving a pointer.</p>



<p>And notice how I&#8217;m not dereferencing R12.</p>



<p>If I did dereferencing around R12, then we would be looking to that address and seeing what&#8217;s there,</p>



<p>which wouldn&#8217;t work for printing a null terminated string.</p>



<p>So let&#8217;s just run it again.</p>



<p>I don&#8217;t know if you can hear him.</p>



<p>This dude is growling at me still because he wants another treat.</p>



<p>He just got denied.</p>



<p>He&#8217;s trying to do it again.</p>



<p>do it again. I let him outside people. He&#8217;s been outside like three times already and he just went</p>



<p>out like two minutes ago. Okay. I love him so much. It hurts my heart and he knows eventually he&#8217;s</p>



<p>going to break me because it hurts my heart or I&#8217;m like too distracted. It&#8217;s like, you know,</p>



<p>pulling the crank on a slot machine in Vegas. You know, eventually something comes out.</p>



<p>That&#8217;s what he does to me. I&#8217;ve accidentally trained him. So now printing the received</p>



<p>Now printing the received string and notice how it prints.</p>



<p>Hello, this is a C string owned by me.</p>



<p>So our assembly module is able to print a C string that was created locally by a C++ module.</p>



<p>So we&#8217;re handing around pointers.</p>



<p>Nice.</p>



<p>Can you hear me?</p>



<p>He&#8217;s getting louder.</p>



<p>So now let&#8217;s modify the incoming long.</p>



<p>Can you shush your freaking pants, please?</p>



<p>Shush your pants.</p>



<p>shush your pants you know the sad thing also is he&#8217;s so old that he&#8217;s deaf now</p>



<p>so he used to know what shush your pants meant it meant I&#8217;m not listening to you</p>



<p>and you might as well stop because I&#8217;m not gonna do anything based on your</p>



<p>harassment but now he can&#8217;t hear me say shush your pants so he just harasses me</p>



<p>all day and all night okay um so I&#8217;m gonna copy paste a little bit more code</p>



<p>Modify the incoming long.</p>



<p>So remember again that the point function, it received a pointer to a long.</p>



<p>We&#8217;re calling the long change me on the inside of this, but it&#8217;s coming in as R13.</p>



<p>And if you notice what I&#8217;m doing here is I&#8217;m just saying let&#8217;s increase the long.</p>



<p>So I&#8217;m going to dereference R13 because R13 is a pointer.</p>



<p>So I&#8217;m saying let&#8217;s go to the memory and change the long that is inside of memory.</p>



<p>And we have to specify that it is a keyword.</p>



<p>it as a keyword so that we you know we don&#8217;t confuse the system the system might think are</p>



<p>you modifying a keyword or like a double word or like a word like how big is your data all we know</p>



<p>is it&#8217;s an integer because it&#8217;s the increase instruction so I&#8217;m saying we got a keyword you</p>



<p>know a 64-bit integer sitting at that memory location I want you to dereference it and increase</p>



<p>it and going back to the driver we&#8217;re providing a pointer to our long so the long starts off is 100</p>



<p>and we&#8217;re just giving a pointer to it the next thing that we can do is we can</p>



<p>ask the driver to print our own stuff actually you know what let&#8217;s run the program right now</p>



<p>just to show that the driver can see the change in the long so i&#8217;m going to run it again notice how</p>



<p>first when the driver says hello it sees its own long as 100 then we&#8217;re inside the assembly module</p>



<p>long and then we return to the caller which is the driver notice how at the</p>



<p>very end of the program the driver sees its long as being 101 so we were able to</p>



<p>modify data that was owned by a different module just by passing pointers</p>



<p>and de-referencing them okay cool so now the next thing that we should do is let&#8217;s</p>



<p>ask the driver to print our own stuff that we own because remember if you go</p>



<p>to the very top you know we own some stuff we own some we own a long we own</p>



<p>float, right? So we want to be able to do something with that. So I&#8217;m going to copy paste this,</p>



<p>ask the driver to print our own stuff. So I&#8217;m going to move three items inside of arguments</p>



<p>for a function call. And then I&#8217;m going to make a function call calling the function,</p>



<p>Hey driver, print this again, Hey driver, print this is actually owned by the C++ module.</p>



<p>a pointer to a long and a pointer to a double remember even pointers to doubles are actually</p>



<p>integers so they use the general purpose register so that&#8217;s the three arguments right there rdi rsi</p>



<p>and rdx m and then we&#8217;re giving the first pointer is going to be the c string so message string</p>



<p>inside asm so you can see that&#8217;s this right here and then the next pointer is the long</p>



<p>inside ASM and the third is the float where did I just go I&#8217;m getting confused my dog is harassing</p>



<p>me right now so bad notice how I&#8217;m not dereferencing so like if when we were increasing the incoming</p>



<p>long before R13 was a pointer so we dereferenced while we increased so that we would increase the</p>



<p>actual value and not the pointer and not the pointer&#8217;s memory location but here we&#8217;re not</p>



<p>C++ module the actual pointers to our data. We don&#8217;t want to give it the data itself. We want</p>



<p>to give pointers to the data so we&#8217;re not derefing with the brackets. So then we call it and when we</p>



<p>get back in here it should just be able to print everything. So I&#8217;m going to run it one more time.</p>



<p>We&#8217;re going to make it and run it and so now let&#8217;s see. So here we&#8217;re inside of our assembly module</p>



<p>And then here the assembly module has just called on hey driver print this.</p>



<p>Remember the C++ module doesn&#8217;t actually call this function.</p>



<p>The assembly module calls it.</p>



<p>So we&#8217;re like going back and forth.</p>



<p>We&#8217;re kind of crisscrossing.</p>



<p>So now the drivers print this function says we got the following string.</p>



<p>Notice how that&#8217;s the string that is owned by assembly.</p>



<p>So we define that inside of our data section in the assembly module.</p>



<p>And then it prints the long.</p>



<p>It prints it as hex.</p>



<p>And it just sort of prints the value.</p>



<p>it just sort of prints the value then it prints it as hex again and then prints at the value</p>



<p>i think actually not hex i think this prints the memory location let&#8217;s double check real fast</p>



<p>yeah so remember um in c plus plus i know this is not like a c plus plus video but um</p>



<p>if the long is a pointer then if we just print it without dereferencing it we should see a memory</p>



<p>location so it&#8217;s telling us uh that the long&#8217;s memory location is this and the doubles memory</p>



<p>location is that and if you stare at those two numbers long enough and you understand hex which</p>



<p>And do you understand hex, which you can see my other videos for?</p>



<p>You&#8217;ll see that those memory locations are right next to each other because that&#8217;s the way we define them inside of assembly.</p>



<p>So we now have the ability to have data that is owned by assembly and give it to C++ or C using pointers.</p>



<p>No problem at all.</p>



<p>And then the printing driver thing exits and then the actual driver regains control.</p>



<p>And it just says that it sees it&#8217;s long as 101.</p>



<p>it sees it&#8217;s long as 101 so uh yeah that&#8217;s that&#8217;s pretty much all i wanted to show you for this</p>



<p>now you hopefully are an expert at passing data back and forth between various modules using</p>



<p>pointers we&#8217;re not using references because references are like a little bit a little bit</p>



<p>less compatible pointers are just really easy they totally work in assembly no problem</p>



<p>one more thing i just wanted to show you real fast before we go even though there&#8217;s another</p>



<p>video you should check out for stack alignment I just want you to see what</p>



<p>happens if I remove this extra push-pop pair so now my stack is about eight</p>



<p>bytes off of its previous alignment because you know we&#8217;re not pushing an</p>



<p>extra eight byte value and somewhere inside of the let&#8217;s see print null</p>



<p>terminated string and then the hey driver print this oh and then we go into</p>



<p>like a bunch of C stuff the program should probably crash because anytime</p>



<p>you use a GCC function or a GCC library or something like that the stack has to</p>



<p>be aligned to 16 bytes so if it&#8217;s off by 8 then it&#8217;ll crash and how did I know</p>



<p>that I needed this well I just ran it first and it crashed and then I added</p>



<p>the extra push pop pair and it didn&#8217;t crash and I realized it was definitely</p>



<p>one more time we should get a seg fault yeah we get a seg fault stack alignment oh no with no</p>



<p>description of what&#8217;s going on if you were in gcc you could i mean sorry if you were in gdb you</p>



<p>could probably figure that out eventually but why not just give it a try add another push pop pair</p>



<p>run the program again with no other modifications now it totally works</p>



<p>okay well uh i think that&#8217;s uh that&#8217;s all i have for this video thank you so much for watching i</p>



<p>I hope you learned a little bit of stuff and you had a little bit of fun.</p>



<p>I will see you in the next video.</p>



<p>Hey everybody.</p>



<p>Thanks for watching this video again from the bottom of my heart.</p>



<p>I really appreciate it.</p>



<p>I do hope you did learn something and have some fun.</p>



<p>If you could do me a please, a small little favor,</p>



<p>could you please subscribe and follow this channel or these videos</p>



<p>or whatever it is you do on the current social media website</p>



<p>that you&#8217;re looking at right now.</p>



<p>It would really mean the world to me</p>



<p>would really mean the world to me and it&#8217;ll help make more videos and grow</p>



<p>this community so we&#8217;ll be able to do more videos longer videos better videos</p>



<p>or just I&#8217;ll be able to keep making videos in general so please do do me a</p>



<p>kindness and and subscribe you know sometimes I&#8217;m sleeping in the middle of</p>



<p>the night and I just wake up because I know somebody subscribed or followed it</p>



<p>just wakes me up and I get filled with joy that&#8217;s exactly what happens every</p>



<p>single time so you could do it as a nice favor to me or you could you control me</p>



<p>up in the middle of the night just subscribe and then I&#8217;ll just wake up I promise that&#8217;s what will</p>



<p>happen also if you look at the middle of the screen right now you should see a QR code which</p>



<p>you can scan in order to go to the website which I think is also named somewhere at the bottom of</p>



<p>this video and it&#8217;ll take you to my main website where you can just kind of like see all the videos</p>



<p>I published and the services and tutorials and things that I offer and all that good stuff and</p>



<p>for</p>



<p>Clarifications or errata or just future videos that you want to see please leave a comment or if you just want to say hey</p>



<p>What&#8217;s up? What&#8217;s going on? You know, just send me a comment, whatever</p>



<p>I also wake up for those in the middle of the night. I get I wake up in a cold sweat. I&#8217;m like this</p>



<p>It would really it really mean the world to me. I would really appreciate it. So again, thank you so much for watching this video and</p>



<p>darkness, which is coming for us all.</p>



<p>Thank you.</p>
<p>The post <a href="https://www.NeuralLantern.com/x86-64-assembly-pointers-dereferencing-explained-hybrid-c-yasm-example/">x86-64 Assembly Pointers &amp; Dereferencing Explained &#8211; Hybrid C++/YASM Example</a> appeared first on <a href="https://www.NeuralLantern.com">NeuralLantern.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.NeuralLantern.com/x86-64-assembly-pointers-dereferencing-explained-hybrid-c-yasm-example/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>x86-64 Assembly: Floating Point Registers Basics with YASM (MOVSD, MULSD, CVTSI2SD)</title>
		<link>https://www.NeuralLantern.com/x86-64-assembly-floating-point-registers-basics-with-yasm-movsd-mulsd-cvtsi2sd/</link>
					<comments>https://www.NeuralLantern.com/x86-64-assembly-floating-point-registers-basics-with-yasm-movsd-mulsd-cvtsi2sd/#respond</comments>
		
		<dc:creator><![CDATA[mike]]></dc:creator>
		<pubDate>Sun, 15 Feb 2026 03:15:33 +0000</pubDate>
				<category><![CDATA[Assembly Language]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[Videos]]></category>
		<category><![CDATA[assembly language tutorial]]></category>
		<category><![CDATA[convert integer to float assembly]]></category>
		<category><![CDATA[cvtsi2sd]]></category>
		<category><![CDATA[double precision assembly]]></category>
		<category><![CDATA[ed jorgensen x86 book]]></category>
		<category><![CDATA[floating point registers]]></category>
		<category><![CDATA[movsd]]></category>
		<category><![CDATA[mulsd]]></category>
		<category><![CDATA[nasm yasm floating point]]></category>
		<category><![CDATA[stack alignment assembly]]></category>
		<category><![CDATA[system v abi xmm]]></category>
		<category><![CDATA[x86 assembly floating point]]></category>
		<category><![CDATA[x86-64 assembly]]></category>
		<category><![CDATA[x86-64 linux assembly]]></category>
		<category><![CDATA[xmm registers]]></category>
		<category><![CDATA[xmm0]]></category>
		<category><![CDATA[Yasm tutorial]]></category>
		<guid isPermaLink="false">https://www.NeuralLantern.com/?p=302</guid>

					<description><![CDATA[<p>Learn the basics of floating-point registers (XMM0–XMM15) in x86-64 assembly with YASM. Covers MOVSD, MULSD, CVTSI2SD, ABI rules, why floats return in XMM0 instead of RAX, saving/restoring around calls, and common stack alignment crashes when using printf.</p>
<p>The post <a href="https://www.NeuralLantern.com/x86-64-assembly-floating-point-registers-basics-with-yasm-movsd-mulsd-cvtsi2sd/">x86-64 Assembly: Floating Point Registers Basics with YASM (MOVSD, MULSD, CVTSI2SD)</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="x86-64 Assembly: Floating Point Registers Basics with YASM (MOVSD, MULSD, CVTSI2SD)" width="1380" height="776" src="https://www.youtube.com/embed/0Wcu_7LDw_w?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>Quick but thorough introduction to floating-point registers in x86-64 assembly using YASM.</p>



<p>Learn why XMM0 is special, how to use MOVSD / MULSD / CVTSI2SD, why you must save floats around function calls, and how easy (or sneaky) stack alignment bugs can crash your program.</p>



<p>Live coding + real examples converting integers to doubles and multiplying them.</p>



<p>Great next step after basic integer assembly tutorials.</p>



<p>00:00 Introduction to Floating Point Registers<br>00:28 Why Floating Point Uses Special Registers<br>01:35 Floating Point Return Value in XMM0<br>02:17 XMM Registers Overview XMM0 to XMM15<br>02:48 ABI Rules No Callee-Saved XMM Registers<br>03:16 128-bit XMM Registers Purpose and Size<br>04:00 Ed Jorgensen x86-64 Textbook Reference<br>05:03 Locating XMM Documentation in Textbook<br>05:20 Earthquake &#8211; I am going to die<br>06:24 Chapter 18 Floating Point Instructions<br>07:34 MOVSS vs MOVSD Single vs Double Precision<br>09:11 Understanding SS and SD Instruction Suffixes<br>10:58 MOVSD Example Register to Register<br>11:03 Conversion Instructions CVT Family<br>13:02 Floating Point Arithmetic ADDSD MULSD SUBSD<br>25:48 Program Demo User Input Section<br>26:01 Converting Integer to Double CVTSI2SD<br>26:29 Multiplying by Constant Float MULSD<br>28:56 Saving Result Printing Modified Float<br>31:38 Multiplying User Integer by User Float<br>33:54 Final Result Display Program Summary<br>35:19 Stack Alignment Crash Demonstration<br>36:24 Conclusion Key Takeaways<br>36:52 Outro Subscribe and Thanks</p>



<p>=-=-=-=-=-=-=-=-=</p>



<p>Thanks for watching!</p>



<p>Find us on other social media here:</p>



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



<li>Twitter / X: https://x.com/NeuralLantern</li>



<li>Rumble: https://rumble.com/c/c-3696939</li>



<li>BitChute: https://www.bitchute.com/channel/pg1Pvv5dN4Gt</li>



<li>Daily Motion: https://www.dailymotion.com/neurallantern</li>



<li>Minds: https://www.minds.com/neurallantern/</li>



<li>Odysee: https://odysee.com/@NeuralLantern:5</li>
</ul>



<p>Please show your support!</p>



<ul class="wp-block-list">
<li>Buy me a coffee: https://ko-fi.com/neurallantern</li>



<li>Subscribe + Sharing on Social Media</li>



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



<li>Subscribe to Blog: https://www.NeuralLantern.com</li>



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



<p>Hey there! In this video we&#8217;re going to talk about pointers and dereferencing in a YASM x8664</p>



<p>assembly program, also as a hybrid program so that assembly and C++ can talk to each other</p>



<p>and send each other pointers and send each other data and things like that.</p>



<p>for what pointers are.</p>



<p>I&#8217;m going to write in C++ for a second.</p>



<p>Suppose you have a pointer for an integer.</p>



<p>We&#8217;ll call it P.</p>



<p>Suppose you have an integer by itself.</p>



<p>We&#8217;ll call it A.</p>



<p>Let&#8217;s say that the value of A is 5.</p>



<p>And if you wanted to say that P points to A,</p>



<p>you could say P equals the address of A.</p>



<p>I&#8217;ll put C++ at the top here.</p>



<p>And so now if I set A to 6</p>



<p>then I print P a dereference of P this is not like a full pointers tutorial</p>



<p>but basically by changing a I&#8217;m changing what P thinks it sees as a value</p>



<p>assuming ID reference it I could also let me do a print 6 here I could also</p>



<p>just change the value through P I could say dereference P and I could say equals</p>



<p>would actually print a seven right so you know you can have regular variables global variables</p>



<p>whatever kind of you know memory stuff on the stack and to get a pointer to it you really just</p>



<p>need to get its memory location in c++ it&#8217;s kind of easy syntactically you can see what&#8217;s happening</p>



<p>in assembly you really just need the memory location stored somewhere you could store that</p>



<p>variable that just simply stored the memory location of some other variable.</p>



<p>You could have a 64-bit register store the value of a variable.</p>



<p>Let&#8217;s say we have like a, I don&#8217;t know, my whatever, my number let&#8217;s say inside of assembly.</p>



<p>I&#8217;ll do ASM here and we say it&#8217;s a quad word and it starts off as this number or whatever.</p>



<p>So if you haven&#8217;t seen my previous videos, go see them for the basics of assembly and</p>



<p>of assembly and linking and make files and all that stuff but you know if you</p>



<p>have an assembly program and you have a data section and you define a global</p>



<p>variable like this what you&#8217;re basically saying is I want to take this giant</p>



<p>number and I want to write it into eight bytes that&#8217;s the DQ it says data quad</p>



<p>word I want to write that giant number across eight bytes and then I want to</p>



<p>get a pointer to it stored in the my number symbol so my number is not</p>



<p>actually the value it&#8217;s a pointer to the value so you know later if you want to</p>



<p>you know later if you want to move you know something into a register if you did this</p>



<p>that would move the pointer into rax but if you did this</p>



<p>with deref symbols after it or around it then you would move</p>



<p>maybe i&#8217;ll put that into rex you&#8217;d move that actual number that we specified into rex</p>



<p>into Rx. It&#8217;s important to understand also that pointers are integers even when we&#8217;re pointing to</p>



<p>doubles. So for example sometimes people make this mistake they&#8217;ll say you know my double</p>



<p>and they&#8217;ll say it&#8217;s a quad word meaning this is going to be a 64-bit double precision floating</p>



<p>point number and they&#8217;ll do like 44.55 or whatever. So that is a double and it is in memory</p>



<p>you know what is the symbol of my double remember it&#8217;s supposed to be just a</p>



<p>pointer right it can&#8217;t be an actual double because a memory location is not</p>



<p>a double a memory location is an integer so that means if you wanted to move a</p>



<p>pointer into a register you would only be able to move the pointer into a</p>



<p>regular general purpose register not a floating point register and you should</p>



<p>use the regular movement instructions for just regular general purpose</p>



<p>So keep that in mind if you see a signature like this like let&#8217;s say function F and we have</p>



<p>You know, let&#8217;s say long a and long B and actually let&#8217;s do pointers</p>



<p>Let&#8217;s say long pointer a and long pointer</p>



<p>B and double pointer C all three of those arguments are actually 64 bit integers</p>



<p>Because they&#8217;re all pointers even if one of the pointers points to adult a double</p>



<p>double why did I say dull pointers aren&#8217;t dull they&#8217;re exciting okay so I&#8217;m gonna open up some</p>



<p>code here real fast so usually I don&#8217;t explain my uh my driver I&#8217;m gonna explain it to you this time</p>



<p>because it&#8217;s kind of doing a little bit more than my other videos um again if you don&#8217;t have uh the</p>



<p>knowledge of how to make a make file see my other videos because that&#8217;s explained there for now I&#8217;m</p>



<p>what we really need to do is write a driver and an assembly module for a</p>



<p>hybrid program again hybrid programs covered in other videos so the driver is</p>



<p>pretty easy I&#8217;m just going to copy paste it honestly here and then just kind of</p>



<p>explain it to you the driver is pretty easy we&#8217;re going to do I O stream so we</p>



<p>can print stuff we&#8217;re going to mark an external function called point as extern</p>



<p>C so that just disables name mangling which means the C++ module will be able</p>



<p>will be able to call on this function called point and it won&#8217;t expect that</p>



<p>the point function has its name mangled like C++ does the reason being is that</p>



<p>point is actually going to be in a side it&#8217;s going to be inside assembly where</p>



<p>its name will not be mangled this disables the ability to overload but</p>



<p>that&#8217;s okay we don&#8217;t care it&#8217;s going to take two pointers a pointer to a character</p>



<p>and a pointer to a long since both of those are pointers they&#8217;re both</p>



<p>64-bit integers even the character pointer and then we have a function that is internal to this</p>



<p>module called hey driver print this remember we&#8217;re inside of the driver program right now</p>



<p>so if you look at the bottom it&#8217;s just a function that takes in some pointers</p>



<p>and then prints some stuff so it&#8217;s going to print like it&#8217;s going to print what the string is</p>



<p>it&#8217;s going to print what the long is my dog&#8217;s growling at me i&#8217;m going to ignore him because</p>



<p>i literally just let him pee and poop at this point now he&#8217;s harassing me for treats</p>



<p>now he&#8217;s harassing me for treats he always does this okay so uh the string the long the double</p>



<p>this function expects to receive three pointers to different data types it&#8217;s just going to print</p>



<p>all of them and the point get it the point of this function is we&#8217;re going to go inside of</p>



<p>the assembly module and then have the assembly module call on this function so that we can we</p>



<p>can prove that we can have stuff sent from assembly to c plus plus or c using pointers</p>



<p>using pointers we can have data sent over so anyway that&#8217;s why both of these</p>



<p>are in here the point needs to be marked as no name mangling because point is</p>



<p>inside of assembly which will not name mangle and then hey driver print this</p>



<p>that needs to have name mangling disabled also so that the assembly</p>



<p>module can call on this other than that we&#8217;re just basically inside of a main</p>



<p>saying hey this is the c string we&#8217;re making a c string inside of the main function notice how</p>



<p>this is a local variable so that c string is going to show up on the stack it&#8217;s going to show up in</p>



<p>the area that is owned by main for main stack area same thing for my long that&#8217;s a local variable on</p>



<p>the stack um and but then we can actually send pointers to those pieces of data to another</p>



<p>function in another module you don&#8217;t have to only transport globals or stuff on the heap</p>



<p>or stuff on the heap, you can transport pointers to local variables. Just make sure that by the</p>



<p>time this function finishes, then nowhere else is actually using that data because,</p>



<p>well, being on the stack, once main function or once any function finishes, then its portion of</p>



<p>the stack will be cleaned up and removed and it&#8217;ll be junk data. You&#8217;ll probably get a seg fault.</p>



<p>But for now, we&#8217;re not going to use anything on the stack. We&#8217;re not going to use these local</p>



<p>just going to use them quickly on this call to point and then we&#8217;re going to return to the</p>



<p>operating system and finish the program. So that&#8217;s the driver. Now the hard part. Let&#8217;s do this in</p>



<p>assembly. So for starters, I&#8217;m going to make a data section and just explain it to you very,</p>



<p>very quickly. Again, if you don&#8217;t understand the basics of YASM x86-64 assembly, did I mention</p>



<p>that that&#8217;s what this language is at the beginning of the video? I guess I should put that in the</p>



<p>put that in the description or record an announcement that I can tack on at the beginning</p>



<p>or something. Anyway, so if you don&#8217;t understand how to do this, see my other videos, but basically</p>



<p>we&#8217;re going to make a data section. We&#8217;re going to define some strings. Here&#8217;s like an announcement.</p>



<p>Oh, we&#8217;re inside of, you know, the module now, the assembly module. And now we&#8217;re going to print</p>



<p>the received string. And then we&#8217;re going to make a string that is owned by assembly, which we can</p>



<p>into C++ when we call the function inside of the driver.</p>



<p>So this string is owned by the assembly module.</p>



<p>Notice how these are null terminated strings.</p>



<p>I just have like a comma zero there,</p>



<p>which means I have some extra functions</p>



<p>I&#8217;m gonna paste in that we&#8217;re not really gonna talk about</p>



<p>because they&#8217;ve been discussed in other videos</p>



<p>just so that we can print null terminated strings.</p>



<p>Then I&#8217;ve got a new line here,</p>



<p>you know, carriage return line feed.</p>



<p>And then I&#8217;ve just got some numbers</p>



<p>that are owned by the assembly module.</p>



<p>Then I&#8217;ve got a system write call,</p>



<p>call code one for the system call writes and file descriptor standard output so I</p>



<p>can print just to the terminal again if you don&#8217;t understand this see my other</p>



<p>videos so now let&#8217;s start the actual text section so this is where our</p>



<p>instructions start so we got the text section here and we&#8217;re going to use some</p>



<p>external symbols don&#8217;t worry about these I&#8217;m just using my own little library to</p>



<p>and input integers if you have access to this library use it if you don&#8217;t if you&#8217;re watching</p>



<p>at home and you don&#8217;t have this library then that&#8217;s fine you can use you know printf or</p>



<p>scanf or something like that to get and print floats from and to the user</p>



<p>but yeah I&#8217;m just using that and then I&#8217;m marking an external function here called hey driver print</p>



<p>this if you recall the driver module has a function called hey driver print this so</p>



<p>just allows my assembly code to call on that external function. Okay now next</p>



<p>piece of code. This is going to be… actually I&#8217;m going to paste the print</p>



<p>null terminated string function and related code because it&#8217;s just like a</p>



<p>big giant mess and we&#8217;re mostly going to ignore it. So just to show you what I&#8217;m</p>



<p>doing here I have a function called print null terminated string so that I</p>



<p>can print these strings up here and then I have it rely on a function called</p>



<p>string length that I have implemented up here and all it does is just</p>
<p>The post <a href="https://www.NeuralLantern.com/x86-64-assembly-floating-point-registers-basics-with-yasm-movsd-mulsd-cvtsi2sd/">x86-64 Assembly: Floating Point Registers Basics with YASM (MOVSD, MULSD, CVTSI2SD)</a> appeared first on <a href="https://www.NeuralLantern.com">NeuralLantern.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.NeuralLantern.com/x86-64-assembly-floating-point-registers-basics-with-yasm-movsd-mulsd-cvtsi2sd/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
