Machine Programming II: Instruc8ons

Size: px
Start display at page:

Download "Machine Programming II: Instruc8ons"

Transcription

1 Machine Programming II: Instrucons Move instrucons, registers, and operands Complete addressing mode, address computaon (leal) Arithmec operaons (including some x6 6 instrucons) Condion codes Control, uncondional and condional branches While loops CSE351 Inaugural Edion Spring Integer Registers (IA32) %ax %cx %dx %bx %si %di %sp %bp %ah %ch %dh %bh %al %cl %dl %bl 16 bit virtual registers (backwards compability) general purpose accumulate counter data base source index destination index stack pointer base pointer Origin (mostly obsolete) CSE351 Inaugural Edion Spring

2 Moving Data: IA32 Moving Data movx Source, Dest x is one of b, w, l movl Source, Dest: Move byte long word movw Source, Dest: Move 2 byte word movb Source, Dest: Move 1 byte byte Lots of these in typical code CSE351 Inaugural Edion Spring Moving Data: IA32 Moving Data movl Source, Dest: Operand Types Immediate: Constant integer data Example: $0x00, $-533 Like C constant, but prefixed with $ Encoded with 1, 2, or bytes Register: One of integer registers Example:, But and reserved for special use Others have special uses for parkcular instruckons Memory: consecukve bytes of memory at address given by register Simplest example: () Various other address modes CSE351 Inaugural Edion Spring 2010

3 movl Operand Combinaons Source Dest Src,Dest C Analog Imm Reg Mem movl $0x, temp = 0x; movl $-17,() *p = -17; movl Reg Reg Mem movl, movl,() temp2 = temp1; *p = temp; Mem Reg movl (), temp = *p; Cannot do memory memory transfer with a single instruc<on CSE351 Inaugural Edion Spring Simple Memory Addressing Modes Normal (R) Mem[Reg[R]] Register R specifies memory address movl (), Displacement D(R) Mem[Reg[R]+D] Register R specifies start of memory region Constant displacement D specifies offset movl (), CSE351 Inaugural Edion Spring

4 Using Simple Addressing Modes void swap(int *xp, int *yp) int t0 = *xp; int t1 = *yp; *xp = t1; *yp = t0; swap: pushl movl, pushl movl (), movl (), movl (), movl (), movl,() movl,() movl -(), movl, popl ret Set Up Body Finish CSE351 Inaugural Edion Spring Using Simple Addressing Modes void swap(int *xp, int *yp) int t0 = *xp; int t1 = *yp; *xp = t1; *yp = t0; swap: pushl movl, pushl movl (), movl (), movl (), movl (), movl,() movl,() movl -(), movl, popl ret Set Up Body Finish CSE351 Inaugural Edion Spring 2010

5 Understanding Swap void swap(int *xp, int *yp) int t0 = *xp; int t1 = *yp; *xp = t1; *yp = t0; Register Value yp xp t1 t0 0 - yp xp Old Old Stack (in memory) movl (), # ecx = yp movl (), # edx = xp movl (), # eax = *yp (t1) movl (), # ebx = *xp (t0) movl,() # *xp = eax movl,() # *yp = ebx CSE351 Inaugural Edion Spring Understanding Swap yp xp 0 movl (), # ecx = yp movl (), # edx = xp movl (), # eax = *yp (t1) movl (), # ebx = *xp (t0) movl,() # *xp = eax movl,() # *yp = ebx Address 0x11c 0x11 0x11 0x110 0x10c 0x10 CSE351 Inaugural Edion Spring

6 Understanding Swap yp xp 0 movl (), # ecx = yp movl (), # edx = xp movl (), # eax = *yp (t1) movl (), # ebx = *xp (t0) movl,() # *xp = eax movl,() # *yp = ebx Address 0x11c 0x11 0x11 0x110 0x10c 0x10 CSE351 Inaugural Edion Spring Understanding Swap yp xp Address 0x11c 0x11 0x11 0x110 0x10c 0x10 movl (), # ecx = yp movl (), # edx = xp movl (), # eax = *yp (t1) movl (), # ebx = *xp (t0) movl,() # *xp = eax movl,() # *yp = ebx CSE351 Inaugural Edion Spring 2010

7 Understanding Swap 56 yp xp Address 0x11c 0x11 0x11 0x110 0x10c 0x10 movl (), # ecx = yp movl (), # edx = xp movl (), # eax = *yp (t1) movl (), # ebx = *xp (t0) movl,() # *xp = eax movl,() # *yp = ebx CSE351 Inaugural Edion Spring Understanding Swap 56 3 yp xp Address 0x11c 0x11 0x11 0x110 0x10c 0x10 movl (), # ecx = yp movl (), # edx = xp movl (), # eax = *yp (t1) movl (), # ebx = *xp (t0) movl,() # *xp = eax movl,() # *yp = ebx CSE351 Inaugural Edion Spring

8 Understanding Swap yp xp Address 0x11c 0x11 0x11 0x110 0x10c 0x10 movl (), # ecx = yp movl (), # edx = xp movl (), # eax = *yp (t1) movl (), # ebx = *xp (t0) movl,() # *xp = eax movl,() # *yp = ebx CSE351 Inaugural Edion Spring Understanding Swap 56 3 yp xp Address 0x11c 0x11 0x11 0x110 0x10c 0x10 movl (), # ecx = yp movl (), # edx = xp movl (), # eax = *yp (t1) movl (), # ebx = *xp (t0) movl,() # *xp = eax movl,() # *yp = ebx CSE351 Inaugural Edion Spring

9 Complete Memory Addressing Modes Most General Form D(Rb,Ri,S) Mem[Reg[Rb]+S*Reg[Ri]+ D] D: Constant displacement 1, 2, or bytes Rb: Base register: Any of integer registers Ri: Index register: Any, except for Unlikely you d use, either S: Scale: 1, 2,, or (why these numbers?) Special Cases (Rb,Ri) Mem[Reg[Rb]+Reg[Ri]] D(Rb,Ri) Mem[Reg[Rb]+Reg[Ri]+D] (Rb,Ri,S) Mem[Reg[Rb]+S*Reg[Ri]] CSE351 Inaugural Edion Spring Address Computaon Examples 0xf000 Expression Address Computaon Address 0x() (,) (,,) 0x0(,,2) CSE351 Inaugural Edion Spring

