<?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>abi calling convention Archives - NeuralLantern.com</title>
	<atom:link href="https://www.NeuralLantern.com/tag/abi-calling-convention/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.NeuralLantern.com/tag/abi-calling-convention/</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=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>abi calling convention Archives - NeuralLantern.com</title>
	<link>https://www.NeuralLantern.com/tag/abi-calling-convention/</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>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>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>=-=-=-=-=-=-=-=-=</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 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>Hey everybody! In this video I&#8217;m going to talk to you a little bit about using functions with</p>



<p>mixed arguments in a YASM x86-64 assembly language program. Although this</p>



<p>video will probably still be useful to you if you&#8217;re using NASM or MASM because the</p>



<p>mixed arguments and their order and how they work is governed by the ABI which is a system</p>



<p>so what the heck am i talking about okay so the first thing that i want to show you is uh</p>



<p>imagine we have a function here let&#8217;s say void f this function doesn&#8217;t take any arguments and it</p>



<p>doesn&#8217;t return anything congratulations you&#8217;re done that was the easiest thing that you&#8217;ve ever</p>



<p>done in your entire life but as soon as you start adding arguments to it you have to uh</p>



<p>start understanding how to uh how to call registers and stuff so imagine we have like a</p>



<p>a long a and a long b so we give it two arguments and maybe we want it to return a long</p>



<p>this is kind of like level one of writing functions in assembly right we just have</p>



<p>a bunch of integers and we realize okay um this long the return value is going to come to the</p>



<p>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>back to the user in rax and the long is coming into the function with rdi, the long a and</p>



<p>the long b is coming into the function with rsi.</p>



<p>So if you understand this then you can write a function in assembly where basically you</p>



<p>two incoming integer arguments and then you return to the caller a long value using rax</p>



<p>keep in mind also that if this second argument was a pointer long pointer then it would be the</p>



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



<p>pointer was not to a long even if the pointer was to a double or a character or whatever it would</p>



<p>pointers are integers. It starts getting a little bit more complicated when you want to mix between</p>



<p>floats and numeric arguments. So what I&#8217;ve been saying so far, it&#8217;s all just integers.</p>



<p>Even if we&#8217;re mixing pointers with regular longs, it&#8217;s just, you know, they&#8217;re all longs basically,</p>



<p>right? So, but as soon as we start introducing floats, then things get a little bit more</p>



<p>complicated. So for starters, what if we did a function that was, that returned a double?</p>



<p>that returned a double. So let&#8217;s say we have a function G and it returns a double. Maybe it</p>



<p>still takes in a long and a double pointer. If it returns a double, let&#8217;s see, is this still</p>



<p>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>that means we have to return to the caller with the XMM0 register. So XMM0 is always designated as</p>



<p>the well the first float argument but also the float return value so keep in</p>



<p>mind if I&#8217;m returning a double to the caller I&#8217;m not going to use our a X at</p>



<p>all I&#8217;m just going to use XMM zero load it up with the return value and then</p>



<p>return to the caller and that&#8217;s it if I wanted to do another function let&#8217;s say</p>



<p>hmm how about H and then we&#8217;ll say I don&#8217;t know maybe the first argument is a</p>



<p>argument is a float we call it a double a that means rdi is not going to be the argument that</p>



<p>or the register that we look at to see our incoming double it has to be a float register</p>



<p>xmm0 is the float register that we look at for the first argument the float registers are really</p>



<p>easy you just kind of go in order like xmm0 is the first argument xmm1 is the next argument xmm2</p>



<p>the general purpose uh integer registers they&#8217;re a little more complicated you have to remember</p>



<p>their their labels uh you know like the letters have an ordering to it uh suppose for the sake</p>



<p>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>just mess the formatting up again i think that&#8217;s okay um again we&#8217;re going to return xmm0</p>



<p>notice how we&#8217;re returning xmm0 oh that&#8217;s why i spaced it forward notice how we are</p>



<p>forward notice how we are returning xmm0 and we&#8217;re also taking xmm0 these float registers tend to be</p>



<p>reused all over the place none of them are designated as callee saved within the abi</p>



<p>so you always have to stash their values somewhere if you&#8217;re ever going to make a function call or</p>



<p>anything or a system call the other thing to keep in mind is notice how rsi i still have rsi there</p>



<p>for the second incoming argument you would imagine that rsi is supposed to be the second argument</p>



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



<p>actually true because the the order i guess like the the ordering of the uh of the registers they</p>



<p>only count against their own class like the float registers the float arguments they only count</p>



<p>against the position of the float and the uh of the float registers and and and the general purpose</p>



<p>they only count against themselves.</p>



<p>What I&#8217;m trying to say is that RSI is the second integer argument,</p>



<p>but if you look at the signature, we only have one integer argument, right?</p>



<p>So RSI is not the second integer argument.</p>



<p>It&#8217;s actually the first integer argument.</p>



<p>So I&#8217;m going to put an RDI there.</p>



<p>You probably can infer that the second float argument should be XMM1 at this point, I hope.</p>



<p>and that&#8217;s true if we just say that there&#8217;s going to be another double</p>



<p>that this function takes then it&#8217;s going to be xmm1</p>



<p>not xmm2 because if you&#8217;re just counting the arguments</p>



<p>and you&#8217;re sort of grouping the integers with the floats together</p>



<p>you might think well first argument is xmm0 second argument would have been xmm1</p>



<p>third argument would have been xmm2 therefore if I see</p>



<p>a float coming into the third argument position it&#8217;ll be xmm2</p>



<p>No, the integers don&#8217;t count against the floats and the floats don&#8217;t count against the integers.</p>



