02 x86 vs x86 64


University of Washington
64 bits wide
x86 64 Integer Registers
%eax %r8d
%rax %r8
%ebx %r9d
%rbx %r9
%ecx %r10d
%rcx %r10
%edx %r11d
%rdx %r11
%esi %r12d
%rsi %r12
%edi %r13d
%rdi %r13
%esp %r14d
%rsp %r14
%ebp %r15d
%rbp %r15
Extend exis ng registers, and add 8 new ones; all accessible as 8, 16, 32, 64 bits.
x86
University of Washington
32 bit vs. 64 bit operands
Long word l (4 Bytes) "! Quad word q (8 Bytes)
New instruc on forms:
movl movq
addl addq
sall salq
etc.
x86 64 can s ll use 32 bit instruc ons that generate 32 bit
results
Higher order bits of des na on register are just set to 0
Example: addl
x86
University of Washington
Swap Ints in 32 bit Mode
void swap(int *xp, int *yp)
swap:
{
pushl %ebp
int t0 = *xp;
movl %esp,%ebp
Setup
int t1 = *yp;
pushl %ebx
*xp = t1;
*yp = t0;
movl 12(%ebp),%ecx
}
movl 8(%ebp),%edx
movl (%ecx),%eax
Body
movl (%edx),%ebx
"
movl %eax,(%edx)
"
movl %ebx,(%ecx)
"
Offset
movl -4(%ebp),%ebx
yp
12
movl %ebp,%esp
Finish
xp popl %ebp
8
ret
Rtn adr
4
%ebp
Old %ebp
0
Old %ebx
-4
x86
University of Washington
Swap Ints in 64 bit Mode
void swap(int *xp, int *yp) swap:
{ movl (%rdi), %edx
int t0 = *xp; movl (%rsi), %eax
int t1 = *yp; movl %eax, (%rdi)
*xp = t1; movl %edx, (%rsi)
*yp = t0; retq
}
Arguments passed in registers (why useful?)
First (xp) in %rdi, second (yp) in %rsi
64 bit pointers
No stack opera ons required
32 bit data
Data held in registers %eax and %edx
movl opera on (the l refers to data width, not address width)
x86
University of Washington
Swap Long Ints in 64 bit Mode
void swap_l swap_l:
(long int *xp, long int *yp) movq (%rdi), %rdx
{ movq (%rsi), %rax
long int t0 = *xp; movq %rax, (%rdi)
long int t1 = *yp; movq %rdx, (%rsi)
*xp = t1; retq
*yp = t0;
}
64 bit data
Data held in registers %rax and %rdx
movq opera on
 q stands for quad word
x86


Wyszukiwarka

Podobne podstrony:
02 x86 vs x86 64
06 x86 64 Procedures and Stacks
06 x86 64 Procedures and Stacks
DP Miscallenous wnt5 x86 32
02 CD P 64
(sadryści vs rząd part 02) Sadr grozi otwartą wojną rządowi
x86 shared
reqs x86
Identification of 32 bit x86 CPUs based on reset signature
gbm x86 stuff index
WinXP Pro SP3 x86 BE 2014 7 13 Valid WGA CD Keys
docs doc x86 stolen functions
Windows 8 Pro VL x86
WinXP Pro SP3 x86 BE 2014 7 13 Changelog
WinXP Pro SP3 x86 BE 2014 7 13 README

więcej podobnych podstron