10 Address Computaon Examples 0xf000 Expression Address Computaon Address 0x() 0xf x 0xf00 (,) 0xf xf100 (,,) 0xf000 + * 0xf00 0x0(,,2) 2*0xf x0 0x1e00 CSE351 Inaugural Edion Spring Address Computaon Instrucon leal Src,Dest Src is address mode expression Set Dest to address denoted by expression Uses CompuKng addresses without a memory reference E.g., translakon of p = &x[i]; CompuKng arithmekc expressions of the form x + k*i k = 1, 2,, or CSE351 Inaugural Edion Spring

11 Some Arithmec Operaons Two Operand Instrucons: Format Computa<on addl Src,Dest Dest = Dest + Src subl Src,Dest Dest = Dest - Src imull Src,Dest Dest = Dest * Src sall Src,Dest Dest = Dest << Src Also called shll sarl Src,Dest Dest = Dest >> Src Arithme<c shrl Src,Dest Dest = Dest >> Src Logical xorl Src,Dest Dest = Dest ^ Src andl Src,Dest Dest = Dest & Src orl Src,Dest Dest = Dest Src No disncon between signed and unsigned int (why?) CSE351 Inaugural Edion Spring Some Arithmec Operaons One Operand Instrucons incl Dest Dest = Dest + 1 decl Dest Dest = Dest - 1 negl Dest Dest = -Dest notl Dest Dest = ~Dest See book for more instrucons CSE351 Inaugural Edion Spring

12 Using leal for Arithmec Expressions int arith (int x, int y, int z) int t1 = x+y; int t2 = z+t1; int t3 = x+; int t = y * ; int t5 = t3 + t; int rval = t2 * t5; arith: pushl movl, movl (), movl (), leal (,), leal (,,2), sall $, addl 16(), leal (,), imull, movl, popl ret Set Up Body Finish CSE351 Inaugural Edion Spring Understanding arith int arith (int x, int y, int z) int t1 = x+y; int t2 = z+t1; int t3 = x+; int t = y * ; int t5 = t3 + t; int rval = t2 * t5; 16 0 z y x Old Stack movl (), # eax = x movl (), # edx = y leal (,), # What does each of ecx = x+y (t1) leal (,,2), # edx = 3*y sall $, # edx these instrucons = *y (t) addl 16(), # ecx = mean? z+t1 (t2) leal (,), # eax = +t+x (t5) imull, # eax = t5*t2 (rval) CSE351 Inaugural Edion Spring

13 Understanding arith int arith (int x, int y, int z) int t1 = x+y; int t2 = z+t1; int t3 = x+; int t = y * ; int t5 = t3 + t; int rval = t2 * t5; 16 0 z y x Old Stack movl (), # eax = x movl (), # edx = y leal (,), # ecx = x+y (t1) leal (,,2), # edx = 3*y sall $, # edx = *y (t) addl 16(), # ecx = z+t1 (t2) leal (,), # eax = +t+x (t5) imull, # eax = t5*t2 (rval) CSE351 Inaugural Edion Spring Understanding arith int arith (int x, int y, int z) int t1 = x+y; int t2 = z+t1; int t3 = x+; int t = y * ; int t5 = t3 + t; int rval = t2 * t5; 16 0 z y x Old Stack movl (), # eax = x movl (), # edx = y leal (,), # ecx = x+y (t1) leal (,,2), # edx = 3*y sall $, # edx = *y (t) addl 16(), # ecx = z+t1 (t2) leal (,), # eax = +t+x (t5) imull, # eax = t5*t2 (rval) CSE351 Inaugural Edion Spring

14 Understanding arith int arith (int x, int y, int z) int t1 = x+y; int t2 = z+t1; int t3 = x+; int t = y * ; int t5 = t3 + t; int rval = t2 * t5; 16 0 z y x Old Stack movl (), # eax = x movl (), # edx = y leal (,), # ecx = x+y (t1) leal (,,2), # edx = 3*y sall $, # edx = *y (t) addl 16(), # ecx = z+t1 (t2) leal (,), # eax = +t+x (t5) imull, # eax = t5*t2 (rval) CSE351 Inaugural Edion Spring Understanding arith int arith (int x, int y, int z) int t1 = x+y; int t2 = z+t1; int t3 = x+; int t = y * ; int t5 = t3 + t; int rval = t2 * t5; 16 0 z y x Old Stack movl (), # eax = x movl (), # edx = y leal (,), # ecx = x+y (t1) leal (,,2), # edx = 3*y sall $, # edx = *y (t) addl 16(), # ecx = z+t1 (t2) leal (,), # eax = +t+x (t5) imull, # eax = t5*t2 (rval) CSE351 Inaugural Edion Spring

15 Another Example int logical(int x, int y) int t1 = x^y; int t2 = t1 >> 17; int mask = (1<<13) - 7; int rval = t2 & mask; logical: pushl movl, movl (), xorl (), sarl $17, andl $15, movl, popl ret Set Up Body Finish movl (), # eax = x xorl (), # eax = x^y sarl $17, # eax = t1>>17 andl $15, # eax = t2 & 15 CSE351 Inaugural Edion Spring Another Example int logical(int x, int y) int t1 = x^y; int t2 = t1 >> 17; int mask = (1<<13) - 7; int rval = t2 & mask; logical: pushl movl, movl (), xorl (), sarl $17, andl $15, movl, popl ret Set Up Body Finish movl (), eax = x xorl (), eax = x^y (t1) sarl $17, eax = t1>>17 (t2) andl $15, eax = t2 & 15 CSE351 Inaugural Edion Spring

