of Memory
Texte intégral
(2) Getting Started M&kinq. ,a. The C. ECo-C sequence. workinq Cqry should do is make a working copy of the the you use the CP/M PIP CP/M in drive A and disk with PIP on your disk in b. (We have used <CR> to signify key.). first thing you Compiler disk. is to place. a blank, formatted pressing the RETURN. A>PIP <CR> * B: =A:*.*. If. it. the ECO-C disk and enter this <---DV option for copyinh. (now place (. <CR>. (Use. utility,. in A) line). the copy is completed, place the original disk in a safe After and use the copy from now on. You will need the following place when compiling a program: files CP. COM XC. COM XM. COM CE. COM CODE. PS CODE. PA ERR. PA STDIO. h. * .REL M80 .COM .COM. L80. " ". " ". Standard Definitions Library Routines (All of them) Microsoft's Macro Assembler " Linker. compiled program will generate (on its own) as intermediate files during compilation. These intermediate be erased automatically as the files will You compilation progresses. probably will want to place your on the disk, too (e.g., the editor on your CP/M disk is editor named ED.COM). you use a screen editor like Micropro's Wordstar, be sure you write your programs in the "non-document" mode. Finally, do not write programs using the file names above. In. addition, and. Macro Pre-processor C Compiler Code Generator Error Reports Overhead Files. TOKEN.CWK. each. PCODE.CWK. If. l.
(3) split. space Ifas disk follows:. is. problem,. a. the. DISKI. -. CP.COM, ERR. PA. DISK2. -. M80.COM. DISK3. CFF.REL, CIF.REL, - L80.COM, EC2. REL. XC.COM,. XM.COM,. files. CE.COM,. may have. CODE.PS,. CFC.REL,. a. maximum. CODE.PA,. CIC.REL,. ECC.REL,. Using the above distribution of files, DISK2 may be used for the source file, compiler output and assembler output. DISKI is used for the compiler and the compiler working files; while DISK3 is used for linking the output of the assembler and the compiler Depending on disk size, groupings of the above disks libraries. be done. For example, may on a North Star system DISK2 and DISK3 would combined be into one disk (e.g., a DISK2) . typically. ready. Having made a working copy of the Eco-C compiler, program. to write and compile a C. of. Features. full. C. syntax is supported. you should. bitfields should b.initializers(lnitializers 1983. Aggregate Initializers April, parametized. know what. is. except;. a.. c. d. e.. are. Eco—C. Before you start using the compiler, and is not supported in this release. The. you. be available in are supported.). macros. #line macro preprocessor directive in compound expression following pansion is not done. a. #if ,. macro. ex-. available in subsequent releases of the optimization (we've concenadditional compiler. and so far) to substantially shrink code floats tratedandon longs speed. You must have a signed license agreement increase size updates. these be on for eligible file to Most. of. the. We. be will expect also. above. 2.
(4) and programming. Facts, Suggestions. Hints. a of specifications and suggestions following is list Some that may prove useful. represent "C spec" rules that are jÁQt obeyed by existing compilers and might cause an error message that would not be generated by other compilers. Others are limi-. The. that. tations. will. disappear. long, l. unsigned an generate will. types. shortly.. unsigned char and unsigned short error message.. data. stdin, stdout, stderr and stdlst equate to fdO, fdl, fd2, (A named INIT.ASM controls the number respectively. file of fcb's and lob's that are generated plus setting the stack.) 2. and fd3. function calls: of float is automatically function parameter proand short or char goes to an int. moted to b. A function cannot return a char; only an int, unsigned, long, double, or pointer no matter how declareá. an int. c. Given the choice of char or int, make avoids internal conversions, thus improving speed. 3.. On. a. A double. it. 4. (e.g.,. .. a initialize the syntax funcl()) ,. To. x. 5.. with of. A. it: it, or. _ptr. =. pointer must. be:. (e. g.. ,. x_ pt r. ). to. It. a. function. &funcl;. structure or union name can only have two things done l)2) take its address with the address operator in front have a period and a member name following its name.. Binding of structure members to a structure is absolute. with pointer to a structure sI and now you want to use If you must is S2, cast the pointer to S2 or we will generate an error 6.. it. a. message.. 7. If a function is not recursive, you are usually better to declare variables as static rather than auto or register.. off generates. If. 8.. likely 9.. more. efficient. code.. When using a large "switch" case Last and the least likely. Currently. we. do. support nested 3. statement,. first.. comments.. place the most. -. '. -' '.
(5) 10.. II. digits.. #include's. may. be nested. only two deep.. Floating. point numbers can have up to 17 significant The range for the exponent is -38 to +38. At the present (BCD time, only binary arithmetic is supported is forthcoming). 12.. Floating point and long constants are combined rather than compile time. This, too, will be fixed.. time. 13. All program source f lies must terminate with return, linefeed pair (CR-LF). Failure to observe this the error handler to produce odd results. :,. 14.. carriage-. will. cause. a.. ."? ,. a. at run. t. " ". and not yet have: lseek() ·QL-.c.un.link(> functions, appending to a f lle. This will disappear when random files are finished. We. do. of the limitations mentioned above will dismajority The soon. very error handler treats all errors as fatal; there is no "cascading" of false error messages. When you do get the error correctan error, you will find that it does diagnose a bit meager at present, but will ly. Finally, the library is The. appear. grow. shortly.. find the Eco-C compiler more "UNIX-like" the market. Further, perf orms its error checking the compliance Finally, we with in strict syntax defined by K&R. K&R presented have adhered to the function definitions as much in CP/M environment. a as possible in we. than. think you. most. on. will. it. .. 4.
(6) the. Using. writinq. ^first. Sollrce. ECO-C. C. Compiler. proqram. C a text ediThe step is to write the program using ED.COM.) Be sure (CP/M as disk provides an editor stored on tor. mode document do some on editors (e.g., not use the that you Wordstar). The document mode can turn the high bit ON and produce mysterious results on occasion.. the file extention given to a CP/M source Typically, how".C" TEST.C). This is ñQt a requirement, (e.g., is program You may C. use any. ever.. cxmpÍl. in.q. j=. Assuming. is on drive. extention you wish.. proqram. the A, the. A>CP. file. TEST. compiler and the source compiler is envoked by:. /*. <CR>. pr"gram. Assumes. a. (e.g.,. TEST.C). ".C" extention. */. one is not program will supply the extention of ".C" supplied when the preprocessor is envoked. If you supply a file A (e.g., ".XXX") , extention overrides the default (".C"). different souce disk may be specified. For example,. The. if. it. A>CP. B:TEST. <CR>. load and run the next two automatically will (XC and XM) no errors are detected. The if XM) is an assembly language pass. The program passes of the compiler. output of the final (i.e., source file (e.g., TEST.MAC). This can be examined you wish.. if. Compiler. and. modified. Switches. switch the compiler to use the integer - i of This the printf () tells version function. It avoids pulling in the floating point library whenever printf () is used. does your program If not use floating point numbers, produce option smaller this will code size.. 5.
(7) As. an. example,. it. To is named TEST.C. the compiler would be invoked with the. suppose. a. source. program. with this option, use following command line arguments: A>cp. test. -i. causing the TEST program to use the integer version of Note that lower case letters may be used you wish.. if. printf ().. This switch uses the library where getchar() and -c putchar() do direct BDOS calls to CP/M for input/output (I/O) rather than through getc() and putc(). This avoids console I/O from going through the f lle handlers thus generating smaller code size. It is envoked with the following command line arguments: A>cp. file. This switch is used to change the name of the output and the drive on which is written. For example:. -o. it. A>cp A>cp Both of to the f. and. test -o b: test test -ob: test. the above examples are allowed. If lle name the default type of '.MAC'. off. This switch is used to turn statistics the compiler generates. -b. NOTE:. switch option other by a. the. or. produce. the. same. a. filenot type be. will. most. is added used.. of the messages. may be used when compiling command in the line must be sepablank space; the order is unimpor-. or part of the switches All Each. program. rated one from tant. Example:. a. both. test -c. A>cp. test. -i. -c. A>cp. test -c. -i. results.. 6.
(8) inq. A,qsemb1. Hie proqram. The assembler becomes the input Microsoft's Macro command. :. output file from the compiler (e.g., TEST.MAC) to the assembler. Your package includes 80file assembler. It is envoked with the following A>M80. Since. M80. has. a. extention of default f lle .MAC. with or without the. be used. /*. =TEST. .MAC,. extention.. blank. Note. space. */. the assembler may. The output f lle from the assembler will be named TEST.REL. Further details about using M80 are in the Microsoft manual. NOTE: there must be a blank space between M80 and the equal sign (=) when the assembler is envoked for CP/M.. .Idlin.kinq. :. =. Proqram. U" The .REL file from the assembler is then linked to the standard library routines (e.g., -CF.RELb EC2.REL, etc.) by using the Microsoft linker (L80). A typical link would be: ·. ":. [" {',. ". ,. A>L80 TEST,TEST/N/E. which causes. f lle The name. TEST.REL. named TEST.COM.. standard. to be the input. TEST.COM. library routines. you wanted If of PRICE.COM,. the input the. syntax. file. and produces becomes the executable C searched. are automatically. TEST.REL file would be:. A>L80 TEST,PRICE/N/E. 7. to have. a. output program.. an. command. f lle.
(9) Linking in Your. Own. Functions. that you have compiled and assembled a function you DATE.C. the name The assembler would have generated a with wrote REL DATE.REL. Now you want named a the into function to link f lle Suppose. named. program. The command arguments. TEST.C.. would. be:. A>L80 TEST,DATE,TEST/n/e. input .REL. ^. ^. ^. l. l. I. file----. I. to be linked with program. function(s). .REL. file. .COM. output. ---------. I. name following 180 on the command line is the file first input f lle (.REL). The last f lle name (before the "/n/e") is the output (.COM) program file. In between these two file names are Each the (.REL) function(s) you want to link in with the program.. The. separated from the other by. be. must. additional. Again, manual.. "". '. ' '. ""'. '. '. '. · · ' '.-'. ': ':" t: ú.·::.-..- : .!. í'-: i. .. '·-' t.! '.,1. '.- l. !,,'. 'i. : t3 fí,'. .:. ·!" },,! --t?. .... i;. : j!....,T ! t.-' :i. :i. ';;'j '.-' :i. !'1 ::'.'1. -"' I::. t ': :··:. L80 are. on. "!' l. ¿i:: :z·:. Iii ft? j¿: gt;;.· ;'",i.i.:tiii.. '!. :i. ; " í" iii" U .i.. i'"" "i i'í. ""' l"""r'". comma.. found. in the Microsoft. ;' r i. !.. l, Iii' t':'. details. a. e 'ii. " 'l" '! l"" ":. y :. '. .!. t'f. -í'"í:í U. .!. '..l'iii. "" i i'"! 'i". .:::'. ·1;MÍ.!. E i;;; i;";. 'l :i. !" jj·':,. t::" ':::'i'míi. E í;;····i?. !.. ¿¿jt't': .i. '" $' '; l"'l 'l "i'"' é". iii: "jj; ;.::'. j. "-· E",. j.|;i. ii:' j"':'.'.'i. ]- :i !"'tt':·:' !'. í'· !,i· í·: i. t.-:'iZ. t'l'l '..! iii 'i,,. i':' s;·;j. 'i'"" i 'l i",. "i" " ¡'"j. I::' i;;t '..!. jj,: i. iii t;;;t ,. I;.. !"lltj!,i. l"|f'-!t.: .h. {t. i'. .::::::::l'"s::'",'.:"..'..:. '"É1""1 "{ "" 'l" f" ;"j '"" 'l' "' "' """. i':.. t Z f' '"' ' 'U Lb I' 'i . ... .. '.. ' t. : ':: i . - ,. . !.. ,1 j:'. -··. i.. ,-. !.,.. ·--·. '!:!:l'..t'.·}:.·.{!:·.'!'. F"'. i't-;.· ". :··' !" 'l. ! $ !. 'l' '. 9>tj.'. j.;,¿,,. It'.'.. .'. }'-.·. ::-. !. '!'"' .i. :í ':·:·:'. l'j. 'f·ii'ít.. i'. '"' ;'t. ;jj ..·""'ijjl. t.-.! i. U"). '.,;'j";. !-:·:'::i{:!íii'. ¿.-.{t-i: "l,'.í..'!"!:ii"'!"'":. é::-iii· :í jj.f,,. "' -""$"-'."..l';..t.'i';:. í'"[: :! f'·. ;i":'"":. g.'.íí.'.: :".:-!::·!';iii'. ."'. :. ;;z..·" 1· ".. y.'f.j l'.' 'i' i :::: ':'" '. .'. i' "i' i;;" :'2 '·::. :ii' i i. "" '. "". ' '! '. ' "l" ""·' i, í·.·.':'. ! !"'1 l', i.; ..,':.:: '.'. .!. !'. t:: '..'..t.l, i;. '.;'i"i': .·.'. :..':.::l:}"·"·'.!..í.[·.':!" j:: k'.l;¿'. "". i. . ... i·'·' "' ! !"'1 i. 'i" '. I":' t..;it,: 'l'"' "" ':::'. 'i.,.1"'!í·.;'. ... ". t...!:i '!'..í"'. !":':!:li:l!:i:. t::' ·jj: l. i. ':1. f.'.·i":·ñ t:.'i'Í. iii' 't" ". " :"'"?··"L.!'Ú. !.|'·.'?"k': :l::" l'":íii'l'f!t':':'".'! ..' , f .., .i. i..' t' '·· l' !::f f.·l f:.',' 'l"' I':' :. g,,..,,,.. ., .... .-, ... .,. .... ,. E "' '"' 'i.'.i"'": '!. .l. t'": ;·". t-'..':::!l..::i.".'.'i !"' '.'.'i .!. t2) .l. :i. i:í í.·..l,!. l"i i:.', .!. :i.' i:.' t·: ,' t'.': -!. !' it: '" '. : " ''. ' !. ". "" I. , .. '·. r "'Z ' '. 'i'" é;.;ti"'. .t : ' ' ' ' ."':- , :.·' " ':: " ' ' t I .' i . :' :;.;'t,: .' · ' . SÍ '.J!T. 8. ' .-' :;, j!. ';""j :13'i'" ". ' :-.
(10) and. Reading. f lies. Writing Data. attempted to make file input and output (i.e., I/O) system as possible given as consistent with the UNIXandoperating CP/!¢l. Below is an example of writthe differences between ing to and then reading from a file using the ECO-C compiler. Both programs in source are included on your distribution disk. We. have. it. /* Writing. an ASCII. Data. File. */. Include file overhead info */ /* Clear for ADDS Viewpoint */ /* Maximumscreen number of characters */ /*. #include "stdio.h" #define CLEARS 12 #define MAX 1000 main() {. int i;. char FILE. c; *fp;. putchar. if. ((fp. }. (CLEARS). ;. /*. Clear. the. fopen("TEXT.TXT", "W")) == TEXT.TXT") ; puts("Can't open =. exit(-l);. l*. */. screen {. NULL). Signals an Error. puts("Enter line of text and press RETURN: \n") ; MAX; ++i) for (i = O; (c = getchar()) != '\n' && i putc(c, fp); putc (CPMEOF, fp) ; l* Must write end-of-file. */. <. */. fclose(fp);. }. begins with the #include preprocessor directive needed to work with disk the file I/O information The #defines are used to def ine the clear screen code for files. an ADDS Viewpoint and set the maximum number of characters that can be entered. The program. to include. main() function marks the beginning of the program and several variables are declared. The FILE typedef refers to the is defined in stdio.h and is used to establish structure that and pointers to fp fopen(). Generally, high-level I/O will require the file declarations to be present in every file program that works with disk files. The call to putchar(CLEARS) simply clears the screen in preparation for entering the text. The. 9.
(11) If your terminal requires two or more characters to clear the screen, change the #define to be a string and change the putchar(CLEARS) you are statement to a puts(). For example, using a SOROC terminal which uses an escape (033 octal) followed by an asterisk (*), the #define would be: #define CLEARS "\033*". You would then use puts(CLEARS) since instead of putchar(CLEARS) we are now treating CLEARS as a string.. if. ifin statement the ASCII. The TEXT.TXT. name text f lle using betheopened the cannot file Ifis displayed a that the file (i.e., fpbe returns opened is aborted by the call to cannot in the exit() function call is used to exit(). The some argumentoccurred. signal that error a. "write" mode. NULL), a message and the program. -l. was. attempts to open. went well, fp serves as our link with If all TEXT.TXT). A prompt asks the opened (e.g., just. the user. that file to enter. text, pressing RETURN when they have finished. Calls to line of () and assign them take the characters f rom the keyboard getchar was a newline to c. A check is made to see if the character RETURN) a which corresponds pressing or i f i e. to , '\n' i. (MAX). exceeds the maximum number a. (. of characters allowed. into. the tests are passed, a call to putc() places character c If the buffer associated with fp. The for loop continues until RETURN When happens, a. characters. is entered.. that. l is made to putc() using the CP/M end-of-file (OxIA) as final call the character. This is necessary when using the ASCII mode for disk files. A call to fclose() writes the buffer to the disk and closes the f lle and the program ends. MAX. -. Readjnq. or. Añ ASCII. Texk. Fj1e. the text file just created closely program to write the f lle. Notice that main() is follows called with two arguments: argc and argv. The argc variable is used to count the number of command line arguments (argument counter) used when the program was envoked. The argvll variable is an array of pointers that points to what command line arguprogram to read. The. used. the. ments. were. For envoked. entered.. example, with:. to read A>READFILE. where. the. <CR>. the TEXT.TXT TEXT. TXT<CR>. represents pressing. 10. RETURN.. file, this. program is.
(12) /*. Reading. an. ASCII. data. f lle */. the overhead screen for ADDS. /* Pull in. #include "stdio.h" #define CLEARS 12. l*. Clear. info again */ viewpoint */. main(argc, argv) int argc; char *argv1l; {. char FILE. c; *fp;. putchar. (CLEARS). (argc. if. != 2). ; {. need to know the file name.\n\n") printf ("I ("Use: printf ; \n\nA>READFILE FILENAME.XXX") ; exit (-l). }. if. fopen(argv1ll, "r")) == NULL) printf ("Can't open file: %s",. ((fp. =. exit(-l);. }. while( (c. = getc (fp)) putchar(c);. !=. ;. {. argvlll);. EOF). fclose(fp);. }. are two arguments (argc = 2) and two pointers in (argvlOl pointing to READFILE and argvlll pointing to argvlj TEXT.TXT). In the program, the argc is checked to make sure that two arguments were supplied when the program was envoked. If argc equal to 2, an error message is given and the program not is aborts. There. the argument count is correct, we try to open the file in "read" mode. If the f lle pointer (fp) returned from the fopen() to is a NULL, an error message is given and the call program aborts. the. If. ASCII. If. a. valid. repeated calls to c. The call. pointer getc() and tofile. while while loop does character in the buffer the characters on the CRT. (EOF) is sensed, whereupon. is returned,. assigns. the. to putchar() displays This continues until the end-of-f lle the file is closed and the program ends.. a worthwhile excercise to list stdio.h to see how symbolic constants are def ined (e.g., FILE, NULL, EOF, etc.), although you probably will not need to know the details contained therein.. It the various may. be. li.
(13) what. to. Do. if. You. Run. Out. of M=ory. Unlike many other compilers that are available, the ECO-C compiler does not require that the entire source code of the program to reside in memory. Even so, is possible to "run out of memory". Usually, this is caused by overflowing the symbol table space. C. it. Space for the symbol table is allocated dynamically. As auto variables are compiled, they are treated as temporaries and "discarded" af ter the function has been compiled. Very long programs with a large number of global variables (i.e., extern storage class) or a very large function with many auto-type variables are the most likely to cause the symbol table to overflow.. not lost. Simply break the source all is two separate source programs and then compile and program into them together. link. If this. happens,. For example, suppose memory during a compile. and find that the program definition named root().. source program TEST.C runs out of Further assume that you inspect TEST.C can be in half after a function your. split. called TESTI.C; this new be a new in TEST.C and delete of the program beginning the the the of to from lines start of the of root(). TESTI.C should now contain the "second definitionTEST.C. Save TESTI.C on disk. Now load TEST.C and delete half" of from the everything definition of the root() f unction to the end of the program and save on disk.. will. Using your. create editor, Now read. a. file.. file. all. it. TEST.C contains the done the above, half" of and TESTI.C the original contains the "second half ". Now program compile and assemble the two separately and then link them together to form one program. The sequence might look like:. "first. Having. A>cp TEST A>cp TESTI A>m80 A>m80. =TEST =TEST1. A>l80. TEST,TEST1,TEST/n/e. which creates an executable "halves" linked together.. program named. 12. TEST.COM. with both.
(14) Standard. Library. of. Functions. C. Listed below are the functions that comprise the Eco-C Standard Function Library. Each function is described by name with any argument list that might be necessary for the f unction the function returns a data type other than integer call. (i.e., int), the data type returned preceeds the function name. The functions order for easier are arranged in alphabetical reference.. If. alloc () char *alloc(u) unsigned u;. l*. Request. for storage. */. pointer to u bytes of storage, where each byte is able to store one char. If the request for u bytes of storage cannot be satisfied, the pointer returned equals NULL (i.e., zero). a Therefore, non-zero pointer value returned from the call to alloc() means that u bytes of consecutive storage are available. Returns. a. atol () atol (S) *s;. l*. char. Return. */. integer of string. Returns the integer value of the string pointed to by "*s". This to be in decimal, hex or octal f unction permits the input string such using the standard values (e.g., "Oxff"). syntax for C. atol() long atol(s) char *s; Functions in the same manner is a long rather than an int.. l* atoi(). as. 13. Return. ,. except. long. the. of. string. */. returned value.
(15) ca1loc() cha r *calloc(count, size) unsigned count, size;. /*. Request. */. storage. Returns a pointer to sufficient storage to for "count" items, each of which requires "size" bytes of storage. the request is successful, each byte is initialized to NULL. IfIf the request for storage cannot be satisfied, the pointer returned equals NULL (i.e., zero). The pointer returned, therefore, can be tested to see if the request was satisf led.. dec imaí (). l*. long decimal(s) char *s; Returns. the. long value of. a. decimal. string. */. long of decimal. Return. pointed to by "*s".. exit (). l*. int exit(i) int i;. terminate. a. program. */. to terminate a program. A non-zero value for "i" is normally to indicate that some error occurred when this f unction was called.. Used used. free (). l*. int free(c). char. *c;. Release. storage area. */. function call frees (i.e., tie-allocates) the region of storpointed to by "c", thus making that area of storage available The function assumes that the pointer "c" was first for re-use. by a al1oc(). obtained call to. The age. 14.
(16) ftoa(). int ftoa(s,. d,. *s ; char d; double. int. /* Float to. prec, type). ASCII. */. prec, type;. Converts a floating point number "d" into an ASCII string and stores the result in "s". Up to 18 significant digits of precision may be requested (i.e., prec = 18). The "type" variable may be 'g', 'e' or Isee discussion of the printf () function]; Since the otherwise the floating point number is free-form. enough be must "s" terminated large (i.e., '\0'), string is null + "prec" hold bytes characters. to. 'f'. l. fclo8e(). int. FILE. fclose (fp) *f p;. Function. buffer. pointer.. l*. close. a. file */. Eflush() to flush the contents of the the file associated with the "fp" file This frees "fp" for use with another file if desired.. calls first then closes. and. fflush() int. FILE. fflush(fp) *f p;. /* write buffer to disk */. Writes the current contents of the buffer the disk (including the EOF indicator) .. 15. associate with "fp" to.
(17) fgets() cha r char. i nt. FILE. *fgets (s, *s. i,. ;. lop). /*. get. string. from. file */. ; i *iop;. Reads. "i" characters from lop and places them into the character a terminates upon reading: array "s". The f unction (l) (3) null 2) and end-of-file character ('\0'), or indicator, characters. The character string at "s" is null terminated ('\0') The function upon return. returns a pointer to the string, or zero if end-of-f lle or an error occurred. (. i-l. _fi1lbuff int FILE _ *fp;. fillbuff. Used next. (fp). to replentish character or. (). /* the EOF.. read. buffer of data. */. buffer associated with fp and returns the. fopen() *f open (name, *name, *mode;. FILE cha r. mode). l*. open. "name" for use in the "mode" Open the two possible modes of operation: are. file. "r. ". Open. Open. "w". Open. file. operation.. There. already exist to use file must have thecarriage-return, text filesadjustment. <CR><LF>). for reading. The. this mode. line-f eed. "rb". file */. ASCII (i. e. ,. for binary reading.. No. <cr><lf> adjustments.. for writing. Any existing file with the same is destroyed and a new file is created. The contents of the old file are lost. Does <CR><LF> adjustment. "name". "wb" Upon. a. Open. for binary writing.. successful open,. to the opened "a", or append,. file. If option. No. <cr><lf> adjustments.. the f unction returns a pointer (e.g., fp) (The an error occurred, NULL is returned. for random f lies is forthcoming) . 16.
(18) fputs. C). l*. lop). int. fputs(s, char *s; FILE *iop; Takes. the character designated by "lop".. Put. a. character out */. pointed to by "s" and puts. it. to the output. getc(). l*. getc (p) *p;. int. FILE. character from. Read. file */. character from the input stream associated with "p". The character is normally returned as a positive integer although EOF upon reading end-of-file may return or TERR an error the read. occurred during Rml. Reads. a. L.. it. if. ·r. getchar (). l*. int getchar() Reads. a. tetmi nal.. single. character. Get. from stdin.. character from stdin. stdin defaults. */. to the. gets (). /*. *gets(buff) *buff ;. char char. stdin and place. Get. a. string. from. sdtin. */. it "*buff". If input is from the console, '\r' is used to sense the ená of the input string; otherwise a newline '\n' is used.. Get. a. string. from. 17. in the buffer pointed to by.
(19) getw(). int getw(fp). /*. *fp;. FILE. Reads the next fp. The word is. Get next. word. from. file */. word, or integer, from the file associated with read is done, but may a successful returned EOE' "ER·Rv,if an error reading upon also return end-of-file or PJL'LG the read. occurred during. if. hex () long char. l*. hex(s). *s;. Convert. the. hex. string. Return. from. long. pointed to by "*s" into. a. long. hexs. */. data. type.. isalpha (). /* Is. int isalpha(c). char. If is. c;. the character "c" is an alphabetic returned; otherwise FALSE (i.e.,. O). c. alphabeticcharacter. character, is returned.. TRUE. */. (i.e., l). isdigit() /* Is i. int isdigit(i) int i ;. If. the character "i" is (O) is returned.. FALSE. a. digit,. TRUE. 18. a. digit */. (I) is returned;. otherwise.
(20) islower(). l*. int islower(c). char. c;. If(l) the is. lower. c. letter */. case. character "c" is a lower-case alphabetic character, returned; otherwise FALSE (O) is returned.. isspace. TRUE. (). l*. int isspace(c). char. Is. c;. Is. "c" is a tab ('\t'), If the character a carriage return ('\n') or otherwise FALSE (O) is returned. ('\r'),. white space. c. a. space TRUE. */. '), a newline (l) i s returned; ('. isupper (). /* Is. int isupper (C). char. c;. If the charactez returned: otherwise. "c". is. FALSE. an. (O). c. upper-case is returned.. in upper case. letter,. */. TRUE. (l) i s. octa1() long char. /*. octal(s) *s;. Returns. long of the octal string. 19. Return. long. of octal. pointed to by "*s",. str */.
(21) printf. (). ;"',. i::" ;'; iii i". Tj'j :::1'. :::.::. ·:.. ·-. '!".?:'í.:fl'!i.. ;""r'-:'t'f"". |'"ll":. É'"q. 1" l'": '.:.'. t'":. l5'..!!s,i'.".,'!. t!.. ;?. t"' i'"' i é l"'. minas j.r!dicaceb. A. ii:. " """"Éf'l'!"·'·"l'"f'l"'"". ' :'". ,::.i'?.·.í'..l!?l'..'!f!.... .$.. ,... "'. i ". i" /"i. ... ,. x). p:" .Z ."! t: í'7.3. : t. 2"¡//g. ';jjg; ·: i U?. ... . ,., ,,.. "x".. if. "x" in a f ield of with a decimal point:. c..n-,zábie. lu-±. úsí'id. '.u'iítt"s L-;,,g.;;j$ after. positions.. and. point.. ': i ',-üdth spL"cifi€r. reserves. also be used with. may. It. tring. s-:. -.. wf.ic: t' rg \T?1F.iaLjZt:. ¿jt: at.t,,3. (Thini. (jR'lgrLí"i. 12. printf ("%6.2f", x); .in a field width of 6 places the decin'.al. :-jt--. t .-'. úf;. '. x);. printf('k25,'"",. d. " t" l-. t t..; $ ?. :. z j :-,>. y. whiic.i':. ':. "' 'i'. ;. of variable. printf("%i2d",. The. j"í ' '. "íU"it'.g consisting of "nn" diqíts following the the control and preceeding ccmverz' Ñu) cxaractez' ch: 'i '" a "' k ' ¿f't i ifií"s the minimum field width to be used For E'j iiu: [!{: íg padding is required (i.e. , numt: -er is i: maUeu: t-§";{3.ütrle width) blanks areusedunlessthe '_i: f'íÑ-'it a iS zero which causes paddina J with zeros. .y "it. A. i. i. "! 'i ií'l 'i 'i' U t"';. ,!, S i , ,.. 't . '..! l . ! ".'.. '.. i ! '.-..' ',.." l ' {..f .:,. t:. 'Ñiii j-et"t-j: mLit'y the ccmtents. digit. ". 'i.' !' :. ign bel ore the conversion control character hat the output is to be left-justifieCL print£("%--d",. nn. i";j]. ,, '..: ,t t.; :i. !"' .f. '.-.·.' .,.. "si"r". :,n:.-tí. l c"i".. í'i- ctr. -'. the. i::ts. íúi.. Ue. i't"t.: í,-. 25. characters of the strinq. (right.-jus'tified). daía. ít: em. is. letter 'i!", tjíii,'""t f"jj.'j", -. zractet'z". a. f ix-st. str);. not. ava"'i. a a. long oneÁ. rather than. X);. able are:. is ¢jri!';te'd 21). in decimal. notati-on.. an. int.. : t. t..' !.
(22) o. The data. item. x. The data item signed) ·" q¿ L. is printed. in octal notation. is printed. in hexadecimal in unsigned. t"l'£: !'. '". u. The. data. item. is printed. c. The data. item. is printed as. a. (unsigned). notation decimal. .. (un-. notation.. single character.. termThedata item is a string. The itemmustbenull inated or have a width specification equal to or less than the length of the string.. s. is a float or double and is printed in notation. Default precision is 6 digits, scientific but may be modified with an "nn" specifier.. e. The data. f. The áata item is decimal notation The precision may. g. Select the shorter of options one with the shortest width) .. item. a. is printed in default precision of 6 digits. be changed with an "nn" specifier*. float. with. and. or double. a. e. or. f (i.eg,. use the. The. conversion characters way be in upper or lower case letters (they are converted to lower case during the parse of the control string) .. putc(). int putc(c, c ;. cha r. struct. p). /*. Output. a. character */. iobbuf *p;. Outputs the character returns the character. "c" to the stream pointed. "C"b. to by "p" and. putchar (). int putchar(c) cliar c; Outputs the character sole. (Thia function arguments.). /*. Send. character to stdout. */. "c" to stdout which is normally the conand stdout as its. calls putc() with "c". 21.
(23) putw. int putw(u, unsigned u; FILE *f p; the. (). fp). /*. Output. word. a. */. unsigned. integer word "u" to the stream pointed to by "fp". This function is accomplished by calls to putc() with the lower byte sent first followed by the high byte. "Word" is taken to be two bytes in length.. Outputs. strcat (). l*. int strcat(s, t) *s, *t;. char. Concatenate. strings. */. string pointed to by "t" is concatenated (i.e., added) onto by the "s". It is the programmer's of the string pointed to responsibility to ensure that the character array pointed to by "s" is large enough to hold both "s" and the appended string at "t" (including the NULL terminator '\0'). The. end. strcmp(). /*. int strcnip(s, t) *s, *t;. char. Compare. */. strings. the two sttings "s" and "t" character-by-character. If the two strings match, a value of zero is returned. Otherwise, the function returns the result of the subtraction of the characin "s". For example, the match ter in "t" from the character and SI41 = 'A' and t14j = 'B', is character on the fifth fails returned (i.e., 'A' in ASCII = 65, 'B' in ASCII = 66; therefore, = 65 - 66). If follows that a negative value is returneá -I the liSCII value in "t" is greater than the ASCII value in "s". Positive values are returned when the ASCII value in "t" is less than the ASCII value in 'c'"* Compares. if. -l. if. 22.
(24) y::+rn""q '"%"2· { "P %! ..S: 6,t..*m€ñd-b " ':;.,3. i nt sttcµy *cÍes2". c 'r¿. ria r. L:. c}µiE:s. {:¿ies"í:F °. U:. i nto st r j) t i na. t. :.Z ei:. i. ñ".j:. E.. string. t. A :" · {. .2. ñc .i.. :·:,, ';j. "": . s... j. u. u. i;. !',. :i ..':.. c. ,/"' "k". )). i": á°: "}i;:"::,"'. .i::' j.. st.. a. *'1'. ng. ;. i? :' 7" } i? '.Z. í2. 'i:: i. t;;: .i,':. C CC:S. ». 'á. :·", '{' (.:. s. j;:, t',í;: 'i.. t? .i:'. 'L!.. e. :"";:'i..í")l:':z:"[! "i:-' c). i. ;. ;"; j?. YCiÍ. c. . ' ¡-'};'· li:, ;.,. ". t: b e ,, g t: t':, '}.'?.é d 'C? .,.· ,.. ,» m ·' t: ' E ))iwi.. t'. c) 1'::'·;':;. s ',}. i.'. i. :st"'. .,. te. c.í. i. i. i. ' ' e .E i;: "i'. ZÜüt cu. c':. t. C) .'"y '"d: y $ y t s r t?: !3 y::' i). s ·r ¿': · i. ¿jj i.: '":i g';' . tí ¿;;.j.1.Cf ti': I:"i t. ,.; '".; ..^ u t 0' '" Y. 4 b' .W "· ·> .:'.. Er S · ";'"2¿.!j.. 'i; e t' in. 3. .na. t:.': o :i:.' 't '"i tj··n "'. i ., n. l? ::. '".:' '? i':' ¿';.'f"{';iMít. :..j':.'. E j". .j.. i: :. í"!·· .:.% ;""·'':. ¿' 't";. t. ':-,.:C" j;: ,, m-,. y. ^b C;: i.:. S. e. r. e'. t itirí a 'i i. C. i: :i " e. }\. ng. t. ;í (;:¡"j. 3 · i. ::.. 4 < !"1·i¿1!. 't:.. ii.:. i"jj u ,::' í.j. e. ;¿rI". *E s t.·' .g"."jL f: .' :"¿ S ,é. i riG char. st: f':i€:rí '"p ;. .:' 'i'. {'j.': :)'. r. 'i--'..,!.'. :'C!. '" ' '""' """ ' ' y" " .'"" '" ··"'··"' "" C 7" "" .) ">'§" p "y' t"·" '·" S' "" :·," d'":. " ' '" · :·'"" '"' "' ' " '"" ","'"· ':6 '·' ":e i 'Z 'rm' ti,., · ' ':'""-·"' i .nAgqul '"'L4DL. m % " ' ¶P f .: S. " : .d p cu..,. al 4 +,. .,., , ,^,. ,"j ". ":ue. · d ,0, ".r . . 5·a. , . '. '. 'M.jn, .. .,' ..,' · ' ,. , b? . ¶... . -4.5 " . J,I'.: % . .. "0 " E' e^ :.:. ' ' "","i: "¿i:I':.? i): ::'. á'u,::. ¿'j"j;..'."' ' tt ¿"j. :j a rí 14p:a "t';.€' u ':'jj';;j; ii. Ia ;';j; . ..' "' ". '."'." i! ',., :í: .:: J'.;.C' ':;.' .I.'"} . yif " m 0 S ',/,"°4T"" i'" "' s } .' '·· ""' "'1 y: ··µ :·W·" l 41. '"· * " ' . "b""' T ·q: "S '. :0 "I {'"'% Y",C J";"'·0 j K "J"'· 'ó 'u"' C . " ·:'-. : . · .'. { '""^ :, , ' Z !·%.· y ^ :.,. : "\ . '..-·' ;.: !.,, ," ¿'"pt;';, , ·2 .'.... '·. '··' · ":C? ":::: i-..¿' . 1,.. .'· ·7'. ·?+K, -'. ·.k.Ág " -! 1~ E, ,L,! U—J' E. +,.? ,C'% WP.. ··. · , .b,:. '., ,:; :. . r ., ; ; · . i.. ;,.! "r "¿ 7 "nq '"· ""· "· ·"' " t 'ri"·' y' 0 ""' """,' 4 .· \" ·r 4·"·.·"" , ' '· · .""' »"'U S , .i . t7 " » "7''<" ". :" " ¿' " "" '.! '" '." '" 0" " "'. ""· " " C ' ·· ··" . t .zLaÁi Ó s ' t.' ' {W ·,. ,'..4 e.,. ',.'' "%. ..0 . .:"· ·-".-'.' i.,. ..0:s c+· ,.... '.. ..·..". e·-' r ,.- ·.,.q. ,S,,-:" : :. ,". i . .: ,¿4 · . i. . '.. .. ' .. ,V .. . ·' C7 0G .u. ". 2" (j} 2 ¿'"¿7¿" t". s t;.. :' :!.. n -:i:z. .?.-t:?jí'"I.tí} t-. h. '·"'.s"'. ·}""':"":g" ,'.%V, '"p ' T'"?qC · r ^¢ .. .' > .^P ny ·A"· e Ei ' ¿ " ;.'"""' :¿¿; ': ; .í" i: a. "" i '. ( P"' :": > ."' '";.í7" t Y"" í\ ·-v' .,$0 " · <\.. <m ~. " .r" C:"'?.'g.:' :!'. ' '. :t".ii!.t...:'"" j4 '4P e··"a ,'.. " T.-· .d-r:·Y.· b -M } -. 2,,t,,, q 4 á':.7. · L+ · J; -L N. ? '·'"' -..ú;¿ ·".. ·. A t"? .'"· ?. '. ·":a 5·'L.... .' *. qr·.:. """" ,.i . d.-. " ij; } JP. % fq ";" "¿ '!" O 1 :. ("Ra ·="r ? "": C Ak b ¿i'...> L. , o,¥te '\...Ah i í.,· C ! íá C: ;. ,," ,. *. í"'fcu'"" , , ·':" i ", '.:' A..\p" j;""' ·.. , q , , ·' ::.. .,,, ".0. L - ·.,:'. 0. i ¿'"","e,q."'" L3 T' ..:. '4,"i :' "~^.4. 'it' ,,/S á"' ::G'":: i::. 'Hq'4.l ¿~.¢4,j ,'. r. I) 'i"" ' " "" :·" ., ' F..? :. ' .' '""' ''" ", :' "'"j L, ~ Udi I'. Y" a,"t €3 mo' ."E b. .... , ' ' L ("i r·~d .u··I"·Y% "3 X ,· ·dl ·W <· ·, · ·-l '. ' r'.· ' ''% "'' ,+ .' "'"" ' Cg ? a ' " ' ·, ,"... g0· 2 '4lám.gw ^ 'L-~ ' 7%" % : · :j~ % :.." Je.G. V+.<'· . ·.· ..·.. 4¿ .., #? .t:: J .^ t y " » - .·-u -q "': '< ' · ' z"·ájs; · " 0 ·, .:t, Y': :".-·, '.. : s-'"t. ,; .L .m. pj a.d. U · .. .'-. -'·' T, ~r "b w. . "·.··..n.. ,-¢1, +5 ?S "" 4" "' " .,,· ^' r¶ )1 .:^'i. "':. ,3t.0^^' ".,.:,a% +. "0·^ .·. ,. --. ' .I0·$0. ,, ,.,··. a t . ·-, .··'Q,. .:, " ;. Cl : µ-s. . ;, ; · 7¿ I u,1¢ :É "...".QXe'¢ Y±,g¿c. m' :. ^. , . ©· . .>.. . :c, .yg %. :'" ...3?'Z ' !,...2. ; í. i i.. e_. "bY~ ,.E"': ,""' -'-6 K .. -0"..16. "] 't'"!. .».. '. gT"·'" U' ' ;' !.' ) f.;í ' -t.:f·: 4. t'. I "q " ~ ,... 't:.-(j:?':.z'..E}:;::AÉi! Z: '( )). i nt t c ': ía.. r. ,..'""g'. :;;' u 'j: 'r:- if;.'2'. '). ':;:. ;' T-k ». c::. i';; ¿"':,'"!"m."' '2 "i::' "i:.'.. i:.:.C:g. :C'. °" i "' t i· r' 'Y"' C""; ·' ¿· ." ." Kj ,g"'t~ - ".' " ea °" ·Jyq·" '"" :··,.r' S t,·~. .: ": t' '' '", ,¿L ·,. ·1Silk,} 0, ' ....., ·. F'": : ·0." .·""-·,· ':.· 0' eD· ' r'"' .» ':'; f::t ii.,eS 'L,.3· "- ·"' '%d" ~L 17.4 r' ·W · ' ':·;,' 0·: '. ".·''' ..34 V. r. P ·"''. ".. C ·e."· b.-· m. tOt' "v s" ·¢ ,''· '"· ·" "'.j-;"'. 'L " , "g ·'""r"' '·· ' .%j· a ·'..p'·..· · ' "-"'" " 'f "" V" 'e %I"l · :' O': .C'' :, G ¥ "' _ó "0.· :,.-. :p ,' , 4j.."m .wd·.,. 4.,}" «.. . ,^. ." ..ii :,, ·. "·q·" ..m ..r . .... ?..., 0· ...Kg. ·"" ¶ W "· · c "' " '".0 Y"p '""' " :"1 · · · ': "" : " , : "; ";1: b..3 ' T"' %· m h b -0 ' . . c .d" )" ·. "p ,. ,. l ' r , , . d Z 4 : G : , ·, S: 3 "C " ". ·· W"w % . . ·,%-4t: ·' ·, ·1 h dL ,.. '?3. "" '" · C.· ? ..' 4Id ,.. "éí'.' u. ;u "f.": ~» ··". 'i.'· :'G . "' . · ' "·% ·. r. C. * ·.40 w."%b t'q ·· . "'b .4'K U.¶" ¶U .: iuy:. ;%. a. S E:!. " G-% a< '' r", \C.b .\.-. "'"",."'. "t 'J N 'r e" ·. e : C·< ' :' % C ".·rr T:t a·""" :· 0...
(25) Assembly The following is may be used. The are be self-explanatory.. Language. of assembly list of the EC2.REL part. /*. Convert. /*. CPM. int ,_ftoa(s,db). /*. Convert. /*. Close. /*. Open. Create. *s;. l*. lose(fd). /*. Cícwe. char *s; double db; (). _ exit. int char. open(s). *s;. int creat(s). char. c:. int. int write(fd,buf,n) /*. i/o. if file. then. n. ítít read(fd,buf, r.) char *buf;. same. chain(s) ci"iar *s; char *sbrk(u) unsigned u;. !l. )j';l-'. t : t I ·.' t ' ". . i.. '" '. 'i" }'·"'f ?.· ; .,".L . t g- t.%. ,. .; r. note. l*. must. /*. '. I*. double. files f lle a. as. write. Load and ruri. float */. to. call */. BDOS. to ASCII. file. str namt"d. */. */ str. "/. associated with. Ed. */'. device. be mult: iple of. ' Read device. */. and end program. named. tile. /* Write tc. *buf;. char. disk. ASCII. i nt bdos(val,call) int val,call;. functions that file. They should. language. a. double atof(s) char *s;. !':. Functions. 128. */. */. */ a. /*. chain("fileaame"). program. Return. u-. bytes. of. storage. *1. */. */'.
(26) Assembler. Function Interface. Language. routines ínay be written and called by the assEInbler language functions. There exist program or other assembler be used to simplify may several support routines that language interface. Assembly. language. "C". $RTN. the. pointed to by the calling f unction.. HL. -. will return. -. will return. the. value contained iri the DE register pair to the calling function. then the value will was requested a long be padded.. $RETM1. -. will return. a. $FE. ·-. calK: the function pointed to by the HL following register pair using parameters the call and information contained in the called function.. $PPAR!Q. the parameter addressed - pushes BC. for the length in. $RETVAL. register. pair. value to the. If. -1 to the calling. program.. in. DE. when a function is defined, the word in the function following the function name is the amount of stack space required far 'working storage Ly the function. This is expres3ed as a This stack space is the equivalent to auto negative value. The code for the function immediately variables. follows this. fiu't. ^. word.. For. example:. FAKE:. :. et c. LD. JP. states that. function. 8. administrative. ,. O. ©. HI, ,ANSWER $RTN##. working stack storage are required by the The stack always contain 8 bytes of data prior to the requested storage.. bytes. FAKE.. -8 IX. DEFY LD. OZ. will. 25.
(27) The. stack looks. like this:. +. +. l. parameter. CLO. STACK. t. n. +. +. I. i. n-l. parameter. +. +. 0 0. +. +. I. + l. requested. + l. 8. The. !. + l. +. adminstrative data STACK STACK+2 STACK+4 STACK+6. '. +. working storage of administration. bytes. +. following:. I. l. parameter. Invoking. on. CURRENT. STACK. consists of the. the stack. - Address Length. of where to return value. to - Address of return. calling program. - Address of old stack. -. a. f unction. in Assembler. Language. To invoke a function in assembler language the convention is used. HL ,FUNCNAME $FE##. LD CALL DEFW DEFW DEFB. All off sets. are. on the stack. equivalent to. old stack offset return value address return value length. positive.. must. atof () ; of some kind.... / *(b) code ; a=atof equivalent assembler. offset. be stored first assembler language. All return values. For example, to do an the following "C" call double. the. following. code. is: 26. call. */.
(28) LD LD CALL. DE, @B BC, 8 $PPARM##. LD CALL DEFW DEFW DEFB. HL ,ATOF## $FE## 8 8 8. Using. ;address. ;length. of. of. ;push ;address. it of ;call ;offsetit for. B B ATOF. return value< ;old stack offset~: . ---;length to return ' -. INIT.ASM. The file INIT.ASM is used to change the number of lob's and fcb's and to set the stack pointer. To change the number of lob's and fcb's, change the number in the EQU statement to the desired number. To change the stack pointer, change the code that inimust be tializes the stack. After INIT.ASM has been assembled, linked in explicitly. For example:. it. A>l80. test, init,test/n/e<CR>. Below is a copy of INIT.ASM modified for 10 files in addition to stdin, stdout, stderr, and stdlst. The stack has also been altered to reside at high memory.. NFCB. $INIT:. :. Z80 . INCLUDE EQU INCLUDE INCLUDE CSEG POP LD. LI) PUSH LO LD LD INC LD LD OR RET DEC LD. FCB.MAP 10 FCB.ASM. ;SET FILES. TO. 10. IOB.ASM BC HL ,0 SP, HL BC HL, $FCB. ;SET. E, L D, H DE BC, NFCB*FCBL. A,B C Z. BC. (HL) ,0. LDIR RET END. 27. STACK. TO. TOP. OF. MEMORY.
(29) files. Remember must be. that,. when INIT.ASM on the disk:. available. is assembled, the following. FCB. MAP FCB.ASM. IOB.ASM. Naming Conventions. all of. In order variables. @.. For. registers to prevent conflicts with the assembler of two characters or less have a prefix character. example:. A BC. Al. -> -> ->. @A @BC. @Al. In addition to the above convention, translated to question marks. For example: A. AB B. -> ->. ?AB A?B. 28. all. underscores. are.
(30) Creating Libraries Custom libraries may be generated for use with of the Compiler. What is presented here is an outline necessary to establish your own library of C functions. information is contained in your MACRO 80 documentation.. the ECO-C procedure Complete. function to be included in the library should be First,and each assembled as you would with any individually just(M80) The be a of from the assembler C. compiled program.. will. output. series. At this point LIB80 is used to consolidate these f lies into library. The following sequence of commands illustrates the creation of a library called OWN, containing two modules (.REL files) called ONE.REL and TWO.REL respectively. a. A>LIB80. <CR>. *OWN=ONE,TWO. *\E. <CR>. <CR>. l*. A>. <--- Control returned to. CP/M. */. Note: in creating a library, the order of the modules is important due to a linker restriction. Any module which referenmodule must be included before ces an external label in another F or module containing the the reference. example, file ONE.REL references a label in file TWO.REL, the above library generation is correct.. if. TWO.REL the other hand, contained a reference to a ONE.REL, above library construction contained in the label f lle (L80). would cause an error message to be generated by the linker The linker makes only one pass through the libraries and therefore will cannnot find any external label referenced in a file "in front of it" in the link sequence.. if. On. creating a library, you can request LIB80 to inform you of any unresolved errors the linker might encounter in searching check OWN for possible unresolved the library. wish you to If references, the sequence is: When. A>LIB80 *OWN/U. <CR> <CR>. 29.
(31) LIB80. will. then. list all. unresolved. references (i.e.,. globals).. want a listing of the modules in a library with If you concerning and points external ormation references, the entry inf following command will cause that listing to be generated on the screen.. A>LIB80 *OWN/L. <CR> <CR>. LIB80 manual contains further information commands to alter or create libraries.. The. other. 30. on. how. to use.
(32) CP/El. I/O Interface. Since the standard library was written to exist in the UNIX environment, implementing the same library in a CP/M environment presents several problems. In implementing the library ECO-C the Compiler the for following approach was used. C. exists in UNIX would require implement the file I/O as double buffering of all file I/O. This approach was considered too costly given the memory space available. Only single buffering in the user's program is used. This buffer is the one created and pointed to by the associated by fopen() lob. _. it. To. The system such as read(), write(), open(), and routines, create() are contained in the user program but should be viewed as part of the operating system. In the UNIX environment, read() and write() may have a count specification of any size when the count must be a dealing with files. In the CP/M environment CP/M a The (i.e. 128). fcb's are mainof size sector multipleby tained these "system" routines and contain information in be fcb intended the fcb's the addition to is proper. that transparent to the user and theref ore cannot be referenced by the. It. user. .. format and are defined in maintain a UNIX ( _ lob's BFLAG) An is used to determine "stdio.h". do additional flag I/O is to conversions on carriage-return, line-feed (CR LE). the _BFLAG the "_BFLAG" is set, no translation takes place. is cleared, the following translations take place. The. if. If. If. input with the exception of _fd==0 will strip all does not matter a <LF> the input stream; follows. The other choice was to look for a <LF> and then do an ungetc() This would make ungetc() unreliis not an <lf>. The by ungetc() function is only inable for use the program. sured to work once, and this once was used by getc(), not the user.. All l. from. <CR>'S. it. if. if it. to make ungetc() of an extra <CR> where this is critical, the program may "wb") and (e.g., "rb" which causes all user's program.. It program. was decided at the expense. available. for. the user. being stripped. In a be opened in binary <CR>'S processed by. file. mode. the. 2. When input is from _fd==0, a <CR> is taken as the end of input. At this point a <LF> is echoed to the screen and '\n' returned to the user program. 3. .. On. all. output,. '\n' translates to 31. <CR>. <LF>. and. '\r'.
(33) remains t '. t. ,, i ' ·· ' :'? 'i-" , .l- t"'t. 'l, ,·. ,,,.,-·,,,,. l. iii. l, t.? i.ú: z'Uií.. , t."' ;;. i 'i: : 'i.. i. '"'j i '; {'. '." ' . l:.-i'"i ':':í' !:ü,í. T"l',t: .:.:F '.::'!'".-·. l'i: i'.?. ¿jj:. as. <CR>. I' ' t;;' , ,, t, i. T t ,:. !'1 ';;;it"'l "" j.'.'!:t !""1:!:: i"' '··2 tií!i.,-' i'·l. é:· fj 'L í':.üi·'". I'"! í:í l"':""' ]' "' 'i. !"1 : 3 'l"t:. t. t:ú. EE!!". :t !'l{: i.:.¶:::ii!·. i. li': s;;ja 'i:·:'. F !'!IÍ 'É'.'."if3,: '.T. j.!..f ','·. "i' ;"j. u. i;; j-:'.·" i"i. ,1? !. :t. iiúu'.!. !Y,t.!!ii. I:.. í::·hiii· 1.·y??. I'"":1. i!. 'i-2 :. 32. ti:. [I j::". i. u iii·t: :· '.'. E? í'Éil tj-,-·.i. '.-'. tii4-1. !"1 d :i. t::" ii:' "l;, t:í i"" :ií 'j'·i¿-;t. i,í-':. í·.!.. ': '::' '<; :i. iii" :' }'-'s!-kí-: iTt'í. ec.¿;: -> j|. i. í-;·;j. !'. i!, ;,.:. :t. iii. ".'. í:. i. :". !.:'FEit !'-'[::? j·-·f¿,:.
(34) a.. Error Messages the Syntactic you tried to. Any error in the source program is detected by how To Parser pass. illustrate this works, suppose compile the following "do-nothing" program:. main() {. char. Assume message. l*. wrong. }. further. generated. that. we. have. need semicolon. named. will look like:. Error in =. or. :. possibilities. 1002 ;. error. Token:. }. v. we forgot program, to add the semicolon after named The compiler f ound the "wrong". variable something of when expected find else. (A to is given as part of the error message.). you look at If the character. character "}". (. line */. The. ERROR.C.. Line: 4 Char: l Error: specif ier, typedef name, [ instead of }.. ERROR.C File: Expected type ). this program. at end of. the. list. it. Since predictive parsing is used, we must look "backwards" from the point where the error was detected to find the error. Since the error was the character in line 4, the error must have been caused by something near the end of line 3. Inspection of line 3 shows that we forgot the semicolon in the declaration of "wrong".. first. of the messages will tell you what should have been found in the program where the error occurred. You will also note that some of the error messages have more than one number associated with them. This is so we can tell exactly where the meswithin the error handler. sages was generated Many. might want to write a few programs with known errors in to "get a feel" as to how they are handled by the error handler. All errors are treated as fatal so there will be no cascading of false error messages. We think you will find that the error handler pinpoints the source of the error. You. them. 33.
(35) Error code. Meaning. Number (s). l. Internal Error - an attempt was made to create a temporary variable of an illegal type. Check source code for legality of statement.. 2. type specifier, storage class specifier ation was expected instead of . A. function. or. declar-. 3 A. 4. comma. or. semicolon. expected. was. instead of. .. 1015. 1009. An. identifier,. (. *. or. was expected. instead of. .. 5 A. semicolon. was. expected. instead of. .. 6 A. closing parenthesis. was. expected. insteaá of. .. An. opening. parenthesis. was. expected. instead of. .. 7. 8 A. closing brace. A. closing bracket. A. parameter. was. expected. instead of. .. 9 was. expected. instead of. .. 10. li. lOll. list. was. expected. instead of. .. was. expected. instead of. .. 1012 An. opening. brace. 12 A. parameter declaration expected instead. list of. 34. or opening .. brace. was.
(36) 13. declaration. The parameter. is in error.. list. 14. array size. An. expected. was. found. but. .. 15 A. or union expected but. structure. opening. tag or found. brace. was. .. 16. a type. specifier. was. but. expected. found. .. 17 A. statement. A. type. or. declaration. expected. was. but. f ound. .. 18. specifier but. f ound. or. storage class specifier. expected. was. .. 19 A. storage class specifier. expected. was. but. found. .. 20 An. attempt. was. made. to "goto" an. An. attempt. was. made. to perf orm. illegal label. name.. 21. illegal "break". an. or. "continue". 22. The. "while". is missing from. a. "cía. While". statement. 23 A. multiply. defined "default". was. found. in the "switch".. 24. Multiply. defined label.. 25 An. opening parenthesis identifier, expected the. in. constant expression instead of. 35. or. was .. ..
(37) 26. Variable is undefined. 27. Illegal indirection. or. Expected. a. closing parenthesis instead of. Internal. Error -. array reference.. 28 comma. or. 29. illegal multiplier.. 30. Illegal bitwise. operand.. 31. Illegal pointer arithmetic. 32. Illegal floating. point operation.. 33. Illegal negation. 34. Illegal logical. not. operation.. 35. Internal. Error -. illegal constant.. 36. Symbol. multiply. defined.. 37. Pointer is not to a structure or union in p->x or type initial f ield is not a structure or union in i.x. 38 A. subfield of the name referenced does not exist structure or union in i.s or p->s.. 36. in the. ..
(38) 39. Input. file. not. found.. 40 A. colon. was. in ternary "? _:. expected. ". but. found.. not. was. 41. The. results. not. expressions in ternary "?_ legal combination.. of. the. of. a. two. :. ". were. 42 A. non-zero integer ternam,' — "?. constant was mixed with : expression.. ". a. pointer. in the. 43. Out. of memory.. 44. Illegal. address. WARNING. -. Illegal. use of. of. (&id). .. 45 An. extra opening. brace. was. found. and. ignored.. 46. struct. or union. as source. operand.. 47. Attempted. assignment. to. a. constant.. 48. Illegal. assignment array name.. Attempt. to "type" a parameter f unction declaration.. to structure,. union, function. name. or. 49. which. is undefined. in the. 51 A. structure,. union. illegally.. or. function. data. type. was. specified. 52 A. referenced structure. or 37. union. tag. has. not been defined..
(39) 53 An. external data def do. :"'. 'C::.'. -. ..,,,,.. ['"i. match.. not. ": ..;i. P.,., ,.. i"";. inition '-. ..m.,. ..... and the. current data def. inition. : ,:,.J ,i-.,,. 54. 60. Initializt:. 'rs. Expected. type. currently. nüt. supported.. 1000. l00l. specifier,. [. {. ). ;. declarator ciel i.initer (e.g, = for a functio3? or { was expected. A. or. =. instead. :. ;) , parameter instead of .. or. ,. oí. :5¿5¿-":¿:if. ¿;j"pc :. Ü': átÉ'ácl. ier, typedef of. (. [. name,. ;. ,. _.--__j. 1003 Expected tyµe ) : = or. specifier, u': íAead of. [. typedef name, __. {. ;. t. __.,^. .1Ú06 icsent: Expected iííiet , * union dectarati-cm instead. 1007. l0l0. Expected. :. Expected. =. o r. ;. o. ;. l". úüesn'. F. iriú z.'a: :,iz.blt: tzen equate i * e * a=8metc;. !.'c,t". it. in structure. :. function O!. now : as. to. -. 38. or. .. instead of. ,. handle. :-. of. or. instead of. ,. 1016 ("onlpiler. (. .. _-.. name. in declaration. as. pointer yet.. pointer to function of function name.. address. _.. declaration. _. 1002 Expected ) = or. _,_. list..
(40) Quick. Function Reference. cha r unsigned. *al1.oc(u) l' :. char char. *gets(buff) *buff ;. double char. atcf (S). unsigned FILE. getw(fp) *f p;. i nt char. atol m. long char. hex(s) *s ;. ! orig char. atollO). i nt i nt. _bdos("d'aÉ,c:. cha r uns ignec3.. *U:s,j }.C.'fí fcm.tnt CC2Li!.Lt,: 3'.i.Zm·:. *s. ; :. "". s :. *s. int. char. ;. val,cail;. aji). int. char. ,size). int. char. int. .: !tT-¿j¿í(s.l. chaL. "ó. ;. ii nt ni:. cl. ose'. {. .. char (. int. f"ji'. cE;. isalpha(c) c ;. isdigit(c). c;. islower(c) c ;. isspace(c) c;. isupper(c). char. c;. i.nt chat. creat..ís. 'k'€ M.>s. long char. octal(s). 'i or' "7 c '7á"í r. 'Feci"l'a': :;':) <7 · * m-' S. char. int. open (S) *s ;. i nt. int. exit(íj l;. int. printf (control,arg,... int. putc(c,fp). char. _.exi.t (i. int. cha. free (s'. at-. int. µzec,. :. i!}a r. ii i. I-ZL. F. !. jjj";. *control,*arg; c ;. *f p;. 'j;. i- /"p¿ * s ; íjµ"jj :'. l. .. int. putchar (c). int. putw(u,fp). char. c;. (Ft ;'. ". (-:. +pm ea .L t '.. i.: ..ii",. Í':7a{E;t.-¿:·..,-I'L(Ac,.type). *. u t". 'i!?-;i. ;. " s :. z. intcha i.' double. í'7. char FILE. *s. t ' " ~ · ^ i". Fy;-"" '' .". · · \. c. ' p:. L"É. "!.LG}}'. unsigned FILE. :·. " ' : ' 1'. *f p;. l. int int cha i i ':" ?· p) I -. t"f. u;. r. cha r unsigned. read(fd,buf,n) fd,n; *buf ; *sbrk(u) u ;. '. "' i: [)·;. int. char 39. sttcat(d,s) *d,*s;.
(41) int. *fgets(s,i,fp) *s ; i;. int. _f. FILE cha r. *f open. *name, *mode;. int. fputs(s,fp). char cha r. illbuff (fp). *f p;. FILE. *s. char FILE. (name. ,mode). strcmp(d,s) *d,*s;. char. int. strcpy(d,s) *d,*s;. int. strlen(s). int. tolower(c). *s. char char. ;. c;. ;. *f p;. toupper(c). int. int. getc(fp). int. getchar (). *f p;. FILE. .. int. *£p;. file. t. char. char. c;. int int char. write(fd,buf,n) fd,n; *buf ;. t. L. Precedence. Operator. (Highest to lowest). l. ->. 2 3 4 5 6 7 8 9 10. 15. . —-. *. /. %. <. >. + << < ==. -. []. !. (cast). ". *. &. sizeof. ->> >. !=. &. ^ i. li. 12 13 14. (). ++. && i I. ?: =. +=. -=. *=. /=. %. <. =. ,. 40. <=. >. >=. &. =. "=. ! =.
(42) Software ECO-C ECO-C. Please. you encounter Ifcompiler, please. Prob1eN. Report. errors that you believe to be in the report them as soon as possible.. any. License Number: describe your:. Operating System: Computer. (including. amount. of memory, disk drives,. etc.). :. Please describe the problem as clearly as possible. If you possible) of the supply us with a copy on disk (8" SD help us to correct it. program that produced the error, will to the problem may Detailing the sequence of events leading up method also prove useful. If you are using some of "getting around the problem", please describe it. We will try to correct any problems as quickly as possible. can. it. 41. if.
(43)
Documents relatifs
Pour communication immédiate avec le Service technique Bulletin technique no : W11490386 Mesure corrective : obligatoire Date de publication : Décembre 2020.. Produits
While a model with a single compartment and an average factor of reduction of social interactions predicts the extinction of the epidemic, a small group with high transmission factor
In order to do so, compare the free energy of a perfectly ordered system with the free energy of a partially disordered case that introduces the less energetic frustrations
Control the Mouse Pointer, User's Point, Machine Learning, Neural Network, Python, eye tracking, mouse pointer, human eye, third party device, artificial neural network,
Bulletin technique n o : W11482561 Mesure corrective : obligatoire Date de publication : juillet 20204. Produits
EventVector: PUBLIC POINTER TO WORD, UserName: PUBLIC POINTER TO bcplSTRING, UserPassword: PUBLIC POINTER TO bcplSTRING, OsFinish: POINTER.. OsFinishCode: PUBLIC
TableBounds: PROCEDURE [table: TableSelector] RETURNS [base: TableBase, size: CARDINAL]:. TrimTable: PROCEDURE [table: TableSelector, size:
Pour communication immédiate avec le Service technique Bulletin technique no : W11378591A Mesure corrective : obligatoire Date de publication : Novembre 2019 Retirer et