{"id":355,"date":"2015-02-26T08:05:02","date_gmt":"2015-02-25T22:05:02","guid":{"rendered":"http:\/\/www.nickdu.com\/?p=355"},"modified":"2015-02-26T08:05:02","modified_gmt":"2015-02-25T22:05:02","slug":"my-first-x64-assembly-code-cooked-by-hand","status":"publish","type":"post","link":"https:\/\/nickdu.com\/?p=355","title":{"rendered":"My first x64 assembly code cooked by hand"},"content":{"rendered":"<p>This is my first hand made x64 assembly code.<\/p>\n<pre lang=\"asm\">extrn MessageBoxA:proc\n\n.DATA\nCONST SEGMENT\n    msg DB \"Hello World!\", 0\nCONST ENDS\n\n.CODE\nmain PROC\n    sub rsp, 28h\n    xor rcx, rcx\n    lea rdx, msg\n    lea r8, msg\n    xor r9, r9\n    call MessageBoxA\nmain ENDP\nEND\n<\/pre>\n<p>To compile this code, in command prompt run<\/p>\n<pre lang=\"\">ml64 helloworld.asm \/link \/subsystem:windows \/defaultlib:user32.lib \/entry:main<\/pre>\n<p>The major different between x86 and x64 calling conventions. The first six integer or pointer arguments are passed in registers RDI, RSI, RDX, RCX, R8, and R9, while XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6 and XMM7 are used for floating point arguments. additional arguments are passed on the stack and the return value is stored in RAX.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is my first hand made x64 assembly code. extrn MessageBoxA:proc .DATA CONST SEGMENT msg DB &#8220;Hello World!&#8221;, 0 CONST ENDS .CODE main PROC sub rsp, 28h xor rcx, rcx lea rdx, msg lea r8, msg xor r9, r9 call MessageBoxA main ENDP END To compile this code, in command prompt run ml64 helloworld.asm \/link &hellip; <a href=\"https:\/\/nickdu.com\/?p=355\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;My first x64 assembly code cooked by hand&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-355","post","type-post","status-publish","format-standard","hentry","category-it"],"_links":{"self":[{"href":"https:\/\/nickdu.com\/index.php?rest_route=\/wp\/v2\/posts\/355","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nickdu.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nickdu.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nickdu.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nickdu.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=355"}],"version-history":[{"count":0,"href":"https:\/\/nickdu.com\/index.php?rest_route=\/wp\/v2\/posts\/355\/revisions"}],"wp:attachment":[{"href":"https:\/\/nickdu.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=355"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nickdu.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=355"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nickdu.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=355"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}