UMBC. A register, an immediate or a memory address holding the values on. Stores a symbolic name for the memory location that it represents.

Similar documents
Assembly Language Each statement in an assembly language program consists of four parts or fields.

Lecture 15 Intel Manual, Vol. 1, Chapter 3. Fri, Mar 6, Hampden-Sydney College. The x86 Architecture. Robb T. Koether. Overview of the x86

MODE (mod) FIELD CODES. mod MEMORY MODE: 8-BIT DISPLACEMENT MEMORY MODE: 16- OR 32- BIT DISPLACEMENT REGISTER MODE

The x86 Architecture

Addressing Modes on the x86

Chapter 3: Addressing Modes

ADDRESSING MODES. Operands specify the data to be used by an instruction

EEM336 Microprocessors I. Addressing Modes

6/20/2011. Introduction. Chapter Objectives Upon completion of this chapter, you will be able to:

Module 3 Instruction Set Architecture (ISA)

X86 Addressing Modes Chapter 3" Review: Instructions to Recognize"

UMBC. 1 (Feb. 9, 2002) seg_base + base + index. Systems Design & Programming 80x86 Assembly II CMPE 310. Base-Plus-Index addressing:

Registers. Ray Seyfarth. September 8, Bit Intel Assembly Language c 2011 Ray Seyfarth

Chapter 11. Addressing Modes

EXPERIMENT WRITE UP. LEARNING OBJECTIVES: 1. Get hands on experience with Assembly Language Programming 2. Write and debug programs in TASM/MASM

CMSC Lecture 03. UMBC, CMSC313, Richard Chang

Interfacing Compiler and Hardware. Computer Systems Architecture. Processor Types And Instruction Sets. What Instructions Should A Processor Offer?

Assembler Programming. Lecture 2

Credits and Disclaimers

Access. Young W. Lim Fri. Young W. Lim Access Fri 1 / 18

Introduction to IA-32. Jo, Heeseung

CSE2421 FINAL EXAM SPRING Name KEY. Instructions: Signature

INTRODUCTION TO IA-32. Jo, Heeseung

Hardware and Software Architecture. Chapter 2

Access. Young W. Lim Sat. Young W. Lim Access Sat 1 / 19

The Microprocessor and its Architecture

3- ADDRESSING MODES in 8086: In this section we use the MOV instruction to describe the data-addressing modes. Figure 3-1 shows the MOV instruction.

Instruction Set Architecture (ISA) Data Types

CS241 Computer Organization Spring 2015 IA

Binghamton University. CS-220 Spring x86 Assembler. Computer Systems: Sections

Credits and Disclaimers

Instruction Set Architectures

Complex Instruction Set Computer (CISC)

Assembly Language Lab # 9

Computer Processors. Part 2. Components of a Processor. Execution Unit The ALU. Execution Unit. The Brains of the Box. Processors. Execution Unit (EU)

We can study computer architectures by starting with the basic building blocks. Adders, decoders, multiplexors, flip-flops, registers,...

MICROPROCESSOR TECHNOLOGY

mith College Computer Science CSC231 - Assembly Week #4 Dominique Thiébaut

Reverse Engineering II: Basics. Gergely Erdélyi Senior Antivirus Researcher

Reverse Engineering II: The Basics

Chapter 4: Data Movement Instructions. 4 1 MOV Revisited

CS 31: Intro to Systems ISAs and Assembly. Martin Gagné Swarthmore College February 7, 2017

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

CMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 03, SPRING 2013

Addressing Modes. Outline

Experiment 8 8 Subroutine Handling Instructions and Macros

Lecture 3: Instruction Set Architecture

CSC 2400: Computer Systems. Towards the Hardware: Machine-Level Representation of Programs

EC-333 Microprocessor and Interfacing Techniques

Lecture (02) The Microprocessor and Its Architecture By: Dr. Ahmed ElShafee