16 Another Example int logical(int x, int y) int t1 = x^y; int t2 = t1 >> 17; int mask = (1<<13) - 7; int rval = t2 & mask; logical: pushl movl, movl (), xorl (), sarl $17, andl $15, movl, popl ret Set Up Body Finish movl (), eax = x xorl (), eax = x^y (t1) sarl $17, eax = t1>>17 (t2) andl $15, eax = t2 & 15 CSE351 Inaugural Edion Spring Another Example int logical(int x, int y) int t1 = x^y; int t2 = t1 >> 17; int mask = (1<<13) - 7; int rval = t2 & mask; 2 13 = 192, = 15 logical: pushl movl, movl (), xorl (), sarl $17, andl $15, movl, popl ret Set Up Body Finish movl (), eax = x xorl (), eax = x^y (t1) sarl $17, eax = t1>>17 (t2) andl $15, eax = t2 & 15 CSE351 Inaugural Edion Spring

Lecture 7: Machine-Level Programming I: Basics Mohamed Zahran (aka Z) mzahran@cs.nyu.edu http://www.mzahran.com

Lecture 7: Machine-Level Programming I: Basics Mohamed Zahran (aka Z) mzahran@cs.nyu.edu http://www.mzahran.com CSCI-UA.0201-003 Computer Systems Organization Lecture 7: Machine-Level Programming I: Basics Mohamed Zahran (aka Z) mzahran@cs.nyu.edu http://www.mzahran.com Some slides adapted (and slightly modified)

More information

Machine-Level Programming II: Arithmetic & Control

Machine-Level Programming II: Arithmetic & Control Mellon Machine-Level Programming II: Arithmetic & Control 15-213 / 18-213: Introduction to Computer Systems 6 th Lecture, Jan 29, 2015 Instructors: Seth Copen Goldstein, Franz Franchetti, Greg Kesden 1

More information

Assembly Language: Function Calls" Jennifer Rexford!

Assembly Language: Function Calls Jennifer Rexford! Assembly Language: Function Calls" Jennifer Rexford! 1 Goals of this Lecture" Function call problems:! Calling and returning! Passing parameters! Storing local variables! Handling registers without interference!

More information

Instruction Set Architecture

Instruction Set Architecture CS:APP Chapter 4 Computer Architecture Instruction Set Architecture Randal E. Bryant adapted by Jason Fritts http://csapp.cs.cmu.edu CS:APP2e Hardware Architecture - using Y86 ISA For learning aspects

More information

Machine-Level Programming I: Basics

Machine-Level Programming I: Basics Machine-Level Programming I: Basics 15-213/18-213: Introduction to Computer Systems 5 th Lecture, May 25, 2016 Instructor: Brian Railing 1 Today: Machine Programming I: Basics History of Intel processors

More information

l C-Programming l A real computer language l Data Representation l Everything goes down to bits and bytes l Machine representation Language

l C-Programming l A real computer language l Data Representation l Everything goes down to bits and bytes l Machine representation Language 198:211 Computer Architecture Topics: Processor Design Where are we now? C-Programming A real computer language Data Representation Everything goes down to bits and bytes Machine representation Language

More information

CS61: Systems Programing and Machine Organization

CS61: Systems Programing and Machine Organization CS61: Systems Programing and Machine Organization Fall 2009 Section Notes for Week 2 (September 14 th - 18 th ) Topics to be covered: I. Binary Basics II. Signed Numbers III. Architecture Overview IV.

More information

CS:APP Chapter 4 Computer Architecture Instruction Set Architecture. CS:APP2e

CS:APP Chapter 4 Computer Architecture Instruction Set Architecture. CS:APP2e CS:APP Chapter 4 Computer Architecture Instruction Set Architecture CS:APP2e Instruction Set Architecture Assembly Language View Processor state Registers, memory, Instructions addl, pushl, ret, How instructions

More information

Faculty of Engineering Student Number:

Faculty of Engineering Student Number: Philadelphia University Student Name: Faculty of Engineering Student Number: Dept. of Computer Engineering Final Exam, First Semester: 2012/2013 Course Title: Microprocessors Date: 17/01//2013 Course No:

More information

Chapter 4 Processor Architecture

Chapter 4 Processor Architecture Chapter 4 Processor Architecture Modern microprocessors are among the most complex systems ever created by humans. A single silicon chip, roughly the size of a fingernail, can contain a complete high-performance

More information

CS412/CS413. Introduction to Compilers Tim Teitelbaum. Lecture 20: Stack Frames 7 March 08

CS412/CS413. Introduction to Compilers Tim Teitelbaum. Lecture 20: Stack Frames 7 March 08 CS412/CS413 Introduction to Compilers Tim Teitelbaum Lecture 20: Stack Frames 7 March 08 CS 412/413 Spring 2008 Introduction to Compilers 1 Where We Are Source code if (b == 0) a = b; Low-level IR code

More information

Lecture 27 C and Assembly

Lecture 27 C and Assembly Ananda Gunawardena Lecture 27 C and Assembly This is a quick introduction to working with x86 assembly. Some of the instructions and register names must be check for latest commands and register names.

More information

Intel Assembler. Project administration. Non-standard project. Project administration: Repository

Intel Assembler. Project administration. Non-standard project. Project administration: Repository Lecture 14 Project, Assembler and Exam Source code Compiler phases and program representations Frontend Lexical analysis (scanning) Backend Immediate code generation Today Project Emma Söderberg Revised

More information

Hacking Techniques & Intrusion Detection. Ali Al-Shemery arabnix [at] gmail

Hacking Techniques & Intrusion Detection. Ali Al-Shemery arabnix [at] gmail Hacking Techniques & Intrusion Detection Ali Al-Shemery arabnix [at] gmail All materials is licensed under a Creative Commons Share Alike license http://creativecommonsorg/licenses/by-sa/30/ # whoami Ali

More information

Unpacked BCD Arithmetic. BCD (ASCII) Arithmetic. Where and Why is BCD used? From the SQL Server Manual. Packed BCD, ASCII, Unpacked BCD

Unpacked BCD Arithmetic. BCD (ASCII) Arithmetic. Where and Why is BCD used? From the SQL Server Manual. Packed BCD, ASCII, Unpacked BCD BCD (ASCII) Arithmetic The Intel Instruction set can handle both packed (two digits per byte) and unpacked BCD (one decimal digit per byte) We will first look at unpacked BCD Unpacked BCD can be either

