1 / 18

Lecture 19

Lecture 19. #include <bios.h> #include <dos.h> void main () { unsigned int cen,yrs,mons,days; _AH =4; geninterrupt(0x1a); cen=_CH; yrs=_CL; mons=_DH; days=_DL; cen = cen <<4; *((unsigned char *)(&cen)) = (*((unsigned char *)(&cen))) >>4; cen = cen + 0x3030;.

tanaya
Download Presentation

Lecture 19

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 19

  2. #include <bios.h>#include <dos.h>void main (){ unsigned int cen,yrs,mons,days; _AH =4; geninterrupt(0x1a); cen=_CH; yrs=_CL; mons=_DH; days=_DL; cen = cen <<4; *((unsigned char *)(&cen)) = (*((unsigned char *)(&cen))) >>4; cen = cen + 0x3030;

  3. mons = mons <<4; *((unsigned char *)(&mons)) = (*((unsigned char *)(&mons))) >>4; mons = mons + 0x3030; yrs = yrs <<4; *((unsigned char *)(&yrs)) = (*((unsigned char *)(&yrs))) >>4; yrs = yrs + 0x3030; days = days <<4; *((unsigned char *)(&days)) = (*((unsigned char *)(&days))) >>4; days = days + 0x3030; clrscr();

  4. printf("%c%c-%c%c-%c%c%c%c", *(((unsigned char*)(&days))+1), *((unsigned char*)(&days)), *(((unsigned char*)(&mons))+1), *((unsigned char*)(&mons)), *(((unsigned char*)(&cen))+1), *((unsigned char*)(&cen)), *(((unsigned char*)(&yrs))+1), *((unsigned char*)(&yrs))); getch();}

  5. unsigned char ASCIItoBCD(char hi, char lo){ hi = hi - 0x30; lo = lo - 0x30; hi = hi << 4; hi = hi | lo; return hi;}void main (){ unsigned char yrs,mons,days,cen; char ch1, ch2; puts("\nEnter the century to update: "); ch1=getche(); ch2=getche(); cen = ASCIItoBCD(ch1, ch2);

  6. puts("\nEnter the yrs to update: "); ch1=getche(); ch2=getche(); yrs = ASCIItoBCD(ch1, ch2); puts("\nEnter the month to update: "); ch1=getche(); ch2=getche(); mons = ASCIItoBCD(ch1, ch2); puts("\nEnter the days to update: "); ch1=getche(); ch2=getche(); days = ASCIItoBCD(ch1, ch2); _CH = cen;_CL=yrs;_DH= mons; _DL=days; _AH =5; geninterrupt(0x1a); puts("Date Updated");}

  7. void interrupt (*oldint)();void interrupt newint();unsigned int far * scr = (unsigned int far *)0xb8000000;void main (){ oldint = getvect(0x4a); setvect(0x4a, newint); _AH=6; _CH =0x23; _CL=0x50; _DH=0; geninterrupt(0x1a); keep(0,1000);}void interrupt newint(){ *scr=0x7041; sound(0x21ff);}

  8. #include <bios.h>#include <dos.h>void interrupt newint70();void interrupt (*oldint70)();unsigned int far *scr = (unsigned int far *)0xb8000000;unsigned char ASCIItoBCD(char hi, char lo){ hi = hi - 0x30; lo = lo - 0x30; hi = hi << 4; hi = hi | lo; return hi;}

  9. void main (void){ int temp; unsigned char hrs,mins,secs; char ch1, ch2; puts("\nEnter the hours to update: "); ch1=getche(); ch2=getch(); hrs = ASCIItoBCD(ch1, ch2); puts("\nEnter the minutes to update: "); ch1=getche(); ch2=getch(); mins = ASCIItoBCD(ch1, ch2);

  10. puts("\nEnter the seconds to update: "); ch1=getche(); ch2=getch(); secs = ASCIItoBCD(ch1, ch2); outportb(0x70,1); outportb(0x71,secs); outportb(0x70,3); outportb(0x71,mins); outportb(0x70,5); outportb(0x71,hrs); outportb(0x70,0x0b);

  11. temp = inport(0x71); temp = temp | 0x70; outportb(0x70,0x0b); outportb(0x71,temp); oldint70 = getvect(0x70); setvect(0x70, newint70); keep(0,1000);}void interrupt newint70(){ outportb(0x70,0x0c); if (( inport(0x71) & 0x20) == 0x20) sound(0x21ff); *scr=0x7041; (*oldint70)();}

  12. Determining Systems Information INT 11H INT 12H INT 11H used to get hardware environment info. On Entry call 11H On Exit AX = System Info.

  13. Determining Systems Information INT 12H used for memory interfaced. INT 15H/88H Returns = No. of KB above 1MB mark.

More Related