{"id":139,"date":"2010-04-17T23:13:21","date_gmt":"2010-04-18T08:13:21","guid":{"rendered":"\/blog\/?p=139"},"modified":"2023-09-21T09:39:20","modified_gmt":"2023-09-21T00:39:20","slug":"__cdecl__stdcall__fastcall-%ed%98%b8%ec%b6%9c%ea%b7%9c%ec%95%bd","status":"publish","type":"post","link":"https:\/\/hasu0707.duckdns.org\/blog\/?p=139","title":{"rendered":"__cdecl,__stdcall__fastcall \ud638\ucd9c\uaddc\uc57d"},"content":{"rendered":"\n<H3>__cdecl <\/H3>\n<P>C\uc5b8\uc5b4 \ud45c\uc900 \ud638\ucd9c \uaddc\uc57d\uc774\ub2e4. \ud30c\ub77c\ubbf8\ud130\ub294 \uc624\ub978\ucabd\uc5d0\uc11c \uc67c\ucabd\uc73c\ub85c \uc2a4\ud0dd\uc744 \ud1b5\ud574 \uc804\ub2ec\ub418\uba70, \ud638\ucd9c\ud55c \uacf3\uc5d0\uc11c \uc2a4\ud0dd\uc744 \uc815\ub9ac\ud55c\ub2e4. \ud2b9\uc9d5\uc801\uc778\uac74 \ud638\ucd9c\ud55c \ucabd\uc5d0\uc11c \uc2a4\ud0dd\uc744 \uc815\ub9ac\ud558\uae30 \ub54c\ubb38\uc5d0 \uac00\ubcc0 \uc778\uc790\ub97c \uc9c0\uc6d0\ud55c\ub2e4\ub294 \uac83\uc774\ub2e4.&nbsp; <\/P>\n<DIV class=dp-highlighter>\n<OL class=dp-wcpp>\n<LI class=alt><SPAN><SPAN class=keyword>extern<\/SPAN><SPAN>&nbsp;<\/SPAN><SPAN class=string>\"C\"<\/SPAN><SPAN>&nbsp;<\/SPAN><SPAN class=datatypes>int<\/SPAN><SPAN>&nbsp;__cdecl CdeclFunc(<\/SPAN><SPAN class=datatypes>int<\/SPAN><SPAN>&nbsp;a, <\/SPAN><SPAN class=datatypes>int<\/SPAN><SPAN>&nbsp;b, <\/SPAN><SPAN class=datatypes>int<\/SPAN><SPAN>&nbsp;c) &nbsp; <\/SPAN><\/SPAN> \n<LI><SPAN>{ &nbsp; <\/SPAN> \n<LI class=alt><SPAN>&nbsp; &nbsp; printf(<\/SPAN><SPAN class=string>\"%d %d %d\\n\"<\/SPAN><SPAN>, a, b, c); &nbsp; <\/SPAN> \n<LI><SPAN>} &nbsp;<\/SPAN><\/LI><\/OL><\/DIV>\uc704 \ud568\uc218\ub97c \ud638\ucd9c\ud558\uae30 \uc704\ud55c \uc5b4\uc148\ube14\ub9ac \ucf54\ub4dc\ub294 \uc544\ub798\uc640 \uac19\ub2e4. add \uba85\ub839\uc5b4\ub97c \ud1b5\ud574\uc11c \ud638\ucd9c \ud55c \ud6c4\uc5d0 \uc2a4\ud0dd\uc744 \uc815\ub9ac\ud574 \uc8fc\uc5b4\uc57c \ud55c\ub2e4. \n<P>&nbsp;<\/P>\n<P>push 3<br \/>push 2<br \/>push 1<br \/>call CdeclFunc<br \/>add esp, 12<\/P>\n<P>&nbsp;<\/P>\n<P>&nbsp;<\/P>\n<H3>__stdcall <\/H3>\n<P>\uc708\ub3c4\uc6b0 API\uc758 \ud45c\uc900 \ud638\ucd9c \uaddc\uc57d\uc774\ub2e4. \ud30c\ub77c\ubbf8\ud130\ub294 \uc624\ub978\ucabd\uc5d0\uc11c \uc67c\ucabd\uc73c\ub85c \uc2a4\ud0dd\uc744 \ud1b5\ud574\uc11c \uc804\ub2ec\ub418\uba70, \uc2a4\ud0dd \uc815\ub9ac\ub294 \ud638\ucd9c \ub2f9\ud55c \uacf3\uc5d0\uc11c \uc774\ub8e8\uc5b4\uc9c4\ub2e4. <\/P>\n<DIV class=dp-highlighter>\n<OL class=dp-wcpp>\n<LI class=alt><SPAN><SPAN class=keyword>extern<\/SPAN><SPAN>&nbsp;<\/SPAN><SPAN class=string>\"C\"<\/SPAN><SPAN>&nbsp;<\/SPAN><SPAN class=datatypes>int<\/SPAN><SPAN>&nbsp;__stdcall StdcallFunc(<\/SPAN><SPAN class=datatypes>int<\/SPAN><SPAN>&nbsp;a, <\/SPAN><SPAN class=datatypes>int<\/SPAN><SPAN>&nbsp;b, <\/SPAN><SPAN class=datatypes>int<\/SPAN><SPAN>&nbsp;c) &nbsp; <\/SPAN><\/SPAN> \n<LI><SPAN>{ &nbsp; <\/SPAN> \n<LI class=alt><SPAN>&nbsp; &nbsp; printf(<\/SPAN><SPAN class=string>\"%d %d %d\\n\"<\/SPAN><SPAN>, a, b, c); &nbsp; <\/SPAN> \n<LI><SPAN>} &nbsp;<\/SPAN><\/LI><\/OL><\/DIV>\n<P>&nbsp;\ud638\ucd9c \ucf54\ub4dc\ub294 \uc544\ub798\uc640 \uac19\ub2e4. __cdecl\uacfc \uc720\uc0ac\ud558\uc9c0\ub9cc \uc2a4\ud0dd \uc815\ub9ac \ucf54\ub4dc\uac00 \uc5c6\ub294\uac8c \ud2b9\uc9d5\uc774\ub2e4.<\/P>\n<P>&nbsp;<\/P>\n<P>push 3<br \/>push 2<br \/>push 1<br \/>call <a class=\"con_link\" href=\"mailto:_StdcallFunc@12\" target=\"_blank\" rel=\"noopener\">_StdcallFunc@12<\/A><\/P>\n<P>&nbsp;<\/P>\n<P>&nbsp;<\/P>\n<P>&nbsp;<\/P>\n<H3>__fastcall <\/H3>\n<P>\ub9d0 \uadf8\ub300\ub85c \ube60\ub978 \ud638\ucd9c\uc774\ub2e4. \ud30c\ub77c\ubbf8\ud130 \uc911 \uc77c\ubd80\ub97c \ub808\uc9c0\uc2a4\ud130\ub97c \ud1b5\ud574\uc11c \uc804\ub2ec\ud558\ub294 \ud568\uc218\ub2e4. x86 \uacc4\uc5f4\uc5d0\uc11c\ub294 \uc77c\ubc18\uc801\uc73c\ub85c ecx, edx\ub85c \ud30c\ub77c\ubbf8\ud130\ub97c \uc804\ub2ec\ud558\uace0 \ub098\uba38\uc9c0\ub294 \uc2a4\ud0dd\uc73c\ub85c \uc804\ub2ec\ud55c\ub2e4. __cdecl\uacfc \uac19\uc774 \uc624\ub978\ucabd\uc5d0\uc11c \uc67c\ucabd\uc73c\ub85c \ud30c\ub77c\ubbf8\ud130\ub97c \uc804\ub2ec\ud558\uba70, \uc2a4\ud0dd \uc815\ub9ac\ub294 \ud638\ucd9c\uc744 \ub2f9\ud55c \uacf3\uc5d0\uc11c \uc218\ud589\ud55c\ub2e4. \ub530\ub77c\uc11c \uac00\ubcc0 \uc778\uc790\ub97c \uc9c0\uc6d0\ud558\uc9c0 \ubabb\ud55c\ub2e4.&nbsp; <\/P>\n<DIV class=dp-highlighter>\n<OL class=dp-wcpp>\n<LI class=alt><SPAN><SPAN class=keyword>extern<\/SPAN><SPAN>&nbsp;<\/SPAN><SPAN class=string>\"C\"<\/SPAN><SPAN>&nbsp;<\/SPAN><SPAN class=datatypes>int<\/SPAN><SPAN>&nbsp;__fastcall FastcallFunc(<\/SPAN><SPAN class=datatypes>int<\/SPAN><SPAN>&nbsp;a, <\/SPAN><SPAN class=datatypes>int<\/SPAN><SPAN>&nbsp;b, <\/SPAN><SPAN class=datatypes>int<\/SPAN><SPAN>&nbsp;c) &nbsp; <\/SPAN><\/SPAN> \n<LI><SPAN>{ &nbsp; <\/SPAN> \n<LI class=alt><SPAN>&nbsp; &nbsp; printf(<\/SPAN><SPAN class=string>\"%d %d %d\\n\"<\/SPAN><SPAN>, a, b, c); &nbsp; <\/SPAN> \n<LI><SPAN>} &nbsp;<\/SPAN><\/LI><\/OL><\/DIV>\n<P>&nbsp;\uc704 \ud568\uc218\ub97c \ud638\ucd9c \ud558\ub294 \ucf54\ub4dc\ub294 \uc544\ub798\uc640 \uac19\ub2e4. \uc55e \ucabd \ub450 \uac1c\uc758 \ud30c\ub77c\ubbf8\ud130\uac00 ecx\uc640 edx\ub97c \ud1b5\ud574\uc11c \uc804\ub2ec\ub41c\ub2e4. \ud30c\ub77c\ubbf8\ud130\uac00 \ub450 \uac1c \uc774\ud558\uc778 \ud568\uc218\uc5d0 \ub300\ud574\uc11c\ub294 \uc2a4\ud0dd\uc744 \uc804\ud600 \uc0ac\uc6a9\ud558\uc9c0 \uc54a\uae30 \ub54c\ubb38\uc5d0 \ube60\ub974\uac8c \ub3d9\uc791\ud55c\ub2e4.<\/P><PRE>push 3<br \/>mov edx, 2<br \/>mov ecx, 1<br \/>call @FastcallFunc@12<\/PRE><PRE>&nbsp;<\/PRE><PRE>&lt; \uc2a4\ud0dd \ud638\ucd9c\uc5d0 \ub530\ub978 \uc774\uc720 &gt;<\/PRE><PRE>__cdecl \uc744 \uc81c\uc678\ud55c \ub2e4\ub978 \ud638\ucd9c\ub4e4\uc740 \ud638\ucd9c \ub2f9\ud55c \uacf3\uc5d0\uc11c \ud568\uc218 \uc885\ub8cc \uc2dc\uc810\uc5d0\uc11c \ud30c\ub77c\ubbf8\ud130\ub4e4\uc774 \ub4e4\uc5b4\uc788\ub294 \uc2a4\ud0dd\uc744 \uc815\ub9ac\ud558\ub294\ub370..<\/PRE><PRE>\uc774\uc720\ub294 \uc18d\ub3c4\uc5d0 \uc788\ub2e4. <\/PRE><PRE>x86 CPU\uc758 \uacbd\uc6b0 ret \uc5b4\uc148\ube14\ub9ac \uba85\ub839\uc5b4\ub97c \ub450 \uac00\uc9c0 \ud615\ud0dc\ub85c \uc9c0\uc6d0\ud55c\ub2e4. <\/PRE><PRE>ret\ub97c \ud558\uba74 \ub2e8\uc21c\ud788 \uc2a4\ud0dd\uc5d0 \uc800\uc7a5\ub41c \ubcf5\uadc0 \uc8fc\uc18c\ub85c \ub9ac\ud134 \ud55c\ub2e4. \ud558\uc9c0\ub9cc ret imm16\uc744 \uc0ac\uc6a9\ud558\uba74 imm16\ub9cc\ud07c \uc2a4\ud0dd\uc5d0\uc11c \ud31d \ud55c \ub2e4\uc74c <\/PRE><PRE>\uaebc\ub0b4\uc9c4 \ubcf5\uadc0 \uc8fc\uc18c\ub85c \ub9ac\ud134 \ud55c\ub2e4. \uc704\uc5d0\uc11c \uc0b4\ud3b4 \ubcf4\uc558\ub4ef\uc774 __cdecl\uc740 \uc2a4\ud0dd \uc815\ub9ac\ub97c \uc704\ud574\uc11c add \uba85\ub839\uc5b4\uac00 \ucd94\uac00\ub41c\ub2e4. \ubc18\uba74\uc5d0 \ud638\ucd9c\uc744 <\/PRE><PRE>\ub2f9\ud55c \uacf3\uc5d0\uc11c \uc815\ub9ac\ud558\ub294 \ubc29\uc2dd\uc740 \ub9ac\ud134\ud560 \ub54c\uc5d0 ret imm16\uc744 \uc0ac\uc6a9\ud568\uc73c\ub85c\uc368 add \uba85\ub839\uc5b4\uac00 \ucd94\uac00\ub418\uc9c0 \uc54a\uc544\ub3c4 \ub41c\ub2e4. \ub610\ud55c 486\uc744 <\/PRE><PRE>\uae30\uc900\uc73c\ub85c \ud588\uc744 \ub54c ret\uc640 ret imm16\uc740 5\ud074\ub7ed \uc0ac\uc774\ud074\uc744 \uc18c\ubaa8\ud558\ub294 \ub3d9\uc77c\ud55c \uba85\ub839\uc5b4\ub85c \ucc98\ub9ac\ub41c\ub2e4. <\/PRE><PRE>\ub530\ub77c\uc11c __cdecl\ubcf4\ub2e4\ub294 \ub2e4\ub978 \ud638\ucd9c \uaddc\uc57d\uc774 \uadfc\uc18c\ud558\uac8c \ube60\ub97c \uc218 \uc788\ub2e4. <\/PRE><PRE>&lt; \uc0ac\uc6a9\ub41c \uc18c\uc2a4 &gt;<\/PRE>\n<OL>\n<LI><SPAN class=datatypes>int<\/SPAN><SPAN>&nbsp;_tmain(<\/SPAN><SPAN class=datatypes>int<\/SPAN><SPAN>&nbsp;argc, _TCHAR* argv[]) &nbsp; <\/SPAN> \n<LI><SPAN>{ &nbsp; <\/SPAN> \n<LI class=alt><SPAN>&nbsp; &nbsp; CdeclFunc(1, 2, 3); &nbsp; <\/SPAN> \n<LI><SPAN>&nbsp; &nbsp; FastcallFunc(1, 2, 3); &nbsp; <\/SPAN> \n<LI class=alt><SPAN>&nbsp; &nbsp; StdcallFunc(1, 2, 3); &nbsp; <\/SPAN> \n<LI><SPAN>&nbsp; <\/SPAN> \n<LI class=alt><SPAN>&nbsp; &nbsp; CCallConv conv; &nbsp; <\/SPAN> \n<LI><SPAN>&nbsp; &nbsp; conv.ThisCall(1,2,3); &nbsp; <\/SPAN> \n<LI class=alt><SPAN>&nbsp; &nbsp; <\/SPAN><SPAN class=keyword>return<\/SPAN><SPAN>&nbsp;0; &nbsp; <\/SPAN> \n<LI><SPAN>}&nbsp; <br \/><\/SPAN><\/LI><\/OL><br \/><PRE>&lt; \ucd9c\ucc98 : <a class=\"con_link\" href=\"http:\/\/www.jiniya.net\/lecture\/techbox\/callconv.html\" target=\"_blank\" rel=\"noopener\">http:\/\/www.jiniya.net\/lecture\/techbox\/callconv.html<\/A> &gt;<\/PRE>\n","protected":false},"excerpt":{"rendered":"<p>__cdecl C\uc5b8\uc5b4 \ud45c\uc900 \ud638\ucd9c \uaddc\uc57d\uc774\ub2e4. \ud30c\ub77c\ubbf8\ud130\ub294 \uc624\ub978\ucabd\uc5d0\uc11c \uc67c\ucabd\uc73c\ub85c \uc2a4\ud0dd\uc744 \ud1b5\ud574 \uc804\ub2ec\ub418\uba70, \ud638\ucd9c\ud55c \uacf3\uc5d0\uc11c \uc2a4\ud0dd\uc744 \uc815\ub9ac\ud55c\ub2e4. \ud2b9\uc9d5\uc801\uc778\uac74 \ud638\ucd9c\ud55c \ucabd\uc5d0\uc11c \uc2a4\ud0dd\uc744 \uc815\ub9ac\ud558\uae30 \ub54c\ubb38\uc5d0 \uac00\ubcc0 \uc778\uc790\ub97c \uc9c0\uc6d0\ud55c\ub2e4\ub294 \uac83\uc774\ub2e4.&nbsp; extern&nbsp;&#8220;C&#8221;&nbsp;int&nbsp;__cdecl CdeclFunc(int&nbsp;a, int&nbsp;b, int&nbsp;c) &nbsp; { &nbsp; &nbsp; &nbsp; printf(&#8220;%d %d %d\\n&#8221;, a, b, c); &nbsp; } &nbsp;\uc704 \ud568\uc218\ub97c \ud638\ucd9c\ud558\uae30 \uc704\ud55c \uc5b4\uc148\ube14\ub9ac \ucf54\ub4dc\ub294 \uc544\ub798\uc640 \uac19\ub2e4. add \uba85\ub839\uc5b4\ub97c \ud1b5\ud574\uc11c \ud638\ucd9c \ud55c [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_import_markdown_pro_load_document_selector":0,"_import_markdown_pro_submit_text_textarea":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[18],"tags":[],"class_list":["post-139","post","type-post","status-publish","format-standard","hentry","category-development_language"],"_links":{"self":[{"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/139","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=139"}],"version-history":[{"count":0,"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/139\/revisions"}],"wp:attachment":[{"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=139"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=139"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=139"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}