Download presentation
Presentation is loading. Please wait.
1
Assembly Language for Intel-Based Computers Chapter 16: Expert MS-DOS Programming (c) Pearson Education, 2006-2007. All rights reserved. You may modify and copy this slide show for your personal use, or for use in the classroom, as long as this copyright statement, the author's name, and the title are not changed.
2
Web siteWeb site ExamplesExamples Irvine, Kip R. Assembly Language for Intel-Based Computers 5/e, 2007. 2 Expert MS-DOS Programming Interrupt Handling Terminate and stay Resident Programs
3
Web siteWeb site ExamplesExamples Irvine, Kip R. Assembly Language for Intel-Based Computers 5/e, 2007. 3 Interrupt Handling Interrupt Handling
4
Web siteWeb site ExamplesExamples Irvine, Kip R. Assembly Language for Intel-Based Computers 5/e, 2007. 4 Interrupt Vectoring Process
5
Web siteWeb site ExamplesExamples Irvine, Kip R. Assembly Language for Intel-Based Computers 5/e, 2007. 5 Overview Interrupt handler (interrrupt service routine) – performs common I/O tasks can be called as functions can be activated by hardware events Examples: keyboard handler divide by zero handler Ctrl-Break handler serial port I/O
6
Web siteWeb site ExamplesExamples Irvine, Kip R. Assembly Language for Intel-Based Computers 5/e, 2007. 6 Interrupt Handling Interrupt Handling Executing Interrupt Handlers:- software interrupt Hardware Interrupt
7
Web siteWeb site ExamplesExamples Irvine, Kip R. Assembly Language for Intel-Based Computers 5/e, 2007. 7 Interrupt Handling Interrupt Handling Interrupt Control Instructions:- STI instruction (enable external interrupts) CLI instruction (disable external interrupts)
8
Web siteWeb site ExamplesExamples Irvine, Kip R. Assembly Language for Intel-Based Computers 5/e, 2007. 8 Writing a Custom Interrupt Handler
9
Web siteWeb site ExamplesExamples Irvine, Kip R. Assembly Language for Intel-Based Computers 5/e, 2007. 9 Ctrl-Break Handler Example
10
Web siteWeb site ExamplesExamples Irvine, Kip R. Assembly Language for Intel-Based Computers 5/e, 2007. 10 Ctrl-Break Handler Example
11
Web siteWeb site ExamplesExamples Irvine, Kip R. Assembly Language for Intel-Based Computers 5/e, 2007. 11 Ctrl-Break Handler Example
12
Web siteWeb site ExamplesExamples Irvine, Kip R. Assembly Language for Intel-Based Computers 5/e, 2007. 12 Terminate and Stay Resident Programs (TSR): Installed in memory, stays there until removed by a removal program, or by rebooting Mov ah,31h Mov dx, code_Length Int 21h
13
Web siteWeb site ExamplesExamples Irvine, Kip R. Assembly Language for Intel-Based Computers 5/e, 2007. 13 Interrupt Vector Table Each entry contains a 32-bit segment/offset address that points to an interrupt service routine Offset = interruptNumber * 4
14
Web siteWeb site ExamplesExamples Irvine, Kip R. Assembly Language for Intel-Based Computers 5/e, 2007. 14 TSR Example: printing a character when print screen button is pressed.Model tiny.code Jmp init Start_TSR: push ax push es mov ax,0b800h mov es,ax mov es:[0],’A’ mov es:[1],07 pop es pop ax iret Init: mov ax,0 mov ds,ax Cli Mov word ptr ds:[20],offset start_TSR Mov word ptr ds:[22],CS sti Mov dx, offset init Mov ah,31h Int 21h End
15
Web siteWeb site ExamplesExamples Irvine, Kip R. Assembly Language for Intel-Based Computers 5/e, 2007. 15 TSR Example: make the print screen button acts as the Caps Lock.Model tiny.code Jmp init Start: push ax push es mov ax, 40h mov es, ax xor byte ptr es : [17h], 01000000b pop es pop ax iret Init: mov ax, 0 mov ds, ax Cli Mov word ptr ds:[20],offset start Mov word ptr ds:[22],CS sti Mov dx, offset init Mov ah,31h Int 21h End
16
Web siteWeb site ExamplesExamples Irvine, Kip R. Assembly Language for Intel-Based Computers 5/e, 2007. 16 TSR
17
Web siteWeb site ExamplesExamples Irvine, Kip R. Assembly Language for Intel-Based Computers 5/e, 2007. 17 TSR Example: toggles the Caps Lock every 55ms.Model tiny.code Jmp init Start: push ax push es mov ax, 40h mov es, ax xor word ptr es : [17h], 01000000b pop es pop ax iret Init: mov ax, 0 mov ds, ax Cli Mov word ptr ds:[1ch*4],offset start Mov word ptr ds:[1ch*4+2],CS sti Mov dx, offset init Mov ah,31h Int 21h End
18
Web siteWeb site ExamplesExamples Irvine, Kip R. Assembly Language for Intel-Based Computers 5/e, 2007. 18 TSR Example: toggles the Caps Lock 3 times.Model tiny.code Jmp init Count db 0 Start: push ax push es cmp cs:[offset count], 3 je Fin inc cs:[offset count] mov ax, 40h mov es, ax xor word ptr es : [17h], 01000000b Fin: pop es pop ax iret Init: mov ax, 0 mov ds, ax Cli Mov word ptr ds:[1ch*4],offset start Mov word ptr ds:[1ch*4+2],CS sti Mov dx, offset init Mov ah,31h Int 21h End
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.