Rax eax r8 r8d rbx ebx r9 r9d rcx ecx r10 r10d rdx

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: bx %eax,(%edx) %ebx,(%ecx) x86 # # # # # # ecx edx eax ebx *xp *yp 0x100 = = = = = = yp xp *yp (t1) *xp (t0) eax ebx University of Washington x86 ­64 Integer Registers 64 ­bits wide %rax %eax %r8 %r8d %rbx %ebx %r9 %r9d %rcx %ecx %r10 %r10d %rdx %edx %r11 %r11d %rsi %esi %r12 %r12d %rdi %edi %r13 %r13d %rsp %esp %r14 %r14d %rbp %ebp %r15 %r15d   Extend exisIng 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 instrucMon forms:           movl → movq addl → addq sall → salq etc. x86 ­64 can sMll use 32 ­bit instrucMons that generate 32 ­bit results   Higher ­order bits of desInaIon register are just set to 0   Example: addl x86 University of Washington Swap Ints in 32 ­bit Mode void swap(int *xp, int *yp) { int t0 = *xp; int t1 = *yp; *xp = t1; *yp = t0; } Offset swap: pushl %ebp movl %esp,%ebp pushl %ebx movl movl movl movl movl movl • • • 12 xp 4 movl -4(%ebp),%ebx movl %ebp,%esp popl %ebp ret yp 8 Rtn adr 0 Old %ebp -4 Old %ebx 12(%ebp),%ecx 8(%ebp),%edx (%ecx),%eax (%edx),%ebx %eax,(%edx) %ebx,(%ecx) %ebp x86 Setup Body Finish University of Washington Swap Ints in 64 ­bit Mode void swap(int *xp, int *yp) { int t0 = *xp; int t1 = *yp; *xp = t1; *yp = t0; }   swap: movl movl movl movl retq (%rdi), %edx (%rsi), %eax %eax, (%rdi) %edx, (%rsi) Arguments passed in registers (why useful?)   First (xp) in %rdi, second (yp) in %rsi   64 ­bit pointers     No stack operaMons required 32 ­bit data   Data held in registers %eax and %edx   movl operaIon (the l refers to data width, not address width) x86 University of Washington Swap Long Ints in 64 ­bit Mode void swap_l (long int *xp, long int *yp) { long int t0 = *xp; long int t1 = *yp; *xp = t1; *yp = t0; }   64 ­bit data   Data held in registers %rax and %rdx   movq operaIon   “q” stands for quad ­word x86 swap_l: movq movq movq movq retq (%rdi), %rdx (%rsi), %rax %rax, (%rdi) %rdx, (%rsi) University of Washington Complete Memory Addressing Modes   Remember, the addresses used...
View Full Document

Ask a homework question - tutors are online