180 likes | 288 Views
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;.
E N D
#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;
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();
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();}
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);
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");}
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);}
#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;}
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);
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);
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)();}
Determining Systems Information INT 11H INT 12H INT 11H used to get hardware environment info. On Entry call 11H On Exit AX = System Info.
Determining Systems Information INT 12H used for memory interfaced. INT 15H/88H Returns = No. of KB above 1MB mark.