<p>That&#8217;s why RDI is the first argument for integers, even though it&#8217;s in the second position,</p>



<p>it&#8217;s still the first integer that we see.</p>



<p>And XMM1 is the second float argument that we see.</p>



<p>That&#8217;s why it&#8217;s XMM1 instead of XMM2, because we&#8217;re looking at it in the third position.</p>



<p>So you&#8217;re not really looking at, whoops, you&#8217;re not looking at overall position.</p>



<p>at position only counting that type of register let me pull open my favorite book to get a little</p>



<p>bit more clarity on this um this book is written by a wonderful professor dr ed jorgensen phd</p>



<p>this book i did not write it ed jorgensen wrote this book it&#8217;s called x86 64 assembly language</p>



<p>programming with ubuntu this book can turn you into an expert with yasm assembly so uh</p>



<p>I recommend everybody grab a copy. It&#8217;s also free and it&#8217;s got a copy left license.</p>



<p>You can see like the license here. But anyway, I wanted to open up this book real fast</p>



<p>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>around the book too long. Kali saved and that brings us to section 12.8.2 register usage.</p>



<p>let&#8217;s see callee saved you&#8217;ll see rbx is callee saved rbp is callee saved probably shouldn&#8217;t</p>



<p>mess with that one too much r12 13 14 15 all callee saved there&#8217;s a couple temporary registers</p>



<p>but if you look carefully rdi is designated as the first argument but it should say really</p>



<p>the first integer argument so rdi is the first integer argument that we see that&#8217;s why</p>



<p>argument that we see that&#8217;s why in all of these examples the first integer argument that we</p>



<p>actually see is rdi so like for function f long a that was the first integer argument</p>



<p>and then in the function g it&#8217;s also the first integer argument and then in function h rdi is</p>



<p>the double pointer b because that is the first integer argument that we actually see</p>



<p>so keep that in mind you would just repeat that pattern you know the second integer argument you</p>



<p>second integer argument you see that&#8217;s RSI. That&#8217;s why RSI is the pointer here because</p>



<p>pointers are integers and the pointer here and we don&#8217;t have anything else but if I guess if we</p>



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



<p>sense and you can you can carry this logic forward for the first argument the second argument the</p>



<p>and then R8 for the fifth argument R9 for the sixth argument and then you can</p>



<p>look for further arguments on the stack if you need more than that but basically</p>



<p>that&#8217;s how you count them up and then the float registers are just a lot</p>



<p>easier they always start at zero and they go all the way up to 15 and so I</p>



<p>don&#8217;t know maybe I should just copy paste well maybe I&#8217;ll start it from</p>



<p>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>And the long is going to be returned with the RAX.</p>



<p>And I guess I have to space this forward a little bit.</p>



<p>And then if we have a bunch of floats, say double A.</p>



<p>Can I maybe just copy paste this a little bit so I don&#8217;t have to do so much typing?</p>



<p>Okay, so we&#8217;ll do double A, double B, double C, double D, double E.</p>



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



<p>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>and just to make sure you&#8217;re paying attention ask yourself this real fast if i were to insert</p>



<p>z what register would we use for that would it be the one two three four five the fifth argument</p>



<p>would it be uh would it be r8 or would it be something else hopefully you understand now</p>



<p>let&#8217;s say we do a character pointer that it would be rdi because that&#8217;s the first integer argument</p>



<p>that we actually see all right and then you know to return we would return in rax and then the</p>



<p>return in RAX and then the floats just keep counting notice how it skipped from XMM2 or it</p>



<p>went from XMM2 to XMM3 even though we crossed over an integer argument in between because the</p>



<p>float arguments don&#8217;t count against the integers and the ints don&#8217;t count against the floats</p>



<p>let&#8217;s see I think</p>



<p>well if you want you can look at section 18.2 which just sort of talks about the floating</p>



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



<p>we really need to do that here I think we pretty much have everything we need to know to to call</p>



<p>on functions with mixed arguments and to have a function within assembly that supports mixed</p>



<p>arguments so again if your C or C++ modules are expecting some kind of signature like this now you</p>



<p>know how to calculate what registers they&#8217;re actually going to populate by the time execution</p>



<p>execution jumps into your assembly function.</p>



<p>And if you want to call a C or a C++ function from assembly,</p>



<p>now you know which registers to populate so that the the other function that</p>



<p>you&#8217;re calling can receive the right data from you.</p>



<p>Don&#8217;t forget about name mangling, which I talked about in another video.</p>



<p>Okay, I think that&#8217;s all I really have to say.</p>



<p>This video was pretty short.</p>



<p>Thank you so much for watching.</p>



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



<p>I&#8217;ll see you in the next video.</p>



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



<p>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>and subscribe you know sometimes i&#8217;m sleeping in the middle of the night and i just wake up because</p>



<p>i know somebody subscribed or followed it just wakes me up and i get filled with joy that&#8217;s</p>



<p>exactly what happens every single time so you could do it as a nice favor to me or you could</p>



<p>you could troll me if you want to just wake me up in the middle of the night just subscribe</p>



<p>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>the screen right now, you should see a QR code, which you can scan in order to go to the website,</p>



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



<p>main website where you can just kind of like see all the videos I published and the services and</p>



<p>tutorials and things that I offer and all that good stuff. And if you have a suggestion for</p>



<p>clarifications or errata or just future videos that you want to see please leave a comment or</p>



<p>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>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>really it really mean the world to me i would really appreciate it so again thank you so much</p>



<p>for watching this video and um enjoy the cool music as as i fade into the darkness which is</p>



<p>for us all.</p>



<p>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>
	</channel>
</rss>