Computer Architecture 1 ح 303

Assembly I: Basic Operations. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Advanced Microprocessors

EEM336 Microprocessors I. Data Movement Instructions

Scott M. Lewandowski CS295-2: Advanced Topics in Debugging September 21, 1998

Assembly level Programming. 198:211 Computer Architecture. (recall) Von Neumann Architecture. Simplified hardware view. Lecture 10 Fall 2012

Lab 2: Introduction to Assembly Language Programming

CSC 8400: Computer Systems. Machine-Level Representation of Programs

Basic Execution Environment

Marking Scheme. Examination Paper Department of CE. Module: Microprocessors (630313)

LAB 5 Arithmetic Operations Simple Calculator

Instruction Set Architectures

Code segment Stack segment

Chapter 2: The Microprocessor and its Architecture

The Instruction Set. Chapter 5

x86 Assembly Tutorial COS 318: Fall 2017

CS412/CS413. Introduction to Compilers Tim Teitelbaum. Lecture 21: Generating Pentium Code 10 March 08

RISC I from Berkeley. 44k Transistors 1Mhz 77mm^2

Machine Code and Assemblers November 6

6/17/2011. Introduction. Chapter Objectives Upon completion of this chapter, you will be able to:

MACHINE-LEVEL PROGRAMMING I: BASICS COMPUTER ARCHITECTURE AND ORGANIZATION

80X86 ASSEMBLY FOR THE HLL PROGRAMMER

Instruction Set Architectures

Computer Architecture and Assembly Language. Practical Session 3

The x86 Architecture. ICS312 - Spring 2018 Machine-Level and Systems Programming. Henri Casanova

System calls and assembler

16.317: Microprocessor Systems Design I Spring 2014

CSCE 212H, Spring 2008 Lab Assignment 3: Assembly Language Assigned: Feb. 7, Due: Feb. 14, 11:59PM

EEM336 Microprocessors I. The Microprocessor and Its Architecture

COMPUTER ENGINEERING DEPARTMENT

iapx Systems Electronic Computers M

Islamic University Gaza Engineering Faculty Department of Computer Engineering ECOM 2125: Assembly Language LAB. Lab # 7. Procedures and the Stack

Microprocessors & Assembly Language Lab 1 (Introduction to 8086 Programming)

16.317: Microprocessor Systems Design I Fall 2013

CS 16: Assembly Language Programming for the IBM PC and Compatibles

IA-32 Architecture. CS 4440/7440 Malware Analysis and Defense

Reverse Engineering II: The Basics

Introduction to Machine/Assembler Language

x86 Programming I CSE 351 Winter

Moodle WILLINGDON COLLEGE SANGLI (B. SC.-II) Digital Electronics

Machine-level Representation of Programs. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Chapter Three Addressing Mode MOV AX, BX

T Reverse Engineering Malware: Static Analysis I

CS241 Computer Organization Spring Introduction to Assembly

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 September 25, 2018

CS165 Computer Security. Understanding low-level program execution Oct 1 st, 2015

Q1: Multiple choice / 20 Q2: Memory addressing / 40 Q3: Assembly language / 40 TOTAL SCORE / 100

Dr. Ramesh K. Karne Department of Computer and Information Sciences, Towson University, Towson, MD /12/2014 Slide 1

Assembly Language: IA-32 Instructions

Transcription:

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 memory location that it represents. OPCODE: The instruction itself. OPERANDS: A register, an immediate or a memory address holding the values on which the operation is performed. There can be from 0 to 3 operands. 1 (Feb 4, 2002)

Data movement instructions move data (bytes, words and doublewords) between registers and between registers and memory. Only the movs instruction can have both operands in memory. Most data transfer instructions do not change the EFLAGS register. Format: opcode destination, source Register mov eax, ebx ebx eax Register Register 2 (Feb 4, 2002)