More information

Computer Organization and Assembly Language

Computer Organization and Assembly Language Computer Organization and Assembly Language Lecture 8 - Strings and Arrays Introduction We already know that assembly code will execute significantly faster than code written in a higher-level language

More information

For a 64-bit system. I - Presentation Of The Shellcode

For a 64-bit system. I - Presentation Of The Shellcode #How To Create Your Own Shellcode On Arch Linux? #Author : N3td3v!l #Contact-mail : 4nonymouse@usa.com #Website : Nopotm.ir #Spcial tnx to : C0nn3ct0r And All Honest Hackerz and Security Managers I - Presentation

More information

Computer Organization and Architecture

Computer Organization and Architecture Computer Organization and Architecture Chapter 11 Instruction Sets: Addressing Modes and Formats Instruction Set Design One goal of instruction set design is to minimize instruction length Another goal

More information

BCD (ASCII) Arithmetic. Where and Why is BCD used? Packed BCD, ASCII, Unpacked BCD. BCD Adjustment Instructions AAA. Example

BCD (ASCII) Arithmetic. Where and Why is BCD used? Packed BCD, ASCII, Unpacked BCD. BCD Adjustment Instructions AAA. Example BCD (ASCII) Arithmetic We will first look at unpacked BCD which means strings that look like '4567'. Bytes then look like 34h 35h 36h 37h OR: 04h 05h 06h 07h x86 processors also have instructions for packed

More information

x64 Cheat Sheet Fall 2015

x64 Cheat Sheet Fall 2015 CS 33 Intro Computer Systems Doeppner x64 Cheat Sheet Fall 2015 1 x64 Registers x64 assembly code uses sixteen 64-bit registers. Additionally, the lower bytes of some of these registers may be accessed

More information

A Tiny Guide to Programming in 32-bit x86 Assembly Language

A Tiny Guide to Programming in 32-bit x86 Assembly Language CS308, Spring 1999 A Tiny Guide to Programming in 32-bit x86 Assembly Language by Adam Ferrari, ferrari@virginia.edu (with changes by Alan Batson, batson@virginia.edu and Mike Lack, mnl3j@virginia.edu)

More information

Return-oriented programming without returns

Return-oriented programming without returns Faculty of Computer Science Institute for System Architecture, Operating Systems Group Return-oriented programming without urns S. Checkoway, L. Davi, A. Dmitrienko, A. Sadeghi, H. Shacham, M. Winandy

More information

G-Free: Defeating Return-Oriented Programming through Gadget-less Binaries

G-Free: Defeating Return-Oriented Programming through Gadget-less Binaries G-Free: Defeating Return-Oriented Programming through Gadget-less Binaries Kaan Onarlioglu Bilkent University, Ankara onarliog@cs.bilkent.edu.tr Davide Balzarotti Eurecom, Sophia Antipolis balzarotti@eurecom.fr

More information

CHAPTER 6 TASK MANAGEMENT

CHAPTER 6 TASK MANAGEMENT CHAPTER 6 TASK MANAGEMENT This chapter describes the IA-32 architecture s task management facilities. These facilities are only available when the processor is running in protected mode. 6.1. TASK MANAGEMENT

More information

612 CHAPTER 11 PROCESSOR FAMILIES (Corrisponde al cap. 12 - Famiglie di processori) PROBLEMS

612 CHAPTER 11 PROCESSOR FAMILIES (Corrisponde al cap. 12 - Famiglie di processori) PROBLEMS 612 CHAPTER 11 PROCESSOR FAMILIES (Corrisponde al cap. 12 - Famiglie di processori) PROBLEMS 11.1 How is conditional execution of ARM instructions (see Part I of Chapter 3) related to predicated execution

More information

Chapter 7D The Java Virtual Machine

Chapter 7D The Java Virtual Machine This sub chapter discusses another architecture, that of the JVM (Java Virtual Machine). In general, a VM (Virtual Machine) is a hypothetical machine (implemented in either hardware or software) that directly

More information

Administration. Instruction scheduling. Modern processors. Examples. Simplified architecture model. CS 412 Introduction to Compilers

Administration. Instruction scheduling. Modern processors. Examples. Simplified architecture model. CS 412 Introduction to Compilers CS 4 Introduction to Compilers ndrew Myers Cornell University dministration Prelim tomorrow evening No class Wednesday P due in days Optional reading: Muchnick 7 Lecture : Instruction scheduling pr 0 Modern

More information

The 80x86 Instruction Set

The 80x86 Instruction Set Thi d t t d ith F M k 4 0 2 The 80x86 Instruction Set Chapter Six Until now, there has been little discussion of the instructions available on the 80x86 microprocessor. This chapter rectifies this situation.

More information

Instruction Set Architecture. or How to talk to computers if you aren t in Star Trek

Instruction Set Architecture. or How to talk to computers if you aren t in Star Trek Instruction Set Architecture or How to talk to computers if you aren t in Star Trek The Instruction Set Architecture Application Compiler Instr. Set Proc. Operating System I/O system Instruction Set Architecture

More information

Outline. Lecture 3. Basics. Logical vs. physical memory. 8086 physical memory. x86 byte ordering

Outline. Lecture 3. Basics. Logical vs. physical memory. 8086 physical memory. x86 byte ordering Outline Lecture 3 bout Memory ddressing memory Data types MOV instruction ddressing modes Instruction format Dr. Dimitrios S. Nikolopoulos SL/UIU Basics Logical vs. physical memory Memory in the x processors

More information

Reduced Instruction Set Computer (RISC)

Reduced Instruction Set Computer (RISC) Reduced Instruction Set Computer (RISC) Focuses on reducing the number and complexity of instructions of the ISA. RISC Goals RISC: Simplify ISA Simplify CPU Design Better CPU Performance Motivated by simplifying

More information

Chapter 2 Topics. 2.1 Classification of Computers & Instructions 2.2 Classes of Instruction Sets 2.3 Informal Description of Simple RISC Computer, SRC

