EG








					    

						  C80

			       .





						   

I        C80.............................1
1.1     e  C80.............1
1.2      C80.......................1
1.3   ,    ........3
1.4       C80................4
1.5   ,    C80..................6
II       .....................7
2.1    LIBC.....................................7
2.1.1   ................................7
2.1.2  ...................................9
2.1.3    CP/M.................................10
2.1.4  -.........................11
2.1.5  -...........................13
2.1.6  ...............................17
2.1.7  ................................17
2.2      MATH..............17


							 - 1 -


				  I     C80.

				  1.1   
						 C80.

	   80             NAME.C,
     .    80
    NAME.ASM,     
  i8080.
	          
 80   l80.
	  ,  
    NAME.COM:


NAME.C-->C80-->NAME.ASM-->M80-->NAME.REL-->L80,LIBC.REL,MATH.REL-->NAME.COM


	          
 SUBMIT-,   
.

			  1.2    c80.

	           
     :

C80 [-m -o NEWNAME.EXT -s -t -eNN -xMM -yKK -zPP] NAME.C <CR>

  NAME.C -  ,     .  
  ,     .


						   - 2 -

		 ,   .

---------------------------------------------------------------
            	      
---------------------------------------------------------------

-o NEWNAME.EXT  
				      
                 ,   NAME.ASM.

-m              
				       
                a   i8080,            
                    '  
                  m80.

 -t             
				           
                   .

  -s            
				        
                  .         
                     
                   ,  
                  .         -s  
                ,        
                 ,     
                   ,        ,
                       .   
                ,      
                  ,      , 
                        .

-eNNNN 
				       
                ,NNNN -  , 
                   .     
                   120        14  .   
                   err36    
                  .

 -xMMMM         
				       ,
                MMMM -     .
                     -  2000  .
                #define     ,  
                     +  4.  
                 err59   .

 -yKKKK
                     
                case      switch.KKKK - 
                         . 
                     200 
                 4   .  
                err76   .


					     - 3 -


 -zPPPP 
				      .   PPPP -
                    .   
                      2000.   
                      
                  .         
                                  
                ( NULL ).   err2
                  .
---------------------------------------------------------------


		1.3 ,   .


        c80     
    :  	
duplicate output file     -    .  
too few arguments for -x option   
                          -    
                             -x.
unknown option x          -   x.
open failure on input     -   
                            .
open failure on output    -   
                            .
out of memory!            -    
                            .
compiler aborted by user! -   
                             .
xxxx: line nnn: error mmm - xxxx    nnn:     
                            mmm.     xxxx   
                             ,   
                                
                            .  nnn -   
                            ,      mmm   -  
                            .


							 - 4 -


		   1.4     C80.

---------------------------------------------------------------
                     
  
---------------------------------------------------------------
  1.           .
  2.              /  -z/.     
  3.         .
  4.        .
  5.         .
  6.        .
  7.         .
  8.         .  
  9.         .
 10.             .
 11.          .
 12.         .
 13.        . 
 14.        .
 15.          .
 16.         .
 17.         .
 18.         .
 19.         .
 20.        .
 21.           .
 22.          .
 23.         .
 24.         .
 25.         .
 26.            '.
 27.         cast.
 28.        .
 30.        :   ?
 31.         .
 32.          .
 33.        .
 34.        .
 35.       typedef  .
 36.           / -e /.
 37.        .
 38.           
		    . 
 39.            
            .
 40.          .
 41.        .
 42.         .
 43.         .
 44.          .
 45.         .


							 - 5 -


 46.         .
 47.         include-.
 48.        .
 49.        . 
 50.         .
 51.         lvalue.
 52.          .
 53.         .
 54.         .
 55.        .
 56.        .
 57.         .
 58.         # .
 59.          / -x/.
 60.           .
 61.           .
 62.            .
 63.        .
 64.        .
 65.         .
 66.         .
 67.        else.
 68.        .
 69.            /;/.
 70.         goto.
 71.        .
 72.        .
 73.        .
 74.          case    .
 75.        :   case.
 76.         case   switch / -y/.
 77.        case  switch.
 78.        .
 79.        default.
 80.        default  switch.
 81.          break/continue.
 82.        .
 83.         include  .
 84.        .
 85.        .
 86.        .
 87.         .
 88.        .
 89.         .
 90.        .
 91.            .
 92.         .
 93.            switch.
 94.          define.
 95.         .
 96.        .
 97.        .
 98.         .
 99.            .


							 - 6 -


			1.5 ,    C80.

	    C80  
  ,   : 
	c80.com  -   ; 
	l80.com  - -;
	m80.com  -   i8080;
	lib.com  -   ' ;
	libc.rel -     ;
	math.rel -   ;
	libc.h   - include-,        
	           ,    CP/M.


							 - 7 -

	     II     .

	            
