Lecture 19 include bios h include dos h
Lecture 19
#include <bios. h> #include <dos. h> void main () { unsigned int cen, yrs, mons, days; _AH =4; geninterrupt(0 x 1 a); cen=_CH; yrs=_CL; mons=_DH; days=_DL; cen = cen <<4; *((unsigned char *)(&cen)) = (*((unsigned char *)(&cen))) >>4; cen = cen + 0 x 3030;
mons = mons <<4; *((unsigned char *)(&mons)) = (*((unsigned char *)(&mons))) >>4; mons = mons + 0 x 3030; yrs = yrs <<4; *((unsigned char *)(&yrs)) = (*((unsigned char *)(&yrs))) >>4; yrs = yrs + 0 x 3030; days = days <<4; *((unsigned char *)(&days)) = (*((unsigned char *)(&days))) >>4; days = days + 0 x 3030; clrscr();
} printf("%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 ASCIIto. BCD(char hi, char lo) { hi = hi - 0 x 30; lo = lo - 0 x 30; hi = hi << 4; hi = hi | lo; return hi; } void main () { unsigned char yrs, mons, days, cen; char ch 1, ch 2; puts("n. Enter the century to update: "); ch 1=getche(); ch 2=getche(); cen = ASCIIto. BCD(ch 1, ch 2);
} puts("n. Enter the yrs to update: "); ch 1=getche(); ch 2=getche(); yrs = ASCIIto. BCD(ch 1, ch 2); puts("n. Enter the month to update: "); ch 1=getche(); ch 2=getche(); mons = ASCIIto. BCD(ch 1, ch 2); puts("n. Enter the days to update: "); ch 1=getche(); ch 2=getche(); days = ASCIIto. BCD(ch 1, ch 2); _CH = cen; _CL=yrs; _DH= mons; _DL=days; _AH =5; geninterrupt(0 x 1 a); puts("Date Updated");
void interrupt (*oldint)(); void interrupt newint(); unsigned int far * scr = (unsigned int far *)0 xb 8000000; void main () { oldint = getvect(0 x 4 a); setvect(0 x 4 a, newint); _AH=6; _CH =0 x 23; _CL=0 x 50; _DH=0; geninterrupt(0 x 1 a); keep(0, 1000); } void interrupt newint() { *scr=0 x 7041; sound(0 x 21 ff); }
#include <bios. h> #include <dos. h> void interrupt newint 70(); void interrupt (*oldint 70)(); unsigned int far *scr = (unsigned int far *)0 xb 8000000; unsigned char ASCIIto. BCD(char hi, char lo) { hi = hi - 0 x 30; lo = lo - 0 x 30; hi = hi << 4; hi = hi | lo; return hi; }
void main (void) { int temp; unsigned char hrs, mins, secs; char ch 1, ch 2; puts("n. Enter the hours to update: "); ch 1=getche(); ch 2=getch(); hrs = ASCIIto. BCD(ch 1, ch 2); puts("n. Enter the minutes to update: "); ch 1=getche(); ch 2=getch(); mins = ASCIIto. BCD(ch 1, ch 2);
puts("n. Enter the seconds to update: "); ch 1=getche(); ch 2=getch(); secs = ASCIIto. BCD(ch 1, ch 2); outportb(0 x 70, 1); outportb(0 x 71, secs); outportb(0 x 70, 3); outportb(0 x 71, mins); outportb(0 x 70, 5); outportb(0 x 71, hrs); outportb(0 x 70, 0 x 0 b);
temp = inport(0 x 71); temp = temp | 0 x 70; outportb(0 x 70, 0 x 0 b); outportb(0 x 71, temp); oldint 70 = getvect(0 x 70); setvect(0 x 70, newint 70); keep(0, 1000); } void interrupt newint 70() { outportb(0 x 70, 0 x 0 c); if (( inport(0 x 71) & 0 x 20) == 0 x 20) sound(0 x 21 ff); *scr=0 x 7041; (*oldint 70)(); }
Determining Systems Information INT 11 H INT 12 H INT 11 H used to get hardware environment info. On Entry call 11 H On Exit AX = System Info.
Determining Systems Information INT 12 H used for memory interfaced. INT 15 H/88 H Returns = No. of KB above 1 MB mark.
- Slides: 18