Machine Programming II: Instruc8ons

Save this PDF as:
 WORD  PNG  TXT  JPG

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

Lecture 4: Machine Code And Assembly Language

Lecture 4: Machine Code And Assembly Language CSCI-GA.1144-001 PAC II Lecture 4: Machine Code And Assembly Language Some slides adapted (and slightly modified) from: Clark Barrett Jinyang Li Randy Bryant Dave O Hallaron Mohamed Zahran (aka Z) mzahran@cs.nyu.edu

More information

Machine Programming I: Basics

Machine Programming I: Basics Machine Programming I: Basics History of Intel processors and architectures Intel processors (Wikipedia) Intel microarchitectures C, assembly, machine code Assembly basics: registers, operands, move instrucaons

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

l Status flags or condition codes are set when the in a zero l Example 1 l mov 0xFFFFFFFF %eax l add 1 %eax

l Status flags or condition codes are set when the in a zero l Example 1 l mov 0xFFFFFFFF %eax l add 1 %eax Machine-Level Programming II: Control Flow Topics Condition Codes Setting Testing Control Flow If-then-else While, for loop Assembly programmer view PC SP BR ALU IR GPR Status Flags ALU: Arithmetic Logic

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

Y86 Instruction Set. Operations. Moves. Branches. %eax %ecx %edx %ebx %esi %edi %esp %ebp R E G I S T E R S. jne. jge. jmp 7 0. cmovne 2 4.

Y86 Instruction Set. Operations. Moves. Branches. %eax %ecx %edx %ebx %esi %edi %esp %ebp R E G I S T E R S. jne. jge. jmp 7 0. cmovne 2 4. Y86 Instruction Set Byte 0 1 2 3 4 5 halt 0 0 nop 1 0 rrmovl ra, rb 2 0 ra rb irmovl V, rb 3 0 8F rb V rmmovl ra, D(rB) 4 0 ra rb D mrmovl D(rB), ra 5 0 ra rb D R E G I S T E R S %eax %ecx %edx %ebx %esi

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

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

Feature of 8086 Microprocessor

Feature of 8086 Microprocessor 8086 Microprocessor Introduction 8086 is the first 16 bit microprocessor which has 40 pin IC and operate on 5volt power supply. which has twenty address limes and works on two modes minimum mode and maximum.

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 3: Machine-Level Representations of Programs

CS:APP Chapter 3: Machine-Level Representations of Programs CS:APP Chapter 3: Machine-Level Representations of Programs Randal E. Bryant David R. O Hallaron January 30, 2002 When programming in a high-level language, such as C, we are shielded from the detailed,

More information

Systems Design & Programming Arithmetic, Logic and Control Instructions. Intel Assembly

Systems Design & Programming Arithmetic, Logic and Control Instructions. Intel Assembly Intel Assembly Arithmetic Operations: Addition Subtraction Multiplication Division Comparison Negation Increment Decrement Logic Operations: AND OR XOR NOT shift rotate compare (test) 1 Arithmetic Operations

More information

The Pentium Processor. Chapter 7 S. Dandamudi

The Pentium Processor. Chapter 7 S. Dandamudi The Pentium Processor Chapter 7 S. Dandamudi Outline Pentium family history Pentium processor details Pentium registers Data Pointer and index Control Segment Real mode memory architecture Protected mode

More information

Architecture and Programming of x86 Processors

Architecture and Programming of x86 Processors Brno University of Technology Architecture and Programming of x86 Processors Microprocessor Techniques and Embedded Systems Lecture 12 Dr. Tomas Fryza December 2012 Contents A little bit of one-core Intel

More information

Introduction to Machine- and Assembly-Language Programming. Prepared for Tynan (and other crazy people)

Introduction to Machine- and Assembly-Language Programming. Prepared for Tynan (and other crazy people) Introduction to Machine- and Assembly-Language Programming Prepared for Tynan (and other crazy people) by Prof. Dr. Brad Richards University of Applied Sciences, NW Switzerland Institute for Business Information

More information

Computer Organization and Assembly Language

Computer Organization and Assembly Language Computer Organization and Assembly Language Lecture 2 x86 Processor Architecture What is a processor? CPU (Central Processing Unit) or Processor - is the brain of the computer. In the PC, the Processor

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

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

Processing Unit. Backing Store

