UMBC. contain new IP while 4th and 5th bytes contain CS. CALL BX and CALL [BX] versions also exist. contain displacement added to IP.

Similar documents
Program Control Instructions

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

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

BASIC INTERRUPT PROCESSING

Basic Execution Environment

Mechanisms for entering the system

+ Overview. Projects: Developing an OS Kernel for x86. ! Handling Intel Processor Exceptions: the Interrupt Descriptor Table (IDT)

The Microprocessor and its Architecture

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

MICROPROCESSOR MICROPROCESSOR ARCHITECTURE. Prof. P. C. Patil UOP S.E.COMP (SEM-II)

Hardware and Software Architecture. Chapter 2

x86 Assembly Tutorial COS 318: Fall 2017

Introduction to IA-32. Jo, Heeseung

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

Addressing Modes on the x86

INTRODUCTION TO IA-32. Jo, Heeseung

Chapter 3: Addressing Modes

Module 3 Instruction Set Architecture (ISA)

SYSC3601 Microprocessor Systems. Unit 2: The Intel 8086 Architecture and Programming Model

The x86 Architecture

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

IA32 Intel 32-bit Architecture

Assembly Language Lab # 9

Microprocessors ( ) Fall 2010/2011 Lecture Notes # 15. Stack Operations. 10 top

SRI VENKATESWARA COLLEGE OF ENGINEERING AND TECHNOLOGY DEPARTMENT OF ECE EC6504 MICROPROCESSOR AND MICROCONTROLLER (REGULATION 2013)

MICROPROCESSOR ALL IN ONE. Prof. P. C. Patil UOP S.E.COMP (SEM-II)

x86 architecture et similia

Experiment 8 8 Subroutine Handling Instructions and Macros

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

The Purpose of Interrupt

3.1 DATA MOVEMENT INSTRUCTIONS 45

Assembler Programming. Lecture 2

Microkernel Construction

MICROPROCESSOR MICROPROCESSOR ARCHITECTURE. Prof. P. C. Patil UOP S.E.COMP (SEM-II)

Complex Instruction Set Computer (CISC)

Microkernel Construction

Assembly Language. Lecture 2 - x86 Processor Architecture. Ahmed Sallam

ECE 485/585 Microprocessor System Design

The Instruction Set. Chapter 5

An Interrupt is either a Hardware generated CALL (externally derived from a hardware signal)

ADVANCED PROCESSOR ARCHITECTURES AND MEMORY ORGANISATION Lesson-11: 80x86 Architecture

eaymanelshenawy.wordpress.com

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

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

Assembly Language. Lecture 2 x86 Processor Architecture

An Interrupt is either a Hardware generated CALL (externally derived from a hardware signal)

Homework / Exam. Return and Review Exam #1 Reading. Machine Projects. Labs. S&S Extracts , PIC Data Sheet. Start on mp3 (Due Class 19)

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

MICROPROCESSOR ARCHITECTURE

Chapter 2: The Microprocessor and its Architecture

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

An Introduction to x86 ASM

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

Chapter 11. Addressing Modes

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

Processor Structure and Function

16.317: Microprocessor Systems Design I Fall 2014

EEM336 Microprocessors I. Addressing Modes

W4118: PC Hardware and x86. Junfeng Yang

A4 Sample Solution Ch3

Memory Models. Registers

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

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

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

CS241 Computer Organization Spring 2015 IA

Function Calls COS 217. Reading: Chapter 4 of Programming From the Ground Up (available online from the course Web site)

William Stallings Computer Organization and Architecture 10 th Edition Pearson Education, Inc., Hoboken, NJ. All rights reserved.

ICS143A: Principles of Operating Systems. Midterm recap, sample questions. Anton Burtsev February, 2017

6x86 PROCESSOR Superscalar, Superpipelined, Sixth-generation, x86 Compatible CPU

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

Stack -- Memory which holds register contents. Will keep the EIP of the next address after the call

Microprocessors and Microcontrollers/High end processors

iapx Systems Electronic Computers M

EECE.3170: Microprocessor Systems Design I Summer 2017 Homework 4 Solution

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

16.317: Microprocessor Systems Design I Spring 2015

Interrupts. Chapter 20 S. Dandamudi. Outline. Exceptions

Chapter 12: INTERRUPTS

administrivia today start assembly probably won t finish all these slides Assignment 4 due tomorrow any questions?

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

Lecture 4 CIS 341: COMPILERS

History of the Intel 80x86

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

Assembly Language Programming Introduction

Reverse Engineering II: The Basics

Stack, subprograms. procedures and modular programming role of stack while using procedures stack implementation (Pentium)

3. Process Management in xv6

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

COMPUTER ENGINEERING DEPARTMENT

Program Exploitation Intro

Computer Architecture and System Software Lecture 06: Assembly Language Programming

9/25/ Software & Hardware Architecture

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

Unit 08 Advanced Microprocessor

CMSC Lecture 03. UMBC, CMSC313, Richard Chang

16.317: Microprocessor Systems Design I Fall 2013

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

Buffer Overflow Attack

Come and join us at WebLyceum

Project 1: Bootloader. COS 318 Fall 2015

Transcription:

Procedures: CALL: Pushes the address of the instruction following the CALL instruction onto the stack. RET: Pops the address. SUM PROC NEAR USES BX CX DX ADD AX, BX ADD AX, CX MOV AX, DX RET SUM ENDP NEAR CALL: Similar to NEAR jump instruction, e.g. 2nd and 3rd bytes of instruction contain displacement added to IP. FAR CALL: Similar to FAR jump instruction, e.g. 2nd and 3rd bytes of instruction contain new IP while 4th and 5th bytes contain CS. CALL BX and CALL [BX] versions also exist. 1 (March 27, 2000 10:41 pm)

