<?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>floating point registers Archives - NeuralLantern.com</title>
	<atom:link href="https://www.NeuralLantern.com/tag/floating-point-registers/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.NeuralLantern.com/tag/floating-point-registers/</link>
	<description></description>
	<lastBuildDate>Sun, 01 Mar 2026 02:14:40 +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>floating point registers Archives - NeuralLantern.com</title>
	<link>https://www.NeuralLantern.com/tag/floating-point-registers/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Mixed Function Arguments in x86-64 Assembly &#8211; Integers &#038; Floats Explained</title>
		<link>https://www.NeuralLantern.com/mixed-function-arguments-in-x86-64-assembly-integers-floats-explained/</link>
					<comments>https://www.NeuralLantern.com/mixed-function-arguments-in-x86-64-assembly-integers-floats-explained/#respond</comments>
		
		<dc:creator><![CDATA[mike]]></dc:creator>
		<pubDate>Sun, 01 Mar 2026 02:14:39 +0000</pubDate>
				<category><![CDATA[Assembly Language]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[Videos]]></category>
		<category><![CDATA[abi calling convention]]></category>
		<category><![CDATA[assembly language]]></category>
		<category><![CDATA[Ed Jorgensen]]></category>
		<category><![CDATA[floating point registers]]></category>
		<category><![CDATA[function calling convention]]></category>
		<category><![CDATA[integer float arguments]]></category>
		<category><![CDATA[linux assembly]]></category>
		<category><![CDATA[low level programming]]></category>
		<category><![CDATA[mixed arguments]]></category>
		<category><![CDATA[nasm]]></category>
		<category><![CDATA[rax return]]></category>
		<category><![CDATA[rdi rsi xmm0]]></category>
		<category><![CDATA[system v abi]]></category>
		<category><![CDATA[ubuntu assembly]]></category>
		<category><![CDATA[x86 assembly]]></category>
		<category><![CDATA[x86-64 assembly]]></category>
		<category><![CDATA[xmm registers]]></category>
		<category><![CDATA[xmm0 return]]></category>
		<category><![CDATA[yasm]]></category>
		<guid isPermaLink="false">https://www.NeuralLantern.com/?p=310</guid>

					<description><![CDATA[<p>In the System V x86-64 ABI, integer and floating-point arguments use separate register assignment sequences. Integer arguments go into rdi, rsi, rdx, rcx, r8, r9 (then stack), while floating-point arguments use xmm0 through xmm7 independently. This means the first integer you see — even if it appears after several doubles — always goes into rdi, and the second float always goes into xmm1 regardless of how many integers came before it.</p>
<p>The post <a href="https://www.NeuralLantern.com/mixed-function-arguments-in-x86-64-assembly-integers-floats-explained/">Mixed Function Arguments in x86-64 Assembly &#8211; Integers &amp; Floats 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="Mixed Function Arguments in x86-64 Assembly - Integers &amp; Floats Explained" width="1380" height="776" src="https://www.youtube.com/embed/ZAY3srLRx8c?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">Quick guide to passing mixed int + float arguments in x86-64 assembly (System V ABI). See why rdi can still be the first integer after several doubles, why xmm registers count separately, and how return values switch between rax and xmm0. Perfect for YASM/NASM programmers interfacing with C/C++.</p>



<p class="wp-block-paragraph">Intro to Mixed Arguments 00:00<br>Simple Integer-Only Functions 00:46<br>Adding Arguments and Return Values 01:01<br>Integer Arguments in RDI and RSI 01:30<br>Pointers Treated as Integers 02:06<br>Introducing Floating-Point Returns 02:31<br>Returning Double in XMM0 03:06<br>First Float Argument in XMM0 03:36<br>Float Registers Count Separately 04:03<br>Integer Register Order Explained 04:16<br>Separate Counting for Integers and Floats 05:21<br>RSI as First Integer After Float 05:38<br>Reference to Ed Jorgensen&#8217;s Book 07:00<br>Callee-Saved Registers Overview 07:56<br>Complex Mixed Argument Examples 09:48<br>Inserting Integer Among Floats 10:57<br>Skipping Float Registers on Integer 11:18<br>Calling C from Assembly Notes 11:56<br>Name Mangling Reminder 12:21<br>Closing Remarks and Thanks 12:30<br>Call to Subscribe and Support 13:04<br>Website and QR Code Mention 13:38<br>Final Thanks and Outro Music 14:19</p>



<p class="wp-block-paragraph">=-=-=-=-=-=-=-=-=</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>



<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 class="wp-block-paragraph">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 the Blog: https://www.NeuralLantern.com</li>



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



<p class="wp-block-paragraph">Hey everybody! In this video I&#8217;m going to talk to you a little bit about using functions with</p>



<p class="wp-block-paragraph">mixed arguments in a YASM x86-64 assembly language program. Although this</p>



<p class="wp-block-paragraph">video will probably still be useful to you if you&#8217;re using NASM or MASM because the</p>



<p class="wp-block-paragraph">mixed arguments and their order and how they work is governed by the ABI which is a system</p>



<p class="wp-block-paragraph">so what the heck am i talking about okay so the first thing that i want to show you is uh</p>



<p class="wp-block-paragraph">imagine we have a function here let&#8217;s say void f this function doesn&#8217;t take any arguments and it</p>



<p class="wp-block-paragraph">doesn&#8217;t return anything congratulations you&#8217;re done that was the easiest thing that you&#8217;ve ever</p>



<p class="wp-block-paragraph">done in your entire life but as soon as you start adding arguments to it you have to uh</p>



<p class="wp-block-paragraph">start understanding how to uh how to call registers and stuff so imagine we have like a</p>



<p class="wp-block-paragraph">a long a and a long b so we give it two arguments and maybe we want it to return a long</p>



<p class="wp-block-paragraph">this is kind of like level one of writing functions in assembly right we just have</p>



<p class="wp-block-paragraph">a bunch of integers and we realize okay um this long the return value is going to come to the</p>



<p class="wp-block-paragraph">Maybe I&#8217;ll do a comment up here, we&#8217;ll do rax, we&#8217;ll say the long is actually coming</p>



<p class="wp-block-paragraph">back to the user in rax and the long is coming into the function with rdi, the long a and</p>



<p class="wp-block-paragraph">the long b is coming into the function with rsi.</p>



<p class="wp-block-paragraph">So if you understand this then you can write a function in assembly where basically you</p>



<p class="wp-block-paragraph">two incoming integer arguments and then you return to the caller a long value using rax</p>



<p class="wp-block-paragraph">keep in mind also that if this second argument was a pointer long pointer then it would be the</p>



<p class="wp-block-paragraph">same thing rsi because pointers are integers they&#8217;re 64-bit unsigned integers even if the</p>



<p class="wp-block-paragraph">pointer was not to a long even if the pointer was to a double or a character or whatever it would</p>



<p class="wp-block-paragraph">pointers are integers. It starts getting a little bit more complicated when you want to mix between</p>



<p class="wp-block-paragraph">floats and numeric arguments. So what I&#8217;ve been saying so far, it&#8217;s all just integers.</p>



<p class="wp-block-paragraph">Even if we&#8217;re mixing pointers with regular longs, it&#8217;s just, you know, they&#8217;re all longs basically,</p>



<p class="wp-block-paragraph">right? So, but as soon as we start introducing floats, then things get a little bit more</p>



<p class="wp-block-paragraph">complicated. So for starters, what if we did a function that was, that returned a double?</p>



<p class="wp-block-paragraph">that returned a double. So let&#8217;s say we have a function G and it returns a double. Maybe it</p>



<p class="wp-block-paragraph">still takes in a long and a double pointer. If it returns a double, let&#8217;s see, is this still</p>



<p class="wp-block-paragraph">lining up? I don&#8217;t think it&#8217;s lining up anymore. There we go. If it&#8217;s returning a double, then</p>



<p class="wp-block-paragraph">that means we have to return to the caller with the XMM0 register. So XMM0 is always designated as</p>



<p class="wp-block-paragraph">the well the first float argument but also the float return value so keep in</p>



<p class="wp-block-paragraph">mind if I&#8217;m returning a double to the caller I&#8217;m not going to use our a X at</p>



<p class="wp-block-paragraph">all I&#8217;m just going to use XMM zero load it up with the return value and then</p>



<p class="wp-block-paragraph">return to the caller and that&#8217;s it if I wanted to do another function let&#8217;s say</p>



<p class="wp-block-paragraph">hmm how about H and then we&#8217;ll say I don&#8217;t know maybe the first argument is a</p>



<p class="wp-block-paragraph">argument is a float we call it a double a that means rdi is not going to be the argument that</p>



<p class="wp-block-paragraph">or the register that we look at to see our incoming double it has to be a float register</p>



<p class="wp-block-paragraph">xmm0 is the float register that we look at for the first argument the float registers are really</p>



<p class="wp-block-paragraph">easy you just kind of go in order like xmm0 is the first argument xmm1 is the next argument xmm2</p>



<p class="wp-block-paragraph">the general purpose uh integer registers they&#8217;re a little more complicated you have to remember</p>



<p class="wp-block-paragraph">their their labels uh you know like the letters have an ordering to it uh suppose for the sake</p>



<p class="wp-block-paragraph">of argument that we&#8217;re going to return a double from this also uh in that case let&#8217;s see did i</p>



<p class="wp-block-paragraph">just mess the formatting up again i think that&#8217;s okay um again we&#8217;re going to return xmm0</p>



<p class="wp-block-paragraph">notice how we&#8217;re returning xmm0 oh that&#8217;s why i spaced it forward notice how we are</p>



<p class="wp-block-paragraph">forward notice how we are returning xmm0 and we&#8217;re also taking xmm0 these float registers tend to be</p>



<p class="wp-block-paragraph">reused all over the place none of them are designated as callee saved within the abi</p>



<p class="wp-block-paragraph">so you always have to stash their values somewhere if you&#8217;re ever going to make a function call or</p>



<p class="wp-block-paragraph">anything or a system call the other thing to keep in mind is notice how rsi i still have rsi there</p>



<p class="wp-block-paragraph">for the second incoming argument you would imagine that rsi is supposed to be the second argument</p>



<p class="wp-block-paragraph">supposed to be the second argument even if it uh you know comes after a double but that&#8217;s not</p>



<p class="wp-block-paragraph">actually true because the the order i guess like the the ordering of the uh of the registers they</p>



<p class="wp-block-paragraph">only count against their own class like the float registers the float arguments they only count</p>



<p class="wp-block-paragraph">against the position of the float and the uh of the float registers and and and the general purpose</p>



<p class="wp-block-paragraph">they only count against themselves.</p>



<p class="wp-block-paragraph">What I&#8217;m trying to say is that RSI is the second integer argument,</p>



<p class="wp-block-paragraph">but if you look at the signature, we only have one integer argument, right?</p>



<p class="wp-block-paragraph">So RSI is not the second integer argument.</p>



<p class="wp-block-paragraph">It&#8217;s actually the first integer argument.</p>



<p class="wp-block-paragraph">So I&#8217;m going to put an RDI there.</p>



<p class="wp-block-paragraph">You probably can infer that the second float argument should be XMM1 at this point, I hope.</p>



<p class="wp-block-paragraph">and that&#8217;s true if we just say that there&#8217;s going to be another double</p>



<p class="wp-block-paragraph">that this function takes then it&#8217;s going to be xmm1</p>



<p class="wp-block-paragraph">not xmm2 because if you&#8217;re just counting the arguments</p>



<p class="wp-block-paragraph">and you&#8217;re sort of grouping the integers with the floats together</p>



<p class="wp-block-paragraph">you might think well first argument is xmm0 second argument would have been xmm1</p>



<p class="wp-block-paragraph">third argument would have been xmm2 therefore if I see</p>



<p class="wp-block-paragraph">a float coming into the third argument position it&#8217;ll be xmm2</p>



<p class="wp-block-paragraph">No, the integers don&#8217;t count against the floats and the floats don&#8217;t count against the integers.</p>



<p class="wp-block-paragraph">That&#8217;s why RDI is the first argument for integers, even though it&#8217;s in the second position,</p>



<p class="wp-block-paragraph">it&#8217;s still the first integer that we see.</p>



<p class="wp-block-paragraph">And XMM1 is the second float argument that we see.</p>



<p class="wp-block-paragraph">That&#8217;s why it&#8217;s XMM1 instead of XMM2, because we&#8217;re looking at it in the third position.</p>



<p class="wp-block-paragraph">So you&#8217;re not really looking at, whoops, you&#8217;re not looking at overall position.</p>



<p class="wp-block-paragraph">at position only counting that type of register let me pull open my favorite book to get a little</p>



<p class="wp-block-paragraph">bit more clarity on this um this book is written by a wonderful professor dr ed jorgensen phd</p>



<p class="wp-block-paragraph">this book i did not write it ed jorgensen wrote this book it&#8217;s called x86 64 assembly language</p>



<p class="wp-block-paragraph">programming with ubuntu this book can turn you into an expert with yasm assembly so uh</p>



<p class="wp-block-paragraph">I recommend everybody grab a copy. It&#8217;s also free and it&#8217;s got a copy left license.</p>



<p class="wp-block-paragraph">You can see like the license here. But anyway, I wanted to open up this book real fast</p>



<p class="wp-block-paragraph">just to show you the registers. Okay. I&#8217;m going to search for Kali saved so I don&#8217;t have to fumble</p>



<p class="wp-block-paragraph">around the book too long. Kali saved and that brings us to section 12.8.2 register usage.</p>



<p class="wp-block-paragraph">let&#8217;s see callee saved you&#8217;ll see rbx is callee saved rbp is callee saved probably shouldn&#8217;t</p>



<p class="wp-block-paragraph">mess with that one too much r12 13 14 15 all callee saved there&#8217;s a couple temporary registers</p>



<p class="wp-block-paragraph">but if you look carefully rdi is designated as the first argument but it should say really</p>



<p class="wp-block-paragraph">the first integer argument so rdi is the first integer argument that we see that&#8217;s why</p>



<p class="wp-block-paragraph">argument that we see that&#8217;s why in all of these examples the first integer argument that we</p>



<p class="wp-block-paragraph">actually see is rdi so like for function f long a that was the first integer argument</p>



<p class="wp-block-paragraph">and then in the function g it&#8217;s also the first integer argument and then in function h rdi is</p>



<p class="wp-block-paragraph">the double pointer b because that is the first integer argument that we actually see</p>



<p class="wp-block-paragraph">so keep that in mind you would just repeat that pattern you know the second integer argument you</p>



<p class="wp-block-paragraph">second integer argument you see that&#8217;s RSI. That&#8217;s why RSI is the pointer here because</p>



<p class="wp-block-paragraph">pointers are integers and the pointer here and we don&#8217;t have anything else but if I guess if we</p>



<p class="wp-block-paragraph">added another you know let&#8217;s say a long D then it would be RSI right there. Hopefully that makes</p>



<p class="wp-block-paragraph">sense and you can you can carry this logic forward for the first argument the second argument the</p>



<p class="wp-block-paragraph">and then R8 for the fifth argument R9 for the sixth argument and then you can</p>



<p class="wp-block-paragraph">look for further arguments on the stack if you need more than that but basically</p>



<p class="wp-block-paragraph">that&#8217;s how you count them up and then the float registers are just a lot</p>



<p class="wp-block-paragraph">easier they always start at zero and they go all the way up to 15 and so I</p>



<p class="wp-block-paragraph">don&#8217;t know maybe I should just copy paste well maybe I&#8217;ll start it from</p>



<p class="wp-block-paragraph">scratch we&#8217;ll say dub no let&#8217;s let&#8217;s mix it up a little bit more we&#8217;ll say long</p>



<p class="wp-block-paragraph">And the long is going to be returned with the RAX.</p>



<p class="wp-block-paragraph">And I guess I have to space this forward a little bit.</p>



<p class="wp-block-paragraph">And then if we have a bunch of floats, say double A.</p>



<p class="wp-block-paragraph">Can I maybe just copy paste this a little bit so I don&#8217;t have to do so much typing?</p>



<p class="wp-block-paragraph">Okay, so we&#8217;ll do double A, double B, double C, double D, double E.</p>



<p class="wp-block-paragraph">and then this is going to be xmm zero why did i put the extra comment there i don&#8217;t know</p>



<p class="wp-block-paragraph">and then we&#8217;re going to have xmm one and then we&#8217;re going to have xmm two xmm three and so forth</p>



<p class="wp-block-paragraph">and just to make sure you&#8217;re paying attention ask yourself this real fast if i were to insert</p>



<p class="wp-block-paragraph">z what register would we use for that would it be the one two three four five the fifth argument</p>



<p class="wp-block-paragraph">would it be uh would it be r8 or would it be something else hopefully you understand now</p>



<p class="wp-block-paragraph">let&#8217;s say we do a character pointer that it would be rdi because that&#8217;s the first integer argument</p>



<p class="wp-block-paragraph">that we actually see all right and then you know to return we would return in rax and then the</p>



<p class="wp-block-paragraph">return in RAX and then the floats just keep counting notice how it skipped from XMM2 or it</p>



<p class="wp-block-paragraph">went from XMM2 to XMM3 even though we crossed over an integer argument in between because the</p>



<p class="wp-block-paragraph">float arguments don&#8217;t count against the integers and the ints don&#8217;t count against the floats</p>



<p class="wp-block-paragraph">let&#8217;s see I think</p>



<p class="wp-block-paragraph">well if you want you can look at section 18.2 which just sort of talks about the floating</p>



<p class="wp-block-paragraph">which just sort of talks about the floating point registers we have 0 through 15 but I don&#8217;t think</p>



<p class="wp-block-paragraph">we really need to do that here I think we pretty much have everything we need to know to to call</p>



<p class="wp-block-paragraph">on functions with mixed arguments and to have a function within assembly that supports mixed</p>



<p class="wp-block-paragraph">arguments so again if your C or C++ modules are expecting some kind of signature like this now you</p>



<p class="wp-block-paragraph">know how to calculate what registers they&#8217;re actually going to populate by the time execution</p>



<p class="wp-block-paragraph">execution jumps into your assembly function.</p>



<p class="wp-block-paragraph">And if you want to call a C or a C++ function from assembly,</p>



<p class="wp-block-paragraph">now you know which registers to populate so that the the other function that</p>



<p class="wp-block-paragraph">you&#8217;re calling can receive the right data from you.</p>



<p class="wp-block-paragraph">Don&#8217;t forget about name mangling, which I talked about in another video.</p>



<p class="wp-block-paragraph">Okay, I think that&#8217;s all I really have to say.</p>



<p class="wp-block-paragraph">This video was pretty short.</p>



<p class="wp-block-paragraph">Thank you so much for watching.</p>



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



<p class="wp-block-paragraph">I&#8217;ll see you in the next video.</p>



<p class="wp-block-paragraph">make more videos and grow this community so we&#8217;ll be able to do more videos longer videos better</p>



<p class="wp-block-paragraph">videos or just i&#8217;ll be able to keep making videos in general so please do do me a kindness and uh</p>



<p class="wp-block-paragraph">and subscribe you know sometimes i&#8217;m sleeping in the middle of the night and i just wake up because</p>



<p class="wp-block-paragraph">i know somebody subscribed or followed it just wakes me up and i get filled with joy that&#8217;s</p>



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



<p class="wp-block-paragraph">you could troll me if you want to just wake me up in the middle of the night just subscribe</p>



<p class="wp-block-paragraph">and then I&#8217;ll just wake up. I promise that&#8217;s what will happen. Also, if you look at the middle of</p>



<p class="wp-block-paragraph">the screen right now, you should see a QR code, which you can scan in order to go to the website,</p>



<p class="wp-block-paragraph">which I think is also named somewhere at the bottom of this video. And it&#8217;ll take you to my</p>



<p class="wp-block-paragraph">main website where you can just kind of like see all the videos I published and the services and</p>



<p class="wp-block-paragraph">tutorials and things that I offer and all that good stuff. And if you have a suggestion for</p>



<p class="wp-block-paragraph">clarifications or errata or just future videos that you want to see please leave a comment or</p>



<p class="wp-block-paragraph">if you just want to say hey what&#8217;s up what&#8217;s going on you know just send me a comment whatever i also</p>



<p class="wp-block-paragraph">wake up for those in the middle of the night i get i wake up in a cold sweat and i&#8217;m like it would</p>



<p class="wp-block-paragraph">really it really mean the world to me i would really appreciate it so again thank you so much</p>



<p class="wp-block-paragraph">for watching this video and um enjoy the cool music as as i fade into the darkness which is</p>



<p class="wp-block-paragraph">for us all.</p>



<p class="wp-block-paragraph">Thank you.</p>
<p>The post <a href="https://www.NeuralLantern.com/mixed-function-arguments-in-x86-64-assembly-integers-floats-explained/">Mixed Function Arguments in x86-64 Assembly &#8211; Integers &amp; Floats Explained</a> appeared first on <a href="https://www.NeuralLantern.com">NeuralLantern.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.NeuralLantern.com/mixed-function-arguments-in-x86-64-assembly-integers-floats-explained/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 class="wp-block-paragraph">Quick but thorough introduction to floating-point registers in x86-64 assembly using YASM.</p>



<p class="wp-block-paragraph">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 class="wp-block-paragraph">Live coding + real examples converting integers to doubles and multiplying them.</p>



<p class="wp-block-paragraph">Great next step after basic integer assembly tutorials.</p>



<p class="wp-block-paragraph">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 class="wp-block-paragraph">=-=-=-=-=-=-=-=-=</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>



<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 class="wp-block-paragraph">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 class="wp-block-paragraph">Hey there! In this video we&#8217;re going to talk about pointers and dereferencing in a YASM x8664</p>



<p class="wp-block-paragraph">assembly program, also as a hybrid program so that assembly and C++ can talk to each other</p>



<p class="wp-block-paragraph">and send each other pointers and send each other data and things like that.</p>



<p class="wp-block-paragraph">for what pointers are.</p>



<p class="wp-block-paragraph">I&#8217;m going to write in C++ for a second.</p>



<p class="wp-block-paragraph">Suppose you have a pointer for an integer.</p>



<p class="wp-block-paragraph">We&#8217;ll call it P.</p>



<p class="wp-block-paragraph">Suppose you have an integer by itself.</p>



<p class="wp-block-paragraph">We&#8217;ll call it A.</p>



<p class="wp-block-paragraph">Let&#8217;s say that the value of A is 5.</p>



<p class="wp-block-paragraph">And if you wanted to say that P points to A,</p>



<p class="wp-block-paragraph">you could say P equals the address of A.</p>



<p class="wp-block-paragraph">I&#8217;ll put C++ at the top here.</p>



<p class="wp-block-paragraph">And so now if I set A to 6</p>



<p class="wp-block-paragraph">then I print P a dereference of P this is not like a full pointers tutorial</p>



<p class="wp-block-paragraph">but basically by changing a I&#8217;m changing what P thinks it sees as a value</p>



<p class="wp-block-paragraph">assuming ID reference it I could also let me do a print 6 here I could also</p>



<p class="wp-block-paragraph">just change the value through P I could say dereference P and I could say equals</p>



<p class="wp-block-paragraph">would actually print a seven right so you know you can have regular variables global variables</p>



<p class="wp-block-paragraph">whatever kind of you know memory stuff on the stack and to get a pointer to it you really just</p>



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



<p class="wp-block-paragraph">in assembly you really just need the memory location stored somewhere you could store that</p>



<p class="wp-block-paragraph">variable that just simply stored the memory location of some other variable.</p>



<p class="wp-block-paragraph">You could have a 64-bit register store the value of a variable.</p>



<p class="wp-block-paragraph">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 class="wp-block-paragraph">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 class="wp-block-paragraph">So if you haven&#8217;t seen my previous videos, go see them for the basics of assembly and</p>



<p class="wp-block-paragraph">of assembly and linking and make files and all that stuff but you know if you</p>



<p class="wp-block-paragraph">have an assembly program and you have a data section and you define a global</p>



<p class="wp-block-paragraph">variable like this what you&#8217;re basically saying is I want to take this giant</p>



<p class="wp-block-paragraph">number and I want to write it into eight bytes that&#8217;s the DQ it says data quad</p>



<p class="wp-block-paragraph">word I want to write that giant number across eight bytes and then I want to</p>



<p class="wp-block-paragraph">get a pointer to it stored in the my number symbol so my number is not</p>



<p class="wp-block-paragraph">actually the value it&#8217;s a pointer to the value so you know later if you want to</p>



<p class="wp-block-paragraph">you know later if you want to move you know something into a register if you did this</p>



<p class="wp-block-paragraph">that would move the pointer into rax but if you did this</p>



<p class="wp-block-paragraph">with deref symbols after it or around it then you would move</p>



<p class="wp-block-paragraph">maybe i&#8217;ll put that into rex you&#8217;d move that actual number that we specified into rex</p>



<p class="wp-block-paragraph">into Rx. It&#8217;s important to understand also that pointers are integers even when we&#8217;re pointing to</p>



<p class="wp-block-paragraph">doubles. So for example sometimes people make this mistake they&#8217;ll say you know my double</p>



<p class="wp-block-paragraph">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 class="wp-block-paragraph">point number and they&#8217;ll do like 44.55 or whatever. So that is a double and it is in memory</p>



<p class="wp-block-paragraph">you know what is the symbol of my double remember it&#8217;s supposed to be just a</p>



<p class="wp-block-paragraph">pointer right it can&#8217;t be an actual double because a memory location is not</p>



<p class="wp-block-paragraph">a double a memory location is an integer so that means if you wanted to move a</p>



<p class="wp-block-paragraph">pointer into a register you would only be able to move the pointer into a</p>



<p class="wp-block-paragraph">regular general purpose register not a floating point register and you should</p>



<p class="wp-block-paragraph">use the regular movement instructions for just regular general purpose</p>



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



<p class="wp-block-paragraph">You know, let&#8217;s say long a and long B and actually let&#8217;s do pointers</p>



<p class="wp-block-paragraph">Let&#8217;s say long pointer a and long pointer</p>



<p class="wp-block-paragraph">B and double pointer C all three of those arguments are actually 64 bit integers</p>



<p class="wp-block-paragraph">Because they&#8217;re all pointers even if one of the pointers points to adult a double</p>



<p class="wp-block-paragraph">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 class="wp-block-paragraph">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 class="wp-block-paragraph">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 class="wp-block-paragraph">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 class="wp-block-paragraph">what we really need to do is write a driver and an assembly module for a</p>



<p class="wp-block-paragraph">hybrid program again hybrid programs covered in other videos so the driver is</p>



<p class="wp-block-paragraph">pretty easy I&#8217;m just going to copy paste it honestly here and then just kind of</p>



<p class="wp-block-paragraph">explain it to you the driver is pretty easy we&#8217;re going to do I O stream so we</p>



<p class="wp-block-paragraph">can print stuff we&#8217;re going to mark an external function called point as extern</p>



<p class="wp-block-paragraph">C so that just disables name mangling which means the C++ module will be able</p>



<p class="wp-block-paragraph">will be able to call on this function called point and it won&#8217;t expect that</p>



<p class="wp-block-paragraph">the point function has its name mangled like C++ does the reason being is that</p>



<p class="wp-block-paragraph">point is actually going to be in a side it&#8217;s going to be inside assembly where</p>



<p class="wp-block-paragraph">its name will not be mangled this disables the ability to overload but</p>



<p class="wp-block-paragraph">that&#8217;s okay we don&#8217;t care it&#8217;s going to take two pointers a pointer to a character</p>



<p class="wp-block-paragraph">and a pointer to a long since both of those are pointers they&#8217;re both</p>



<p class="wp-block-paragraph">64-bit integers even the character pointer and then we have a function that is internal to this</p>



<p class="wp-block-paragraph">module called hey driver print this remember we&#8217;re inside of the driver program right now</p>



<p class="wp-block-paragraph">so if you look at the bottom it&#8217;s just a function that takes in some pointers</p>



<p class="wp-block-paragraph">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 class="wp-block-paragraph">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 class="wp-block-paragraph">i literally just let him pee and poop at this point now he&#8217;s harassing me for treats</p>



<p class="wp-block-paragraph">now he&#8217;s harassing me for treats he always does this okay so uh the string the long the double</p>



<p class="wp-block-paragraph">this function expects to receive three pointers to different data types it&#8217;s just going to print</p>



<p class="wp-block-paragraph">all of them and the point get it the point of this function is we&#8217;re going to go inside of</p>



<p class="wp-block-paragraph">the assembly module and then have the assembly module call on this function so that we can we</p>



<p class="wp-block-paragraph">can prove that we can have stuff sent from assembly to c plus plus or c using pointers</p>



<p class="wp-block-paragraph">using pointers we can have data sent over so anyway that&#8217;s why both of these</p>



<p class="wp-block-paragraph">are in here the point needs to be marked as no name mangling because point is</p>



<p class="wp-block-paragraph">inside of assembly which will not name mangle and then hey driver print this</p>



<p class="wp-block-paragraph">that needs to have name mangling disabled also so that the assembly</p>



<p class="wp-block-paragraph">module can call on this other than that we&#8217;re just basically inside of a main</p>



<p class="wp-block-paragraph">saying hey this is the c string we&#8217;re making a c string inside of the main function notice how</p>



<p class="wp-block-paragraph">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 class="wp-block-paragraph">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 class="wp-block-paragraph">the stack um and but then we can actually send pointers to those pieces of data to another</p>



<p class="wp-block-paragraph">function in another module you don&#8217;t have to only transport globals or stuff on the heap</p>



<p class="wp-block-paragraph">or stuff on the heap, you can transport pointers to local variables. Just make sure that by the</p>



<p class="wp-block-paragraph">time this function finishes, then nowhere else is actually using that data because,</p>



<p class="wp-block-paragraph">well, being on the stack, once main function or once any function finishes, then its portion of</p>



<p class="wp-block-paragraph">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 class="wp-block-paragraph">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 class="wp-block-paragraph">just going to use them quickly on this call to point and then we&#8217;re going to return to the</p>



<p class="wp-block-paragraph">operating system and finish the program. So that&#8217;s the driver. Now the hard part. Let&#8217;s do this in</p>



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



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



<p class="wp-block-paragraph">that that&#8217;s what this language is at the beginning of the video? I guess I should put that in the</p>



<p class="wp-block-paragraph">put that in the description or record an announcement that I can tack on at the beginning</p>



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



<p class="wp-block-paragraph">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 class="wp-block-paragraph">Oh, we&#8217;re inside of, you know, the module now, the assembly module. And now we&#8217;re going to print</p>



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



<p class="wp-block-paragraph">into C++ when we call the function inside of the driver.</p>



<p class="wp-block-paragraph">So this string is owned by the assembly module.</p>



<p class="wp-block-paragraph">Notice how these are null terminated strings.</p>



<p class="wp-block-paragraph">I just have like a comma zero there,</p>



<p class="wp-block-paragraph">which means I have some extra functions</p>



<p class="wp-block-paragraph">I&#8217;m gonna paste in that we&#8217;re not really gonna talk about</p>



<p class="wp-block-paragraph">because they&#8217;ve been discussed in other videos</p>



<p class="wp-block-paragraph">just so that we can print null terminated strings.</p>



<p class="wp-block-paragraph">Then I&#8217;ve got a new line here,</p>



<p class="wp-block-paragraph">you know, carriage return line feed.</p>



<p class="wp-block-paragraph">And then I&#8217;ve just got some numbers</p>



<p class="wp-block-paragraph">that are owned by the assembly module.</p>



<p class="wp-block-paragraph">Then I&#8217;ve got a system write call,</p>



<p class="wp-block-paragraph">call code one for the system call writes and file descriptor standard output so I</p>



<p class="wp-block-paragraph">can print just to the terminal again if you don&#8217;t understand this see my other</p>



<p class="wp-block-paragraph">videos so now let&#8217;s start the actual text section so this is where our</p>



<p class="wp-block-paragraph">instructions start so we got the text section here and we&#8217;re going to use some</p>



<p class="wp-block-paragraph">external symbols don&#8217;t worry about these I&#8217;m just using my own little library to</p>



<p class="wp-block-paragraph">and input integers if you have access to this library use it if you don&#8217;t if you&#8217;re watching</p>



<p class="wp-block-paragraph">at home and you don&#8217;t have this library then that&#8217;s fine you can use you know printf or</p>



<p class="wp-block-paragraph">scanf or something like that to get and print floats from and to the user</p>



<p class="wp-block-paragraph">but yeah I&#8217;m just using that and then I&#8217;m marking an external function here called hey driver print</p>



<p class="wp-block-paragraph">this if you recall the driver module has a function called hey driver print this so</p>



<p class="wp-block-paragraph">just allows my assembly code to call on that external function. Okay now next</p>



<p class="wp-block-paragraph">piece of code. This is going to be… actually I&#8217;m going to paste the print</p>



<p class="wp-block-paragraph">null terminated string function and related code because it&#8217;s just like a</p>



<p class="wp-block-paragraph">big giant mess and we&#8217;re mostly going to ignore it. So just to show you what I&#8217;m</p>



<p class="wp-block-paragraph">doing here I have a function called print null terminated string so that I</p>



<p class="wp-block-paragraph">can print these strings up here and then I have it rely on a function called</p>



<p class="wp-block-paragraph">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>