Processing Unit. Backing Store SYSTEM UNIT Basic Computer Structure Input Unit Central Processing Unit Main Memory Output Unit Backing Store The Central Processing Unit (CPU) is the unit in the computer which operates the whole computer

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

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

Assembly Language: Overview! Jennifer Rexford!

Assembly Language: Overview! Jennifer Rexford! Assembly Language: Overview! Jennifer Rexford! 1 Goals of this Lecture! Help you learn:! The basics of computer architecture! The relationship between C and assembly language! IA-32 assembly language,

More information

Multiplication and Division Instructions

Multiplication and Division Instructions Multiplication and Division Instructions MUL Instruction IMUL Instruction DIV Instruction Signed Integer Division Implementing Arithmetic Expressions Irvine, Kip R. Assembly Language for Intel-Based Computers,

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

5. Arithmetic and Logic Functions

5. Arithmetic and Logic Functions 5. Arithmetic and Logic Functions Background Arithmetic, shift/rotate, and logical operations are included in every microprocessor instruction set. This lab examines the x86 capabilities in these areas.

More information

Chapter 3 Machine-Level Representation of Programs

Chapter 3 Machine-Level Representation of Programs Chapter 3 Machine-Level Representation of Programs Computers execute machine code, sequences of bytes encoding the low-level operations that manipulate data, manage memory, read and write data on storage

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

Important programs of 8086 (Exam point of view)

Important programs of 8086 (Exam point of view) Important programs of 8086 (Exam point of view) 1. Write an ALP to find factorial of number for 8086. MOV AX, 05H MOV CX, AX Back: DEC CX MUL CX LOOP back ; results stored in AX ; to store the result at

More information

Assembly Language Lab # 9 Shift,Rotate,Multiplication and Division Instruction

Assembly Language Lab # 9 Shift,Rotate,Multiplication and Division Instruction Faculty of Engineering Computer Engineering Department Islamic University of Gaza Assembly Language Lab # 9 Shift,Rotate,Multiplication and Division Instruction Eng. Alaa.I.Haniya Assembly Language Fundamentals

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

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

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

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

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

Intel IA-32 Assembly

Intel IA-32 Assembly Intel IA-32 Assembly Simon Kågström Department of Systems and Software Engineering Blekinge Institute of Technology Ronneby, Sweden http://www.ipd.bth.se/ska/unix programming.html Simon Kågström (BTH,

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

Introduction to Machine-Level Representation of C Programs 1

Introduction to Machine-Level Representation of C Programs 1 Introduction to Machine-Level Representation of C Programs 1 Edited by Alberto José Proença Dep. Informática, Universidade do Minho, Portugal Contents 1. Information is Bits in Context, 1 2. Programs are

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

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

Loop Example. CMPE 325 Computer Architecture II. Loop Solution. Loops in C. Improved Loop Solution. Loop Efficiency. Assembly Language (cont)

Loop Example. CMPE 325 Computer Architecture II. Loop Solution. Loops in C. Improved Loop Solution. Loop Efficiency. Assembly Language (cont) CMPE 325 Computer rchitecture II Cem Ergün Eastern Mediterranean University ssembly Language (cont) Loop Example Consider the code where array is an integer array with 100 elements Loop: g = g + [i] i

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

Intel microprocessor history. Intel x86 Architecture. Early Intel microprocessors. The IBM-AT

Intel microprocessor history. Intel x86 Architecture. Early Intel microprocessors. The IBM-AT Intel x86 Architecture Intel microprocessor history Computer Organization and Assembly Languages g Yung-Yu Chuang with slides by Kip Irvine Early Intel microprocessors Intel 8080 (1972) 64K addressable

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

Most people today use decimal representation to count. In the decimal system there are 10 digits:

Most people today use decimal representation to count. In the decimal system there are 10 digits: Numbering Systems Tutorial What is it? There are many ways to represent the same numeric value. Long ago, humans used sticks to count, and later learned how to draw pictures of sticks in the ground and

More information

Week /8088 Addressing Modes, Instruction Set & Machine Codes

Week /8088 Addressing Modes, Instruction Set & Machine Codes Week 3 8086/8088 Addressing Modes, Instruction Set & Machine Codes Addressing Modes When the 8088 executes an instruction, it performs the specified function on data These data, called operands, May be

More information

Topics Introduction to Microprocessors

Topics Introduction to Microprocessors Topics 2102440 Introduction to Microprocessors Chapter 1 Intro to 80x86 Introduction Goals Brief History of Microprocessors Microprocessor Systems Overview Microprocessor Data Types Intro to 80x86 Suree

