1 / 13

Lecture 10

Lecture 10. unsigned long int * time = (unsigned long int *) 0x0040006C void main() { unsigned long int tx; unsigned int divisor = 0x21FF; while (divisor >= 0x50) { outportb(0x43,0xB4); outportb(0x42,*((char*)(&divisor))); outportb(0x42,*(((char*)(&divisor))+1));

Download Presentation

Lecture 10

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. Lecture 10

  2. unsigned long int * time = (unsigned long int *) 0x0040006C void main() { unsigned long int tx; unsigned int divisor = 0x21FF; while (divisor >= 0x50) { outportb(0x43,0xB4); outportb(0x42,*((char*)(&divisor))); outportb(0x42,*(((char*)(&divisor))+1)); outportb(0x61,Inportb(0x61) | 3); tx = *time; tx = tx + 4; while (*time <= tx); divisor =divisor -30; } }

  3. #include <dos.h> #include <bios.h> void interrupt (*oldint15) ( ); void interrupt newint15 (unsigned int BP, unsigned int DI, unsigned int SI, unsigned int DS, unsigned int ES, unsigned int DX, unsigned int CX, unsigned int BX, unsigned int AX, unsigned int CS, unsigned int IP, unsigned int flags); void main ( ) { oldint15 = getvect (0x15); setvect (0x15, newint15); keep (0, 1000); }

  4. void interrupt newint15( unsigned int BP, unsigned int DI, unsigned int SI, unsigned int DS, unsigned int ES, unsigned int DX, unsigned int CX, unsigned int BX, unsigned int AX, unsigned int CS, unsigned int IP, unsigned int flags){ if (_AH = = 0x4F) { if (_AL == 0x1F) { outport (0x43, 0xB4); outport (0x42, 0xFF); outport (0x42, 0x21); outport (0x61, Inport(0x61) ^ 3); } } else (*oldint15) ( ); }

  5. #include <dos.h>#include <bios.h>unsigned int divisors[4]={0x21ff,0x1d45,0x1b8a,,0x1e4c};unsigned long int far *time =(unsigned long int far *)0x0040006C;void main (){ unsigned long int tx; int i=0; while (!kbhit()) { while (i<4) { outport(0x43,0xB4); outport(0x42,*((char *)(&divisor[i]))); outport(0x42,*(((char *)(&divisor[i]))+1)); outport(0x61, inport(0x61)|3); tx=*time; tx=tx+4; while (tx >= (*time)); i++; } i=0; } outport(0x61,inport(0x61)&0xFC);}

  6. #include <stdio.h>#include <dos.h>#include <bios.h> struct tagTones { unsigned int divisor; unsigned int delay; };struct tagTones Tones[4]={ {0x21ff,3},{0x1d45,2},{0x1b8a,3},{0x1e4c,4}};int i,ticks,flag=0 ;void interrupt (*oldint15)();void interrupt (*oldint8)();void interrupt newint15();void interrupt newint8();

  7. unsigned char far *scr = (unsigned char far *)(0x00400017); void main () { oldint15=getvect(0x15); setvect(0x15,newint15); oldint8=getvect(0x08); setvect(0x08,newint8); keep(0,1000); }

  8. void interrupt newint15(){ if (_AH==0x4f) { if ((_AL==0x1f)&&(((*scr)&12)==12)) { ticks=0; i=0; outport(0x43,0xb4); outport(0x42,*((char *)(&Tones[i].divisor))); outport (0x42,*(((char *)(&Tones[i].divisor))+1)); outport(0x61,inport(0x61)|3); flag=1; } else if ((_AL==0x1E)&&(((*scr)&12)==12)) { outport(0x61,inport(0x61)&0xfc); flag=0; } return; } (*oldint15)();}

  9. void interrupt newint8(){ if (flag==1) { ticks++; if (ticks == Tones[i].delay) { if (i==3) i=0; else i++; outport (0x43, 0xB4); outport(0x42,*((char *)(&Tones[i].divisor))); outport(0x42,*(((char *)(&Tones[i].divisor))+1)); outport(0x61,inport(0x61)|3); ticks = 0; } } (*oldint8)();}

  10. Parallel Ports (PPI)

  11. Output D0 D1 D2 CPU D7 Busy Strobe Parallel Communication Parallel Out Put Device

  12. Parallel Communication Input D0 D1 D2 Parallel Input Device CPU D7 DR I/O Controller CPU

  13. Parallel Communication • Faster • Only Economically Feasible For Small Distances

More Related