Friday, February 14, 2020

X86_64 and AArch64


X86 64 Register and Instruction

x86-64 (also known as x64x86_64AMD64 and Intel 64[note 1]) is the 64-bit version of the x86 instruction set

Resister: a register may hold an instruction, a storage address or any kind of data. Some instructions specify registers as part of the instruction. A register must be large enough to hold an instruction.


 General-Purpose of register
It is extended of 16-bit version.
64-bit register using the ‘r’ prefix. ‘r’ stand for register,  ‘x’ stand for extended.
Ex) rax, rax, rcx, rdx, rbp(register base pointer), rsp(register stack pointer), rsi(register source index), rdi( register destination index)

       the register added for 64-bit mode are named
         r8,r9,r10,r11,r12,r13,r14,r15

         32_bit register using the ‘e’ prefix or ‘d’ suffix ex) eax, r15d
         16_bit register using no prefix or ‘w’ suffix ex) ax, r15w
          8_bit register using ‘h’ suffix or ‘l’ suffix or ‘b; suffix ex) ah, bh, al, bl, r15b



        

Usage during syscall/fuction call
         -first six arguments are in rdi, rsi,rdx,rcx,r8d,r9d; remaining arguments are on the stack
         -syscall number is in rax
         -return valure in rax
         -The called routine is expected to preserve rsp,rbp, rbx, r12, r13, r14, and r15 but
may trample any other registers.

Instruction
Register names – prefixed by %
Immediate values – prefixed by $
Indirect memory access is indicated by ( )
Hexadecimal values are indicated by a 0x prefix.
Character values are indicated by quotation mark
Data sources are given as the first argument

        

AArch64 Register and Instruction Quick Start
Aarch64 is the name for the new 64-bit ARM architecture, also known as ARMv8 or ARM64. Hardware designed for this hardware.

Register
General-Purpose registers
R0 ~ r30 : to refer generally to the register
X0 ~ x30 : for 64_bit_wide access
W0 ~ w30: for 32 _bit_wide access

31 is one or two registers depending on the instruction
         -for instructions dealing with the stack, it is the stack pointer, named rsp
         -for all other instructions, it is a zero register, which return 0 when read and discards
 data when written, named rzr

usage during syscall/function call
R0~r7 are used for arguments and return values
Syscall number is in r8
R9-r15 are for temporary values.
R16-r18 are used for intra-procedure-call ad platform values
The called routine is expected to preserve r19-r28
R29 and r30 are used as the frame register and link register

Instruction
Register named are not prefixed.
Immediate value are not prefixed with a character
Indirect memory access is indicated by [  ]
Hexadecimal values are indicated by Ox prefix..
Character values are indicated by quotation marks.
Destinations are given as the first argument.

No comments:

Post a Comment