Mouse Interrupt

20
MOUSE INTERRUPT 1

Transcript of Mouse Interrupt

Page 1: Mouse Interrupt

1

MOUSE INTERRUPT

Page 2: Mouse Interrupt

2

CONTENTSInterruptInterrupts in 8086CPU’s ‘Fetch-Execute’ cycleThe operation of an interrupt sequence on 8086Mouse features

PixelMouse pointerMickey

Interrupt Vector Table(IVT)IVT FormatMouse functions

Page 3: Mouse Interrupt

3

INTERRUPT

In computing an interrupt is an asynchronous signal

indicating the need for attention.

Interrupts are a commonly used technique for computer

multitasking, Such a system is said to be interrupt driven.

An act of interrupting is referred to as an interrupt request

(IRQ).

The part of a program that deals with the interrupt is

referred to as an service routine (ISR) or interrupt

handler.

Page 4: Mouse Interrupt

4

An 8086 Interrupt can come from any of three sources.

Hardware Interrupt

• External interrupt applied to non-maskable interrupt NMI.

Interrupt response cannot be disabled ( masked) by any program instruction.

• External interrupt applied to maskable interrupt INTR.

Software Interrupt

• Execution of INT instruction.

Interrupts in 8086

Page 5: Mouse Interrupt

CPU’s ‘Fetch-Execute’ Cycle

Fetch instruction at IP

Advance IP to next instruction

Decode the fetched instruction

Execute the decoded instruction

Interrupt?

no

Save context

Get INTR ID

Lookup ISR

Execute ISR

yes IRET

5

Page 6: Mouse Interrupt

6

The Operation of an Interrupt sequence on the 8086 Microprocessor:1. External interface sends an interrupt signal, to the Interrupt

Request

(INTR) pin, or an internal interrupt occurs.

2. The CPU finishes the present instruction (for a hardware

interrupt) and

sends Interrupt Acknowledge (INTA) to hardware interface.

3. The interrupt type N is sent to the Central Processor Unit

(CPU) via the

Data bus from the hardware interface.

4. The contents of the flag registers are pushed onto the stack.

5. Both the interrupt (IF) and (TF) flags are cleared. This

disables the INTR pin and the trap or single-step feature.

Page 7: Mouse Interrupt

7

Interrupt sequence contd…6. The contents of the code segment register (CS) are pushed onto the

Stack.

7. The contents of the instruction pointer (IP) are pushed onto the Stack.

8. The interrupt vector contents are fetched, from (4 x N) and then placed

into the IP and from (4 x N +2) into the CS so that the next instruction

executes at the interrupt service procedure addressed by the interrupt

vector.

9. While returning from the interrupt-service routine by the Interrupt

Return(IRET) instruction, the IP, CS and Flag registers are popped from

the Stack and return to their state prior to the interrupt.

Page 8: Mouse Interrupt

8

Interfacing with mouseSecond primary input devices used is the mouse.

It has a greater flexibility and movement.

Mouse system consist of the mouse and the mouse driver.

Mouse driver is the memory resident program that

provides communication between the mouse and the

computer.

Mouse driver maintains the cursor position of the mouse and

the status of the mouse buttons.

Page 9: Mouse Interrupt

9

Mouse FeaturesPixel:A pixel or pel (picture element) is a single point in a raster

image, or the smallest addressable screen element in a display

device.

It is the smallest unit of picture that can be represented or

controlled.

Each pixel has its own address.

The address of a pixel corresponds to its coordinates.

Pixels are normally arranged in a two-dimensional grid and are

often represented using dots or squares.

Each pixel is a sample of an original image. More samples typically

provide more accurate representations of the original image.

Page 10: Mouse Interrupt

10

Mouse Features

Mouse pointer:A mouse pointer, or a cursor, is a visible indicator displayed

on a computer screen.

By moving the mouse, the computer's user can move the

mouse pointer around the screen.

The mouse pointer located on the screen can determine

how and where the user can press a button on the mouse to

input text or execute a command.

Page 11: Mouse Interrupt

11

Mouse FeaturesMickey:

A unit of measure for movement of the mouse, approximately

1/200 of an inch.

A mickey is a unit of measurement for the speed and

movement direction of a computer mouse.

The speed of the mouse is the ratio between how many pixels

the cursor moves on the screen and how many centimeters

you move the mouse on the mouse pad.

Page 12: Mouse Interrupt

12

Interrupt Vector Table – IVT (in memory)

x86 has 256 interrupts, specified by Type Number or Vector.

1 byte of data must accompany each interrupt(specifies Type).

Vector is a pointer (address) into Interrupt Vector Table (IVT).

- IVT is stored in memory from 0000:0000 to 0000:03ffh

- IVT contains 256 far pointer values (addresses)

- Far pointer is CS:IP values

Each far pointer is address of Interrupt Service Routine (ISR).

- Also referred to as Interrupt Handler.

Page 13: Mouse Interrupt

IVT FormatOffset

Offset

Offset

Segment

Segment

SegmentInterrupt 0

Interrupt 1

Interrupt 255

0000:0000

0000:0001

0000:0002

0000:0003

0000:0004

0000:0005

0000:0006

0000:0007

0000:03fc

0000:03fd

0000:03fe

0000:03ff

IP LSB

IP MSB

CS LSB

CS MSB

Given a Vector, where is the ISR address stored in memory ?

4Offset Type

Example: int 36h

Offset = (544) = 216 = 00d8h

Page 14: Mouse Interrupt

14

Mouse functions

We can access the cursor position and the button status with

interrupt 33h.

The mouse driver has several functions by specifying the

function number in the AX register when calling interrupt

33h.

Some of the functions are

0- Resets the mouse and retrieves the mouse status.

1- Displays the mouse cursor

2- Hides the mouse cursor.

3- Retrieves the mouse cursor positioned the status of

the mouse buttons.

Page 15: Mouse Interrupt

15

Mouse functions contd…Initializing the mouse:

To be able to use the mouse it must be first tested whether it is

present or not. int 33h mov ax,00 int 33h mov result,ax

Using int 33h is the necessary first step toward using the mouse.

If this service returns a non-zero value, the mouse is initialized.

Otherwise, the mouse cannot be used.

Page 16: Mouse Interrupt

16

Mouse functions contd…Display mouse cursor:

Initializing the mouse does not display the mouse cursor.

A function that initialize the mouse and returns the result.

Int 33h service 1 – display mouse cursor.

mov ax,01h

int 33h

At this point ,the mouse system is active and the cursor

has appeared on the screen.

Page 17: Mouse Interrupt

17

Mouse functions contd…

Hide mouse cursor:

If the cursor is already off, it stays off (int 33h service 2).

The very important reason for hiding the mouse cursor , as

the mouse cursor moves over the screen,the mouse driver

software reads the character at the preset position before it

displays the mouse cursor.

mov ax,02h

int 33h

Page 18: Mouse Interrupt

18

Mouse functions contd…

Mouse buttons:

It is also possible to read right and left button information from the

mouse int 33h service 3.

Getting mouse information:

Int 33h service 3 set AX=3 .This will return

BX meaning

0 No button down

1 Left button down

2 Right button down

3 Both the buttons down

CX = current mouse cursor column.

DX= current mouse cursor row.

Page 19: Mouse Interrupt

19

Mouse functions contd… Mov ax, 03h Int 33h Mov button, bx Mov row, dx Mov col, cx

This service 3, returns information in bx, dx, and cx.

bx indicates which button(s) are down.

This service also returns the current row and column of

the mouse cursor in dx and cx, respectively.

Page 20: Mouse Interrupt

20

THANK YOU