CS 31: Intro to Systems ISAs and Assembly. Martin Gagné Swarthmore College February 7, 2017
|
|
- Sherman Potter
- 6 years ago
- Views:
Transcription
1 CS 31: Intro to Systems ISAs and Assembly Martin Gagné Swarthmore College February 7, 2017
2 ANNOUNCEMENT All labs will meet in SCI 252 (the robot lab) tomorrow.
3 Overview How to directly interact with hardware Instruction set architecture (ISA) Interface between programmer and CPU Established instruction format (assembly lang) Assembly programming (IA-32)
4 Abstraction User / Programmer Wants low complexity Applications Specific functionality Software library Reusable functionality Operating system Manage resources Complex devices Compute & I/O
5 Abstraction Applications Specific functionality This week: Machine Interface Operating system Manage resources Complex devices Compute & I/O Last week: Circuits, Hardware Implementation
6 Compilation Steps (.c to a.out) text C program (p1.c) Usually compile to a.out in a single step: gcc m32 p1.c -m32 tells gcc to compile for 32-bit Intel machines Compiler (gcc m32) Reality is more complex: there are intermediate steps! executable binary Executable code (a.out)
7 Compilation Steps (.c to a.out) CS75 text C program (p1.c) Compiler (gcc m32 -S) You can see the results of intermediate compilation steps using different gcc flags text Assembly program (p1.s) executable binary Executable code (a.out)
8 Assembly Code Human-readable form of CPU instructions Almost a 1-to-1 mapping to Machine Code Hides some details: Registers have names rather than numbers Instructions have names rather than variable-size codes We re going to use IA32 (x86) assembly CS lab machines are 64 bit version of this ISA, but they can also run the 32-bit version (IA32) Can compile C to IA32 assembly on our system: gcc m32 -S code.c # open code.s in vim to view
9 Compilation Steps (.c to a.out) text C program (p1.c) Compiler (gcc m32 -S) You can see the results of intermediate compilation steps using different gcc flags text Assembly program (p1.s) binary executable binary Assembler (gcc -c (or as)) Object code (p1.o) Linker (gcc (or ld)) Executable code (a.out) Other object files (p2.o, p3.o, ) Library obj. code (libc.a)
10 Object / Executable / Machine Code Assembly push %ebp mov %esp, %ebp sub $16, %esp movl $10, -8(%ebp) movl $20, -4(%ebp) movl -4(%ebp), %eax addl %eax, -8(%ebp) movl -8(%ebp), %eax leave int main() { Machine Code (Hexadecimal) 55 int a = 10; 89 E5 83 EC int b 10= 20; C7 45 F8 0A C7 45 a = FC a + 14 b; B 45 FC F8 B8 45 return F a; }
11 Compilation Steps (.c to a.out) text C program (p1.c) High-level language text Compiler (gcc m32 -S) Assembly program (p1.s) Interface for speaking to CPU binary executable binary Assembler (gcc -c (or as)) Object code (p1.o) Linker (gcc (or ld)) Executable code (a.out) CPU-specific format (011010) Other object files (p2.o, p3.o, ) Library obj. code (libc.a)
12 Instruction Set Architecture (ISA) ISA (or simply architecture): Interface between lowest software level and the hardware. Defines specification of the language for controlling CPU state: Provides a set of instructions Makes CPU registers available Allows access to main memory Exports control flow (change what executes next)
13 Instruction Set Architecture (ISA) The agreed-upon interface between all software that runs on the machine and the hardware that executes it. Application / Program Compiler CPU / Processor Operating System I/O system Instruction Set Architecture Digital Circuits Logic Gates
14 ISA Examples Intel IA-32 (80x86) ARM MIPS PowerPC IBM Cell Motorola 68k Intel IA-64 (Itanium) VAX SPARC Alpha IBM 360 How many of these have you used?
15 ISA Characteristics High-level language Hardware Implementation ISA Above ISA: High-level language (C, Python, ) Hides ISA from users Allows a program to run on any machine (after translation by human and/or compiler) Below ISA: Hardware implementing ISA can change (faster, smaller, ) ISA is like a CPU family
16 Instruction Translation sum.c (High-level C) int sum(int x, int y) { int res; res = x+y; return res; } sum.s (Assembly) sum: pushl %ebp movl %esp,%ebp subl $24, %esp movl -12(%ebp),%eax addl -8(%ebp),%eax movl %eax, -12(%ebp) leave ret sum.s from sum.c: gcc m32 S sum.c Instructions to set up the stack frame and get argument values An add instruction to compute sum Instructions to return from function
17 ISA Design Questions sum.c (High-level C) int sum(int x, int y) { int res; res = x+y; return res; } sum.s (Assembly) sum: pushl %ebp movl %esp,%ebp subl $24, %esp movl -12(%ebp),%eax addl -8(%ebp),%eax movl %eax, -12(%ebp) leave ret sum.s from sum.c: gcc m32 S sum.c What should these instructions do? What is/isn t allowed by hardware? How complex should they be? Example: supporting multiplication.
18 C statement: A = A*B Simple instructions: LOAD A, eax LOAD B, ebx PROD eax, ebx STORE ebx, A Powerful instructions: MULT B, A Translation: Load the values A and B from memory into registers, compute the product, store the result in memory where A was.
19 Which would you use if you were designing an ISA for your CPU? (Why?) Simple instructions: LOAD A, eax LOAD B, ebx PROD eax, ebx STORE ebx, A Powerful instructions: MULT B, A A. Simple B. Powerful C. Something else
20 RISC versus CISC (Historically) Complex Instruction Set Computing (CISC) Large, rich instruction set More complicated instructions built into hardware Multiple clock cycles per instruction Easier for humans to reason about Reduced Instruction Set Computing (RISC) Small, highly optimized set of instructions Memory accesses are specific instructions One instruction per clock cycle Compiler: more work, more potential optimization
21 So... Which System Won? Most ISAs (after mid/late 1980 s) are RISC The ubiquitous Intel x86 is CISC Tablets and smartphones (ARM) taking over? x86 breaks down CISC assembly into multiple, RISC-like, machine language instructions Distinction between RISC and CISC is less clear Some RISC instruction sets have more instructions than some CISC sets
22 Intel x86 Family (IA-32) Intel i386 (1985) 12 MHz - 40 MHz ~300,000 transistors Component size: 1.5 µm Intel Core i7 4770k (2013) 3,500 MHz ~1,400,000,000 transistors Component size: 22 nm Everything in this family uses the same ISA (Same instructions)!
23 Assembly Programmer s View of State CPU %eax %ecx %edx %ebx %esi %edi %esp %ebp name %eip 32-bit Registers value next instr addr (PC) BUS Addresses Data Instructions address 0x x Memory value Program: data instrs stack %EFLAGS cond. codes 0xffffffff Registers: PC: Program counter (%eip) Condition codes (%EFLAGS) General Purpose (%eax - %ebp) Memory: Byte addressable array Program code and data Execution stack
24 Processor State in Registers Information about currently executing program Temporary data ( %eax - %edi ) Location of runtime stack ( %ebp, %esp ) Location of current code control point ( %eip, ) Status of recent tests %EFLAGS ( CF, ZF, SF, OF ) %eax %ecx %edx %ebx %esi %edi %esp %ebp General purpose registers Current stack top Current stack frame %eip Instruction pointer (PC) CF ZF SF OF Condition codes
25 General purpose Registers Remaining Six are for instruction operands Can store 4 byte data or address value (ex ) Register name Register value %eax 3 %ecx 5 %edx 8 %ebx %esi %edi %esp %ebp %eip %EFLAGS The low-order 2 bytes and two low-order 1 bytes of some of these can be named. %ax is the low-order 16 bits of %eax %al is the low-order 8 bits of %eax May see their use in ops involving shorts or chars %eax %ax %ah %al %ecx %cx %ch %cl %edx %dx %dh %dl %ebx %bx %bh %bl %esi %edi %esp %ebp %si %di %sp %bp
26 Types of IA32 Instructions Data movement Move values between registers and memory Example: movl Load: move data from memory to register Store: move data from register to memory
27 Data Movement Move values between memory and registers or between two registers. Program Counter (PC): Memory address of next instr 0: (Memory) Instruction Register (IR): Instruction contents (bits) 1: 2: 3: 4: Data in WE Data in WE Data in WE Data in WE 32-bit Register #0 32-bit Register #1 32-bit Register #2 32-bit Register #3 MUX MUX A L U N-1: Register File
28 Types of IA32 Instructions Data movement Move values between registers and memory Arithmetic Uses ALU to compute a value Example: addl
29 Arithmetic Use ALU to compute a value, store result in register / memory. Program Counter (PC): Memory address of next instr 0: (Memory) Instruction Register (IR): Instruction contents (bits) 1: 2: 3: 4: Data in WE Data in WE Data in WE Data in WE 32-bit Register #0 32-bit Register #1 32-bit Register #2 32-bit Register #3 MUX MUX A L U N-1: Register File
30 Types of IA32 Instructions Data movement Move values between registers and memory Arithmetic Uses ALU to compute a value Control Change PC based on ALU condition code state Example: jmp
31 Control Change PC based on ALU condition code state. Program Counter (PC): Memory address of next instr 0: (Memory) Instruction Register (IR): Instruction contents (bits) 1: 2: 3: 4: Data in WE Data in WE Data in WE Data in WE 32-bit Register #0 32-bit Register #1 32-bit Register #2 32-bit Register #3 MUX MUX A L U N-1: Register File
32 Types of IA32 Instructions Data movement Move values between registers and memory Arithmetic Uses ALU to compute a value Control Change PC based on ALU condition code state Stack / Function call (We ll cover these in detail later) Shortcut instructions for common operations
33 Addressing Modes Data movement and arithmetic instructions: Must tell CPU where to find operands, store result You can refer to a register by using %: %eax addl %ecx, %eax Add the contents of registers ecx and eax, store result in register eax.
34 Addressing Mode: Immediate Refers to a constant value, starts with $ movl $10, %eax Put the constant value 10 in register eax.
35 Addressing Mode: Memory Accessing memory requires you to specify which address you want. Put address in a register. Access with () around register name. movl (%ecx), %eax Use the address in register ecx to access memory, store result in register eax
36 Addressing Mode: Memory movl (%ecx), %eax Use the address in register ecx to access memory, store result in register eax name value %eax 0 %ecx CPU Registers 0x1A68 (Memory) 0x0: 0x4: 0x8: 0xC: 0x1A64 0x1A x1A6C 0x1A70 0xFFFFFFFF:
37 Addressing Mode: Memory movl (%ecx), %eax Use the address in register ecx to access memory, store result in register eax name %eax 0 %ecx CPU Registers value 0x1A68 1. Index into memory using the address in ecx. (Memory) 0x0: 0x4: 0x8: 0xC: 0x1A64 0x1A x1A6C 0x1A70 0xFFFFFFFF:
38 Addressing Mode: Memory movl (%ecx), %eax Use the address in register ecx to access memory, store result in register eax name %eax 42 %ecx CPU Registers value 0x1A68 2. Copy value at that address to eax. 1. Index into memory using the address in ecx. (Memory) 0x0: 0x4: 0x8: 0xC: 0x1A64 0x1A x1A6C 0x1A70 0xFFFFFFFF:
39 Addressing Mode: Displacement Like memory mode, but with constant offset Offset is often negative, relative to %ebp movl -12(%ebp), %eax Take the address in ebp, subtract 12 from it, index into memory and store the result in eax
40 Addressing Mode: Displacement movl -12(%ebp), %eax Take the address in ebp, subtract 12 from it, index into memory and store the result in eax name value %eax 0 %ecx %ebp CPU Registers 0x1A68 0x1A70 1. Access address: 0x1A70 12 = 0x1A64 0x0: 0x4: 0x8: 0xC: 0x1A x1A x1A6C 0x1A70 0xFFFFFFFF: (Memory)
41 Addressing Mode: Displacement movl -12(%ebp), %eax Take the address in ebp, subtract 12 from it, index into memory and store the result in eax name value %eax 11 %ecx %ebp CPU Registers 0x1A68 0x1A70 2. Copy value at that address to eax. 1. Access address: 0x1A70 12 = 0x1A64 0x0: 0x4: 0x8: 0xC: 0x1A x1A x1A6C 0x1A70 0xFFFFFFFF: Not this! (Memory)
42 Let s try a few examples...
43 What will memory look like after these instructions? x is 2 at %ebp-8, y is 3 at %ebp-12, z is 2 at %ebp-16 movl -16(%ebp),%eax sall $3, %eax imull $3, %eax movl -12(%ebp), %edx addl -8(%ebp), %edx addl %edx, %eax movl %eax, -8(%ebp) Registers name value %eax? %edx? %ebp 0x1270 address value 0x x x x126c 0x1270 Memory
44 What will memory look like after these instructions? x is 2 at %ebp-8, y is 3 at %ebp-12, z is 2 at %ebp-16 movl -16(%ebp),%eax sall $3, %eax imull $3, %eax movl -12(%ebp), %edx addl -8(%ebp), %edx addl %edx, %eax movl %eax, -8(%ebp) D: address value 0x x x x126c 0x1270 address value address value 0x x A: 0x B: 0x C: 0x x x126c 0x126c 0x1270 0x1270 address value 0x x x x126c 0x1270
45 Solution x is 2 at %ebp-8, y is 3 at %ebp-12, z is 2 at %ebp-16 movl -16(%ebp), %eax sall $3, %eax imull $3, %eax movl -12(%ebp), %edx addl -8(%ebp), %edx addl %edx, %eax movl %eax, -8(%ebp) Equivalent C code: x = z*24 + y + x; name %eax %edx value 0x x x %ebp 0x1270 0x126c 0x1270
46 Solution x is 2 at %ebp-8, y is 3 at %ebp-12, z is 2 at %ebp-16 movl -16(%ebp), %eax # R[%eax] z (2) sall $3, %eax # R[%eax] z<<3 (16) imull $3, %eax # R[%eax] 16*3 (48) movl -12(%ebp), %edx # R[%edx] y (3) addl -8(%ebp), %edx # R[%edx] y + x (5) addl %edx, %eax # R[%eax] 48+5 (53) movl %eax, -8(%ebp) # M[R[%ebp]+8] 5 (x=53) Z*24 Equivalent C code: x = z*24 + y + x; name %eax %edx value 0x z 0x y 0x x %ebp 0x1270 0x126c 0x1270
47 REMINDER All labs will meet in SCI 252 (the robot lab) tomorrow.
CS 31: Intro to Systems ISAs and Assembly. Kevin Webb Swarthmore College February 9, 2016
CS 31: Intro to Systems ISAs and Assembly Kevin Webb Swarthmore College February 9, 2016 Reading Quiz Overview How to directly interact with hardware Instruction set architecture (ISA) Interface between
More informationCS 31: Intro to Systems ISAs and Assembly. Kevin Webb Swarthmore College September 25, 2018
CS 31: Intro to Systems ISAs and Assembly Kevin Webb Swarthmore College September 25, 2018 Overview How to directly interact with hardware Instruction set architecture (ISA) Interface between programmer
More informationInstruction Set Architectures
Instruction Set Architectures ISAs Brief history of processors and architectures C, assembly, machine code Assembly basics: registers, operands, move instructions 1 What should the HW/SW interface contain?
More informationMachine-level Representation of Programs. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University
Machine-level Representation of Programs Jin-Soo Kim (jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Program? 짬뽕라면 준비시간 :10 분, 조리시간 :10 분 재료라면 1개, 스프 1봉지, 오징어
More informationInstruction Set Architectures
Instruction Set Architectures! ISAs! Brief history of processors and architectures! C, assembly, machine code! Assembly basics: registers, operands, move instructions 1 What should the HW/SW interface
More informationLecture 15 Intel Manual, Vol. 1, Chapter 3. Fri, Mar 6, Hampden-Sydney College. The x86 Architecture. Robb T. Koether. Overview of the x86
Lecture 15 Intel Manual, Vol. 1, Chapter 3 Hampden-Sydney College Fri, Mar 6, 2009 Outline 1 2 Overview See the reference IA-32 Intel Software Developer s Manual Volume 1: Basic, Chapter 3. Instructions
More informationThe x86 Architecture
The x86 Architecture Lecture 24 Intel Manual, Vol. 1, Chapter 3 Robb T. Koether Hampden-Sydney College Fri, Mar 20, 2015 Robb T. Koether (Hampden-Sydney College) The x86 Architecture Fri, Mar 20, 2015
More informationTurning C into Object Code Code in files p1.c p2.c Compile with command: gcc -O p1.c p2.c -o p Use optimizations (-O) Put resulting binary in file p
Turning C into Object Code Code in files p1.c p2.c Compile with command: gcc -O p1.c p2.c -o p Use optimizations (-O) Put resulting binary in file p text C program (p1.c p2.c) Compiler (gcc -S) text Asm
More informationCS241 Computer Organization Spring 2015 IA
CS241 Computer Organization Spring 2015 IA-32 2-10 2015 Outline! Review HW#3 and Quiz#1! More on Assembly (IA32) move instruction (mov) memory address computation arithmetic & logic instructions (add,
More informationMACHINE-LEVEL PROGRAMMING I: BASICS COMPUTER ARCHITECTURE AND ORGANIZATION
MACHINE-LEVEL PROGRAMMING I: BASICS COMPUTER ARCHITECTURE AND ORGANIZATION Today: Machine Programming I: Basics History of Intel processors and architectures C, assembly, machine code Assembly Basics:
More informationadministrivia today start assembly probably won t finish all these slides Assignment 4 due tomorrow any questions?
administrivia today start assembly probably won t finish all these slides Assignment 4 due tomorrow any questions? exam on Wednesday today s material not on the exam 1 Assembly Assembly is programming
More informationX86 Addressing Modes Chapter 3" Review: Instructions to Recognize"
X86 Addressing Modes Chapter 3" Review: Instructions to Recognize" 1 Arithmetic Instructions (1)! Two Operand Instructions" ADD Dest, Src Dest = Dest + Src SUB Dest, Src Dest = Dest - Src MUL Dest, Src
More informationCSE2421 FINAL EXAM SPRING Name KEY. Instructions: Signature
CSE2421 FINAL EXAM SPRING 2013 Name KEY Instructions: This is a closed-book, closed-notes, closed-neighbor exam. Only a writing utensil is needed for this exam. No calculators allowed. If you need to go
More informationCSC 2400: Computer Systems. Towards the Hardware: Machine-Level Representation of Programs
CSC 2400: Computer Systems Towards the Hardware: Machine-Level Representation of Programs Towards the Hardware High-level language (Java) High-level language (C) assembly language machine language (IA-32)
More informationModule 3 Instruction Set Architecture (ISA)
Module 3 Instruction Set Architecture (ISA) I S A L E V E L E L E M E N T S O F I N S T R U C T I O N S I N S T R U C T I O N S T Y P E S N U M B E R O F A D D R E S S E S R E G I S T E R S T Y P E S O
More informationCSC 8400: Computer Systems. Machine-Level Representation of Programs
CSC 8400: Computer Systems Machine-Level Representation of Programs Towards the Hardware High-level language (Java) High-level language (C) assembly language machine language (IA-32) 1 Compilation Stages
More informationIntroduction to IA-32. Jo, Heeseung
Introduction to IA-32 Jo, Heeseung IA-32 Processors Evolutionary design Starting in 1978 with 8086 Added more features as time goes on Still support old features, although obsolete Totally dominate computer
More informationINTRODUCTION TO IA-32. Jo, Heeseung
INTRODUCTION TO IA-32 Jo, Heeseung IA-32 PROCESSORS Evolutionary design Starting in 1978 with 8086 Added more features as time goes on Still support old features, although obsolete Totally dominate computer
More informationAssembly level Programming. 198:211 Computer Architecture. (recall) Von Neumann Architecture. Simplified hardware view. Lecture 10 Fall 2012
19:211 Computer Architecture Lecture 10 Fall 20 Topics:Chapter 3 Assembly Language 3.2 Register Transfer 3. ALU 3.5 Assembly level Programming We are now familiar with high level programming languages
More informationCredits and Disclaimers
Credits and Disclaimers 1 The examples and discussion in the following slides have been adapted from a variety of sources, including: Chapter 3 of Computer Systems 2 nd Edition by Bryant and O'Hallaron
More informationEXPERIMENT WRITE UP. LEARNING OBJECTIVES: 1. Get hands on experience with Assembly Language Programming 2. Write and debug programs in TASM/MASM
EXPERIMENT WRITE UP AIM: Assembly language program for 16 bit BCD addition LEARNING OBJECTIVES: 1. Get hands on experience with Assembly Language Programming 2. Write and debug programs in TASM/MASM TOOLS/SOFTWARE
More informationPractical Malware Analysis
Practical Malware Analysis Ch 4: A Crash Course in x86 Disassembly Revised 1-16-7 Basic Techniques Basic static analysis Looks at malware from the outside Basic dynamic analysis Only shows you how the
More informationMACHINE-LEVEL PROGRAMMING I: BASICS
MACHINE-LEVEL PROGRAMMING I: BASICS CS 429H: SYSTEMS I Instructor: Emmett Witchel Today: Machine Programming I: Basics History of Intel processors and architectures C, assembly, machine code Assembly Basics:
More informationCS 31: Intro to Systems Functions and the Stack. Martin Gagne Swarthmore College February 23, 2016
CS 31: Intro to Systems Functions and the Stack Martin Gagne Swarthmore College February 23, 2016 Reminders Late policy: you do not have to send me an email to inform me of a late submission before the
More informationWe can study computer architectures by starting with the basic building blocks. Adders, decoders, multiplexors, flip-flops, registers,...
COMPUTER ARCHITECTURE II: MICROPROCESSOR PROGRAMMING We can study computer architectures by starting with the basic building blocks Transistors and logic gates To build more complex circuits Adders, decoders,
More informationSoftware. Hardware. x86 basics. ISA View. a brief history of x86 10/6/15. Program, Application. Programming Language. Compiler/Interpreter
x6 basics ISA context and x6 history Translation: Compile C à machine code Disassemble machine code x6 Basics: isters Data movement instructions Memory addressing modes Arithmetic instructions 1 Software
More informationComplex Instruction Set Computer (CISC)
Introduction ti to IA-32 IA-32 Processors Evolutionary design Starting in 1978 with 886 Added more features as time goes on Still support old features, although obsolete Totally dominate computer market
More informationCS165 Computer Security. Understanding low-level program execution Oct 1 st, 2015
CS165 Computer Security Understanding low-level program execution Oct 1 st, 2015 A computer lets you make more mistakes faster than any invention in human history - with the possible exceptions of handguns
More informationx86 Assembly Tutorial COS 318: Fall 2017
x86 Assembly Tutorial COS 318: Fall 2017 Project 1 Schedule Design Review: Monday 9/25 Sign up for 10-min slot from 3:00pm to 7:00pm Complete set up and answer posted questions (Official) Precept: Monday
More informationCarnegie Mellon. 5 th Lecture, Jan. 31, Instructors: Todd C. Mowry & Anthony Rowe
Machine Level Programming I: Basics 15 213/18 213: 213: Introduction to Computer Systems 5 th Lecture, Jan. 31, 2012 Instructors: Todd C. Mowry & Anthony Rowe 1 Today: Machine Programming gi: Basics History
More informationReverse Engineering II: Basics. Gergely Erdélyi Senior Antivirus Researcher
Reverse Engineering II: Basics Gergely Erdélyi Senior Antivirus Researcher Agenda Very basics Intel x86 crash course Basics of C Binary Numbers Binary Numbers 1 Binary Numbers 1 0 1 1 Binary Numbers 1
More informationCredits and Disclaimers
Credits and Disclaimers 1 The examples and discussion in the following slides have been adapted from a variety of sources, including: Chapter 3 of Computer Systems 3 nd Edition by Bryant and O'Hallaron
More informationToday: Machine Programming I: Basics
Today: Machine Programming I: Basics History of Intel processors and architectures C, assembly, machine code Assembly Basics: Registers, operands, move Intro to x86-64 1 Intel x86 Processors Totally dominate
More informationReverse Engineering II: The Basics
Reverse Engineering II: The Basics Gergely Erdélyi Senior Manager, Anti-malware Research Protecting the irreplaceable f-secure.com Binary Numbers 1 0 1 1 - Nibble B 1 0 1 1 1 1 0 1 - Byte B D 1 0 1 1 1
More informationProcess Layout and Function Calls
Process Layout and Function Calls CS 6 Spring 07 / 8 Process Layout in Memory Stack grows towards decreasing addresses. is initialized at run-time. Heap grow towards increasing addresses. is initialized
More informationHardware and Software Architecture. Chapter 2
Hardware and Software Architecture Chapter 2 1 Basic Components The x86 processor communicates with main memory and I/O devices via buses Data bus for transferring data Address bus for the address of a
More informationx86 architecture et similia
x86 architecture et similia 1 FREELY INSPIRED FROM CLASS 6.828, MIT A full PC has: PC architecture 2 an x86 CPU with registers, execution unit, and memory management CPU chip pins include address and data
More informationMODE (mod) FIELD CODES. mod MEMORY MODE: 8-BIT DISPLACEMENT MEMORY MODE: 16- OR 32- BIT DISPLACEMENT REGISTER MODE
EXERCISE 9. Determine the mod bits from Figure 7-24 and write them in Table 7-7. MODE (mod) FIELD CODES mod 00 01 10 DESCRIPTION MEMORY MODE: NO DISPLACEMENT FOLLOWS MEMORY MODE: 8-BIT DISPLACEMENT MEMORY
More informationThe von Neumann Machine
The von Neumann Machine 1 1945: John von Neumann Wrote a report on the stored program concept, known as the First Draft of a Report on EDVAC also Alan Turing Konrad Zuse Eckert & Mauchly The basic structure
More informationMachine Level Programming I: Basics
Carnegie Mellon Machine Level Programming I: Basics Kai Shen Why do I care for machine code? Chances are, you ll never write programs in machine code Compilers are much better & more patient than you are
More informationUMBC. A register, an immediate or a memory address holding the values on. Stores a symbolic name for the memory location that it represents.
Intel Assembly Format of an assembly instruction: LABEL OPCODE OPERANDS COMMENT DATA1 db 00001000b ;Define DATA1 as decimal 8 START: mov eax, ebx ;Copy ebx to eax LABEL: Stores a symbolic name for the
More informationAssembly Programmer s View Lecture 4A Machine-Level Programming I: Introduction
Assembly Programmer s View Lecture 4A Machine-Level Programming I: Introduction E I P CPU isters Condition Codes Addresses Data Instructions Memory Object Code Program Data OS Data Topics Assembly Programmer
More informationComputer Systems Architecture I. CSE 560M Lecture 3 Prof. Patrick Crowley
Computer Systems Architecture I CSE 560M Lecture 3 Prof. Patrick Crowley Plan for Today Announcements Readings are extremely important! No class meeting next Monday Questions Commentaries A few remaining
More informationLab 2: Introduction to Assembly Language Programming
COE 205 Lab Manual Lab 2: Introduction to Assembly Language Programming - page 16 Lab 2: Introduction to Assembly Language Programming Contents 2.1. Intel IA-32 Processor Architecture 2.2. Basic Program
More informationX86 Review Process Layout, ISA, etc. CS642: Computer Security. Drew Davidson
X86 Review Process Layout, ISA, etc. CS642: Computer Security Drew Davidson davidson@cs.wisc.edu From Last Time ACL-based permissions (UNIX style) Read, Write, execute can be restricted on users and groups
More informationThe Instruction Set. Chapter 5
The Instruction Set Architecture Level(ISA) Chapter 5 1 ISA Level The ISA level l is the interface between the compilers and the hardware. (ISA level code is what a compiler outputs) 2 Memory Models An
More informationSystems I. Machine-Level Programming I: Introduction
Systems I Machine-Level Programming I: Introduction Topics Assembly Programmerʼs Execution Model Accessing Information Registers IA32 Processors Totally Dominate General Purpose CPU Market Evolutionary
More informationCSCE 212H, Spring 2008 Lab Assignment 3: Assembly Language Assigned: Feb. 7, Due: Feb. 14, 11:59PM
CSCE 212H, Spring 2008 Lab Assignment 3: Assembly Language Assigned: Feb. 7, Due: Feb. 14, 11:59PM February 7, 2008 1 Overview The purpose of this assignment is to introduce you to the assembly language
More informationInstruction Set Architectures
Instruction Set Architectures Computer Systems: Section 4.1 Suppose you built a computer What Building Blocks would you use? Arithmetic Logic Unit (ALU) OP1 OP2 OPERATION ALU RES ALU + Registers R0: 0x0000
More informationAccess. Young W. Lim Fri. Young W. Lim Access Fri 1 / 18
Access Young W. Lim 2017-01-27 Fri Young W. Lim Access 2017-01-27 Fri 1 / 18 Outline 1 Introduction References IA32 Operand Forms Data Movement Instructions Young W. Lim Access 2017-01-27 Fri 2 / 18 Based
More informationBinghamton University. CS-220 Spring x86 Assembler. Computer Systems: Sections
x86 Assembler Computer Systems: Sections 3.1-3.5 Disclaimer I am not an x86 assembler expert. I have never written an x86 assembler program. (I am proficient in IBM S/360 Assembler and LC3 Assembler.)
More informationASSEMBLY II: CONTROL FLOW. Jo, Heeseung
ASSEMBLY II: CONTROL FLOW Jo, Heeseung IA-32 PROCESSOR STATE Temporary data Location of runtime stack %eax %edx %ecx %ebx %esi %edi %esp %ebp General purpose registers Current stack top Current stack frame
More informationx86 assembly CS449 Fall 2017
x86 assembly CS449 Fall 2017 x86 is a CISC CISC (Complex Instruction Set Computer) e.g. x86 Hundreds of (complex) instructions Only a handful of registers RISC (Reduced Instruction Set Computer) e.g. MIPS
More informationCS241 Computer Organization Spring Introduction to Assembly
CS241 Computer Organization Spring 2015 Introduction to Assembly 2-05 2015 Outline! Rounding floats: round-to-even! Introduction to Assembly (IA32) move instruction (mov) memory address computation arithmetic
More informationCS429: Computer Organization and Architecture
CS429: Computer Organization and Architecture Warren Hunt, Jr. and Bill Young Department of Computer Sciences University of Texas at Austin Last updated: October 1, 2014 at 12:03 CS429 Slideset 6: 1 Topics
More informationToday: Machine Programming I: Basics. Machine Level Programming I: Basics. Intel x86 Processors. Intel x86 Evolution: Milestones
Today: Machine Programming I: Basics Machine Level Programming I: Basics 15 213/1 213: Introduction to Computer Systems 5 th Lecture, Jan 29, 2013 History of Intel processors and architectures C, assembly,
More informationCISC 360. Machine-Level Programming I: Introduction Sept. 18, 2008
CISC 360 Machine-Level Programming I: Introduction Sept. 18, 2008 Topics Assembly Programmerʼs Execution Model Accessing Information Registers Memory Arithmetic operations IA32 Processors Totally Dominate
More informationCompiler Construction D7011E
Compiler Construction D7011E Lecture 8: Introduction to code generation Viktor Leijon Slides largely by Johan Nordlander with material generously provided by Mark P. Jones. 1 What is a Compiler? Compilers
More informationAccess. Young W. Lim Sat. Young W. Lim Access Sat 1 / 19
Access Young W. Lim 2017-06-10 Sat Young W. Lim Access 2017-06-10 Sat 1 / 19 Outline 1 Introduction References IA32 Operand Forms Data Movement Instructions Data Movement Examples Young W. Lim Access 2017-06-10
More informationProgram Exploitation Intro
Program Exploitation Intro x86 Assembly 04//2018 Security 1 Univeristà Ca Foscari, Venezia What is Program Exploitation "Making a program do something unexpected and not planned" The right bugs can be
More informationMachine-Level Programming I: Introduction Jan. 30, 2001
15-213 Machine-Level Programming I: Introduction Jan. 30, 2001 Topics Assembly Programmer s Execution Model Accessing Information Registers Memory Arithmetic operations IA32 Processors Totally Dominate
More informationLast Time: Floating Point. Intel x86 Processors. Lecture 4: Machine Basics Computer Architecture and Systems Programming ( )
Last Time: Floating Point Lecture : Machine Basics Computer Architecture and Systems Programming (252-0061-00) Timothy Roscoe Herbstsemester 2012 Fractional binary numbers IEEE floating point standard:
More informationAddressing Modes on the x86
Addressing Modes on the x86 register addressing mode mov ax, ax, mov ax, bx mov ax, cx mov ax, dx constant addressing mode mov ax, 25 mov bx, 195 mov cx, 2056 mov dx, 1000 accessing data in memory There
More informationMachine-Level Programming Introduction
Machine-Level Programming Introduction Today Assembly programmer s exec model Accessing information Arithmetic operations Next time More of the same Fabián E. Bustamante, Spring 2007 IA32 Processors Totally
More informationAssembly II: Control Flow. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University
Assembly II: Control Flow Jin-Soo Kim (jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu IA-32 Processor State %eax %edx Temporary data Location of runtime stack
More informationx86 assembly CS449 Spring 2016
x86 assembly CS449 Spring 2016 CISC vs. RISC CISC [Complex instruction set Computing] - larger, more feature-rich instruction set (more operations, addressing modes, etc.). slower clock speeds. fewer general
More informationW4118: PC Hardware and x86. Junfeng Yang
W4118: PC Hardware and x86 Junfeng Yang A PC How to make it do something useful? 2 Outline PC organization x86 instruction set gcc calling conventions PC emulation 3 PC board 4 PC organization One or more
More informationAdvanced Microprocessors
Advanced Microprocessors Notes #2 Software Architecture & Instruction Set Architecture Part 1 EE 467/567 Winter 2012 by Avinash Kodi SWA.1 Background Materials Textbook: 2.1, 2.2, 3.1 Other: IA-32 Intel
More informationThe Hardware/Software Interface CSE351 Spring 2013
The Hardware/Software Interface CSE351 Spring 2013 x86 Programming II 2 Today s Topics: control flow Condition codes Conditional and unconditional branches Loops 3 Conditionals and Control Flow A conditional
More informationAssembly Language: IA-32 Instructions
Assembly Language: IA-32 Instructions 1 Goals of this Lecture Help you learn how to: Manipulate data of various sizes Leverage more sophisticated addressing modes Use condition codes and jumps to change
More informationThe von Neumann Machine
The von Neumann Machine 1 1945: John von Neumann Wrote a report on the stored program concept, known as the First Draft of a Report on EDVAC also Alan Turing Konrad Zuse Eckert & Mauchly The basic structure
More informationT Reverse Engineering Malware: Static Analysis I
T-110.6220 Reverse Engineering Malware: Static Analysis I Antti Tikkanen, F-Secure Corporation Protecting the irreplaceable f-secure.com Representing Data 2 Binary Numbers 1 0 1 1 Nibble B 1 0 1 1 1 1
More informationMachine Programming 2: Control flow
Machine Programming 2: Control flow CS61, Lecture 4 Prof. Stephen Chong September 13, 2011 Announcements Assignment 1 due today, 11:59pm Hand in at front during break or email it to cs61- staff@seas.harvard.edu
More informationMeet & Greet! Come hang out with your TAs and Fellow Students (& eat free insomnia cookies) When : TODAY!! 5-6 pm Where : 3rd Floor Atrium, CIT
Meet & Greet! Come hang out with your TAs and Fellow Students (& eat free insomnia cookies) When : TODAY!! 5-6 pm Where : 3rd Floor Atrium, CIT CS33 Intro to Computer Systems XI 1 Copyright 2017 Thomas
More informationSungkyunkwan University
- 2 - Complete addressing mode, address computation (leal) Arithmetic operations Control: Condition codes Conditional branches While loops - 3 - Most General Form D(Rb,Ri,S) Mem[ Reg[ R b ] + S Reg[ R
More informationComputer Processors. Part 2. Components of a Processor. Execution Unit The ALU. Execution Unit. The Brains of the Box. Processors. Execution Unit (EU)
Part 2 Computer Processors Processors The Brains of the Box Computer Processors Components of a Processor The Central Processing Unit (CPU) is the most complex part of a computer In fact, it is the computer
More informationMachine-Level Programming II: Control and Arithmetic
Machine-Level Programming II: Control and Arithmetic CSCI 2400: Computer Architecture Instructor: David Ferry Slides adapted from Bryant & O Hallaron s slides 1 Today Complete addressing mode, address
More informationRepresentation of Information
Representation of Information CS61, Lecture 2 Prof. Stephen Chong September 6, 2011 Announcements Assignment 1 released Posted on http://cs61.seas.harvard.edu/ Due one week from today, Tuesday 13 Sept
More informationAssembly Language Each statement in an assembly language program consists of four parts or fields.
Chapter 3: Addressing Modes Assembly Language Each statement in an assembly language program consists of four parts or fields. The leftmost field is called the label. - used to identify the name of a memory
More informationAssembler Programming. Lecture 2
Assembler Programming Lecture 2 Lecture 2 8086 family architecture. From 8086 to Pentium4. Registers, flags, memory organization. Logical, physical, effective address. Addressing modes. Processor Processor
More informationCSCI 192 Engineering Programming 2. Assembly Language
CSCI 192 Engineering Programming 2 Week 5 Assembly Language Lecturer: Dr. Markus Hagenbuchner Slides by: Igor Kharitonenko and Markus Hagenbuchner Room 3.220 markus@uow.edu.au UOW 2010 24/08/2010 1 C Compilation
More informationThe x86 Architecture. ICS312 - Spring 2018 Machine-Level and Systems Programming. Henri Casanova
The x86 Architecture ICS312 - Spring 2018 Machine-Level and Systems Programming Henri Casanova (henric@hawaii.edu) The 80x86 Architecture! To learn assembly programming we need to pick a processor family
More informationRISC I from Berkeley. 44k Transistors 1Mhz 77mm^2
The Case for RISC RISC I from Berkeley 44k Transistors 1Mhz 77mm^2 2 MIPS: A Classic RISC ISA Instructions 4 bytes (32 bits) 4-byte aligned Instructions operate on memory and registers Memory Data types
More informationCS642: Computer Security
X86 Review Process Layout, ISA, etc. CS642: Computer Security Drew Davidson davidson@cs.wisc.edu From Last Week ACL- based permissions (UNIX style) Read, Write, execute can be restricted on users and groups
More informationAssembly Language. Lecture 2 - x86 Processor Architecture. Ahmed Sallam
Assembly Language Lecture 2 - x86 Processor Architecture Ahmed Sallam Introduction to the course Outcomes of Lecture 1 Always check the course website Don t forget the deadline rule!! Motivations for studying
More informationX86 Assembly -Data II:1
X86 Assembly -Data II:1 Administrivia HW1 due tonight Paper to locker, file to blackboard Lab1 Check scoreboard Quiz0 Remind me if you don t see in the lecture slide online Reading: chapter 3 now! II:2
More informationWhat is a Compiler? Compiler Construction SMD163. Why Translation is Needed: Know your Target: Lecture 8: Introduction to code generation
Compiler Construction SMD163 Lecture 8: Introduction to code generation Viktor Leijon & Peter Jonsson with slides by Johan Nordlander Contains material generously provided by Mark P. Jones What is a Compiler?
More informationCMSC Lecture 03. UMBC, CMSC313, Richard Chang
CMSC Lecture 03 Moore s Law Evolution of the Pentium Chip IA-32 Basic Execution Environment IA-32 General Purpose Registers Hello World in Linux Assembly Language Addressing Modes UMBC, CMSC313, Richard
More informationAssembly Language for Intel-Based Computers, 4 th Edition. Chapter 2: IA-32 Processor Architecture Included elements of the IA-64 bit
Assembly Language for Intel-Based Computers, 4 th Edition Kip R. Irvine Chapter 2: IA-32 Processor Architecture Included elements of the IA-64 bit Slides prepared by Kip R. Irvine Revision date: 09/25/2002
More informationMachine-Level Programming II: Control Flow
Machine-Level Programming II: Control Flow Today Condition codes Control flow structures Next time Procedures Fabián E. Bustamante, Spring 2010 Processor state (ia32, partial) Information about currently
More informationSystem calls and assembler
System calls and assembler Michal Sojka sojkam1@fel.cvut.cz ČVUT, FEL License: CC-BY-SA 4.0 System calls (repetition from lectures) A way for normal applications to invoke operating system (OS) kernel's
More informationMachine Level Programming I: Basics. Credits to Randy Bryant & Dave O Hallaron
Machine Level Programming I: Basics Lecture 3, Feb. 24, 2011 Alexandre David Credits to Randy Bryant & Dave O Hallaron from Carnegie Mellon 1 Today: Machine Programming I: Basics History of Intel processors
More informationCS241 Computer Organization Spring Addresses & Pointers
CS241 Computer Organization Spring 2015 Addresses & Pointers 2-24 2015 Outline! Addresses & Pointers! leal - load effective address! Condition Codes & Jumps! conditional statements: if-then-else! conditional
More informationInterfacing Compiler and Hardware. Computer Systems Architecture. Processor Types And Instruction Sets. What Instructions Should A Processor Offer?
Interfacing Compiler and Hardware Computer Systems Architecture FORTRAN 90 program C++ program Processor Types And Sets FORTRAN 90 Compiler C++ Compiler set level Hardware 1 2 What s Should A Processor
More informationBasic Execution Environment
Basic Execution Environment 3 CHAPTER 3 BASIC EXECUTION ENVIRONMENT This chapter describes the basic execution environment of an Intel Architecture processor as seen by assembly-language programmers.
More informationAssembly Language Lab # 9
Faculty of Engineering Computer Engineering Department Islamic University of Gaza 2011 Assembly Language Lab # 9 Stacks and Subroutines Eng. Doaa Abu Jabal Assembly Language Lab # 9 Stacks and Subroutines
More informationCMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 03, SPRING 2013
CMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 03, SPRING 2013 TOPICS TODAY Moore s Law Evolution of Intel CPUs IA-32 Basic Execution Environment IA-32 General Purpose Registers
More informationMachine-Level Programming II: Arithmetic & Control. Complete Memory Addressing Modes
Machine-Level Programming II: Arithmetic & Control CS-281: Introduction to Computer Systems Instructor: Thomas C. Bressoud 1 Complete Memory Addressing Modes Most General Form D(Rb,Ri,S)Mem[Reg[Rb]+S*Reg[Ri]+
More informationThe course that gives CMU its Zip! Machine-Level Programming I: Introduction Sept. 10, 2002
15-213 The course that gives CMU its Zip! Machine-Level Programming I: Introduction Sept. 10, 2002 Topics Assembly Programmer s Execution Model Accessing Information Registers Memory Arithmetic operations
More informationSecond Part of the Course
CSC 2400: Computer Systems Towards the Hardware 1 Second Part of the Course Toward the hardware High-level language (C) assembly language machine language (IA-32) 2 High-Level Language g Make programming
More information