Chapter 2 Topics. 2.1 Classification of Computers & Instructions 2.2 Classes of Instruction Sets 2.3 Informal Description of Simple RISC Computer, SRC Chapter 2 Topics 2.1 Classification of Computers & Instructions 2.2 Classes of Instruction Sets 2.3 Informal Description of Simple RISC Computer, SRC See Appendix C for Assembly language information. 2.4

More information

Hacking the Preboot execution Environment

Hacking the Preboot execution Environment Hacking the Preboot execution Environment Using the BIOS network stack for other purposes Julien Vanegue jfv@cesar.org.br CESAR Recife Center for Advanced Studies and Systems, Brasil. September 27, 2008

More information

CS:APP Chapter 4 Computer Architecture. Wrap-Up. William J. Taffe Plymouth State University. using the slides of

CS:APP Chapter 4 Computer Architecture. Wrap-Up. William J. Taffe Plymouth State University. using the slides of CS:APP Chapter 4 Computer Architecture Wrap-Up William J. Taffe Plymouth State University using the slides of Randal E. Bryant Carnegie Mellon University Overview Wrap-Up of PIPE Design Performance analysis

More information

CS:APP Chapter 4 Computer Architecture Instruction Set Architecture

CS:APP Chapter 4 Computer Architecture Instruction Set Architecture Adaptation par J.Bétréma CS:APP Chapter 4 Computer Architecture Instruction Set Architecture Randal E. Bryant Carnegie Mellon University http://csapp.cs.cmu.edu CS:APP Instruction Set Architecture Application

More information

Compilers I - Chapter 4: Generating Better Code

Compilers I - Chapter 4: Generating Better Code Compilers I - Chapter 4: Generating Better Code Lecturers: Paul Kelly (phjk@doc.ic.ac.uk) Office: room 304, William Penney Building Naranker Dulay (nd@doc.ic.ac.uk) Materials: Office: room 562 Textbook

More information

PCI BIOS SPECIFICATION. Revision 2.1

PCI BIOS SPECIFICATION. Revision 2.1 PCI BIOS SPECIFICATION Revision 2.1 August 26, 1994 ii PCI BIOS Specification Revision 2.1 REVISION REVISION HISTORY DATE 1.0 Original issue distributed by Intel 9/28/92 2.0 Updated to be in synch with

More information

Instruction Set Architecture (ISA)

Instruction Set Architecture (ISA) Instruction Set Architecture (ISA) * Instruction set architecture of a machine fills the semantic gap between the user and the machine. * ISA serves as the starting point for the design of a new machine

More information

Systems Design & Programming Data Movement Instructions. Intel Assembly

Systems Design & Programming Data Movement Instructions. Intel Assembly Intel Assembly Data Movement Instruction: mov (covered already) push, pop lea (mov and offset) lds, les, lfs, lgs, lss movs, lods, stos ins, outs xchg, xlat lahf, sahf (not covered) in, out movsx, movzx

More information

Writing an 8086 emulator in Python

Writing an 8086 emulator in Python Writing an 8086 emulator in Python Cesare Di Mauro PyCon 2015 Florence April 2015 April 2015 Cesare Di Mauro PyCon 2015 Writing an 8086 emulator in Python 1 The geek experience Writing your own o.s.: A

More information

Programming Languages

Programming Languages Programming Languages In the beginning To use a computer, you needed to know how to program it. Today People no longer need to know how to program in order to use the computer. To see how this was accomplished,

More information

Intel 8086 architecture

Intel 8086 architecture Intel 8086 architecture Today we ll take a look at Intel s 8086, which is one of the oldest and yet most prevalent processor architectures around. We ll make many comparisons between the MIPS and 8086

More information

Anatomy and Performance of SSL Processing

Anatomy and Performance of SSL Processing Anatomy and Performance of SSL Processing Li Zhao, Ravi Iyer, Srihari Makineni, Laxmi Bhuyan Computer Science Department University of California, Riverside {zhao, bhuyan}@cs.ucr.edu Communications Technology

More information

Lecture 3 Addressing Modes, Instruction Samples, Machine Code, Instruction Execution Cycle

Lecture 3 Addressing Modes, Instruction Samples, Machine Code, Instruction Execution Cycle Lecture 3 Addressing Modes, Instruction Samples, Machine Code, Instruction Execution Cycle Contents 3.1. Register Transfer Notation... 2 3.2. HCS12 Addressing Modes... 2 1. Inherent Mode (INH)... 2 2.

More information

Computer Architectures

Computer Architectures Computer Architectures Parameters Passing to Subroutines and Operating System Implemented Virtual Instructions (System Calls) Czech Technical University in Prague, Faculty of Electrical Engineering Ver.1.10

More information

Complete 8086 instruction set

Complete 8086 instruction set Page 1 of 53 Complete 8086 instruction set Quick reference: AAA AAD AAM AAS ADC ADD AND CALL CBW CLC CLD CLI CMC CMP CMPSB CMPSW CWD DAA DAS DEC DIV HLT IDIV IMUL IN INC INT INTO I JA JAE JB JBE JC JCXZ

More information

Assembly Language Tutorial

Assembly Language Tutorial Assembly Language Tutorial ASSEMBLY LANGUAGE TUTORIAL by tutorialspoint.com tutorialspoint.com i ABOUT THE TUTORIAL Assembly Programming Tutorial Assembly language is a low-level programming language for

More information

M A S S A C H U S E T T S I N S T I T U T E O F T E C H N O L O G Y DEPARTMENT OF ELECTRICAL ENGINEERING AND COMPUTER SCIENCE

M A S S A C H U S E T T S I N S T I T U T E O F T E C H N O L O G Y DEPARTMENT OF ELECTRICAL ENGINEERING AND COMPUTER SCIENCE M A S S A C H U S E T T S I N S T I T U T E O F T E C H N O L O G Y DEPARTMENT OF ELECTRICAL ENGINEERING AND COMPUTER SCIENCE 1. Introduction 6.004 Computation Structures β Documentation This handout is

More information

About the Tutorial. Audience. Prerequisites. Copyright & Disclaimer

