64-Bit Architectures Topics 64-bit data New registers and instructions Calling conventions CS 105 “Tour of the Black Holes of Computing!”

Slides:



Advertisements
Similar presentations
University of Washington Procedures and Stacks II The Hardware/Software Interface CSE351 Winter 2013.
Advertisements

Machine/Assembler Language Putting It All Together Noah Mendelsohn Tufts University Web:
Machine-Level Programming V: Miscellaneous Topics Topics Buffer Overflow Linux Memory Layout Understanding Pointers Floating-Point Code CS 105 Tour of.
Machine Programming I: Basics
Machine-Level Programming I: Basics
Machine Programming – Procedures and IA32 Stack CENG334: Introduction to Operating Systems Instructor: Erol Sahin Acknowledgement: Most of the slides are.
X86 Programming CS 740 Sept. 12, 2007 Topics Basics Accessing and Moving Data Arithmetic operations Control Flow Procedures Data Structures.
Carnegie Mellon 1 Machine-Level Programming I: Basics /18-243: Introduction to Computer Systems 4 th Lecture, Sep. 2, 2010 Instructors: Randy Bryant.
University of Washington Last Time For loops  for loop → while loop → do-while loop → goto version  for loop → while loop → goto “jump to middle” version.
Carnegie Mellon 1 Machine-Level Programming I: Basics /18-213: Introduction to Computer Systems 5 th Lecture, Tue. May 27, 2015 Instructors: Nathaniel.
Machine-Level Programming III: Procedures Apr. 17, 2006 Topics IA32 stack discipline Register saving conventions Creating pointers to local variables CS213.
Machine-Level Programming III: Procedures Sept. 17, 2007 IA32 stack discipline Register saving conventions Creating pointers to local variablesx86-64 Argument.
– 1 – , F’02 ICS05 Instructor: Peter A. Dinda TA: Bin Lin Recitation 4.
Machine-Level Programming I: Introduction Jan. 22, 2008 Topics Assembly Programmer’s Execution Model Accessing Information Registers Memory Arithmetic.
Machine-Level Programming III: Procedures Jan 30, 2003
Machine-Level Programming III: Procedures Sept. 15, 2006 IA32 stack discipline Register saving conventions Creating pointers to local variablesx86-64 Argument.
Assembly Language Alan L. Cox Some slides adapted from CMU slides.
Machine-Level Programming I: Introduction Sept. 10, 2007 Topics Assembly Programmer’s Execution Model Accessing Information Registers Memory Arithmetic.
Stack Activation Records Topics IA32 stack discipline Register saving conventions Creating pointers to local variables February 6, 2003 CSCE 212H Computer.
Carnegie Mellon 1 Machine-Level Programming I: Basics /18-213: Introduction to Computer Systems 5 th Lecture, Sep. 11, 2012 Instructors: Dave O’Hallaron,
1 Machine-Level Programming I: Basics Computer Systems Organization Andrew Case Slides adapted from Jinyang Li, Randy Bryant and Dave O’Hallaron.
MACHINE-LEVEL PROGRAMMING I: BASICS COMPUTER ARCHITECTURE AND ORGANIZATION.
Carnegie Mellon 1 Machine-Level Programming I: Basics /18-213: Introduction to Computer Systems 5 th Lecture, Jan 28, 2014 Instructors: Seth Copen.
Lee CSCE 312 TAMU 1 Machine-Level Programming I: Basics Instructor: Dr. Hyunyoung Lee Based on slides provided by: Randy Bryant and Dave O’Hallaron.
1 1 Machine-Level Programming IV: x86-64 Procedures, Data Andrew Case Slides adapted from Jinyang Li, Randy Bryant & Dave O’Hallaron.
Ithaca College Machine-Level Programming IV: IA32 Procedures Comp 21000: Introduction to Computer Systems & Assembly Lang Spring 2013 * Modified slides.
Machine-Level Programming I: Topics Assembly Programmer’s Execution Model Accessing Information Registers Memory Arithmetic operations CS 105 “Tour of.
Machine-Level Programming III: Switch Statements and IA32 Procedures Seoul National University.
University of Washington Today More on procedures, stack etc. Lab 2 due today!  We hope it was fun! What is a stack?  And how about a stack frame? 1.
Fabián E. Bustamante, Spring 2007 Machine-Level Programming III - Procedures Today IA32 stack discipline Register saving conventions Creating pointers.
Sungkyunkwan University This Powerpoint slides are modified from its original version available at
The x86 Architecture Lecture 15 Fri, Mar 4, 2005.
Machine-Level Programming: X86-64 Topics Registers Stack Function Calls Local Storage X86-64.ppt CS 105 Tour of Black Holes of Computing.
1 Machine-Level Programming II: Basics Comp 21000: Introduction to Computer Organization & Systems Spring 2015 Instructor: John Barr * Modified slides.
Derived from "x86 Assembly Registers and the Stack" by Rodney BeedeRodney Beede x86 Assembly Registers and the Stack Nov 2009.
Carnegie Mellon 1 Odds and Ends Intro to x86-64 Memory Layout.
Chapter 2 Parts of a Computer System. 2.1 PC Hardware: Memory.
1 Procedure Call and Array. 2 Outline Data manipulation Control structure Suggested reading –Chap 3.7, 3.8.
University of Washington x86 Programming I The Hardware/Software Interface CSE351 Winter 2013.
Carnegie Mellon 1 Machine-Level Programming I: Basics Lecture, Feb. 21, 2013 These slides are from website which accompanies the.
Machine/Assembler Language Control Flow & Compiling Function Calls Noah Mendelsohn Tufts University Web:
1 Machine-Level Programming II: Basics Comp 21000: Introduction to Computer Organization & Systems Spring 2016 Instructor: John Barr * Modified slides.
IA32 Stack –Region of memory managed with stack discipline –Grows toward lower addresses –Register %esp indicates lowest stack address address of top element.
1 Binghamton University Machine-Level Programming I: Basics CS220: Computer Systems II.
A job ad at a game programming company
CS 3214 Computer Systems Lecture 2 Godmar Back.
Reading Condition Codes (Cont.)
Instruction Set Architecture
Credits and Disclaimers
Machine-Level Programming I: Basics
Credits and Disclaimers
C function call conventions and the stack
Machine-Level Programming 1 Introduction
Machine-Level Programming III: Switch Statements and IA32 Procedures
Y86 Processor State Program Registers
Instructors: Majd Sakr and Khaled Harras
Machine-Level Programming 4 Procedures
Roadmap C: Java: Assembly language: OS: Machine code: Computer system:
Roadmap C: Java: Assembly language: OS: Machine code: Computer system:
Machine-Level Programming III: Procedures Sept 18, 2001
Machine Level Representation of Programs (IV)
Machine-Level Programming: Introduction
Machine Level Representation of Programs (IV)
Machine-Level Representation of Programs (x86-64)
Machine-Level Programming II: Basics Comp 21000: Introduction to Computer Organization & Systems Instructor: John Barr * Modified slides from the book.
Machine-Level Programming I: Basics
“Way easier than when we were students”
Credits and Disclaimers
Presentation transcript:

64-Bit Architectures Topics 64-bit data New registers and instructions Calling conventions CS 105 “Tour of the Black Holes of Computing!”

– 2 – CS 105 Data Representations: IA32 + x86-64 Sizes of C Objects (in Bytes) C Data TypeTypical 32-bitIntel IA32x86-64 unsigned444 int444 long int448 char111 short222 float444 double888 long double810/1216 char *448 Or any other pointer

– 3 – CS 105 %rax %rbx %rcx %rdx %rsi %rdi %rsp %rbp x86-64 Integer Registers Extend existing registers. Add 8 new ones. Make %ebp / %rbp general purpose %eax %ebx %ecx %edx %esi %edi %esp %ebp %r8 %r9 %r10 %r11 %r12 %r13 %r14 %r15 %r8d %r9d %r10d %r11d %r12d %r13d %r14d %r15d %ax %bx %cx %dx %si %di %sp %bp %r8w %r9w %r10w %r11w %r12w %r13w %r14w %r15w %dx %si %di %sp %bp %r8w %r9w %r10w %r11w %r12w ahal bhbl chcl dhdl sil dil spl bpl r8b r9b r10b r11b r12b r13b r14b r15b

– 4 – CS 105 %rax %rbx %rcx %rdx %rsi %rdi %rsp %rbp x86-64 Integer Registers Extend existing registers. Add 8 new ones. Make %ebp / %rbp general purpose %eax %ebx %ecx %edx %esi %edi %esp %ebp %r8 %r9 %r10 %r11 %r12 %r13 %r14 %r15 %r8d %r9d %r10d %r11d %r12d %r13d %r14d %r15d

– 5 – CS 105 Instructions Long word l (4 Bytes) ↔ Quad word q (8 Bytes) New instructions: movl → movq addl → addq sall → salq movzbq, movslq etc. 32-bit instructions that generate 32-bit results Set higher order bits of destination register to 0 Example: addl, movl ( thus no movzlq)

– 6 – CS 105 Swap in 32-bit Mode void swap(int *xp, int *yp) { int t0 = *xp; int t1 = *yp; *xp = t1; *yp = t0; } swap: pushl %ebp movl %esp,%ebp pushl %ebx movl 12(%ebp),%ecx movl 8(%ebp),%edx movl (%ecx),%eax movl (%edx),%ebx movl %eax,(%edx) movl %ebx,(%ecx) movl -4(%ebp),%ebx movl %ebp,%esp popl %ebp ret Body Setup Finish

– 7 – CS 105 Swap in 64-bit Mode Operands passed in registers (why useful?) First ( xp ) in %rdi, second ( yp ) in %rsi 64-bit pointers No stack operations required 32-bit data Data held in registers %eax and %edx movl operation void swap(int *xp, int *yp) { int t0 = *xp; int t1 = *yp; *xp = t1; *yp = t0; } swap: movl(%rdi), %edx movl(%rsi), %eax movl%eax, (%rdi) movl%edx, (%rsi) retq

– 8 – CS 105 Swap Long Ints in 64-bit Mode 64-bit data Data held in registers %rax and %rdx movq operation Otherwise same void swap_l (long int *xp, long int *yp) { long int t0 = *xp; long int t1 = *yp; *xp = t1; *yp = t0; } swap_l: movq(%rdi), %rdx movq(%rsi), %rax movq%rax, (%rdi) movq%rdx, (%rsi) retq

– 9 – CS 105 New Calling Conventions Most procedures no longer need stack frame First six arguments passed in registers Register %rbp available for general use Stack frame accessed via %rsp 128 bytes below %rsp usable by function (“red zone”)