More information

8. Procedures. X86 Assembly Language Programming for the PC 71

8. Procedures. X86 Assembly Language Programming for the PC 71 8 Procedures X86 Assembly Language Programming for the PC 71 Stack Operation A stack is a region of memory used for temporary storage of information Memory space should be allocated for stack by the programmer

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

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

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

Using sticks to count was a great idea for its time. And using symbols instead of real sticks was much better.

Using sticks to count was a great idea for its time. And using symbols instead of real sticks was much better. Tutorial Emu86 1) Numbering systems tutorial What is it? There are many ways to represent the same numeric value. Long ago, humans used sticks to count, and later learned how to draw pictures of sticks

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

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

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

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

4.0 Chapter Overview. 4.1 The 80x86 CPUs:A Programmer s View

4.0 Chapter Overview. 4.1 The 80x86 CPUs:A Programmer s View Thi d d i h F M k 4 0 2 Memory Layout and Access Chapter Four Chapter One discussed the basic format for data in memory. Chapter Three covered how a computer system physically organizes that data. This

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

Mips Code Examples Peter Rounce

Mips Code Examples Peter Rounce Mips Code Examples Peter Rounce P.Rounce@cs.ucl.ac.uk Some C Examples Assignment : int j = 10 ; // space must be allocated to variable j Possibility 1: j is stored in a register, i.e. register $2 then

More information

The Hardware Configuration Interface On Toshiba Laptops

The Hardware Configuration Interface On Toshiba Laptops The Hardware Configuration Interface On Toshiba Laptops Jonathan Buzzard jonathan@buzzard.org.uk February 2000 Version 0.7 DISCLAIMER: The information in this document has been obtained by reverse engineering

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

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

Lecture 4-5: Bits, Bytes, and Integers

Lecture 4-5: Bits, Bytes, and Integers CSCI-UA.0201-003 Computer Systems Organization Lecture 4-5: Bits, Bytes, and Integers Mohamed Zahran (aka Z) mzahran@cs.nyu.edu http://www.mzahran.com Slides adapted from: Jinyang Li Bryant and O Hallaron

More information

Chapter 4 Data Transfers, Addressing, and Arithmetic

Chapter 4 Data Transfers, Addressing, and Arithmetic Chapter 4 Data Transfers, Addressing, and Arithmetic 4.1 Data Transfer Instructions 79 4.1.1 Introduction 79 4.1.2 Operand Types 80 4.1.3 Direct Memory Operands 80 4.1.4 MOV Instruction 81 4.1.5 Zero/Sign

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

Computer Architecture and Assembly Language. Practical Session 4

Computer Architecture and Assembly Language. Practical Session 4 Computer Architecture and Assembly Language Practical Session 4 Labels Definition - advanced label: (pseudo) instruction operands ; comment valid characters in labels are: letters, numbers, _, $, #, @,

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

Return-to-libc Attack Lab

Return-to-libc Attack Lab Laboratory for Computer Security Education 1 Return-to-libc Attack Lab Copyright c 2006-2010 Wenliang Du, Syracuse University. The development of this document is funded by the National Science Foundation

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

CSE 141 Midterm Exam

CSE 141 Midterm Exam CSE 141 Midterm Exam 2011 Winter Professor Steven Swanson 1. Please write your name at the top of each page 2. This is a close book, closed notes exam. No outside material may be used. 3. You may use a

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

Operating Systems. Week 2 Recitation: The system call. Paul Krzyzanowski. Rutgers University. Spring 2015

Operating Systems. Week 2 Recitation: The system call. Paul Krzyzanowski. Rutgers University. Spring 2015 Operating Systems Week 2 Recitation: The system call Paul Krzyzanowski Rutgers University Spring 2015 February 14, 2015 2014-2015 Paul Krzyzanowski 1 System calls System calls are an operating system s

More information

CSC 574 Computer and Network Security. Reverse Engineering

CSC 574 Computer and Network Security. Reverse Engineering CSC 574 Computer and Network Security Reverse Engineering Alexandros Kapravelos kapravelos@ncsu.edu (Derived from slides by Chris Kruegel) Introduction Reverse engineering process of analyzing a system

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

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

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

Simple Practice Programs. ; store the higher byte

