A. What are Interrupts? (in real mode)
View more random threads:
- MGMT627 PROJECT MANAGEMENT Assignment No. 1 Solution Fall...
- CS601- Data Communication Assignment No. 3 Solutions and...
- CS502 Assignment 6 Idea Solution 31 July 2010
- Semester “Fall 2011” “Principles of Marketing (MGT301)”...
- cs408 cs610 cs604 mgt502 idea solution...
- ENG201 Business and Technical English Writing Assignment...
- CS001 Solution Assignment 2 Spring 2010 May 7
- CS702 Advanced Algorithms Analysis and Design Assignment...
- Assignment # 1(Spring 2010) English Comprehension (ENG 101)
- PHY101 Physics Assignment No. 01 Fall Semester 2013 Due...
Interrupts are signals generated by the computer, by either software or hardware, every time a certain event occurs. For example, anytime a key is pressed at any point during program execution, the 0x09 interrupt is generated, causing the 0x09 interrupt handler to be called, which does its job then returns control back to the program were it left off. The interrupts are numbered from 0x00 to 0xFF and each have a special function (most are unused). In real mode, the first 1,024 bytes of memory of the computer are used as the interrupt handler table. This table has a 4 byte far address to the interrupt handler (Interrupt Service Routine - ISR) for each of the 256 interrupts. Interrupts may also be simulated by calling them with the INT command in real mode, or the __dpmi_int command in protected mode
B. Protected Mode
C. Adding your own ISRs
Many times it is useful to have your own functions be automatically called every time a specific event occurs, without having to continuously check for it. This can be done by changing the proper entry in the interrupt handler table to point to your new ISR. But many times you must have your ISR first call the original ISR to make sure the event is handled properly. To do this the address of the original ISR must be taken, and the old ISR must be called from within the new ISR. This is called chaining. The whole process is implemented in the next section
II. Implementation in DJGPP (protected mode)
A. Using _go32_dpmi functions
There are three steps to using custom interrupt handler functions
Get the address the current ISR and save it
Chain your new ISR onto the old on
Replace the old ISR once the program is done
the whole process is shown in the example code below.
//Simple Example of chaining interrupt handlers
//Adopted from Matthew Mastracci's code
//macros by Shawn Hargreaves from the Allegro library for locking
//functions and variables.
#define LOCK_VARIABLE(x) _go32_dpmi_lock_data((void *)&x,
#define LOCK_FUNCTION(x) _go32_dpmi_lock_code(x,(long)sizeof(x));
//timer interrupt 8 is generated every 18.2 ms
#define TIMER 8
int counter = 0;
//the new ISR, will be called automatically every 18.2 ms once
//structures to hold selector: offset info for the ISRs
_go32_dpmi_seginfo OldISR, NewISR;
printf("About to chain the new ISR onto the old timer ISR..\n");
//lock the functions and variables
//load the address of the old timer ISR into the OldISR structure
_go32_dpmi_get_protected_mode_interrupt_vector(TIM ER, &OldISR);
//point NewISR to the proper selector: offset for handler function
NewISR.pm_offset = (int)TickHandler;
NewISR.pm_selector = _go32_my_cs();
//chain the new ISR onto the old one so that first the old timer ISR
//will be called, then the new timer ISR
//notice no changes to counter in this loop- the interrupt
printf("Removing new ISR from the timer ISR chain\n");
//load the old timer ISR back without the new ISR chained on
_go32_dpmi_set_protected_mode_interrupt_vector(TIM ER, &OldISR);
B. Using other DPMI functions
there's a bunch of them that are for doing stuff with interrupts
C. Calling (simulating) Interrupts
The __dpmi_regs structure holds the register values __dpmi_int calls the interrupt. This example sets to video mode 0x13 by calling the video I/O interrupt 0x10.
r.x.ax = 0x13;
Last edited by viki; 07-01-2010 at 05:27 AM.
[B]The more knowledge you have, the greater will be your fear of Allah.[/B]
Please Join My [B]Group Vuhelp[/B][B], Birthday Wishing, Daily Hadees[/B] [CODE][B]http://vuhelp.net/groups/vuhelp.html[/B]
There are currently 1 users browsing this thread. (0 members and 1 guests)