About the Tutorial. Audience. Prerequisites. Copyright & Disclaimer About the Tutorial Assembly language is a low-level programming language for a computer or other programmable device specific to a particular computer architecture in contrast to most high-level programming

More information

Modbus RTU Communications RX/WX and MRX/MWX

Modbus RTU Communications RX/WX and MRX/MWX 15 Modbus RTU Communications RX/WX and MRX/MWX In This Chapter.... Network Slave Operation Network Master Operation: RX / WX Network Master Operation: DL06 MRX / MWX 5 2 D0 Modbus Network Slave Operation

More information

Stack Overflows. Mitchell Adair

Stack Overflows. Mitchell Adair Stack Overflows Mitchell Adair Outline Why? What? There once was a VM Virtual Memory Registers Stack stack1, stack2, stack3 Resources Why? Real problem Real money Real recognition Still prevalent Very

More information

8085 INSTRUCTION SET

8085 INSTRUCTION SET DATA TRANSFER INSTRUCTIONS Opcode Operand Description 8085 INSTRUCTION SET INSTRUCTION DETAILS Copy from source to destination OV Rd, Rs This instruction copies the contents of the source, Rs register

More information

64-Bit NASM Notes. Invoking 64-Bit NASM

64-Bit NASM Notes. Invoking 64-Bit NASM 64-Bit NASM Notes The transition from 32- to 64-bit architectures is no joke, as anyone who has wrestled with 32/64 bit incompatibilities will attest We note here some key differences between 32- and 64-bit

More information

Language Processing Systems

Language Processing Systems Language Processing Systems Evaluation Active sheets 10 % Exercise reports 30 % Midterm Exam 20 % Final Exam 40 % Contact Send e-mail to hamada@u-aizu.ac.jp Course materials at www.u-aizu.ac.jp/~hamada/education.html

More information

COMPUTERS ORGANIZATION 2ND YEAR COMPUTE SCIENCE MANAGEMENT ENGINEERING JOSÉ GARCÍA RODRÍGUEZ JOSÉ ANTONIO SERRA PÉREZ

COMPUTERS ORGANIZATION 2ND YEAR COMPUTE SCIENCE MANAGEMENT ENGINEERING JOSÉ GARCÍA RODRÍGUEZ JOSÉ ANTONIO SERRA PÉREZ COMPUTERS ORGANIZATION 2ND YEAR COMPUTE SCIENCE MANAGEMENT ENGINEERING UNIT 1 - INTRODUCTION JOSÉ GARCÍA RODRÍGUEZ JOSÉ ANTONIO SERRA PÉREZ Unit 1.MaNoTaS 1 Definitions (I) Description A computer is: A

More information

PC Assembly Language. Paul A. Carter

PC Assembly Language. Paul A. Carter PC Assembly Language Paul A. Carter November 20, 2001 Copyright c 2001 by Paul Carter This may be reproduced and distributed in its entirety (including this authorship, copyright and permission notice),

More information

x86-64 Machine-Level Programming

x86-64 Machine-Level Programming x86-64 Machine-Level Programming Randal E. Bryant David R. O Hallaron September 9, 2005 Intel s IA32 instruction set architecture (ISA), colloquially known as x86, is the dominant instruction format for

More information

Instruction Set Architecture

Instruction Set Architecture Instruction Set Architecture Consider x := y+z. (x, y, z are memory variables) 1-address instructions 2-address instructions LOAD y (r :=y) ADD y,z (y := y+z) ADD z (r:=r+z) MOVE x,y (x := y) STORE x (x:=r)

More information

Giving credit where credit is due

Giving credit where credit is due CSCE 230J Computer Organization Processor Architecture VI: Wrap-Up Dr. Steve Goddard goddard@cse.unl.edu http://cse.unl.edu/~goddard/courses/csce230j Giving credit where credit is due ost of slides for

More information

8. MACROS, Modules, and Mouse

8. MACROS, Modules, and Mouse 8. MACROS, Modules, and Mouse Background Macros, Modules and the Mouse is a combination of concepts that will introduce you to modular programming while learning how to interface with the mouse. Macros

More information

TODAY, FEW PROGRAMMERS USE ASSEMBLY LANGUAGE. Higher-level languages such

TODAY, FEW PROGRAMMERS USE ASSEMBLY LANGUAGE. Higher-level languages such 9 Inline Assembly Code TODAY, FEW PROGRAMMERS USE ASSEMBLY LANGUAGE. Higher-level languages such as C and C++ run on nearly all architectures and yield higher productivity when writing and maintaining

More information

Z80 Instruction Set. Z80 Assembly Language

Z80 Instruction Set. Z80 Assembly Language 75 Z80 Assembly Language The assembly language allows the user to write a program without concern for memory addresses or machine instruction formats. It uses symbolic addresses to identify memory locations

More information

ELEG3924 Microprocessor Ch.7 Programming In C

ELEG3924 Microprocessor Ch.7 Programming In C Department of Electrical Engineering University of Arkansas ELEG3924 Microprocessor Ch.7 Programming In C Dr. Jingxian Wu wuj@uark.edu OUTLINE 2 Data types and time delay I/O programming and Logic operations

More information

Buffer Overflows. Security 2011

Buffer Overflows. Security 2011 Buffer Overflows Security 2011 Memory Organiza;on Topics Kernel organizes memory in pages Typically 4k bytes Processes operate in a Virtual Memory Space Mapped to real 4k pages Could live in RAM or be

More information

Flash Microcontroller. Memory Organization. Memory Organization

Flash Microcontroller. Memory Organization. Memory Organization The information presented in this chapter is collected from the Microcontroller Architectural Overview, AT89C51, AT89LV51, AT89C52, AT89LV52, AT89C2051, and AT89C1051 data sheets of this book. The material

More information

Overview. CISC Developments. RISC Designs. CISC Designs. VAX: Addressing Modes. Digital VAX

Overview. CISC Developments. RISC Designs. CISC Designs. VAX: Addressing Modes. Digital VAX Overview CISC Developments Over Twenty Years Classic CISC design: Digital VAX VAXÕs RISC successor: PRISM/Alpha IntelÕs ubiquitous 80x86 architecture Ð 8086 through the Pentium Pro (P6) RJS 2/3/97 Philosophy