Simple Practice Programs. ; store the higher byte Simple Practice Programs Program 1: - Exchange the content of FFh and FF00h Solution: - Here one is internal memory location and other is memory external location. so first the content of ext memory location

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

CS 64 Lecture 5: Decision Instruc4ons

CS 64 Lecture 5: Decision Instruc4ons CS 64 Lecture 5: Decision Instruc4ons So Far Basic Arithme4c add, sub, addi, mult, div Load memory: lw $s0, 8($t0) Store memory: sw $s0, - 8 ($t0) Q1 What opera4on copies data from main memory to a register

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

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

Assembly language programs are made up of statements. Each statement may be composed of constants, literals, names, mnemonics, operands, and comments.

Assembly language programs are made up of statements. Each statement may be composed of constants, literals, names, mnemonics, operands, and comments. CS221 Assembly Language Fundamentals : Irvine Chapter 3 While debug is good for writing very small programs and experimenting with memory, interrupts, and function calls, it is not very good for larger

More information

Save from: 2 nd. class Micro-Processors and Assembly Programming المعالجات الميكروية والبرمجة بلغة التجميع

Save from:  2 nd. class Micro-Processors and Assembly Programming المعالجات الميكروية والبرمجة بلغة التجميع Save from: wwwuotechnologyeduiq 2 nd class Micro-Processors and Assembly Programming المعالجات الميكروية والبرمجة بلغة التجميع مم الماده: استاذة نور مشرق عبدالحميد 2 References The 8086 Microprocessors

More information

8086 Microprocessor. A Seminar report on SUBMITTEDTO: SUBMITTED BY:

8086 Microprocessor.  A Seminar report on SUBMITTEDTO: SUBMITTED BY: A Seminar report on 8086 Microprocessor Submitted in partial fulfillment of the requirement for the award of degree Of Electronics SUBMITTEDTO: SUBMITTED BY: www.studymafia.org www.studymafia.org Preface

More information

Computer Organization and Assembly Language

Computer Organization and Assembly Language Computer Organization and Assembly Language Lecture 3 Assembly Language Fundamentals Basic Elements of Assembly Language An assembly language program is composed of : Constants Expressions Literals Reserved

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

Assembly Language Programming

Assembly Language Programming Assembly Language Programming Status Flags The status flags reflect the outcomes of arithmetic and logical operations performed by the CPU. The carry flag (CF) is set when the result of an unsigned arithmetic

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

Computer Organization and Architecture Low Level Programming Physical Communication Mechanisms What Language Does a Computer Speak?

Computer Organization and Architecture Low Level Programming Physical Communication Mechanisms What Language Does a Computer Speak? Computer Organization and Architecture Low Level Programming "How do I get this thing to do what I want it to do????" Department of Computer Science University of Maine Since computers were invented, we've

More information

EC6504 MICROPROCESSOR AND MICROCONTROLLERS LECTURE NOTES

EC6504 MICROPROCESSOR AND MICROCONTROLLERS LECTURE NOTES EC6504 MICROPROCESSOR AND MICROCONTROLLERS LECTURE NOTES Prepared By Mrs. J.Doulas, AP/CSE www.francisxavier.ac.in 1 EC6504 MICROPROCESSOR AND MICROCONTROLLER L T P C 3 0 0 3 OBJECTIVES: The student should

More information

Table 1a: The complete MSP430 instruction set of 27 core instructions

Table 1a: The complete MSP430 instruction set of 27 core instructions Table a: The complete MSP430 instruction set of 27 core instructions core instruction mnemonics core instruction binary Single-operand arithmetic 5 4 3 2 0 9 8 7 6 5 4 3 2 0 0 0 0 0 0 opcode B/ As source

More information

Lecture 3: MIPS Instruction Set

Lecture 3: MIPS Instruction Set Lecture 3: MIPS Instruction Set Today s topic: More MIPS instructions Procedure call/return Reminder: Assignment 1 is on the class web-page (due 9/7) 1 Memory Operands Values must be fetched from memory

More information

Using Block Prefetch for Optimized Memory Performance Advanced Micro Devices Mike Wall Member of Technical Staff Developer Performance Team

Using Block Prefetch for Optimized Memory Performance Advanced Micro Devices Mike Wall Member of Technical Staff Developer Performance Team Using Block Prefetch for Optimized Memory Performance Advanced Micro Devices Mike Wall Member of Technical Staff Developer Performance Team Introduction In recent years, clock speeds of X86 processors

More information