{"id":5508,"date":"2014-03-30T23:23:53","date_gmt":"2014-03-30T23:23:53","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/explanation-of-the-disassembly-of-the-simplest-program-x86-collection-of-common-programming-errors\/"},"modified":"2014-03-30T23:23:53","modified_gmt":"2014-03-30T23:23:53","slug":"explanation-of-the-disassembly-of-the-simplest-program-x86-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/explanation-of-the-disassembly-of-the-simplest-program-x86-collection-of-common-programming-errors\/","title":{"rendered":"Explanation of the disassembly of the simplest program (x86)-Collection of common programming errors"},"content":{"rendered":"<p>The instructions sets up the stack frame upon the runtime loader entering the <code>int _main()<\/code> function,<\/p>\n<pre>\nPUSH EBP\nMOV EBP, ESP\n<\/pre>\n<p>Stack frame is set up and to access the parameters if any were supplied would be offset from <code>EBP<\/code> + the size of the parameter (WORD, BYTE, LONG, etc).<\/p>\n<p>Usually the <code>EAX<\/code> register is the normal register to return an exit status from the runtime environment to the operating system loader,<\/p>\n<pre>\nMOV EAX, 0\nLEAVE\n<\/pre>\n<p>in other words, to say the program has exited successfully returning a 0 to the Operating system.<\/p>\n<p>Where a return is used, the stack frame is restored upon runtime execution prior to handing control back to the Operating system.<\/p>\n<pre>\nPOP EBP\n<\/pre>\n<p>The general consensus is, if an error has occurred, the value would be non-zero, and can be used both from batch files (harking back to the old DOS days) and unix scripts where it checks if the program ran successfully or not and proceed onwards depending on the nature of the batch file or script.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The instructions sets up the stack frame upon the runtime loader entering the int _main() function, PUSH EBP MOV EBP, ESP Stack frame is set up and to access the parameters if any were supplied would be offset from EBP + the size of the parameter (WORD, BYTE, LONG, etc). Usually the EAX register is [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-5508","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5508","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=5508"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5508\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=5508"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=5508"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=5508"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}