{"id":3439,"date":"2021-08-20T13:21:22","date_gmt":"2021-08-20T11:21:22","guid":{"rendered":"https:\/\/andreas-klingler.de\/infosec\/?p=3439"},"modified":"2021-08-21T14:44:24","modified_gmt":"2021-08-21T12:44:24","slug":"basic-x86-x64-assembly-registers-and-commands","status":"publish","type":"post","link":"https:\/\/infosec.andreas-klingler.de\/?p=3439","title":{"rendered":"Basic x86\/x64 assembly registers and commands"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Registers<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">General purpose registers<\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Reg\u00adis\u00adter x86<\/th><th>Reg\u00adis\u00adter x64<\/th><th>Name<\/th><th>Descrip\u00adtion<\/th><\/tr><\/thead><tbody><tr><td><code>EAX<\/code><\/td><td><code>RAX<\/code><\/td><td>Accu\u00admu\u00adla\u00adtor<\/td><td>For results of cal\u00adcu\u00adla\u00adtions and return codes<\/td><\/tr><tr><td><code>EBX<\/code><\/td><td><code>RBX<\/code><\/td><td>Base reg\u00adis\u00adter<\/td><td>Gen\u00ader\u00adal purpose<\/td><\/tr><tr><td><code>ECX<\/code><\/td><td><code>RCX<\/code><\/td><td>Count reg\u00adis\u00adter<\/td><td>For num\u00adber of iter\u00ada\u00adtions, often used for&nbsp;loops<\/td><\/tr><tr><td><code>EDX<\/code><\/td><td><code>RDX<\/code><\/td><td>Data reg\u00adis\u00adter<\/td><td>For data of cal\u00adcu\u00adla\u00adtions or a point\u00ader to large&nbsp;data<\/td><\/tr><tr><td><code>ESI<\/code><\/td><td><code>RSI<\/code><\/td><td>Source index<\/td><td>Point\u00ader to a loca\u00adtion to read&nbsp;from<\/td><\/tr><tr><td><code>EDI<\/code><\/td><td><code>RDI<\/code><\/td><td>Des\u00adti\u00adna\u00adtion&nbsp;index<\/td><td>Point\u00ader to a loca\u00adtion to write&nbsp;into<\/td><\/tr><tr><td><code>EBP<\/code><\/td><td>( <code>RBP<\/code> )<\/td><td>Extend\u00aded base point\u00ader in x68<br>Gen\u00ader\u00adal pur\u00adpose reg\u00adis\u00adter in&nbsp;x64<\/td><td>Fixed point\u00ader dur\u00ading a func\u00adtion call as a ref\u00ader\u00adence to access vari\u00adables on the&nbsp;stack.<\/td><\/tr><tr><td><code>ESP<\/code><\/td><td><code>RSP<\/code><\/td><td>Stack point\u00ader<\/td><td>Holds the top address of the&nbsp;stack<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Segment registers<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">These are all 16 bit register.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Reg\u00adis\u00adter<\/th><th>Name<\/th><th>Descrip\u00adtion<\/th><\/tr><\/thead><tbody><tr><td><code>CS<\/code><\/td><td>Code seg\u00adment reg\u00adis\u00adter (also: Text seg\u00adment register)<\/td><td>Point\u00ader to the start address of the exe\u00adcute\u00adable&nbsp;code<\/td><\/tr><tr><td><code>SS<\/code><\/td><td>Stack seg\u00adment register<\/td><td>Point\u00ader to some off\u00adset address with\u00adin the&nbsp;stack<\/td><\/tr><tr><td><code>DS<\/code><\/td><td>Data seg\u00adment register<\/td><td>Point\u00ader to an address of some data structure<\/td><\/tr><tr><td><code>ES<\/code><\/td><td>Extra seg\u00adment register<\/td><td>Point\u00ader to an address of some data structure<\/td><\/tr><tr><td><code>FS<\/code><\/td><td>Extra data seg\u00adment register<\/td><td>Point\u00ader to an address of some data struc\u00adture.<br>Win\u00addows: Point\u00ader to the <em><span class=\"caps\">TIB<\/span> Thread Infor\u00adma\u00adtion&nbsp;Block<\/em><\/td><\/tr><tr><td><code>GS<\/code><\/td><td>Extra data seg\u00adment register<\/td><td>Point\u00ader to an address of some data struc\u00adture.<br>Win\u00addows: Point\u00ader to the <em><span class=\"caps\">TLS<\/span> Thread Local Storage<\/em><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Commands<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Com\u00admand<\/th><th>Descrip\u00adtion<\/th><\/tr><\/thead><tbody><tr><td><code>push %edi<\/code><\/td><td>1. Writes the val\u00adue from %edi on top on the stack and<br>2. decreas\u00ades the <span class=\"caps\">ESP<\/span> Stack Pointer<\/td><\/tr><tr><td><code>pop %ebp<\/code><\/td><td>1. Loads the val\u00adue on top of the stack into the giv\u00aden reg\u00adis\u00adter <code>$ebp<\/code> and<br>2. increas\u00ades the <span class=\"caps\">ESP<\/span> Stack Pointer.<\/td><\/tr><tr><td><code>ret<\/code><\/td><td>1. Sets the <span class=\"caps\">IP<\/span> Instruc\u00adtion point\u00ader to the address on top of the stack and<br>2. increas\u00ades the <span class=\"caps\">ESP<\/span> Stack Pointer.<\/td><\/tr><tr><td><code>call func<\/code><\/td><td>1. Stores the next address (after the call func\u00adtion) on top on the stack (basi\u00adcal\u00adly the return address),<br>2. decreas\u00ades the <span class=\"caps\">ESP<\/span> Stack Point\u00ader and<br>3. sets the <span class=\"caps\">IP<\/span> Instruc\u00adtion Point\u00ader to the address of <code>func<\/code>.<\/td><\/tr><tr><td><code>mov %eax, %edi<\/code><\/td><td><span class=\"caps\">AT<\/span><span class=\"amp\">&amp;<\/span>T syn\u00adtax: Copies the val\u00adue of <code>%eax<\/code> into <code>%edi<\/code>.<\/td><\/tr><tr><td><code>mov edi, eax<\/code><\/td><td>Intel syn\u00adtax: Copies the val\u00adue of <code>eay<\/code> into <code>edi<\/code>.<\/td><\/tr><tr><td><code>xchg %eax, %eax<\/code><\/td><td>Swaps the val\u00adues from both registers.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Reg\u00adis\u00adters Gen\u00ader\u00adal pur\u00adpose reg\u00adis\u00adters Reg\u00adis\u00adter&nbsp;x86 Reg\u00adis\u00adter&nbsp;x64 Name Descrip\u00adtion <span class=\"caps\">EAX<\/span> <span class=\"caps\">RAX<\/span> Accu\u00admu\u00adla\u00adtor For results of cal\u00adcu\u00adla\u00adtions and return codes <span class=\"caps\">EBX<\/span> <span class=\"caps\">RBX<\/span> Base reg\u00adis\u00adter Gen\u00ader\u00adal pur\u00adpose <span class=\"caps\">ECX<\/span> <span class=\"caps\">RCX<\/span> Count reg\u00adis\u00adter For num\u00adber of iter\u00ada\u00adtions, often used for&nbsp;loops <span class=\"caps\">EDX<\/span> <span class=\"caps\">RDX<\/span> Data reg\u00adis\u00adter For data of cal\u00adcu\u00adla\u00adtions or a point\u00ader to large&nbsp;data <span class=\"caps\">ESI<\/span> <span class=\"caps\">RSI<\/span> Source index Point\u00ader to&nbsp;a&nbsp;[\u2026]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"wp_typography_post_enhancements_disabled":false,"footnotes":""},"categories":[355],"tags":[423],"class_list":["post-3439","post","type-post","status-publish","format-standard","hentry","category-reverse-engineering","tag-assembly"],"_links":{"self":[{"href":"https:\/\/infosec.andreas-klingler.de\/index.php?rest_route=\/wp\/v2\/posts\/3439","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/infosec.andreas-klingler.de\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/infosec.andreas-klingler.de\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/infosec.andreas-klingler.de\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/infosec.andreas-klingler.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3439"}],"version-history":[{"count":12,"href":"https:\/\/infosec.andreas-klingler.de\/index.php?rest_route=\/wp\/v2\/posts\/3439\/revisions"}],"predecessor-version":[{"id":3457,"href":"https:\/\/infosec.andreas-klingler.de\/index.php?rest_route=\/wp\/v2\/posts\/3439\/revisions\/3457"}],"wp:attachment":[{"href":"https:\/\/infosec.andreas-klingler.de\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3439"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/infosec.andreas-klingler.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3439"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/infosec.andreas-klingler.de\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3439"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}