:   libc.rel     math.rel.       
  ,    
      4.2.     libc.rel    
 :    
/,    /,   
 ,   ,    
  CP/M.

					 2.1   LIBC.

				 2.1.1    .
  
atof
	double atof(nptr)	/*ascii-to-float*/
	char *nptr;

atoi
	atoi (nptr)        /*ascii-to-int*/
	char *nptr; 

atol
	long atol (nptr)    /*ascii-to-long*/
	char *nptr;

ftoa
	int ftoa(m,str,precision,type)	/*float-to-ascii*/
	double	m;
	char *str;
	int precision,type;
	: precision -   ;
	 type =0 - E-, type =1 - F-.

strlen
	strlen(str)			/* */
	char *str;

strcat
	char *strcat(s,t)	/* */
	char *s,*t;
	 t  s.
	 s.

strncat
	char *strncat(s,t,n)
	char *s,*t;
	int n;
	 strcat ,    n 
	(   '\0' ).


							 - 8 -


strcpy
	strcpy(dest,src)	/* */
	char *dest,*src;
	 src  dest.

strncpy
	strncpy(dest,src,n)
	char *dest,*src;
	int n;
	 strcpy ,    n ,
	   0-.

strcmp
	strcmp(s,t)			/* */
	char *s,*t;
	:	0 -  ,
				<0 - s < t,
				>0 - s > t.

strncmp
	strncmp(s,t,n)
	char *s,*t;
	int n;
	 strcmp ,    n .

index
	char *index(str,pttrn)	/*   */
	char *str,*pttrn;
	:	   (*pttrn),
				NULL -   .

rindex
	char *rindex(str,pttrn)
	char *str,*pttrn;
	 index ,     .

	
						   - 9 -


					2.1.2   .

alloc
	char *alloc(size)	/* */
	int size;
	 size      
	   .


clear
	clear(start,length,value) /*  */
	char *start;
	int length;
	char value;
	 length     start
	 value.


blockmv
	blockmv(dest,src,length)	/* */
	 length   src  dest.


format
	format(func,fmt,argptr)	/**/
	int (*func)();
	char *fmt;
	unsigned *argptr;
	      
	 fmt      
	.
	 printf    :
		printf(fmt,arg)
		char *fmt;
		unsigned arg;
		{	format(putchar,fmt,&arg);  }
	: long  float   .


isspace
	isspace(c)
	char c;

isdigit
	isdigit(c)
	char c;

islower
	islower(c)
	char c;


							- 10 -

isupper
	isupper(c)
	char c;

tolower
	tolower(c)
	char c;

toupper
	toupper(c)
	char c;



				   2.1.3     CP/M.


bdos
	bdos(bc,de)		/* BDOS*/
	int bc,de;
	:	 A.


cpm
	cpm(bc,de)
	int bc,de;
	  bdos.


bdoshl
	bdoshl(bc,de)
	int bc,de;
	:	 HL.


bios
	bios(n,bc,de)		/* BIOS*/
	int n,bc,de;
	:	 A.


bioshl
	bioshl(n,bc,de)
	int n,bc,de;
	:	 HL.

 
exit
	exit(n)		/*   */
	int n;
	  ,    fopen. n
       : n=0 - 
    .   n   0  
     SUBMIT-.



							- 11 -


