{"id":19197,"date":"2025-09-11T15:56:20","date_gmt":"2025-09-11T15:56:20","guid":{"rendered":"http:\/\/www.max-sperling.bplaced.net\/?p=19197"},"modified":"2025-09-11T16:26:01","modified_gmt":"2025-09-11T16:26:01","slug":"calling-conventions-system-v-amd64-vs-microsoft-x64","status":"publish","type":"post","link":"http:\/\/www.max-sperling.bplaced.net\/?p=19197","title":{"rendered":"Calling conventions &#8211; System V AMD64 vs. Microsoft x64"},"content":{"rendered":"<p><strong>General<\/strong><br \/>\nCalling conventions specify the low-level details for function calls. They are a part of an ABI.<\/p>\n<hr>\n<p><strong>Comparison<\/strong><\/p>\n<table>\n<tr>\n<th><\/th>\n<th>System V AMD64<\/th>\n<th>Microsoft x64<\/th>\n<\/tr>\n<tr>\n<th>Arguments<\/th>\n<td>\n<ul>\n<li>Amount: 6 Integer + 8 Float<\/li>\n<li>Integer: 1. RDI, 2. RSI, 3. RDX, 4. RCX, 5. R8, 6. R9<\/li>\n<li>Float: XMM0 \u2013 XMM7 (1.-8.)<\/li>\n<\/ul>\n<\/td>\n<td>\n<ul>\n<li>Amount: 4 (Integer\/Float)<\/li>\n<li>Integer\/Float: 1. RCX\/XMM0, 2. RDX\/XMM1, 3. R8\/XMM2, 4. R9\/XMM3<\/li>\n<\/ul>\n<\/td>\n<\/tr>\n<tr>\n<th>Return<\/th>\n<td colspan=\"2\">\n<ul>\n<li>Integer: RAX<\/li>\n<li>Float: XMM0<\/li>\n<\/ul>\n<\/td>\n<\/tr>\n<tr>\n<th>Caller-saved (volatile)<\/th>\n<td>RAX, RCX, RDX, RSI, RDI, R8 &#8211; R11<\/td>\n<td>RAX, RCX, RDX, R8 &#8211; R11<\/td>\n<\/tr>\n<tr>\n<th>Callee-saved (nonvolatile)<\/th>\n<td>RBX, R12\u2013R15, RBP, RSP<\/td>\n<td>RBX, RSI, RDI, R12\u2013R15, RBP, RSP<\/td>\n<\/tr>\n<\/table>\n<hr>\n<p><strong>System V AMD64<\/strong><\/p>\n<pre class=\"brush: cpp; gutter: false; title: ; notranslate\" title=\"\">\r\nvoid func(\r\n    int a, int b, int c,       \/\/ a in RDI, b in RSI, c in RDX\r\n    float d, float e, float f, \/\/ d in XMM0, e in XMM1, f in XMM2\r\n    int g, int h, int i,       \/\/ g in RCX, h in R8, i in R9\r\n    float j, float k, float l, \/\/ j in XMM3, k in XMM4, l in XMM5\r\n    float m, float n);         \/\/ m in XMM6, n in XMM7\r\n\/\/ The next integer or float args would be added to the stack.\r\n<\/pre>\n<hr>\n<p><strong>Microsoft x64<\/strong><\/p>\n<pre class=\"brush: cpp; gutter: false; title: ; notranslate\" title=\"\">\r\nvoid func(int a, float b, int c, float d, int e);\r\n\/\/ a in RCX, b in XMM1, c in R8, d in XMM3\r\n\/\/ The next integer or float args would be added to the stack.\r\n<\/pre>\n<hr>\n<p><strong>Details<\/strong><br \/>\nIn C++ classes, the &#8220;this&#8221; pointer is the first argument.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>General Calling conventions specify the low-level details for function calls. They are a part of an ABI. Comparison System V<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false},"categories":[28],"tags":[],"_links":{"self":[{"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=\/wp\/v2\/posts\/19197"}],"collection":[{"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=19197"}],"version-history":[{"count":45,"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=\/wp\/v2\/posts\/19197\/revisions"}],"predecessor-version":[{"id":19242,"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=\/wp\/v2\/posts\/19197\/revisions\/19242"}],"wp:attachment":[{"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=19197"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=19197"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=19197"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}