Sei sulla pagina 1di 8

<bios.

h>
Access to bios services. #if !defined(__BIOS_H) #define __BIOS_H #if !defined(__DEFS_H) #include <_defs.h> #endif /* diskinfo_t structure for _bios_disk() */ struct diskinfo_t { unsigned drive, head, track, sector, nsectors; void far *buffer; }; /* cmd values for _bios_disk() */ #define _DISK_RESET 0 /* controller hard reset */ #define _DISK_STATUS 1 /* status of last operation */ #define _DISK_READ 2 /* read sectors */ #define _DISK_WRITE 3 /* write sectors */ #define _DISK_VERIFY 4 /* verify sectors */ #define _DISK_FORMAT 5 /* format track */ /* cmd values for _bios_keybrd() */ #define _KEYBRD_READ 0 /* read key */ #define _NKEYBRD_READ 0x10 /* read key - enhanced */ #define _KEYBRD_READY 1 /* check key ready */ #define _NKEYBRD_READY 0x11 /* check key ready - enhanced */ #define _KEYBRD_SHIFTSTATUS 2 /* get shift status */ #define _NKEYBRD_SHIFTSTATUS 0x12 /* get shift status - enhanced */ /* cmd values for _bios_printer() */ #define _PRINTER_WRITE 0 /* send a byte to printer */ #define _PRINTER_INIT 1 /* initialize printer */ #define _PRINTER_STATUS 2 /* read printer status */ /* cmd values for _bios_serialcom() */ #define _COM_INIT 0 /* set communication parms to a byte */ #define _COM_SEND 1 /* send a byte to port */ #define _COM_RECEIVE 2 /* read character from port */ #define _COM_STATUS 3 /* get status of port */ /* byte values for _COM_INIT cmd of _bios_serialcom() */

#define _COM_CHR7 0x02 /* 7 data bits */ #define _COM_CHR8 0x03 /* 8 data bits */ #define _COM_STOP1 0x00 /* 1 stop bit */ #define _COM_STOP2 0x04 /* 2 stop bits */ #define _COM_NOPARITY 0x00 /* no parity */ #define _COM_EVENPARITY 0x18 /* even parity */ #define _COM_ODDPARITY 0x08 /* odd parity */ #define _COM_110 0x00 /* 110 baud */ #define _COM_150 0x20 /* 150 baud */ #define _COM_300 0x40 /* 300 baud */ #define _COM_600 0x60 /* 600 baud */ #define _COM_1200 0x80 /* 1200 baud */ #define _COM_2400 0xa0 /* 2400 baud */ #define _COM_4800 0xc0 /* 4800 baud */ #define _COM_9600 0xe0 /* 9600 baud */ /* cmd values for _bios_timeofday() */ #define _TIME_GETCLOCK 0 /* get clock count */ #define _TIME_SETCLOCK 1 /* set clock count */ /* register structure definitions for int86(), int86x() */ #ifndef _REG_DEFS #define _REG_DEFS struct WORDREGS { unsigned int ax, bx, cx, dx, si, di, cflag, flags; }; struct BYTEREGS { unsigned char al, ah, bl, bh, cl, ch, dl, dh; }; union REGS { struct WORDREGS x; struct BYTEREGS h; }; struct SREGS { unsigned int es; unsigned int cs; unsigned int ss; unsigned int ds; }; struct REGPACK { unsigned r_ax, r_bx, r_cx, r_dx; unsigned r_bp, r_si, r_di, r_ds, r_es, r_flags;

}; #endif /* _REG_DEFS */ #ifdef __cplusplus extern "C" { #endif /* New MSC-compatible BIOS functions. */ unsigned _Cdecl _bios_equiplist(void); unsigned _Cdecl _bios_disk(unsigned __cmd, struct diskinfo_t *__dinfo); unsigned _Cdecl _bios_keybrd(unsigned __cmd); unsigned _Cdecl _bios_memsize(void); unsigned _Cdecl _bios_printer(unsigned __cmd, unsigned __port, unsigned __abyte); unsigned _Cdecl _bios_serialcom(unsigned __cmd, unsigned __port, unsigned __abyte); unsigned _Cdecl _bios_timeofday(unsigned __cmd, long *__timeval); /* Old-style BIOS functions. */ int _Cdecl bioscom(int __cmd, char __abyte, int __port); int _Cdecl biosdisk(int __cmd, int __drive, int __head, int __track, int __sector, int __nsects, void *__buffer); int _Cdecl biosequip(void); int _Cdecl bioskey(int __cmd); int _Cdecl biosmemory(void); int _Cdecl biosprint(int __cmd, int __abyte, int __port); long _Cdecl biostime(int __cmd, long __newtime); /* Miscellaneous prototypes for MSC compatibility */ int _Cdecl int86(int __intno, union REGS *__inregs, union REGS *__outregs); int _Cdecl int86x(int __intno, union REGS *__inregs, union REGS *__outregs, struct SREGS *__segregs); #ifdef __cplusplus } #endif #endif /* __BIOS_H */