settop
	settop(size)	/*    */
	int size;
	      
	size.
	:	   ,
				NULL     512   SP.


fcbinit
	fcbinit(name,fcbptr)	/* FCB*/
	char *name;
	struct _fcb *fcbptr;
	 _fcb  0-  name  
	 .fcbptr     
	36 .


			   2.1.4   -.
   
creat
	creat(name)	/*     */
	char *name;
	:	fd --(  ,
				     
				  .)
				-1 - creat   ; errno
				   .


open
	open (name, mode)		/* */
	char *name;
	int mode;      
	:	fd --, 
				-1	     .
	    :
	-   ;
	-    ;
	-     ().
	      
	  :
   
	 mode       	 
     
	O_RDONLY            0			 
	O_WRONLY            1			 
	O_RDWR              2			  
	O_CREAT				0x100		  
	O_TRUNC				0x200		  
	O_EXCL				0x400		 
						0x500		   ,
									 .
	     :
	CON: , 	LST: , PRN: , PUN: , RDR: .


							- 12 -

close
	close (fd)		/* */
	int fd;
	:	fd -  ,
				-1 - ;   errno 
				ebadf ( -).


unlink
	unlink(filename)	/* */
	char *filename;
	:	0-3   ,
				-1   .
	   errno.


rename
	rename(oldname,newname)	/* */
	char *oldname,*newname;
	 newname (  )  .
	   errno.


lseek
	long lseek( fd, offset, how)	/* */
	long offset;
	int fd,how;
	   how     
	  :
	how=0 -  = offset.     
	how=1 -  += offset.
	how=2 -  = _ + offset.
	       
          ,
          
       .
	:   .
	:
	lseek      
	  .


posit
	posit(fd,num)		/*    */
	int fd,num;
	      128-
	.num =0,1,...


							- 13 -


read
	read (fd,buf,nbytes)		/*  */
	char *buf;
	int fd,nbytes;
	 nbytes      buf.
	:	  .
				0 -   .
	    :
	-    ;
	-    ;
	-     nbytes;
	-     .
 
 
write
	write (fd,buf,nbytes)		/*  */
	char *buf;
	int fd,nbytes;
	 nbytes   buf  .
	:	   .  
			 , .  
			 :
	-   -,   
	  ;
	-   /.



			   2.1.5  -.
 
fopen
	FILE *fopen (fname,how)		/* */
	char *fname, *how;
	      :
	CON: , LST: , PRN: , PUN: ,	RDR: .
	       
	  .
	 how    : 

	  "r"  -   .   ,
			  NULL.
	  "w"  -   .  .
	  "a"  -   .   ,
			   .
	  "r+" -      (  "r"). 
	  "w+" -      (  "w"). 
	  "a+" -      (  "a").

	:	fp --, 
				NULL       errno.


							- 14 -

fclose
	int fclose (fp)		/*    */
	FILE *fp;
	:	 ,
				-1  ;    errno.

 
   
fseek
	fseek (fp, offset, how)		/*  */
	FILE *fp;
	long offset;
	int how;
	     how  offset
	 lseek.
	:	  ,
				-1     .

	!!!	 fseek    ungetc.


ftell
	long ftell (fp)		/*   */
	FILE *fp;
   

fread
	fread (dest, sizeof(*dest), nitems, fp)	/*  */
	FILE *fp;
	int nitems;
	 nitems * sizeof(*dest)   dest .
	:	   .
				NULL-     .

     
fwrite
	fwrite (src, sizeof(*src), nitems, fp)	/*  */
	FILE *fp;
	int nitems;
	   nitems *sizeof(*src)   src .
	:	    .
				NULL  -     .



getc
	int getc(fp)		/*   */
	FILE *fp;
	:	,
				EOF       .
				..    ,  
				   getw 
				  feof  ferror.


							- 15 -

agetc
	agetc(fp)
	FILE *fp;
	 getc ,    ASCII -:
	  CR-LF    '\n',
	  ^Z( )  EOF.


getchar
	int getchar ()		/*   stdin*/
	:	,
				EOF


