1 / 25

System Programming

NFC-IET-2011. System Programming. Lecture-08 Interrupt Mechanism-Microprocessor Signals Dated: April 11, 2011 By Somia Razzaq Note: Some slides and images of following lecture are taken from VU. Keyboard Buffer. Keyboard Buffer is located in BIOS Data Area. Starts at 40: IEH

orli-nixon
Download Presentation

System Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. NFC-IET-2011 System Programming Lecture-08 Interrupt Mechanism-Microprocessor Signals Dated: April 11, 2011 By Somia Razzaq Note: Some slides and images of following lecture are taken from VU

  2. Keyboard Buffer Keyboard Buffer is located in BIOS Data Area. Starts at 40: IEH Ends at 40 : 3DH Has 32 byes of memory 2 bytes for each character. Head points is located at address 40 : 1A to 40 : IBH Tail points located at address 40 : IC to 40 : IDH

  3. 40:1AH 40:1CH Head Tail 40:1EH 40:3DH

  4. 0x20 0x21 0x22 0x23 Head = 0x24

  5. 0xIE Tail 0x20 Head = 0x24

  6. So KBD buffer acts as a circular buffer. The tail value should be examination to get to the start of the buffer.

  7. #include <dos.h>void interrupt (*old)();void interrupt new1();char for *scr = (char far*) 0x0040001C; void main(){ old = getvect(0x09); setvect(0x09,new1); keep(0,1000);}

  8. void interrupt new1 (){if(inportb(0x60)==83){*((char far*)0x0040000+*scr)=25; if((*scr)==60) *scr=30; else *scr+=2;outportb(0x20,0x20);return;}}

  9. EOI Code for Slave IRQ

  10. For Master outportb(0x20,0x20);For Slave outportb(0x20,0x20); outportb(0xA0,0x20);

  11. OCW2*OCW3 00 If EOI is to be Initialized 001 FOR Non Specific EOI 01 If other Registers are to be accessed

  12. 01 To read IRR or ISR 10 = IRR 11= In-Service Register

  13. No EOI relevant Don’t Care Other Register to be Accessed

  14. IRR Accessed 01 PIC Notified about reading operation

  15. ISR Accessed 01 PIC Notified about reading operation

  16. #include <stdio.h>#include <dos.h>#include <bios.h>void main ( ){ char a;outport(0x20,8);outport(0x20,0x0A); a=inport(0x20);printf (“value of IRR is %x”, a);outport(0x20,0x08);outport(0x20,0x0B); a=inport(0x20);printf (“value of ISR is %x”, a); }

  17. More about TSR Programs • A TSR need to be loaded once in memory • Multiple loading will leave redundant copies in memory • So we need to have some check which will load the program only once

  18. Using a Global Variable as a flag

  19. int flag;flag =1;Keep(0,1000);if (flag==1) Make TSRelse exit Program But this wont Work

  20. Answers is to use a memory area as flag that is global to all programs.i.e. IVT

  21. int 65 is empty, we can use its vector as a flag. Address of vector seg = 0 offset = 65H * 4

  22. #include<stdio.h> #include<BIOS.H> #include<DOS.H> unsigned int far * int65vec = (unsigned far *) MK_FP(0,0x65*4) void interrupt (*oldint) ( ); void interrupt newfunc ( ); void main() { if((*int65vec) = = 0xF00F) { oldint =getvect (0x08); setvect(0x08, newint); (*int65vec) = 0xF00F; keep (0,1000); }else { puts (“Program Already Resident”); }} void interrupt newfunc () { ::::::: ::::::: (*oldint) ( ); }

  23. But what if another program is resident or using this vector. Another Method Service # 0xFF usually does not exist for ISR’s. Key is to create another service # 0xFF for the ISR interrupt besides other processing.

  24. #include<stdio.h> #include<BIOS.H> #include<DOS.H> void interrupt (*oldint) ( ); void interrupt newfunc ( unsigned int BP,..…,flags); void main() { _DI = 0; _AH = 0xFF; geninterrupt (0x13); if (_DI = = 0xF00F) { puts (“Program Already Resident”); exit (0); }

  25. else { oldint = getvect (0x13); setvect (0x13, newint); Keep (0, 1000); }} void interrupt newint ( ) { if (_AH == 0xFF){ DI = 0xF00F; return; }else { ::::::: ::::::: } (*oldint) ( ); }

More Related