<MATH.H>
acos, asin, atan, atan2, (real) <MATH.H> acosl, asinl, atanl, atan2l (complex) <COMPLEX.H> Arc cosine, arc sine, and arc tangent functions Declaration: Real: double acos(double x); double asin(double x); double atan(double x); double atan2(double y, double x); long double acosl(long double (x)); long double asinl(long double (x)); long double atanl(long double (x)); long double atan2l(long double (y), long double (x)); Complex: complex acos(complex z); complex asin(complex z); complex atan(complex x); Remarks: Real versions acos and acosl of a real value compute the arc cosine of that value asin and asinl of a real value compute the arc sine of that value atan and atanl calculate the arc tangent of the input value atan2 and atan2l also calculate the arc tangent of the input value Real arguments to acos, acosl, asin, and asinl must be in the range -1 to 1. Complex versions Complex arc cosine: acos(z) = -i log(z + i sqrt(1 - z**2)) Complex arc sine: asin(z) = -i * log(i * z + sqrt(1 - z**2)) Complex arc tangent: atan(z) = -0.5 i log((1 + i*z)/(1 - i*z)) Return Value: On success, acos and acosl return the arc cosine of the input value (in the range 0 to pi) asin and asinl return the arc sine of the input value (in the range -pi/2 to pi/2) atan and atanl return the arc tangent of the input value (in the range -pi/2 to pi/2) atan2 and atan2l return the arc tangent of y/x (in the range -pi to pi). atan2 and atan2l produce correct results even when the resulting angle is near pi/2 or -pi/2 (x near 0). On error (if the arguments are not in the range -1 to 1), the acos, acosl, asin, and asinl functions return NAN and set errno to EDOM (domain error). If both x and y are set to 0, atan2 sets errno to EDOM.

<STDLIB.H>
Macro that converts string to integer Declaration: int atoi(const char *s); Remarks: atoi converts a string pointed to by s to int. atoi recognizes (in the following order) an optional string of tabs and spaces an optional sign a string of digits The characters must match this format: [ws] [sn] [ddd] In atoi, the first unrecognized character ends the conversion. There are no provisions for overflow in atoi (results are undefined). Return Value: On success, returns the converted value of the input string. If the string can't be converted, returns 0. Portability: DOS UNIX ANSI C C++ Only Yes Yes Yes See Also: atof atol Example: #include <stdlib.h> #include <stdio.h> int main(void) { int n; char *str = "12345.67"; n = atoi(str); printf("string = %s integer = %d\n", str, n); return 0; }

ecvt

fcvt

gcvt

scanf strtod

stop and wait protocol


#include<stdio.h> #include<stdlib.h> #include<math.h> #define V 2.0e8 void main(void) { char instring[80]; double d,R,pr_bit,P,a,U,U1; long int L; clrscr(); printf(".................................."); printf("Program to compute utilization of stop and wait protocol\n"); printf(".................................."); printf("\n Length of the link in m:"); scanf("%s",instring); d=atof(instring); printf("\nData rate of the link in bits per sec:"); scanf("%s",instring); R=atof(instring); printf("\nSize of frame in bytes:"); scanf("%s",instring); L=8*atoi(instring); printf("\npr[bit error](0.0 to 1.0):"); scanf("%s",instring); pr_bit=atof(instring); P=1-pow((1-pr_bit),(double)L); a=((double)R*d)/((double)V*L); U=(1-P)/(1+(2*a)); U1=(1)/(1+(2*a)); printf("\n....................\n"); printf("\n......-protocol is STOP AND WAIT_...........\n"); printf("..........-a=%f............\n",a); printf("...........-pr[frameloss]=%f.........\n",P); printf("...........-Utilisation factor with error=%f.........\n",100.0*U); printf("...........Utilisation factor without error-U=%f.............\n",100.0*U1); printf("..............\n"); getch(); }

Go back N ARQ protocol #include<stdlib.h> #include<math.h> #define V 2.0e8 void main(void) { char instring[80]; double d,R,pr_bit,P,a,U; long int L,N; clrscr(); printf(".................................."); printf("Program to compute utilization of Go back N ARQ protocol\n"); printf(".................................."); printf("\n Length of the link in m:"); scanf("%s",instring); d=atof(instring); printf("\nData rate of the link in bits per sec:"); scanf("%s",instring); R=atof(instring); printf("\nSize of frame in bytes:"); scanf("%s",instring); L=8*atoi(instring); printf("\npr[bit error](0.0 to 1.0):"); scanf("%s",instring); pr_bit=atof(instring); printf("\n Size of window:"); scanf("%s",instring); N=atoi(instring); P=1-pow((1-pr_bit),(double)L); a=((double)R*d)/((double)V*L); if (N>=((2*a)+1)) U=(1-P)/(1+(2*a)); else U=(N*(1-P))/(1+(2*a)*(1-P+N*P)); printf("\n....................\n"); printf("\n......-protocol is sliding window-Go back N ARQ-...........\n"); printf("..........-a=%f............\n",a); printf("...........-pr[frameloss]=%f.........\n",P); printf("...........-U=%f.........\n",100.0*U); printf("..............\n"); getch(); }

selective repeat protocol


#include<stdlib.h> #include<math.h> #define V 2.0e8 void main(void) { char instring[80]; double d,R,pr_bit,P,a,U; long int L,N; clrscr(); printf(".................................."); printf("Program to compute utilization of selective repeat protocol\n"); printf(".................................."); printf("\n Length of the link in m:"); scanf("%s",instring); d=atof(instring); printf("\nData rate of the link in bits per sec:"); scanf("%s",instring); R=atof(instring); printf("\nSize of frame in bytes:"); scanf("%s",instring); L=8*atoi(instring); printf("\npr[bit error](0.0 to 1.0):"); scanf("%s",instring); pr_bit=atof(instring); printf("\n Size of window:"); scanf("%s",instring); N=atoi(instring); P=1-pow((1-pr_bit),(double)L); a=((double)R*d)/((double)V*L); if (N>=((2*a)+1)) U=(1-P); else U=(N*(1-P))/(1+(2*a)); printf("\n....................\n"); printf("\n......-protocol is selective reject N ARQ-...........\n"); printf("..........-a=%f............\n",a); printf("...........-pr[frameloss]=%f.........\n",P); printf("...........-U=%f.........\n",100.0*U); printf("..............\n"); getch(); }

Potrebbero piacerti anche