getw
	int getw (fp)		/*   */
	FILE *fp;
		,
				EOF


fgets
	char *fgets (dest,numb,fp);	/*   */
	char *dest;
	int numb;
	FILE *fp;
	   numb-1     <CR> ( ).
	fgets     .
	:	dest .
				NULL       .


gets
	char *gets(str);			/*   stdin*/
	char *str;
	 .      .
	:	str ,
				NULL       .


ungetc
	ungetc (c, fp)		/*   */
	FILE *fp;
	  c    .
	       
    ,       ,   
     .    
        EOF.
	: c,
				EOF,      .


							- 16 -

putc
	int putc(c, fp)	/*   */
	char c;
	FILE *fp;
	:	 ,
				EOF  .


aputc
	aputc(c,fp)
	char c;
	FILE *fp;
	 putc,   '\n'  CR-LF.


putchar
	putchar(c)			/*   stdout*/
	char c;
	  putc(stdout).
	  stdout  ,   
      ;   ,
     setbuf.


putw
	putw (w, fp)		/*   */
	FILE *fp;
	:	 ,
				EOF  .


fputs
	fputs (s, fp) 			/*   */
	char *s;
	FILE *fp;
	    <CR>.


puts
	puts(s)					/*   stdout*/
	char *s;
	   , '\0'  .


fflush
	fflush(fp)		/* */
	FILE *fp;
	:	0 -   ,
				EOF -  .


							- 17 -

				 2.1.6   .
 

printf
	printf (format[,arg]..) /*   stdout*/
	char *format;


fprintf
	fprintf(fp,format[,arg]..)/*   */
	FILE *fp;
	char *format;


sprintf
	sprintf(s,format[,arg]..)/*   */
	char *s, format;
 


				 2.1.7   .
 
scanf
	scanf (format [,pointer]...)	/*  stdin*/
	char *format;
	:	     ,
				EOF    .EOF  
				0, ,    
				,,- 
				   .


fscanf
	fscanf (fp, format [,pointer]...) /*  */
	FILE *fp;
	char *format;
	:	 scanf.


sscanf
	sscanf (s, format [,pointer]...) /*  */
	char *s, *format;
	:	 scanf.

 

		   2.2    MATH.

	     math.rel 
,        
, ,     ..
     include-
MATH.H.


							- 18 -

exp
	double exp(x) 		/**/
	double x;


log
	double log(x) 		/* */
	double x;
	      errno
	 edom.


log10
	double log10(x) 	/* */
	double x;
	      errno
	 edom.


pow
	double pow(x,y) 	/* x   y */
	double x,y;
	  x<0  x=y=0, errno   edom.


sqrt
	double sqrt(x) 		/* */
	double x;
	    errno  edom.


:	      
  errno   erange. 


floor
	double floor(x) 		/* */
	double x;
	:	 , x.


ceil
	double ceil(x)			/* */
	double x;
	:	  , x.

sin
	double sin(x)
	double x;

cos
	double cos(x)
	double x;

tan
	double tan(x)
	double x;


							- 19 -

cotan
	double cotan(x)
	double x;
	:	  , -
				  .   ,
				    . 
				6.7465e9 .( cotan   
				   1.91e-152 .)
				   errno  erange.

asin
	double asin(x)		/*arcsin*/
	double x;
	:     -/2  /2.

acos
	double acos(x)		/*arccos*/
	double x;
	:	     0  .

atan
	double atan(x)		/*arctg*/
	double x;
	:	   
				 -/2  /2.

atan2
	double atan2(x,y)	/*arctg(x/y)*/
	double x,y;
	:	  x/y  
				 -  .
				 x=y=0,  errno  edom.

sinh
	double sinh(x)		/*sh*/
	double x;

cosh
	double cosh(x)		/*ch*/
	double x;

tanh
	double tanh(x)		/*th*/
	double x;
	:       
				errno   erange. errno  edom.

sinh
	double sinh(x)		/*sh*/
	double x;

cosh
	double cosh(x)		/*ch*/
	dou