Immediate mov ch, 0x4b 4b ch Data Register Direct (eax), Displacement (other regs) seg_base + DISP mov [0x4321], eax eax [0x4321] Register Memory Register Indirect mov [ebx], cl seg_base + ebx cl [ebx] Register Memory Any of eax, ebx, ecx, edx, ebp, edi or esi may be used. 3 (Feb 4, 2002)

Base-plus-index mov [ebx+esi], ebp seg_base+ebx+esi ebp [ebx+esi] Register Memory Any combination of eax, ebx, ecx, edx, ebp, edi or esi. Register relative mov cl, [ebx+4] seg_base+ebx+4 [ebx+4] cl Memory Register A second variation includes: mov eax, [ARR+ebx] 4 (Feb 4, 2002)

Base relative-plus-index mov [ARR+ebx+esi], edx seg_base+arr+ebx+esi edx [...] Register Memory A second variation includes: mov eax, [ebx+edi+4] Scaled-index seg_base+ebx+2*esi mov [ebx+2*esi], eax eax [...] Register Memory A second variation includes: mov eax, ebx*2+ecx+offset Scaling factors can be 2X, 4X or 8X. 5 (Feb 4, 2002)

Register addressing: 16-bit registers ah ax al 8-bit 16-bit names 32-bit extensions eax ebx ecx edx esp ebp edi esi ah ax al bh bx bl ch cx cl dh dx dl sp bp di si Accumulator Base Index Count Data Stack Pointer Base Pointer ination Index Index Note: mov really COPIES data from the source to destination register. Never mix an 16-bit register with a 32-bit, etc. For example mov eax, bx ;ERROR: NOT permitted. None of the mov instruction effect the EFLAGS register. 6 (Feb 4, 2002)

Immediate addressing: The value of the operand is given as a constant in the instruction stream. mov eax, 0x12345 Use b for binary, q for octal and nothing for decimal. ASCII data requires a set of apostrophes: mov eax, A ;Moves ASCII value 0x41 into eax. Register and immediate addressing example: global main main: section.text ;start of the code segment. mov eax, 0 ;Immediate addressing. mov ebx, 0x0000 mov ecx, 0 mov esi, eax... ;Register addressing. 7 (Feb 4, 2002)

Direct addressing: Transfers between memory and al, ax and eax. Usually encoded in 3 bytes, sometime 4: mov al, DATA1 ;Copies a byte from DATA1. mov al, [0x4321] ;Some assemblers don t allow this. mov al, ds:[0x1234] mov DATA2, ax ;Copies a word to DATA2. Displacement: mov cl, DATA1 ;Copies a byte from DATA1. mov edi, SUM ;Copies a doubleword from SUM. Displacement instructions are encoded with up to 7 bytes (32 bit register and a 32 bit displacement). 8 (Feb 4, 2002)

Direct and displacement addressing example: global main 0000 section.data 0000 10 DATA1 db 0x10 0001 00 DATA2 db 0 0000 main: 0017 A0 0000 R 001A 8B 1E 0001 R section.text mov al, DATA1 mov bx, DATA2 Note: Direct addressing (using al) requires 3 bytes to encode while Displacement (using bx) requires 4. Register Indirect addressing: Offset stored in a register is added to the segment register. mov ecx, [ebx] mov [edi], [ebx] The memory to memory mov is allowed with string instructions. 9 (Feb 4, 2002)

Register Indirect addressing (cont) Any register EXCEPT esp for the 80386 and up. For eax, ebx, ecx, edx, edi and esi: The data segment is the default. For ebp: The stack segment is the default. Some versions of register indirect require special assembler directives byte, word, or dword mov al, [edi] ;Clearly a byte-sized move. mov [edi], 0x10 ;Ambiguous. Does [edi] address a byte, a word or a double-word? The assembler can t determine the size of 0x10! Use: mov byte [edi], 0x10 ;A byte transfer. 10 (Feb 4, 2002)