More information

How To Use A Computer With A Screen On It (For A Powerbook)

How To Use A Computer With A Screen On It (For A Powerbook) page 44,100 TITLE ASMXMPLE Video equ 10h ;video functions interrupt number Keyboard equ 16h ;keyboard functions interrupt number DOS equ 21h ;call DOS interrupt number PrtSc equ 5h ;Print Screen Bios interrupt

More information

The Hardware/So7ware Interface CSE351 Spring 2010 (Inaugural Edi5on) 1 st Lecture, 29 March

The Hardware/So7ware Interface CSE351 Spring 2010 (Inaugural Edi5on) 1 st Lecture, 29 March The Hardware/So7ware Interface CSE351 Spring 2010 (Inaugural Edi5on) 1 st Lecture, 29 March Instructor: Gaetano Borriello Teaching Assistants: Paul Pham, Andrew Reutsch, Ben Wood CSE351 Inaugural EdiDon

More information

Chapter 1. Bootstrap. Hardware

Chapter 1. Bootstrap. Hardware DRAFT as of September 23, 2010: Copyright 2009 Cox, Kaashoek, Morris Chapter 1 Bootstrap Hardware A computer s CPU (central processing unit, or processor) runs a conceptually simple loop: it inspects the

More information

The x86 PC: Assembly Language, Design, and Interfacing 5 th Edition

The x86 PC: Assembly Language, Design, and Interfacing 5 th Edition Online Instructor s Manual to accompany The x86 PC: Assembly Language, Design, and Interfacing 5 th Edition Muhammad Ali Mazidi Janice Gillispie Mazidi Danny Causey Prentice Hall Boston Columbus Indianapolis

More information

Review: MIPS Addressing Modes/Instruction Formats

Review: MIPS Addressing Modes/Instruction Formats Review: Addressing Modes Addressing mode Example Meaning Register Add R4,R3 R4 R4+R3 Immediate Add R4,#3 R4 R4+3 Displacement Add R4,1(R1) R4 R4+Mem[1+R1] Register indirect Add R4,(R1) R4 R4+Mem[R1] Indexed

More information

Off-by-One exploitation tutorial

Off-by-One exploitation tutorial Off-by-One exploitation tutorial By Saif El-Sherei www.elsherei.com Introduction: I decided to get a bit more into Linux exploitation, so I thought it would be nice if I document this as a good friend

More information

Using the RDTSC Instruction for Performance Monitoring

Using the RDTSC Instruction for Performance Monitoring Using the Instruction for Performance Monitoring http://developer.intel.com/drg/pentiumii/appnotes/pm1.htm Using the Instruction for Performance Monitoring Information in this document is provided in connection

More information

Under The Hood: The System Call

Under The Hood: The System Call 2 Under The Hood: The System Call In this note, we ll peak under the hood of one simple and neat OS called xv6 [CK+08]. The xv6 kernel is a port of an old UNIX version 6 from PDP-11 (the machine it was

More information

X86-64 Architecture Guide

X86-64 Architecture Guide X86-64 Architecture Guide For the code-generation project, we shall expose you to a simplified version of the x86-64 platform. Example Consider the following Decaf program: class Program { int foo(int

More information

Mouse Programming. 25.1 Mouse Interrupts. 25.2 Useful Mouse functions. 25.2.1 Mouselib.h. 25.2.2 Mouselib.c

Mouse Programming. 25.1 Mouse Interrupts. 25.2 Useful Mouse functions. 25.2.1 Mouselib.h. 25.2.2 Mouselib.c 25 Show respect for all people. Mouse Programming As everyone knows, mouse is one of the inputting devices. In this chapter, I explain interrupts for mouse programming and a few concepts regarding mouse

More information

Egil Aspevik Martinsen Polymorphic Viruses. Material from Master Thesis «Detection of Junk Instructions in Malicious Software»

Egil Aspevik Martinsen Polymorphic Viruses. Material from Master Thesis «Detection of Junk Instructions in Malicious Software» Egil Aspevik Martinsen Polymorphic Viruses Material from Master Thesis «Detection of Junk Instructions in Malicious Software» 1 History 1982 Elk Cloner Brain 1987 1260 1992 Ply 1997 Melissa ILOVEYOU Zmist

More information

Stack machines The MIPS assembly language A simple source language Stack-machine implementation of the simple language Readings: 9.1-9.

Stack machines The MIPS assembly language A simple source language Stack-machine implementation of the simple language Readings: 9.1-9. Code Generation I Stack machines The MIPS assembly language A simple source language Stack-machine implementation of the simple language Readings: 9.1-9.7 Stack Machines A simple evaluation model No variables

More information

Andreas Herrmann. AMD Operating System Research Center

Andreas Herrmann. AMD Operating System Research Center Myth and facts about 64-bit Linux Andreas Herrmann André Przywara AMD Operating System Research Center March 2nd, 2008 Myths... You don't need 64-bit software with less than 3 GB RAM. There are less drivers

More information

CVE-2012-1535 Adobe Flash Player Integer Overflow Vulnerability Analysis

CVE-2012-1535 Adobe Flash Player Integer Overflow Vulnerability Analysis Your texte here. CVE-2012-1535 Adobe Flash Player Integer Overflow Vulnerability Analysis October 11 th, 2012 Brian MARIANI & Frédéric BOURLA A FEW WORDS ABOUT FLASH PLAYER Your Adobe texte Flash here

More information

Instruction Set Design

Instruction Set Design Instruction Set Design Instruction Set Architecture: to what purpose? ISA provides the level of abstraction between the software and the hardware One of the most important abstraction in CS It s narrow,

More information

Keil C51 Cross Compiler

Keil C51 Cross Compiler Keil C51 Cross Compiler ANSI C Compiler Generates fast compact code for the 8051 and it s derivatives Advantages of C over Assembler Do not need to know the microcontroller instruction set Register allocation

More information

Microcontroller Basics A microcontroller is a small, low-cost computer-on-a-chip which usually includes:

Microcontroller Basics A microcontroller is a small, low-cost computer-on-a-chip which usually includes: Microcontroller Basics A microcontroller is a small, low-cost computer-on-a-chip which usually includes: An 8 or 16 bit microprocessor (CPU). A small amount of RAM. Programmable ROM and/or flash memory.

More information

Advanced Computer Architecture-CS501. Computer Systems Design and Architecture 2.1, 2.2, 3.2

Advanced Computer Architecture-CS501. Computer Systems Design and Architecture 2.1, 2.2, 3.2 Lecture Handout Computer Architecture Lecture No. 2 Reading Material Vincent P. Heuring&Harry F. Jordan Chapter 2,Chapter3 Computer Systems Design and Architecture 2.1, 2.2, 3.2 Summary 1) A taxonomy of

More information

8086 Microprocessor (cont..)

8086 Microprocessor (cont..) 8086 Microprocessor (cont..) It is a 16 bit µp. 8086 has a 20 bit address bus can access upto 2 20 memory locations ( 1 MB). It can support upto 64K I/O ports. It provides 14, 16-bit registers. It has

More information

Intel Virtualization Technology FlexMigration Application Note

Intel Virtualization Technology FlexMigration Application Note Intel Virtualization Technology FlexMigration Application Note This document is intended only for VMM or hypervisor software developers and not for application developers or end-customers. Readers are

More information

Computer Architectures

Computer Architectures Computer Architectures 2. Instruction Set Architectures 2015. február 12. Budapest Gábor Horváth associate professor BUTE Dept. of Networked Systems and Services ghorvath@hit.bme.hu 2 Instruction set architectures

More information

An Overview of Stack Architecture and the PSC 1000 Microprocessor

An Overview of Stack Architecture and the PSC 1000 Microprocessor An Overview of Stack Architecture and the PSC 1000 Microprocessor Introduction A stack is an important data handling structure used in computing. Specifically, a stack is a dynamic set of elements in which

More information

MICROPROCESSOR BCA IV Sem MULTIPLE CHOICE QUESTIONS

MICROPROCESSOR BCA IV Sem MULTIPLE CHOICE QUESTIONS MICROPROCESSOR BCA IV Sem MULTIPLE CHOICE QUESTIONS 1) Which is the microprocessor comprises: a. Register section b. One or more ALU c. Control unit 2) What is the store by register? a. data b. operands

