Machine-Level Programming I: Basics Comp 21000: Introduction to Computer Organization & Systems Instructor: John Barr * Modified slides from the book.

Slides:



Advertisements
Similar presentations
CPU Structure and Function
Advertisements

University of Washington Instruction Set Architectures ISAs Brief history of processors and architectures C, assembly, machine code Assembly basics: registers,
Pentium 4 and IA-32 ISA ELEC 5200/6200 Computer Architecture and Design, Fall 2006 Lectured by Dr. V. Agrawal Lectured by Dr. V. Agrawal Kyungseok Kim.
Instruction Set Architectures
COMP3221: Microprocessors and Embedded Systems Lecture 2: Instruction Set Architecture (ISA) Lecturer: Hui Wu Session.
The AMD and Intel Architectures COMP Jamie Curtis.
Computer Organization and Assembly language
System Calls 1.
INTRODUCTION TO MICROPROCESSORS
1 Machine-Level Programming I: Basics Comp 21000: Introduction to Computer Organization & Systems Spring 2015 Instructor: John Barr * Modified slides from.
The Pentium Processor.
The Pentium Processor Chapter 3 S. Dandamudi To be used with S. Dandamudi, “Introduction to Assembly Language Programming,” Second Edition, Springer,
The Pentium Processor Chapter 3 S. Dandamudi.
University of Amsterdam Computer Systems – a guided tour Arnoud Visser 1 Computer Systems A guided Tour.
1 4.2 MARIE This is the MARIE architecture shown graphically.
Computers organization & Assembly Language Chapter 0 INTRODUCTION TO COMPUTING Basic Concepts.
Fall 2012 Chapter 2: x86 Processor Architecture. Irvine, Kip R. Assembly Language for x86 Processors 6/e, Chapter Overview General Concepts IA-32.
University of Washington Roadmap 1 car *c = malloc(sizeof(car)); c->miles = 100; c->gals = 17; float mpg = get_mpg(c); free(c); Car c = new Car(); c.setMiles(100);
University of Washington Roadmap 1 car *c = malloc(sizeof(car)); c->miles = 100; c->gals = 17; float mpg = get_mpg(c); free(c); Car c = new Car(); c.setMiles(100);
Chapter 8 CPU and Memory: Design, Implementation, and Enhancement The Architecture of Computer Hardware and Systems Software: An Information Technology.
Architecture of Microprocessor
1 The Instruction Set Architecture September 27 th, 2007 By: Corbin Johnson CS 146.
The Evolution of the Intel 80x86 Architecture Chad Derrenbacker Chris Garvey Manpreet Hundal Tom Opfer CS 350 December 9, 1998.
1 Machine-Level Programming I: Basics Comp 21000: Introduction to Computer Organization & Systems Spring 2015 Instructor: John Barr * Modified slides from.
Computer Operation. Binary Codes CPU operates in binary codes Representation of values in binary codes Instructions to CPU in binary codes Addresses in.
1 x86 Programming Model Microprocessor Computer Architectures Lab Components of any Computer System Control – logic that controls fetching/execution of.
CPU (Central Processing Unit). The CPU is the brain of the computer. Sometimes referred to simply as the processor or central processor, the CPU is where.
Spring 2016Machine Code & C Roadmap 1 car *c = malloc(sizeof(car)); c->miles = 100; c->gals = 17; float mpg = get_mpg(c); free(c); Car c = new Car(); c.setMiles(100);
Chapter Overview General Concepts IA-32 Processor Architecture
William Stallings Computer Organization and Architecture 6th Edition
Computer Organization and Architecture Lecture 1 : Introduction
Machine-Level Programming I: Basics
Assembly language.
Computer Systems MTSU CSCI 3240 Spring 2016 Dr. Hyrum D. Carroll
IA32 Processors Evolutionary Design
Chapter 1: A Tour of Computer Systems
A Closer Look at Instruction Set Architectures
CIT 668: System Architecture
Roadmap C: Java: Assembly language: OS: Machine code: Computer system:
Advanced Topic: Alternative Architectures Chapter 9 Objectives
INTRODUCTION TO MICROPROCESSORS
Overview Introduction General Register Organization Stack Organization
Basics Of X86 Architecture
William Stallings Computer Organization and Architecture 8th Edition
INTRODUCTION TO MICROPROCESSORS
Basic Computer Organization
INTRODUCTION TO MICROPROCESSORS
عمارة الحاسب.
Central Processing Unit
5.6 Real-World Examples of ISAs
Today’s agenda Hardware architecture and runtime system
CSCE 313 – Introduction to UNIx process
Evolution of ISA’s ISA’s have changed over computer “generations”.
Introduction to Microprocessor Programming
Machine-Level Programming I: Basics Comp 21000: Introduction to Computer Organization & Systems Instructor: John Barr * Modified slides from the book.
COMS 361 Computer Organization
Introduction to Computer Systems
Evolution of ISA’s ISA’s have changed over computer “generations”.
Machine-Level Programming II: Basics Comp 21000: Introduction to Computer Organization & Systems Instructor: John Barr * Modified slides from the book.
Course Outline for Computer Architecture
Machine-Level Programming II: Basics Comp 21000: Introduction to Computer Organization & Systems Spring 2016 Instructor: John Barr * Modified slides.
Evolution of ISA’s ISA’s have changed over computer “generations”.
CPU Structure CPU must:
A Level Computer Science Topic 5: Computer Architecture and Assembly
Lecture 3 (Microprocessor)
The von Neumann Machine
Evolution of ISA’s ISA’s have changed over computer “generations”.
CSE378 Introduction to Machine Organization
Presentation transcript:

Machine-Level Programming I: Basics Comp 21000: Introduction to Computer Organization & Systems Instructor: John Barr * Modified slides from the book “Computer Systems: a Programmer’s Perspective”, Randy Bryant & David O’Hallaron, 2011

Today: Machine Programming I: Basics History of Intel processors and architectures C, assembly, machine code Assembly Basics: Registers, operands, move Intro to x86-64 Real programmers can write assembly code in any language. -- Larry Wall, creator of the Perl language

Processors What is a processor? Computer brains

Intel x86 Processors Totally dominate laptop/desktop/server market but not the phone/tablet market (that’s ARM) Evolutionary design Backwards compatible up until 8086, introduced in 1978 Added more features as time goes on Complex instruction set computer (CISC) Many different instructions with many different formats But, only small subset encountered with Linux programs Hard to match performance of Reduced Instruction Set Computers (RISC) But, Intel has done just that! In terms of speed. Less so for low power.

Intel x86 Evolution: Milestones Name Date Transistors MHz 8086 1978 29K 5-10 First 16-bit Intel processor. Basis for IBM PC & DOS 1MB address space 386 1985 275K 16-33 First 32 bit Intel processor , referred to as IA32 Added “flat addressing”, capable of running Unix Pentium 4E 2004 125M 2800-3800 First 64-bit Intel x86 processor, referred to as x86-64 Core 2 2006 291M 1060-3500 First multi-core Intel processor Core i7 2008 731M 1700-3900 Four cores

Intel x86 Processors, cont. Machine Evolution 386 1985 0.3M Pentium 1993 3.1M Pentium/MMX 1997 4.5M PentiumPro 1995 6.5M Pentium III 1999 8.2M Pentium 4 2001 42M Core 2 Duo 2006 291M Core i7 2008 731M Corie i7 2018 1.75B Added Features Instructions to support multimedia operations Instructions to enable more efficient conditional operations Transition from 32 bits to 64 bits More cores

Intel x86 Processors: Overview Architectures Processors X86-16 8086 286 X86-32/IA32 386 486 Pentium Pentium MMX Pentium III Pentium 4 Pentium 4E MMX SSE SSE2 SSE3 X86-64 / EM64t Pentium 4F Core 2 Duo Core i7 time SSE4 IA: often redefined as latest Intel architecture

2015 State of the Art Desktop Model Server Model Core i7 Skylake 2015 (6th generation) Cannon Lake is 10nm version in 2018 Desktop Model 4 cores Integrated HD graphics 530 14 pipeline stages 3.4-4.0 GHz 15W Server Model 8 cores Integrated I/O 2-2.6 GHz 65W

More Information Intel processors (Wikipedia) Intel microarchitectures

x86 Clones: Advanced Micro Devices (AMD) Historically AMD has followed just behind Intel A little bit slower, a lot cheaper Then Recruited top circuit designers from Digital Equipment Corp. and other downward trending companies Built Opteron: tough competitor to Pentium 4 Developed x86-64, their own extension to 64 bits Recent Years Intel got its act together Leads the world in semiconductor technology AMD has fallen behind Relies on external semiconductor manufacturer

