x64_cheatsheet.pdf

Description
CSCI0330 Intro​ ​Computer​ ​Systems Doeppner x64​ ​Cheat​ ​Sheet Fall​ ​2017 1.​ ​x64​ ​Registers x64​ ​assembly​ ​code​ ​uses​ ​sixteen​ ​64-bit​ ​registers.​ ​Additionally,​ ​the​ ​lower​ ​bytes​ ​of​ ​some​ ​of​ ​these registers​ ​may​ ​be​ ​accessed​ ​independently​ ​as​ ​32-,​ ​16-​ ​or​ ​8-bit​ ​registers.​ ​The​ ​register

Please download to get full document.

View again

of 10
All materials on our website are shared by users. If you have any questions about copyright issues, please report us to resolve them. We are always happy to assist you.
Information
Category:

Documents

Publish on:

Views: 2 | Pages: 10

Extension: PDF | Download: 0

Share
Transcript
   CSCI0330 Intro Computer Systems Doeppner x64   Cheat Sheet Fall 2017    1. x64 Registers x64 assembly code uses sixteen 64-bit registers. Additionally, the lower bytes of some of these registers may be accessed independently as 32-, 16- or 8-bit registers. The register names are as follows: 8-byte register Bytes 5-8 Bytes 7-8 Byte 8 %rax %eax %ax %al %rcx %ecx %cx %cl %rdx %edx %dx %dl %rbx %ebx %bx %bl %rsi %esi %si %sil %rdi %edi %di %dil %rsp %esp %sp %spl %rbp %ebp %bp %bpl %r8 %r8d %r8w %r8b %r9 %r9d %r9w %r9b %r10 %r10d %r10w %r10b %r11 %r11d %r11w %r11b %r12 %r12d %r12w %r12b %r13 %r13d %r13w %r13b %r14 %r14d %r14w %r14b %r15 %r15d %r15w %r15b For more details of register usage, see Register Usage, below. 2. Operand Specifiers The basic types of operand specifiers are below. In the following table, ● Imm  refers to a constant value, e.g. 0x8048d8e  or 48 , ● E   x   refers to a register, e.g.   %rax , ● R[E   x   ]   refers to the value stored in register E   x  , and ● M[x]   refers to the value stored at memory address  x  .   CSCI0330 x86-64 Guide Doeppner Type From Operand Value Name Immediate $Imm Imm Immediate Register E  a R[E  a  ] Register Memory Imm M[Imm]  Absolute Memory (E  a  ) M[R[E  b  ]]  Absolute Memory Imm(E  b , E  i,  s) M[Imm + R[E  b  ] + (R[E  i   ] x s)] Scaled indexed More information about operand specifiers can be found on pages 169-170 of the textbook. 3. x64 Instructions In the following tables, ●“byte” refers to a one-byte integer (suffix b ), ●“word” refers to a two-byte integer (suffix w ), ●“doubleword” refers to a four-byte integer (suffix   l ), and ●“quadword” refers to an eight-byte value (suffix   q ). Most instructions, like mov , use a suffix to show how large the operands are going to be. For example, moving a quadword from %rax  to %rbx  results in the instruction movq %rax, %rbx . Some instructions, like ret , do not use suffixes because there is no need. Others, such as movs  and movz  will use two suffixes, as they convert operands of the type of the first suffix to that of the second. Thus, assembly to convert the byte in %al  to a doubleword in %ebx  with zero-extension would be movzbl %al, %ebx . In the tables below, instructions have one suffix unless otherwise stated. 3.1 Data Movement Instruction Description Page # Instructions with one suffix mov   S, D Move source to destination 171 push   S Push source onto stack 171 pop   D Pop top of stack into destination 171 Instructions with two suffixes mov   S, D Move byte to word (sign extended) 171 push   S Move byte to word (zero extended) 171 Instructions with no suffixes cwtl   Convert word in %ax  to doubleword in %eax  (sign-extended) 182 cltq   Convert doubleword in %eax  to quadword in %rax   (sign-extended) 182 cqto   Convert quadword in %rax  to octoword in   %rdx:%rax  182   CSCI0330 x86-64 Guide Doeppner 3.2 Arithmetic Operations Unless otherwise specified, all arithmetic operation instructions have one suffix. 3.2.1 Unary Operations  Instruction Description Page # inc D Increment by 1 178 dec D Decrement by 1 178 neg D  Arithmetic negation 178 not D Bitwise complement 178 3.2.2 Binary Operations Instruction Description Page # leaq   S, D Load effective address of source into destination 178 add S, D  Add source to destination 178 sub S, D Subtract source from destination 178 imul S, D Multiply destination by source 178 xor S, D Bitwise XOR destination by source 178 or S, D Bitwise OR destination by source 178 and S, D Bitwise AND destination by source 178 3.2.3 Shift Operations Instruction Description Page # sal / shl   k, D Left shift destination by k   bits 179 sar k, D  Arithmetic right shift destination by k   bits 179 shr k, D Logical right shift destination by k   bits 179 3.2.4 Special Arithmetic Operations Instruction Description Page # imulq S Signed full multiply of %rax by S Result stored in %rdx:%rax 182   CSCI0330 x86-64 Guide Doeppner mulq   S   Unsigned full multiply of %rax  by S Result stored in %rdx:%rax 182 idivq S Signed divide  %rdx:%rax  by S Quotient stored in %rax Remainder stored in %rdx 182 divq S   Unsigned divide %rdx:%rax  by S Quotient stored in %rax Remainder stored in %rdx 182 3.3 Comparison and Test Instructions Comparison instructions also have one suffix. Instruction Description Page # cmp S 2  , S 1   Set condition codes according to S 1  - S 2  185 test S 2  , S 1   Set condition codes according to S 1  & S 2  185 3.4 Accessing Condition Codes None of the following instructions have any suffixes. 3.4.1 Conditional Set Instructions Instruction Description Condition Code Page # sete  / setz   D Set if equal/zero ZF 187 setne   / setnz   D  Set if not equal/nonzero ~ ZF 187 sets   D  Set if negative SF 187 setns   D  Set if nonnegative ~ SF 187 setg  / setnle   D   Set if greater (signed) ~ (SF ^ 0F)&  ~ ZF 187 setge  / setnl   D  Set if greater or equal (signed) ~ (SF ^ 0F) 187 setl  / setnge   D   Set if less (signed) SF^0F 187 setle  / setng   D   Set if less or equal (SF ^ OF)|ZF 187 seta  / setnbe   D  Set if above (unsigned) ~ CF&  ~ ZF 187 setae  / setnb   D  Set if above or equal (unsigned) ~ CF 187 setb  / setnae   D  Set if below (unsigned) CF 187 setbe  / setna   D  Set if below or equal (unsigned) CF|ZF 187
Related Search
We Need Your Support
Thank you for visiting our website and your interest in our free products and services. We are nonprofit website to share and download documents. To the running of this website, we need your help to support us.

Thanks to everyone for your continued support.

No, Thanks