Interrupts: Hardware generated CALL: I/O Device Software generated CALL: Internally derived from an instruction or exception. We will look at both of these. Interrupt Vectors: Real Mode: A 4 byte number stored in the first 1024 bytes of memory. Protected Mode: A interrupt descriptor table is used instead. Each descriptor is 8 bytes long. There are 256 interrupt vectors. Intel reserves the 0-31. Interrupts 33-255 are user definable. Vectors 1-6, 7, 9, 16 and 17 function in real and protected mode. The rest function only in protected mode. 2 (March 27, 2000 10:41 pm)

Interrupt Vectors: Number Address Microprocessor Function 0 00-03 All Divide error 1 04-07 All Single step 2 08-0B All NMI pin 3 0C-0F All Breakpoint 4 10-13 All Interrupt on overflow 5 14-17 80186-Pentium Bound instruction (print screen) 6 18-1B 80186-Pentium Invalid opcode 7 1C-1F 80186-Pentium Coprocessor emulation 8 20-23 80386-Pentium Double fault (clock tick) 9 24-27 80386 Coprocessor segment overrun (keyboard) A 28-2B 80386-Pentium Invalid task state segment (IRQ2) B 2C-2F 80386-Pentium Segment not present (IRQ3) C 30-33 80386-Pentium Stack fault (IRQ4) D 34-37 80386-Pentium General protection fault (IRQ5) E 38-3B 80386-Pentium Page fault (IRQ6) F 3C-3F ----- Reserved (IRQ7) 10 40-43 80286-Pentium Floating-point error (Video) 11 44-47 80486SX Alignment check interrupt 12 48-4F Pentium Machine check exception 13-1F 50-7F --- Reserved 3 (March 27, 2000 10:41 pm)

Interrupt Instructions. Real mode: Fetches a vector from the vector table (address of ISR). Protected mode: Fetches an interrupt descriptor (contains addr of ISR). Similar to a FAR CALL: pushes both IP/EIP and CS onto stack. 3 types are available: INT There are 256 software interrupt instructions. The INT instruction takes a numeric operand: 0-255. Real mode: It s multiplied by 4 to get address of vector. Protected mode: It s multiplied by 8 (descriptors are 8 bytes long). 4 (March 27, 2000 10:41 pm)

INT Instruction. Processing sequence for an INT instruction: Push FLAGS. Clear T and I flag bits (hardware interrupts disabled). Push CS. Fetch new value for CS from interrupt vector. Push IP/EIP. Fetches new value of IP/EIP from vector. Jump to new location. INT instruction is 2 bytes long. Replaces FAR CALL, which is 5 bytes long. Commonly used to call system functions. Decouples programs from system function addresses. IRET(Real)/IRETD(Protected): Undoes call: POP IP/EIP, POP CS, POP FLAGS Popping FLAGS restores T and I bits. 5 (March 27, 2000 10:41 pm)

Interrupt Instructions. 2nd type: INTO Interrupt on overflow. Conditional software interrupt that tests the overflow flag (O). If O=0, INTO does nothing. If O=1, the procedure at interrupt vector 4 is called. 3rd type: INT3 Designed to function like a breakpoint to debug software. It is a 1 byte instruction. Form of an ISR: ISR PROC FAR... IRET ;Pops EIP, CS and FLAGS ISR ENDP 6 (March 27, 2000 10:41 pm)

Hardware Interrupt Control. STI: Places a 1 into the I flag, this enables interr upts. CLI: Places a 0 there, disabling interrupts. Miscellaneous Machine Instructions: STC (set carry), CLC (clear carry) and CMC (complement carry) In addition to propagating carry and borrow in multiple-word/double-word addition, these are used to return error conditions in system calls. C = 1: Error occurred. C = 0: No error occurred. HLT Stops instruction execution. Three ways to resume execution: interrupt, hardware reset or DMA operation. Used to synchronize hardware interrupts with system software. 7 (March 27, 2000 10:41 pm)

Miscellaneous Machine Instructions. LOCK Prefi x: Appended to an instruction. Toggle the LOCK pin, disabling external bus masters and other peripherials. ENTER/LEAVE Used with stack frames, which provide a mechanism to pass stack parameters and allocate storage for local variables for procedures. ENTER pushes BP, and loads BP with the uppermost address of stack frame. Stack variables can then be accessed through the BP register. LEAVE restores previous values of BP and SP, e.g. MOV SP BP POP BP 8 (March 27, 2000 10:41 pm)

ENTER/LEAVE: EAX EBX ECX EDX ESP EBP EDI ESI CS DS ES SS F F F C F F F A 3 0 0 0 ENTER 8, 0 1) Push old BP *10H old SP 2) Set BP FFFA 3) Allocate Stack Frame FFF2 + 3FFFC Stack Seg Old BP 3FFFC 3FFFA 3FFF8 3FFF6 3FFF4 3FFF2 9 (March 27, 2000 10:41 pm)

ENTER/LEAVE: ENTER 4, 0 MOV AX, DATA1 MOV [BP-4], AX MOV AX, DATA2 MOV [BP-2], AX CALL SYS MOV AX, [BP-4] MOV RES1, AX MOV AX, [BP-2] MOV RES2, AX LEAVE ;Save parameters on the stack. ;System call that uses stack ;parameters ;Get results... ;Other code continues here. SYS PROC NEAR PUSHA MOV AX, [BP-4] MOV BX, [BP-2]... 10 (March 27, 2000 10:41 pm)