Intel’s 64-Bit History 2001: Intel Attempts Radical Shift from IA32 to IA64 Totally different architecture (Itanium) Executes IA32 code only as legacy Performance disappointing 2003: AMD Steps in with Evolutionary Solution x86-64 (now called “AMD64”) Intel Felt Obligated to Focus on IA64 Hard to admit mistake or that AMD is better 2004: Intel Announces EM64T extension to IA32 Extended Memory 64-bit Technology Almost identical to x86-64! All but low-end x86 processors support x86-64 But, lots of code still runs in 32-bit mode

Our Coverage IA32 x86-64/EM64T Presentation The traditional x86 The standard server> gcc hello.c server> gcc –march=x86-64 hello.c Presentation Book covers x86-64 Web aside on IA32 We will only cover x86-64 This forces the compiler to produce 64-bit code on a 32-bit machine

Today: Machine Programming I: Basics History of Intel processors and architectures C, assembly, machine code Assembly Basics: Registers, operands, move Intro to x86-64

Definitions Architecture: (also ISA: instruction set architecture) The parts of a processor design that one needs to understand or write assembly/machine code. Examples: instruction set specification, registers. Microarchitecture: Implementation of the architecture. Examples: cache sizes and core frequency. Code Forms: Machine Code: The byte-level programs that a processor executes Assembly Code: A text representation of machine code Example ISAs: Intel: x86, IA32, Itanium, x86-64 ARM: Used in almost all mobile phones

Assembly Programmer’s View Memory CPU Addresses Registers Object Code Program Data OS Data PC Data Condition Codes Instructions Stack Programmer-Visible State PC: Program counter Address of next instruction “RIP” (x86-64) Register file Heavily used program data Condition codes Store status information about most recent arithmetic operation Used for conditional branching Memory Byte addressable array Code, user data Stack to support procedures

Program’s View: memory invisible to user code Kernel virtual memory 0xC0000000 User stack (created at runtime) %esp (stack pointer) Variables in functions go here Memory mapped region for shared libraries 0x40000000 NOTE: MEMORY GROWS UP; 0 IS AT BOTTOM! brk Variables in main() go here Run-time heap (created at runtime by malloc) Read/write segment (.data, .bss) Loaded from the executable file Machine instructions and constants go here Read0nly segment (.init, .text, .rodata) 0x08048000 Unused .data = global and static variables; .bss = global variables initialized to 0; .text = code; .rodata = constants (read only)

CPU’s View: fetch, decode, execute Kernel virtual memory Memory invisible to user code CPU 0xc0000000 User stack (created at runtime) Registers R I P %esp (stack pointer) Condition Codes Memory mapped region for shared libraries 0x40000000 brk Run-time heap (created at runtime by malloc) Read/write segment (.data, .bss) Fetch instruction from memory (%rip contains the address in memory) Increment %rip to next instruction address Loaded from the executable file Read-only segment (.init, .text, .rodata) 0x08048000 Unused

CPU’s View CPU Registers R I P Condition Codes Memory invisible to user code Kernel virtual memory CPU 0xc0000000 User stack (created at runtime) Registers R I P %esp (stack pointer) Condition Codes Memory mapped region for shared libraries 0x40000000 brk Run-time heap (created at runtime by malloc) 2. Decode instruction and fetch arguments from memory (if necessary) Operand could come from R/W segment, heap or user stack Read/write segment (.data, .bss) Loaded from the executable file Read-only segment (.init, .text, .rodata) 0x08048000 Unused

CPU’s View CPU Registers R I P Condition Codes Memory invisible to user code Kernel virtual memory CPU 0xc0000000 User stack (created at runtime) Registers R I P %esp (stack pointer) Condition Codes Memory mapped region for shared libraries 0x40000000 brk Run-time heap (created at runtime by malloc) 3. Execute instruction and store results Operand could go to R/W segment, heap or user stack Read/write segment (.data, .bss) Loaded from the executable file Read-only segment (.init, .text, .rodata) 0x08048000 Unused

CPU’s View CPU Registers R I P Condition Codes Memory invisible to user code Kernel virtual memory CPU 0xc0000000 User stack (created at runtime) Registers R I P %esp (stack pointer) Condition Codes Memory mapped region for shared libraries 0x40000000 brk Run-time heap (created at runtime by malloc) Read/write segment (.data, .bss) 1. Repeat: Fetch next instruction from memory (%rip contains the addess in memory) Loaded from the executable file Read-only segment (.init, .text, .rodata) 0x08048000 Unused

Example See: http://courses.cs.vt.edu/csonline/MachineArchitecture/Lessons/CPU/index.html Much simpler than the IA32 architecture. Does not make the register file explicit. Uses an accumulator (not in IA32).