More information

Application-Specific Attacks: Leveraging the ActionScript Virtual Machine

Application-Specific Attacks: Leveraging the ActionScript Virtual Machine IBM Global Technology Services April 2008 Application-Specific Attacks: Leveraging the ActionScript Virtual Machine By Mark Dowd X-Force Researcher IBM Internet Security Systems (markdowd@au1.ibm.com)

More information

CPU Organization and Assembly Language

CPU Organization and Assembly Language COS 140 Foundations of Computer Science School of Computing and Information Science University of Maine October 2, 2015 Outline 1 2 3 4 5 6 7 8 Homework and announcements Reading: Chapter 12 Homework:

More information

An Introduction to Assembly Programming with the ARM 32-bit Processor Family

An Introduction to Assembly Programming with the ARM 32-bit Processor Family An Introduction to Assembly Programming with the ARM 32-bit Processor Family G. Agosta Politecnico di Milano December 3, 2011 Contents 1 Introduction 1 1.1 Prerequisites............................. 2

More information

1 The Java Virtual Machine

1 The Java Virtual Machine 1 The Java Virtual Machine About the Spec Format This document describes the Java virtual machine and the instruction set. In this introduction, each component of the machine is briefly described. This

More information

Application Note. Introduction AN2471/D 3/2003. PC Master Software Communication Protocol Specification

Application Note. Introduction AN2471/D 3/2003. PC Master Software Communication Protocol Specification Application Note 3/2003 PC Master Software Communication Protocol Specification By Pavel Kania and Michal Hanak S 3 L Applications Engineerings MCSL Roznov pod Radhostem Introduction The purpose of this

More information

CSC 2405: Computer Systems II

CSC 2405: Computer Systems II CSC 2405: Computer Systems II Spring 2013 (TR 8:30-9:45 in G86) Mirela Damian http://www.csc.villanova.edu/~mdamian/csc2405/ Introductions Mirela Damian Room 167A in the Mendel Science Building mirela.damian@villanova.edu

More information

PART B QUESTIONS AND ANSWERS UNIT I

PART B QUESTIONS AND ANSWERS UNIT I PART B QUESTIONS AND ANSWERS UNIT I 1. Explain the architecture of 8085 microprocessor? Logic pin out of 8085 microprocessor Address bus: unidirectional bus, used as high order bus Data bus: bi-directional

More information

CS3235 - Computer Security Thirteenth topic: System attacks. defenses

CS3235 - Computer Security Thirteenth topic: System attacks. defenses Overflows... Security case studies CS3235 - Computer Security Thirteenth topic: System attacks and defenses Hugh Anderson National University of Singapore School of Computing March/April, 2016 Hugh Anderson

More information

Abysssec Research. 1) Advisory information. 2) Vulnerable version

Abysssec Research. 1) Advisory information. 2) Vulnerable version Abysssec Research 1) Advisory information Title Version Discovery Vendor Impact Contact Twitter CVE : Apple QuickTime FlashPix NumberOfTiles Remote Code Execution Vulnerability : QuickTime player 7.6.5

More information

Automated Repair of Binary and Assembly Programs for Cooperating Embedded Devices

Automated Repair of Binary and Assembly Programs for Cooperating Embedded Devices Automated Repair of Binary and Assembly Programs for Cooperating Embedded Devices Eric Schulte 1 Jonathan DiLorenzo 2 Westley Weimer 2 Stephanie Forrest 1 1 Department of Computer Science University of

More information

IA-32 Intel Architecture Software Developer s Manual

IA-32 Intel Architecture Software Developer s Manual IA-32 Intel Architecture Software Developer s Manual Volume 2B: Instruction Set Reference, N-Z NOTE: The IA-32 Intel Architecture Software Developer s Manual consists of four volumes: Basic Architecture,

More information