Home

Supersoft C Compiler Table Of Contents Introduction

image

Contents

1. e mm DI gt samu me char fgets s n d char s unsigned n STREAM fd C Reads a maximum of n l characters bytes from a file opened for buffered input via fopen into the string beginning at s The file is specified by the pointer fd to its file descriptor fgets will not read past a newline or more than n l characters whichever comes first fgets then appends a mull character to the characters read to create a null terminated string fgets if successful returns a pointer to this string identical t the value passed in s fgets returns a null pointer value 0 if 1 fd does not point to a valid file descriptor 2 the file could not be read due to an error at the operating system level or 3 the end of tne file has been reached sese K amp R p 155 O FILE fileno sEti STREAM sfd Returns the file descriotor associated with the STREAM sfd FOPEN Supersoft C Compiler User s Manual c 1933 Supersoft 71l STREAM fopen fspec mode buffer_size FILESPEC tspec char mode int buffer size Creates and or opens a file for buffered I O with the file specification given in fspec It uses open see the open function later in this chapter to actually open the file Thus full file specifications may be used If fopen is successful it returns a pointer to a valid file descriptor for the file specified You should store this pointer for subsequent use in your program fopen returns N
2. SuperSoft C Compiler User s Manual c 1983 SuperSoft efficiency adequate for system as well as application level programming One measure of its efficiency is that for ar least one operating system CP M with the exception of a ten line procedure in assembly code required as a link to the operating system the entire I 9 interface of the compiler is written in SuperSoft C I Design decisions made with regard to code generation allow the SupezrSoft C Compiler to generate rather good code for Subroutine entry and exit These decisions allow us to have true register variables even on machines with few registers Specifically on the 8083 series SuperSoft C uses the BC register pair as a true register variable MOOULARITY The fact that each pass of the SuperSoft C Compiler is modular confers certain imoortant advantages Dividing the compiler into separate self contained programs allows it to run with a relatively small amount of available memory and Still support most of the C language This modular Structure also leads to a clean interface between the first pass or Parser CC and the optional optimization pass COD2COD and between the optimization pass and the final pass or Code Generator C2 or C2136 The output file oi one pass simply becomes the input file of the next Modularity also facilitates adapting the compiler to tner machines and operating systems since the first module is machine and system independent and o
3. 25 CC Machine Dependent Command Line Options 3 C2 COD2COD and C2186 Command Line Options 33 The Compiler Preprocessor Directives cere The JSEFINE Directive L bo5 e69 9 Saws 9 Valen e dua d e A Tha ICINE DifectlUud Lo v6 i ee 9r SE ege SC THe RINCLUDE Directive 2 49 PREX ERGAX AO RUNE V 29 The RIF IFDEF IFNOEF ELSz Aud ESNOIBO Ol rset ives lodo 4 2 vv ru eee a 22 The ASM and ENDASM Directive c een Th UNDEF Directiva l l 9429 6 9a pae esas ques He Using List FUNSEL OOS sew s eI bye eens verd sede ed Se D 00 A A Oh ON 3 E opor ta pun hove LA p GA 029 ILU FOENT THT FIRED TR aa A lang nn Ada AM AA 11 CHAPTER 3 The SupercSof t C List of Functions CHAPTER 4 Standard Lisracy EGDOtIODS c x IRI s Descriptions Gf khe EOgnectl0HS uaque adus eeh Fue es The Functions Grouped According to Use eae e e a e ee ee e eege ee e ee ee e e ep e ee 6 e eg e e e e e Combining Source Code and Altering Assembly Code Method 1 Method 2 Method 3 Metnod 4 eo 6 eg Method 5S The Relocating Assemolers Modules d and Libraries S ee ge ee e e ge e ee oe ee e e ae e 6 99909 The INCLUDE Directiva Ee eee kA e RA The CC Command Line Filename List Precomoilation and Insertion in a Header Eile sesser eeano Shree LA Sikes wha eee Cut and Paste Se ep a a e e ee 9 e ep e ee e
4. OPERATING SYSTEM PASS NAME INPUT FILE OUTPUT PILE C2 M 80 ASM ASM 5 f HEX CP M 82 MAC ASM gt HEX CP M 842 u ASM gt fREL CP M 83 RMAC AS M gt f REL CP M 86 ASMB86 A86 gt H86 D MS DOS MASM ASM 0BJ ZMOS RASM f REG gt E IMAG After the compilation pass the output file must o2 transformed into an executable file This completes che compilation process Here are some examples of tals completion organized by Operating System and tile transformation 0 24 A SuperSoft C Compiler User s Manual c 1983 Supersoft OPERATING SYSTEM PASS NAME INPUT FILE OUTPUT FILE CP M 86 LOAD HEX gt COM CP M 8 Leg REL i COM CP M 89 ELINK f REL gt f COM CP M 80 LINK80 f REL COM MS DOS LINK 0BJ gt EXE As an example of the kind of procedure that must be foliowed to compile and run a SuperSoft C program in a specific machine and operating system environment we will describe the procedures required under the various operating systems We will assume that you feel ready to compile and run your first C program SAMPI C After first checking that ail the necessary files are availacle on your disk and that your program inciudes all data and function de Ge required you are ready to begin iere HC TUE H PREP HUE PTT 67 HE m Tee SHR TTP IET IPTE HHR RTT 8 exa gu D au ern hoiled me i hace ea SuperSoft
5. The line directive sets the source line number as used b the compiler This will affect the line number as printe by the compiler when errors occur The form is L ke line LINENUMBER where LINENUMBER is a constant INCLUDE DIRECTIVE If a line of the form include drivename filename or a line of the form Zinclude lt drivename filename gt is input to the compiler it causes the preprocessor to replace that line with the entire contents of the file so named on the 3rive specified If the preprocessor cannot find a file it will look for it on the current drive In the future that is not in the current version the preprocessor will look for the named file on all drives that it knows are available all drives mentioned up to this point if the INCLUDE filename directive is used Any INCLUDE directives found in a INCLUDE d file will be processed in the same way Hence nesting of INCLUDE directives is possible For examples and information refer to pages 86 143 and 297 in Kernighan and Ritchie 4 e deer Pb KX i FT b Noirs w AS fN H T ROBES OP Big G EE tu bab R mn d W Ta bees MT UI AUD es ak hl vN ve TIME eM as sl dak te Hah Ec n G e Je n SEN Bux utm dit ee me me we 20 eee ow I I Oe SuperSoft C Compiler User s Manual c 1983 Supersoft
6. g if YX wel if otherwise mus RN z ata eee os oru 4 oan manm dee EA E ee va RR n ee 9 SuperSoft C Compiler User s Manual c 1983 Supersoft Bseterrflg 2 Sets the global Berrflg to e if it is clear 163 m M T m P SuperSoft C Compiler User s Manual c 1983 Supersoft 169 5roup 4 double Y Bmant dest n double n char dest Places the mantissa of n into dest The functions Bmant and Bexpo return values a and b respectively where the argument x is of the form x s a lQ b for l lt ja ci except when x Hi S Sexpo x double x Returns the integer exponent of x The functions 3mant and BSexpo return values a and 5 respectively where the argument x is of the form x a l 5 for l lt faj lt 1 except when x 2 Bmov dest argl double dest argl Copies arjl into dest jest far3l Bround dest i double dest int i Rounds dest by adding 5 E i to the dest mantissa 5 with exponent i int25cd dest i double dest int i Converts from integer to double Bcd2int argl double arg Returns the integer part of argl rounded away from zero 7600 PE STEP D GI oe be co Qm o erp d 6 ae Fe r par oam umeme ES m on s re ep ta ws V9 ei m amame mah aeae nend ER ly pr RAS ame dae eee C aca mm manr Gb R p 8 po m t 4 t ve i men ae ma a SuperSoft C Compiler User s M
7. RESULT fprintf fd format argl arg2 FILE fd char format TYPE argl TYPE ar32 Identical to printf except that instead of writing to the Standard output it writes its formatted output string to the I O buffer associated with a file opened for buffered output via fooen beginning at the current location in that buffer Whenever that buffer becomes full it is automatically flushed 1 2 its entire contents are written to the fila The file is specified by the pointer Z to its file descriptor fprintf is a list function See p 43 i fprintf returns SUCCESS 0 if its entire output string was successfully written to the buffer However due to the buffering of file I O operations such a return value cannot guarantee that this same string will be successfully written to the file since errors resulting from and affecting the outcome of a particular call to fprintf may not become apoarent until some later function call causes that file s I O buffer to be flushed fprintf returns ERROR 1 if 1 fd does not point to a valid file descriptor 2 thre file was not opened for buffered output via fooen 3 tne file could not be written due to an error at the operating System level or 4 the entire string could not 5e written to the file due to a lack of disk space see K amp R D 152 72 bye Wren Rr E x Gi FPUTC SuperSoft C Compiler User s Manual c 1983 SuperSofe RESULT fputc c fd char
8. function has seen previously declared as something other than a function For instance the following will cause this message int fn fni a struct or union element CC An attempt to use a operator or a 5 operator but the right hand side of the operation is not a struct or union element declared d CC An attempt to use an undeclared variable This error message will appear only on the first such occurrence of tne variable l B a re CENA m e GA e 7 supera3sott C Complier User s Manual c 1983 S Te 70 iU t4 WwW O et t r Opcode error l l C2 or 0D2C909 Either an invalid U code was input to C2 or COD2C229 or the optimizer generated a bad oocode most likely an internai error Open failure CC C2186 COD2COD or C2 Can t open the output file Such an error could be caused if the file system does not exist if it is not correctiy set up i e no disx in drive if there is no room on the disk or if the filename is incorrectly formed d Operation on incompatible pointers CC Optimizer table overflow Two pointers are used in an arithmetic operation but they point to different objects H C2 or COD2COD An attempt was made to add a U code to the internal memory of the optimizer but there was no room This indicates chat the optimizer is out of memory Reduce the size of tne largest function or use the o option Also see tne bufsiz opt
9. ors LE WM SERS E Adre Age ER T Lo CG U D D Loi o th T e A O 3 tu b ta SwaB swao sl s2 n char sl s2 int n Copies n bytes from sl unsigned int tell fd ELLE d Returns the byte offset which the next I O oper file is specified by ta If tell is called for a return value is subject and rtell char tolower c char c a e Jser s Manual Cc 1983 SuperSoft Y d to s2 swapping every pair of bytes 4 from tae beginning of a file az sion on that file will begin Tha ocincer 4 t9 its file descrigtor file greater than 64K long its zo arithmetic overfiow See oteli Returns the lower case equivalent of c if c is an upper case alphabetical ASCII K amp R pp 145 156 character otherwise lt recurns C a 7 W S4 VE yr UN D Y a VA Sey awe Jr RUM ram T PR M RR cere mb AGE Sree Sege ra ez ee Wind de A Loge E A N ail AM La hun 7 ry LAN C a 5 TE EX ZA d di SuperSoft C Compiler User s Manual c 1983 SuserSofe 119 TOPOFMEM char topofmem Returns CCEDATA see brk evn5rk and sbrk TOSPPER char toupper c kg char c Returns the uoder case equivalent of c if c is a lswer 72253 alphabetical ASCII character otherwise it returns c sea K amp R D 156 UBRK char ubrk u Ge unsigned u r EE c Returns a pointer to a memory regio
10. 0 x EXIT SuperSoft C Compiler Jser s Mangai c 1983 Supersoft exit i int i Transfers control from the program back to the operating System causes an exit to system level exit never returns It calls fclose to close stdout and stderr the redirected standard output file and standard error file See xmain No other files are flushed written to disk nor are any other open files closed See KER D 154 The parameter i is currently ignored under CP M and MS DOS If an exit to the operating system is desired without any I O occurring cali ccexit instead of exit char externs Returns a pointer to the first byte ain the external data area of your program Unless you have re origined this area this value will be the sam2 as that returned by codenc Not currently implemented SuperSoft C Compiler User s Manual c 1983 Supersoft FABORT RESULT fabort fd FILE td Frees the file descriptor allocated to an open file without Closing that file The file is specified by the pointer f to its file descriptor Calling fabort will have no effacr on the contents of a file opened for input only but calling it for a file opened for output may cause the loss of some or all of the data written to that file We have included this function for the sake of compatability with BDS C wa do not recommend that you use it fabort if successful returns SUCCESS 0 fabdort returns ERROR 1 if d does not point to a va
11. Double Floating Point Functions e e The functions in DOUBLE C can be divided into four groups Group l1 contains the three operand arithmetic functions of addition suotraction multiplication division and modulus remainder These functions return the computed value in their first argument The return value is the address of this first argument Group 2 functions are for the most part two argument functions which return the computed value in the second argument These commands are double to string string to doudie integer truncation sine cosine tangent square root exponentiation natural logarithm negation absolute value and factorial Radians area used for functions requiring or returning angle measurement Group 3 contains for the most part two operand conditional and testing functions These functions return TRUE 1 if the given condition is met between the arguments otherwise FALSE 0 Group 3 commands are equal not equal qreater than greater than or equal to less than and less than or equal to Also available is a test function whie returns POSITIVE 1 ZERO 2 or NEGATIVE 1 depending uson the argument These functions do not set Berrfilag Group 4 contains miscellaneous functions E Ka eee SuperSof t C Compiler User s Manual c 1983 Supersoft 152 Group 1 double Badd dest argl arg2 double dest argl ar32 Three operand addiction dest argl ar32 double
12. Once linked a fils may be used over and over again Linking also allows groups of people to work on a program giving any one of those people the ability to combine and execute the program but disallowing each access to the other s source TALS last advantage is extremely imoortant in a large project or in a smail orojertt compieted over time especially an Systems that do not have adequate security between users The use of libraries is the easiest method of combining variables and functions into working programs It requires a librarian as weil as a linker In the case of CP M 87 the linker might be SugerSoft ELINK and the li5carian might be LI380 You must compile each relocataole module follow tha librarian instructions to create a library that includes all modules and then specify that library to link a program M st linkers do noc anake much oF a distinction detwean a relocatable module and a library Either can be specified to build an executable file The difference is mainly in the way that they are combined Relocatasle modules are loade3 into the execuradslea file in their entirety Libraries are built from multiple relocatable modules ney are searched by the linker in order to include only those modules which satisfy external references not previously defined The SuperSoft C compiler under CP M 83 comes with a library of standard functions LIBC REL built from the files FORMATIO C STOIO C STOIO H FUNC C CRUNT2
13. TYPE e EC L l gt Identical to scanf except that the input string is read from the I O buffer associated with a file opened for buffered input via fopen rather than from the standard input The ME file is specified by the pointer fd to its file descriptor fscanf begins reading at the current position in the 1 90 m buffer It stops reading when it has successfully assignec ee values to the bytes corressonding to each item Listed in tane Ka format string or when it has reached the end of tne file whichever comes first fscanf is a list function See USING LIST FUNCTIONS at tne end of Chapter 2 If no errors occur fscanf returns the number of values Successfully assigned fscanf returns ERROR 1 aad performs no input if 1 fd does not point to a valid file descriotor 2 the file was not opened for buffered input via fopen or 3 the file could not be read due t an erroc at the operating system level see K amp R p 152 Ja e 1 1 e T SuperSoft C Compiler User s Manual c 1983 Supersoft FWRITE STC int fwrite 5uf sizeofitem nitems f TYPE buf unsigned sizeofitem unsigned nitems STREAM d Writes a number of items nitems into STREAM fd The size of an individual item is sizeofitems buf is the address t write from fwrite returns the number of items written or ERROR 1 on error fwrites can be interspersed with putz fputc put25 and putw all described in this chnap
14. en k ee o ET 0 24 cnar evnbrk n unsigned n Performs identically to sbrk with the exception that it always returns an even value a pointer with its low order bit zero It accomplishes this by skipping one byte if SOrK returns an odd value for the given n argument I successful evnork returns a pointer to the first memory location in the block added otherwise it returns a vaiue of ERROR 1 Failure can be caused by 1 overlapping a Stored projram 2 overlaoding the run time stack or 3 exceeding the available memory Note that n is unsigned Also see sbrk ubrk wrdbrx and brk Performs an interprogram jump to the file specified in the null terminated string pointed to by fspec exec is a call t2 execl with two arguments axecl fspec J It is included for compatibility with BDS C Sea execl below DIR I EO OMET UTE MT Igi UNE EE VIII or log og AL Wr 2 iS ror Pe Ar am OU Ad PE gt EXECL ue l SuperSoft C Coms ler isar s Manyal c 1383 SuperSoft RESULT execl fspec arjG argl arg2 argn FILESPE fsoec char T LL argl arg2 e a 3n Performs an interprogram jump to the file specified in the null terminated string pointed to bv fspec That is it loads anj executes the code that file ssec is assumed to contain Interorogram jumping is sometimes referred to as program chaining execl enables you to successively execute a series of programs with each
15. reclen int cmp qsort performs an ascending order sort on the double dimensioned array tbl nrecs reclen That is tbl points to the base of the array recisn is ae length of the record that is to be sorted arecs is the number of recoris emp tne function t3 be used to perforr the comparison It will be called with two pointers t records Effectively its declaration is t t int cmo a 9 Char a reclen caar b reclen e wg It must return a value less than zero if the comvarison Ge less than a value of zero if the comparison is same and it must return a valje greater than zero otherwise int rand Returns the next value in a pseudo random number sequence initialized by a prior call to srand Values in the sequence will range from to 65 535 r The C expression rand n A will evaluates to an integer greater than or equal to but less than n Ld Zelt ees THF daa AE cE n d ETE RUE CC d E ut d EG CERES lr e U Y U d M 4 Super Sot C Coeai sr User s Manual c 1983 SuperSott 122 int read fd bufr n FILE fd TYPE oulte unsigned n Reads a maximum of n bytes from a fil opened for either direct or buffered input beginning ac the current location of the file I O pointer into the memory buffer pointed to by bufr The file is specified by the pointer f3 to its file descriotor You should define the buffer pointed to by buf
16. this anks utive 58 kel 3 A4 EY arc y t TE AT H ES ei ZHP MM 71 A ODIT 1 4 Yi LSA Bos Se TE tag md ie S a Aot se aa rma BDOS 0 i SuperSoft C Compiler User s Manual c 1983 SuperSoft int bdos fn parm int fn parm bdos enables users to incorporate direct BDOS function calls into programs written in SuperSoft C Programs utilizing odos will nct always be portable For example BDOS function call 7 under CP M 868 and CP M 86 represents Get I O Byte but under MS DOS the same function number represents Direct Console Input On the other hand BDOS function call 9 Print String represents the same function under all three systems Users should consult their system interface guide for further information Under CP M 80 bos loads machine register C with fn anc machine register pair Ge with parm then calis location Ss It returns as an integer a single byte identical to the contents of the A register except under BDOS function calis 12 24 27 29 and 31 when it returns a word identical to the contents cf the HL register pair Under CP M 86 bdos loads machine register CX with fn and machine register DX with parm then operferms an INT 224 instruction It returns as an integer a single byte identical to the contents of the AL register except under BDOS function calls 12 24 27 29 and 31 when it returns a word identical to the contents of the EX re
17. x int 50 bl Two operand imnediate multiplication where b bl are integers that form the most significant and least significant part respectively of tne immediate long x Ss 50 51 c2iadd x 50 2 lona x int 50 Dl Two operand immediate addition where D gt l are integers that Form the most significant and least significant part respectively of the immediate long H 58 51 cGe2Zand a gt d lona 3 b Two operand icgicai and cczneg a long a Two Opezand negation Sa 5 e H cc2sub a b long Sa Pai Two operand subtraction ta D e aran em en e e E e x up a p e emm 1 E SuperSoft C Compiler User s Manual c 1983 Super So lt 74 co3add g 3 2 long Q fa bi Three operand addition c3andta b c lone a D tes Three operand logical and l Sa x h amp Se cc3or a 2 c Lons a b Pc Three operand logical or a D c cc3xor a b c long a b XG Three cperand exclusive or cc3sub a b c long a 2 XC Tnree operand subtraction a rh c cc2div d s cocxd em long ec s ccxdrem A fora of thres operand signed division with remainder Xd s tecexdram d A s 7 E i i i
18. 1 o the argument which should be an integer is converted to octal notation x the argument which should be aan integer is converted to hexadecimal notation H u the argument which should be an unsigned integer is converted to decimal notation S the argument is interpreted as a string pointer Characters from the string pointed to are read ans written until either a null character is read or an optionally specified maximum number of characters has bean written See item 3 above LU the character is written This is an escape sequence No argument is invoived See K amp R po 7 ll 145 U do 8 if KR MAL VK e i s H raf EH Wel fe E PUTC oupersore S Complier user s Manual c 1382 Supersoft RESULT Sutc c 3 G char c STREAM fi Writes the character c to the I O buffer associated with a file opened for buffered output via fooen beginning at the Current location in that buffer Whenever that buffer becomes full it is automatically flushed that is its entire contents are written to the file The file is Specified by the pointer fd to its file descriptor pute returns ERROR 1 and does not write the character i lL fd does not ooint to a valid file descriptor 2 t file was not opened for Suffered output via Zapen or the buffer could not be written due to an error at t operating system level Otherwise putc writes G character to the file s I O buffer and ret
19. C MDEP C LONG C DOUBLE C and a number of ASM files The SU8M option of the C compiler described below and the SUBMIT file LIBC SUB was used to build tnis library Version 3 44 of M80 and LIB88 from Microsoft was used to assemble and collect the library This library contains all of tne functions that are described in Chapter 3 You could add your own functions or alter the supplied functions y adding relocatable module names to the CLIBC SUB file ana compiling the appropriate source files j lt ee rm Da om SuperSoft C Compiler User s Manual c 1933 Suparsoft L t9 4 If you are using another linking system you may or may not De able to max2 use of the LISC REL library ELINK is compatible with LIBC REL the LINK8 may not be If you have any problems you should rebuild the library as described below This is not a task to take lightiy LE requires a considera5le amount of disk space mostly directory space for a lot of small files and time It may take hours The method described below may also be used to build your own unique libraries In building a library you will probably have to sort the modules into a dependency order if module A refers to module B then module A will have t be before module B in the library If this is too much trouble you can try searching the library more than once in order to pick up all references Mosr linkers allow thea Searching of more than one Library so adding anothe
20. C ALLOC C FUNC C FORMATIO C This method has all the advantages and disadvantages of the previous one asing INCLUDES but is more flexible T change the files incorporated into your program rather than changing vour program you would just type a different ser cf filenames in the CC command line ty Ji wrs m ae owe SuperSoft C Compiler User s Manual z 1983 SuperSo t ME METHOD 4 PRECOMPILATION AND INSERTION IN A HEADER FILE Any of the library files which are in SuperSoft C sou code may be compiled and the resulting file inserted wi minor editing into the compiler s run time library T increases the speed with which you can compile programs t incorporate these functions However this method sha the same disadvantage of possibly excessive program si with the two other all inclusive methods described above t a Maw D hi by ri G iW e D Of course you are not limited t including the libraries as a whole I you have an idea of the functions you will commonly use in your programs you may Create your own version of the run time library by orecomoiling ans inserting these functions into your header file Nor is necessary that these functions be the functions suppli with the compiler they may be of your own creation method can save you considerable time in compilinr y programs and considerabila prog am space by eliminat unnecessary functions is O X ve A LG ort dy tre u bor1 o A4 Supe
21. D iter cim 9b SEER Clee rot gg 8 AU 39 LL uAL where QV E rei 18 34 R NYE memi d gnn ng qv 168 T Iw wii w 1 999989 HON trem teen mR tt B Bde el uum men ey SuperSoft C Compiler Jser s Manual c 1983 Sugersofrt L a Or double Bfac dest argi double dest argl Takes the factorial of argl dest s argl argl is tested against being negative or too large transcendental functions double 3sia dest ar21 double dest argl Su Returns the sine of argl in dest dest sin arsl l double Boos dest argl double dest argl Returns the cosine of farsl in dest Jest cos ar31 double Y Btan dest argl doubie dest arsi w l Returns tha tangent of argl in dest M l ud Jest tan argl QS double Barctan dest argl double dest argl Sets dest to the arc tangent of argl Jest arctan argl SuperSoft C Compiler User s Manual c 1983 Supersof 167 Group 3 Bsign x double x Ble x Bgt x Beq x Bne x Bl2 x Bge x Btest x y double x y Returns 1 if x d if x l if x y double x y Returns l iff ss y double x ty Returns l iff es y double x y Returns 1 iff x y dousle x y Returns 1 iff x y double x y Returns l iff Ss y double x y Returns l iff es lt is positive is zero otherwise H H C Returns 1l if x gt Xv
22. Overlays have the added benefit of requiring discipline in Structuring the modularity of a program The tree structure imposed by overlays is fortunately ideal for supporting a number of types of systems such as menu driven programs The overlays can mirror exactly the structure of the program E By putting the C libraries in the root significant savinzs can be made because they occur in only one piace and do nor have to be loaded with each overiay ELINK does NO CALL PATH CHECKING and assumes that the parent in the overlay tree is resident with the child This mean simply that each overlay structure can only call routines in the entire path to the root up the tree You must avoic having a function make an AUTO load call to a function another overlay at tne same level in the structure would cause the return t2 Jo to a non resident fun because the function that was called overlayed the ca rey T 2t 10 r 3 ul La Ot OQ tz gr K ELINK contains a modified C2 RH anc C2 RT which use features of ELINK and ar required for overlaving changes are very simple and deal only witn the locating c the top of the user program ALLOC and several othe functions will not work properly without these modifisa files 4 fu hi t el QO 1 CG D LL It tn IL U TO create and execute an overlayed program perform tne foliowing steps l Comoile all of the C files with SuperSoft C and assemble with M80 RMAC may
23. The value assigned to offset has a different interoretation deoending on the value assigned to origin If origin is Q0 then the file 1 9 sointer will point to the beginning of the file plus offset bytes i IS origin ee l then the frla 1 9 polcter will soint ts 125 current position in the file plus offset bytes If origin is 2 then the file I O pointer will point to the end of the file pius offset bytes If origin is 3 then the file I O pointer will point to tne beginning of the file plus offset times 512 dsytes If origin is 4 then the file I O pointer will point to current position in the file plus offset times bytes If origin is 5 then the file I O pointer will point to tne end of the file pius offset times 512 bytes See K amp R p 164 H 3237144 evt C Y ae Kin Rah E BS es O VIS TE Fle eee CH MA Wf EE Ww RTT D e rar e mm gt SuperSoft C Compiler Yser s Manual c 1983 SuperSofe 11 SETEXIT int setexit Calling setexit sets its location as the reset point the point to which subsequent calis to reset transfer prograz execution 3 is returned Each call to reset that follows Causes an apoarent return from the function Setexit setexit appears to return the value of the parameter nN that was passed to reset Ses reset and setjmp V TIMP setjmp saveare2a int savearealsaves ze Calling setjmp stores the proeram stats in the savearea ans returns H sav
24. U ei context of the current switch Nested switches can each have one default pecting formal arg CC we This error appears when inside of the arqument lisc declaration of a function an identifier is expected That is a or a has been seen i pecting function body CS All of the formal arguments for this function declaration haze been declared The first of the function body is expected at this point moecting t Og an E CC Inside of a function formal argument list neither a of a was found when expected EC N e S apecting or CC A declaration of the type of a formal argument was not followed by a or a Sometimes indicates confusion on the part of the comoiler with regard to your intentions in declarations It appears that the C syntax leaves little opportunity for error recovery in declarations PExpecting HE or In function call CC Refers to a badly formed function call Ion D 4 1 n of th T ah it u a a 4 Aa ams m mi GE 8 SuperSoft C Comgiisr User s Manual z Expecting type declaration A struct element declaration is expected declaration with a dase type File close error n output error has occurred file Usually indicates that there is just short of bytes to the output on the output file system remedy gen err tl An invalid U code has Seen was read by C2186 or there C2186 gen err t2
25. a RASM SAMPL SAMP1 i Each of tne above commands causes a new file to be created on the currently lojyged in disk These are SAMP1 COD output from CC SAMDI REG Output from C2780 g1l SAMPL IMAG output from RASM You will also need the files WHEADER REG and WTR present on cisk AP MAAN 1 boar on Sis a ew tiles Be LE AA dass SLBA a Or NET Bei 0 2 Supersoft m ar Compiler User s Manual c 1983 SuperSoft 28 COMMAND LINE OPTIONS i CC MACHINE INDEPENDENT COMMAND LINE OPTIONS U A places the address of the last memory location used ody CC in front of each C source code line comment into the output file This effect unless tne option L has also This memory allocation information determining if ard when the compiler is out of memory Default is d i inserted as a option has no been selected s helpful in BUFSIZ is followed immediately by a decimal integer This integer becomes tne buffer size for The larger this valse the faster zes use less memory A number of 123 is Smailer Si about the minimum for most systems effect for both inpet and output buffers below If this option is used be printed on the console Default CO forces output to console Default is filename COD CR appends a Carriage Return to each generat expect ec thi Certain text editors s format Default is CR I th Thi i e g Q operations
26. a file on your disk tyre SUBMIT C SAMPI Then press RETURN If CP M finds C SUB on the current disk the following five commands will be executed Sanel has Geen substituted for each occurrence of S1 CZ ga Plc C2 SAMP1 COD ASM MAC SAMP1 LOAD SAMPl1 SAMP1 For further information about SUBMIT files consult the CP M documentation or one of the several CP M manuals available U U y Pred A ARARE WE tA IV Da CS Rei E i t vt NL STO we Y T n Tui De a Tae ee e Aut ww Lc a ur E a eoa di Ae oe Mie A Bu Id DA en FEM Eu E 4 1 E L ae E Sj fi BK LR L AM Qa Ae Zeg Au aa ee wa s ll hL Bete sn Bok a4 PEENE d ones A t Lt E SuperSoft C Compiler User s Manual c 1983 Supersoft 19 COMPILATION USING ASM86 THE STANDARD CP M 86 ASSEMBLER To transform SAMP1 into an executable command file so that it can be run under CZP M 86 you shozld type each of the commanis listed below in sequence Type Co SAMP1 C COD2COD SAMP1 COD C2186 SAMPL U zr r LS ASM86 SAMPIl GENCMD SAMPl DATATIX1000 a Each of the above commands causes a new file to be creat on the disk which contains SAMP1l C The names of the files are respectively e S m SAMP1 COD Output from CC SAMP1 U output from COD22COD SAMP1 AB6 Output from C2786 i SAMP1 H86 Output from ASM86 SAMPlI CMD Output from GENCMD The last file created is the e
27. also work but we have no verification of this 2 With all the REL files on the current disk type ELINK so cex This will cause ELINK to read CEX LNK for commands tna will create the overlay structure defined above For furthur reference see the ELINK documentation 7 wi Ar Y S ar d P d 4 SuperSoft C Compiler User s Manual c 1983 Supersoft 143 CMAIN COM and CMAIN OVL are created The COM file should contain the root and C libraries along with the ELINK run time package The source of this run time is included with ELINX in case you wish to customize your environment CMAIN OVL contains all of the overlay code in absolute form along with a directory to the overlays in the file CP M 2 2 is required for single file overlays and AUTO load entry points Direct overlay of files is supported under CP M 1 4 See the ELINK manual for more details Simply typing CMAIN will execute the program The overlays Will be called as needed N Ota Age A formal arj is not declared Co 2 P L SuperSoft C Compiler User s Manual c 1383 SuperSoft l Apoendix F Error Messages The function declaration that precedes this error has a formal argument witnout a corresponding type declaration For instance func a 5 l char Sa i will generate this error i Already defined CC This is a function formal argument local auto or structure element that was previously def
28. c STREAM fd Writes the character c to the STREAM fd Identical with puts descrioed later except that it is guaranteed not to be a preorocessor macro RESULT foutsis 24 l i char ser STREAM fd Writes the null terminated string z2oiata buffer associated with a file opened for buffered output via fopen beginning at the current location n that buffer Whenever that buffer becomes full it is automaticail flusned i e its entire contents are written to the file The file is specified by the pointer fd to its file descriptor For each newline character Mn appearing in the string a carriage return and a newline r n are written to the Duffer The terminal null character is not written oy s to the I O 2 MI fputs returns ERROR 1 and does not write the string if 1 d does not point to a valid file descriptor 2 the file was not opened for buffered output via fooen or 3 the file could not be written due to an error at the eoerating system level Otherwise fputs returns the number of bytes actually written to the buffer minus the number sf Carriage return characters inserted However due to tne buffering of file I O operations such a return value does not guarantee that those same bytes will be successfully written to tha file since errors resulting from and affecting the outcome of a particular cali to fputs may not become apparent until some later function call causes tnat file s I O buffer to be
29. coding of very reliasle programs For instance the following poorly formed function call can be detected lect its arguments a fprintf amp s This detection ability is a feature that few C compilers have With most C compilers the above code would cause undefined and potentially disastrous I O operations t2 occur RAE CER HOMER invocation of that function the last oe age Oan Y AN HI iiv tiis JT AUN NU LAO N N E i i 2mm LL a i SuperSoft C Compiler User s Manual c 1983 SuperSoft 44 The body of a list function should look something like this pf nar3s int nargs unsigned cnt int ps ent nargs if ent lt MINIMUM ent gt MAXIMUM return p Xrev amp nargs lib arg reversal fn at this point A cnt is the count of passed parameters P is the leftmost parameter x p 1 is the 2n leftmost parameter p 2 is the 3rd leftmost parameter z ee and so on up to D cent i CER W I KR 19 e U WR e SuperSoft C Compiler User s Mansal c 1983 Supersoft 45 CHAPTER 3 Tne SuperSoft C Standard Library Functions The standard library functions supplied with the SuperSoft C Compiler are defined in the following files e UNDER cP M 823 ae lt t S C2 3H run time library header E RT run time library trail
30. e comdilation S Size is in see WBUIFSIZ the selected value will S BUFSIZ1924 CO output to U code output line e CP M s ED D followed immediately no white space by an identifier Gefines that identifier just as i encountered for that identifier ENDIF pr eprocessor directives predefine no identifier DDT incorporates additional debugging output file Default is DOT F flushes G turns off U code generation checking the syntax of a source code file writes to file all U code immediately after each line of C processed then each source code comment line placed in the output file is followed immediately by ail generated execution of both CC and C2 or C2I certain optimizations normally performed by C2 or COD2COD If options L and F ar from it Selecting th Default is F f De l a DEFINE was Useful for IFDEF and fault is to information into the ines generates source code is e the is 36 both selected U code lines ootion slows and inhibits This option is useful for Selecting E 48 3 3 E Pa 7 Z E ta E R mita A i a dla er id SuperSoft C Compiler User s Manual c 1983 SuperSoft 29 this option and option L below will also produce a numbered listing of the C soutze code with macro defines expandec Default is to generate U code Default is G L lists each
31. fb n Lo o rt t0 Q Q O 3J U ke e a wv P PERROR perror s cnaz ui TI Prints the string s then a colon and then prints a string interoreting the value of errno the I O error value Dr errno is zero no interpretation is printed SETC lgt sserciria A i Identical to getc excep t t that it replaces the system end of line indicator with a n iz Under CP M and MS DOS this means tnat whenever encounters a carriage return character r followed immediacaly by a newline character n it returns oniy tne newline mgetc thus converts lines within files from CP M to UNIX ANSI format D us th SuperSoft C Compiler User s Manual c 1933 Supersoft 96 POKE poke addr Di char ad3ir b Writes the byte b into the memory byte at addr b musz be an ivalue expression see K amp R p 183 The function poke which has been included for compatibility with 3825 C is redundant in C since indirection is a feature of the language i be Ke K i i l PUTC i i int sogtc ts 2 char Cc STREAM d Ientizal to oucz exceot tnat it replaces the n cnaract witn the system end of line character Jnder CP M ans MS 2OS this means that whenever it passes a newline character n it first writes a carriage rerun i Cnacacter r to the file s I O bufier and then writes the newline character that was gassed pputc thus converts 7 lines written to fi
32. flusned see K amp R pe EE 73 FREAD i SuperSoft C Compiler User s Manual c 1983 Supersoft int fread 5uf fsizeofitem nitems fi TYPE b5 f unsigned sizeofitems unsigned nitems STREAM fd Reads a number of items nitems from STREAM fd The size of an individual item is sizeofitems buf is the address to read into fread returns the number sof items read or ERROR l on error freads can be interspersed with getc fgetc get2 gt and getw all descrided in this chnaster Alignment is of no concern Also see read described later free p char p Frees a block in memory previously ailocated by a call to alloc The argument p waichn should be identical to the value returned by that call to alloc isa pointer t tne first memory location in the block Allocated slocks may 32 freed in any order To call free with an argument not previously obtained by a call to alloc is a serious error see K amp R pp 97 177 e r L m e P Ge van T EK vat antt Mi pt Jj pus 4 L S Manual c 1983 SuperSo SuperSoft C Compiler User FREOPEN E STREAM freopen fspec mode buffer size strm FILE 5s0ec j STREAM strm char mod2 unsigned buffer size Te fv CG Redirects strm as if strm fopen fspec mode buffar size been called Returns NULL if unsuccessful Ne d SCANE RESJLT fscani ra format arsl arfj2 R H FILE fd chaz fformat argl farj2 ss TYPZ argl
33. generate error messages indicating defects in your program Although these messages are Largely self explanatory a complete explanation of them can be found in Appendix F of this manual The CP M documentation provides information on the error messages generated by MAC Two types of messages from MAC can have roots in poorly formed C programs 1 Phase errors and multiply defined labels are usually caused by the redefinition of a C external including C functions Note that externals have only so many significant leading characters This number depends on the assembler and NI l i Vic A SuperSoft C Compiler User s Manual c 1983 Supersoft loader used 2 Undefined labels usually indicate un defined C externais including C functions i S In the course of developing programs you are likely to repeat the procedure just described with no change except in the filename specified an enormous number of times It would save considerable time if you could cause this entire procedure to be carried out by means of a single command Under CP M the SUBMIT command and SUBMIT files provide tne means of accomplishing tnis 1 An appropriate SUBMIT file with filename C SUB woulda contain the following command lines CC 1 c C2 1 COD ASM MAC 1 LOAD l i S1 X 1 where S1 is a symbolic parameter to be later replaced by the first actual parameter of a SUBMIT command After you have created such
34. in preparation for merging into the C2 RH Ziler REN CRUNT2 LIB zCRUN 2 A SA A minor amount of editing must be done before the CRUNT2 LIS file can 5e meryzecd Type the followinc A gt ED CRUNT2 3 3T you will then see C Optimizer V1 2 ORG 256 SC Compiler V1 2 When you list the top of the file on your screen your file should be the same except for version numbers as that listed here You must now delete the following line ORG 256 L After deleting this line exit the edit with an EI thus saving your changes RE TH R 9 IE PPM TM EIER PN nee 111 RET EEGEN FURS Y OP D gur VO Owns n US gan GENERIS ra ana TONS SuperSofe C Compiler User s Manual c 1983 Suparsoft t 34 METHOD 5 CUT AND PASTE This method is simple in concept but laborious in execution The idea is to create from the standard library function files a file or files containing only those data ani function definitions required by your program cut and then merge the files thus created into your program before compiling it paste The advantage of this approach is that both the source and object code for your program will be as small as your program s implementation will allow Of course you must De careful that all data and function definitions required for execution of your program are present and intact Cleariv this can be time consuming and some troublesome bugs can creeo in during the process How
35. line of C source code as a comment in the U code output file The source lines are grouped together by function and are thus only loosely associated with their corresponding U code lines Macros are expanded and line numbers appear before each source code line Default is L l i S LISTLNO suppresses listing of line numbers in the output file Active only if L is also specified Default is LNO places source coce line number in front of first corresponding line of U code in the outdut file Output also indicates line number at which each file incorporated by use of a INCLUDE directive begins Nested INCLUDES are clearly indicated as well Default is LNO N is followed immeGiateiy by an integer specifying the initial value for the consecutively numoered labels generated by CC Default is an initial value of two OFILE redirects tbe output file to any specified drive under any specified filename It is followed immediately by a filename which will be used for the output file There must be no whitespace between OFILE and the filename PRE is equivalent to specifying L LISTNO C Creates a file that has been preprocessed only The cutput can be rerun througn CC Default is PRE S prints symbol table information as each symboli is entered into the symbol table Mostly of use to the compiler writer Default is S SILENT suppresses some output header information Helos lower the clutter on the console Default is SILE
36. looks for a capital X creat witnout conflicting with an existing file If mktemp cannot it and replaces it and the following character with a two digit decimal number ales e v een gg gegen SuperSoft C Compiler User s Manual c 1983 Supersoft MOVMEM movmem source dest n char source dest int n Copies the contents of the n contiguous bytes in memory beginning at source into the n contiguous bytes beginning at dest There is no restriction on the overlapping of tnese two regions The bytes in the region pointed to by source are unaltered unless they are overwritten as a result of overlapping between the regions Sets the priority of the current process A null procedure under CP M and MS DOS ER PH PT 1 SP Cerne Y Teme serre we oe wr e PR Tp Tr rye STrTUTMOY monem 5 eae eX 1 EL TN Le td TT TR 0 OPEN Bi NU Super Sot C Compiler User s Manual c 1983 Supersoft FILE open fspec mode FILESPEC fspec unsigned mode Opens the file specified in fspec for direct I O This fila must already exist See creat open if successful returns a pointer to a valid file descriptor for the file specified You should store this pointer for subsequent use in your program open returns ERROR 1 and does not open the file if 1 not enough user memory is available for a new file descriptor 2 the file specification given is invalid 3 the file specified either d
37. of ERROR 1 is returned to indicate an error Every file descriptor contains a pointer to the next record to be accessed in file I O operations A call to write ad ances that pointer by the numder of Dytes written A subsequent call to read or to write will Segin at the new position of tnis pointer By calling seek you may alter the position of this file I O pointer without reading or writing See K amp R p 160 XMAIN SuperSoft C Compiler User s Manual c 1983 SuparSoft H a H xmain The first C function called upon program start up It sets up the arguments to main and does I O redirection if the switzh REDIRECT is set in CUSTOMIZ H before CRUNT2 C is recompiled I 0 redirection is the ability to redirect the console input the consoles output or command arguments t gt or from files Console input is redirected by specifying a filename preceded by a lt on the command line Console input is then taken from the file Console output is redirected by specifying a filename precede by a gt on the command line Console output is then sent to that file Command argument redirection is specified by preceding a filename with an 3 on the command line Command arguments are then taxen from the file Command line arguments are passed to the program by setting up two parameters in the call to main The left parameter is the count of the numzer of arguments The righx parameter is an array of pointers to strings one st
38. of the included code Ie may also max2 your program unnecessarily large Dy incorporating into it functions that are never called 1c you are using a relocating assemsler you will orobably want to compile Cha sample orograms in a modified manner Remove tne SINCLUDES statements from tne sampi programs Then compile as soecified in Chapter 2 will pe about 25 file that you wo Also compilati The result executasis assembler of the orginal compilation tim t of the size of the if you used an absolute will be a small perzent de 9 UN TOY yg TIU cdi T T d L TYRE gt Lat x M ay Kr g N Ke My AN NEED Ki AT BA A CES LOEIT f Say S i m pe YE R d V 1 wit PA A a M d Eed AR Cat Ch E uT td 3 Ey Pau h l Mart be B L b wa EA parue RENE Se te ue SuperSoft C Compiler User s Manual c 1983 Supersoft 132 METHOD 3 THE CC COMMAND LINE FILENAME LIST If you list a number of filenames on the command line for CC the first pass of the compiler all the files named will be parsed in the order listed as if they were one file The output will still be placed in a single output file Thus you may incorporate any C source code file into your program simply by listing its filename in the command line for CC The CC command line that would incorporate all tne SuperSoft C standard library functions into the program Y C is CC Y CRUNT2 C STOIO
39. or in the case of SAMP REG the sample programs gt U H 1 MITT PH i rr e OA e a i E e e a E e ene meem B 1i amal Smt69 i SuperSoft C Compiler User s Manual c 1383 Superso c i I d FILES NEEDED FCR COMPILATION OF YOUR PROGRAMS TO compile a program you will need the executable files appropriate to your particular operating system In addition you will need the appropriate header and trailer files and the files containing any library functions desired The code generation pass of the compiler automatically incorporates all the code segments ani functions contained in its run time library and the header and trailer files into your program during compilation It using a relocating assembler you will need the appropriate trailer file C2 RTM for CP M 83 and LIBC Using a relocating assembler you will have to link in the run time Library functions A H or if your orogram cails one or more of its functions Siace the functions contained in these files are such basis buildiag blocks most programs will cail a substantial number of them Therefore if your program does require any of the functions defined in these C or H files you must see that it incorporates all necessary function and data definitions from those files and in turn that ic incorporates the same information from the functions that these functions call for Five methods of accomplishing this are described in the section of Chapter 4 called Inco
40. previously used as an argument to setjmp described later Upon a call to longjmp with the same savearea the state is restored effectively appearing as if a return from setjmp has occurred witn the return value being i longjmp is a generalized version of reser LLOC char malloc a unsigned n Allocates a contiguous memory region of length n Every block it allocates starts on an even addres malloc i successful returns a pointer to the first memory location in the block You should store this pointer for subsequent use in your program malloc returns a NULL pointer value 9 and does not allocate any memory if allocating a contiguous block of the size requested would overlap 1 a stored program 2 the run time stack op 3 a previously allocated block in memory See K amp R s description of alloc pp 97 175 33 s Ho aiir Lass e FS Fas Je ALA S 3 Sad ixi p ecd at TES eec EN H S rkab CNA ag 4 nt at RENE mt a pog dee TB EC E SuperSoft C Compiler User s Manual c 1983 SeperSoft MAX int max a b int a b Returns the greater of a or b N N min a 5 int ss 5 e Returns the lesser of a or D i TEMP I mktemp t d l FILES PEC f e VI 29 Alters the FILESPEC string to a unique filename the string that is returned can be used in an fogen open or form a unique filename then it returns NULL if it can returns f its argument mktemp
41. processing units CPUs See Apoendix B for a list of the currently available machine ans operating system configurations Due to the inherent portability of the C language and its particular implementation in our compiler configurations for other Operating systems and machines can be easily and rapidiy developed A wealth of user callable functions ar supo SuperSoft C These include many UNIX compatible allowing the porting of source between UNIX C and Supersofic C with few if any source changes A full standard I O package STDIO is provided This package allows file I O that is indeoendent of the natural record size of the target system For instance under CP M a SuperSoft C program may open a file seek to any byte in the program and then close the file The approoriate byte and only the appropriate byte will be changed by this sequence of operations Beyond that porting services are available from SuperSoft Writing our compiler in the language it implements not only has facilitated its development and maintenance but also has provided the most direct means of testing it It has undergone many other extensive tests including the fact that it is used in most of our programming projects As a result SuperSoft C has been tested on tens of thousands of unique lines of C source code As a result of the optimizations performed the code generated by the compiler has spatial and temporal CELL I7 019 1 F F tk a Dl Le lal
42. programmer Since the code generated is intentionally not specific to any one of the assemdlers in use on a given machine practically any hardware compatibie assembler including aosolute as well as reiocatinz assemDiers may Se used Thus the output of tnis compiler can be integrated into any soztware system already writte in or compatible with assembl source code Th programmer can aiso insert lines of assemply code directi into a C source file by bracketing them with the compiler directives ASM and ENDASM Lines so inserted are not optimized or altered in any way by the compiler l Use of assembly sourc code also satisfies our design specification requiring that the output of each pass be intelligisle to a human being The resulting readaboility o the compiler s output facilitates debugging and ailows any user to see the kind of code generated by the compiler Thus the programmer need not take for granted that tne code generated is what was desired and may eitner alter the source code or hand polish the generated code to maka the result more Suitaoie for a particularly demanding application EXECUTION TIME VS COMPILATION TIME A major trade off in the design of any compiler is in the time required to compile a program versus the time required to execute it Since one of our primary design goals was to generate code efficient enough for system level programming we have emphasized speed of execution at the expense of speed
43. to by p and returns CCEDATA which is ecuivaient to the pointer value it was passed CCEDATA is initially set to the byte immediately following the less byte in your program s external data area Since CCEDATA is use as a base value by the other dynamic memory allocation fonetions this cftODerclV anitiselezes those ftuncticas Zor S u will almost never need to call brk in youvrf ot rem Ce s your own programs SEK retorns ERROR 1f it could net V perfcrm she Sreak Allocates a ccontigucus memory recicn whose length equals tne Procues of nthinzs and i1c896l tc5 D9s Sverv lock Alolocetec ox et Z A eb de mote starts on an even ac dress The bytes of the biock contz n e po zero 7 value See mailoc e i re VS 1 EE C E Ee ees ae o m omm een SuperSoft C Compiler User s Manual 2 1933 Severso gt ft int ccall addr hi a bz d Car acsry a int NI gt c de call sets machine rejgiszecs hl a be and de to the values given in hi a e ani 92 cesnectively and calls the assemoly language subroutine beginning at addr Seal cretacns tha value Oresent in the hl register after execution of the sudroutine Programs catling ccaii will not De porta3i ie beyond the 8383 series CPUs Ccalla is identical to occa Value present in the r Ee oe Prosrams portasle 5evond tne S082 Scion wf kN wili also apu S t LY tL As an example of the use of tnis function consid
44. trailer files respectively to output code definitions ely by a decimal integer This integer becomes the buffe size for I O operations The larger tnis value the faster the compilation Smalier sizes use less memory A number of 128 is about the minimum for most systems This size is in effect for both input and output buffers see WB FSIZ Y r des below If this option is used the selected value will be printed on the console Default is BUFSIZ1024 forces output to conscle where output may be viewed Default is to output tc filename ASM ENT lt keyword gt defines the keyword used to declare the entry point of a label for relocating assemblers Note no Space between ENT and tne keyword Default is ENTENTRY EXT lt keyword gt defines the keyword used to declare an external label for relocating assemblers Note no Space between EXT and the keyword Default is EXTPUBLIC turns off assembly code generation Default is to L generate assembly output code places each line of U code in the assembly code output file as a comment If optimization is performed U code lines are grouped together by function otherwise they occur directly before the code that is generated for the line Default is L MSDOS instructs C2I86 to output code compatible with MS DOS PC DOS assembler 23 are k d ba je wi E TEC EE MAEN th neg E D n 3 k v r m X tat zes Super Sot C Co
45. with an additional function attrisute called list The SuperSeft C standard library functions include the following predefined list functions printf scanf fprintf fscanf sprintf ani sscanf The operation of these list functions is transparent to the user you need not do anything specia to take advantage of these buiit in functions However if you wish to use your own list functions you will have to know how the list attribute is declared and how S are passed For the list functions of your own Parameter Creation to execute properly they must be declared before they are first used by your orogram as follows TYPE ViSts 224 T where listi is an arbitrary list function and TYPE is the return value declaration for listt which should of course match ail otner declarations for listf This declaration causes for each argument on tne parameter stack to be thre ragument count If this declaration appears at the top of your program as a global external it need appear only once in your program The 5ody of a list function must coii special manner in orser to take into accounz the parameter stack You may want to look at the body of on the above functions for the special coding necessary t utilize the additional information available via the parameter stack The list attribute allows C functions which expect a certain number of arguments to protest themselves from being passed an incorrect number of arguments permitting the
46. 39 E Es Te THE 4IF IFDEF iFNDEF ELSE AND ENDIF DIRECTIVES k i A These directives perform conditional compilation The E general form is Tue i lt e t CONDITIONAL Ve i Ex TRUECODE S l bei se E we EU s E FALSECODE E Zencif i 3 where CONDITIONAL is one of IF I1FDEF or 1FNDEF The Sl That is the form can be e i i ELSE is optional CONDITIONAL S e TRUZCOCE L Wi Wi M I t a o c eee eee endif If the CONDITIONAL is considered to be true then lines and the lines labeled L shown as TRUECODE are compiled FALSECODE are ignored If the CONDITIONAL is considered to be false then the lines labeled FALSECODE are compiled and the lines shown as TRUECODE are ignored aad Kat The IF directive is of the form if CONSTANT The CONSTANT must be a constant If it is then the IF 15 considered to be true The IFDEF directive is of the form RAMIS Le HE 1 SuperSoft C Compiler User s Manual c 1983 SuperSofc 49 ifdef IDENTIFIER The IDENTIFIER must be a 3DEFINE style identifier If IDENTIFIER has Deen previously defined via a DEFINE then the IFDEF is considered to be true ifndef IDENTIFIER The IDENTIFIER must be a DEFINE style identifier I IDENTIFIER has been previously defined by means of a DEFINE then the IFNDEF is considered to be ASM AND ENDASM DIRECTIVES This special feature of SuperSoft C allows you to insert lines of assembl
47. AMP1L ASM Output from C2786 SAMP1 0BJ Output from MASM SAMPl EXE Output from LINK The last file created is the executable command file for your program This is the only form in which your program can be run under MS DOS The others may be deleted Once this file is created you need only type SAMP Then hit RETURN and execution of your program will begin CC Cop2cod C2186 and MASM may also generate error messages indicating defects in your program Although these messages are largely self explanatory a compiete explanation of them can be found in Appendix F of this manual In addition the MS DOS documentation provides information on the error messages generated by MASM Two types of messages from MASM can have roots in poorly formed C programs l Phase errors and multiply defined labe s are usually caused by the redefinition of a C external fincluding C functions Note that externals have oniy so many significant leading characters This number depends on the assembler and loader used 2 Undefined labels usually indicate undefined C externals including C functions T i uk KN ON o SS SR ov RENE PE LE RTT M lt K SuperSoft C Compiler User s Manual c 1983 SuperSoftt i In the course of developing programs you are likely to repeat the procedure just Jescrioed with no change excep in the filename specified an enormous number of tim
48. ASM can have roots in poorly formed C programs 1 Phase errors anc multisly defined labels are usually caused by tne redefinition of a C external including C functions Note that ext rnals have only so many significant leading characters This number depends on the assembler and nutre X LR R BLES URAL RR OR Ll pe i prp npr ER Reg 1 8 8 6 In roim Se R p L L Ras TRET DE 1200 Z then SES dm RP PORT QUUD VG BHT ERR HULL DIER s RC SuperSoft C Compiler User s Manual c 1983 SupercSoft l6 loader used 2 Undefined labels usually indicate un defined C externals including C functions l In the course of developing programs you are likely to repeat the procedure just described with no change except in the filename specified an enormous number of times Ges would save considerable time if you could cause this entire procedure to be carried out by means of a single command Under CP M the SUBMIT command and SUBMIT files provide tha means of accomplishing this 4 2 An appropriate SUBMIT file with filename C SUB would contain the following command lines ASM SUD n Ce Slo j C2 S1 COD ASM ASM S1 LOAD S1 1 where Sl is a symbolic parameter t be later replaced by the first actual parameter of a SUBMIT command After you have created such a file on your disk type SUBMIT C SAMPI Then press RETURN If CP M finds C SUB on the current disk the following five commands will ba executed SAMPl has Seen Sub
49. An invalid U code has deen was read by C2186 or there C2186 gen err t3 An invalid U code has been was reac by C2186 or there C2185 gen err t6 An invalid U code has been was read by C2186 or there C2186 l 1383 SuperSoft L CC This should start Such as int Or char CC C2 or COD2COD while or during the writing the last few actual close enough space See the ofile option for a C2136 Seen Either an invalid U cods is a memory problem internal ts C2136 invalid U cods internal to seen Either an LS a Mamory problenm C2136 invalid internal to seen Either an is a memory problem C2186 invalid U code internal to seen Either an is a memory proolem Ut lw Y code TT ween NR 0 LHR KLEER MR B TE Ar ee LEE RAR oue Bt olla ehm wn wb Internal error optdel t SuperSoft C Compiler User s Manual c 1983 SuperSoft gen err t7 j C2189 An invalid U code has been seen Either an invalid U code was read by C2186 or there is a memory problem internal to C2186 Internal error close on bad fd l CC E A close on an include file that should have succeeded didn t This should never happen and usually means that th compiler s stack has been overwritten Add mors memory E your system or decrease the number of declarations in compile for instance by splitting the program into files each separately compiled Also see the ae option for decreas
50. C Compiler User s Manual c 1983 Supersoft COMPILATION USING ASM THE STANDARD C2 M 880 ASSEMBLER To transform SAMPl C into an executable command file so that it can be run under CP M 80 you should type each of the commands listed below in sequence This procedure is similar to the procedure for MAC described later Make sure that the files C2 RH and C2 RT are on the default disk usually the same disk as C2 COM Execution of each of these CP M commands begins as soon as you hit RETURN at the end of the line Type CC SAMP1 C C2 S3AMPI COD ASM ASM SAMPI LOAD SANS SAMP1 i Each of the above commanis causes a new file to be created on the disk which contains SAMPI1 C The names of these files are respectively SAMPl COD output from CC SAMPl ASM Outpuc from C2 SAMPL HEX Output from ASM SAMP1 COM Output from LOAD The last file created is the axecutable command file for your program This is the only form in which your progran Can De run under CP M The others may be deleted Once this file is created you need only type SAMPL Then hit RETURN and execution of your program will begin Cc C2 and ASM may also generate error messages indicating defects in your program Although these messages are largely self explanatory a complete explanation of them can be found in Appendix F of this manual The CP M documentation provides information on the error messages generated by ASM Two types of messages from
51. ES R TE A E SuperSofe C Compiler User s Manual c 1933 Supersoft 141 Appendix B Currently Available Machine and Operating System Configurations of the SuperSoft C Compiler Current operating systems are CP M 80 MP M 80 3ZCP M 86 Concurrent CP M 86 CP M CP M 89 3 4 MP M 86 and compatible PC DOS MS DOS and compatible UNIX XENIX and comoatinle and Centrzal Data ZMOS Current host or target CPU Intel S036 Intel 3088 In S are Intel 8883 Intal 8 Zilog 28021 Zilog 289002 2 ces 1 186 Intel 188 Zilog 262 ilog Z289803 and Zilog 239004 SuperSoft supplies any vaiid combination of host target and operating system Those interested in such systens should contact SuperSof for information abpcuot availability E DNE S Rm Va ts Supersofe C Comoller User s Manual c 1983 SuoarsSoft Lau 6 Apoendix C Some Common Problems and Solutions Problem During assembly or link a function is unde Solution Remember to include the files containing th needed functions See Chapter 4 E aed 2 Problem During assamdly or link some variables ars undefined Solution Remenber to declare all variables Proslem During assamaly or link a function or variante is flagged with duplicate definition errors Solution Have you accidentally defined a function of variable more than once Have you used a name that the C support uses How many significant letters truncation limit does yo
52. NT SUBM conditions the output to allow separate assembly of each C function If this switch is specified as a Ce parameter then it also should be specified as a C2 or C2186 parameter Default is SUBM CASE accepts keywords without regard to upper lower case This applies to preprocessor keywords as well as C keywords Useful with terminals tnat accept upper case only Note the include file CBRACK H has upper gase keywords for common C tokens such as and This is useful for keyboards without lower case Default is ai Ne aet SuperSoft C Compiler User s Mangal c 1983 Supersoft WBUFSIZ is foliowed immediately by a decimal integer This integer becomes the buffer size for output operations The larger this value the faster the compilation Smaller sizes use less memory A number of 128 is about the minimum for most systems If this option is used the selected value will be printed on the console Default is WBUFSI21924 M T D Ze An E Y at A vie D d 2 D L i hae Ede r HH N ch Di b Dag Ze Pes 0 24 l U SuperSoft C Compiler User s Manual c 1963 SuperSoft j CC MACHINE DEPENDENT COMMAND LINE OPTIONS I The three options below may be used to tailor CC for a particular tarzet processor CPu They are the only machine dependent options If the value set for any of these options is not apsropriate
53. OW i 7 x e EI UD J Ae Ca TET ve PR OE 12 U na EPEHA SuperSoft C Compiler User s Manual c 1983 SuperSoft SO 8 ABS int abs i int 1 abs returns the absolute value of i i if i is less than zero i otherwise This function is not available under MS DOS or CP M 86 because of an assembler keyword conflict See absval below VS BSVAL int absval i E int i i 3 i acSval returns the absolute value of i i if i is less than E l zero i otherwise See abs above i ew EH CCESS EL GE N S BOOL access filename mode FILESPEC filename unsigned mode access returns TRUE 1 if the file is accessible to the given mode FALSE 9 otherwise E i R d accrue las um hi is SuperSoft C Compiler User s Manual c 1983 SuperSoft 51 ALLOC char alloc n unsigned n alloc allocates a contiguous memory region of length n Every block it allocates starts on an even address malloc its identical twin NH SSERT ERA BOOL ASSERT b i BOOL b assert prints Assertion failed n on the console and if b is FALSE otherwise assert merely returns sia TOT ka S d int atoi s e char Ser atoi returns the decimal integer value corresponding Co null terminated ASCII string pointed to by s If String contains characters other than leading tabs bl and a minus sign all optional followed by consec decimal digits atoi returns see K amp R pp 39 see exits the
54. T unlink fspec FILES PE Eeoae Deletes the file specified in fspec from the file system unlink returns SUCCESS 0 if the file was successfully deleted unlink returns ERROR 1 and does not delate the file if l the file soecification given is invalid or 2 the file could not be deleted due to an error at thre operating system level see K amp R o 163 V NAIT i RESULT wait 21id e unsigned sid Blocks tne execution of the process uncii the comoietion cf the rocess with process if pid Returns z3223 l if as d such process id is waiting Always returns immediately witz an ERROR value v Sa 1 WRDBRK wribrk u unsigned n Returns pointer to a memory region of size u Since u is unsigned wrd5rk cannot give back any allocated D n It returns ERROR l1 if it cannot locate a free region of the proper size see sbrk evnbrk ubrk and brk ais described in this chapter SuperSofc C Com2iler User s Manal c 1983 Sugersoftcz 12 WRITE l int write fd buffer num 5ytss EILE fd TYPE oul ters int num_bytes Outputs the number of bytes specified in num bytes from the area pointed to by buffer Output is to a file opened for direct unbuffered output The file is specified by a file descriptor fd write returns the actual number of bytes written This may be less than num bytes If the fiie descriptor is invalid or the file cannot be written a value
55. TRUE isnumeric is defined only if 1 lt radix lt 36 VY E N S ISPRINT BOOL isprint c enar c m Returns TRUE 1 if c is a printable ASCII character otherwise it returns FALSE 40 MER ARR nb TT C EG d T Ka a HERH SuperSoft C Compiler User s Manual c 1983 SuperSoft 86 ISPUNCT 800L isgunct c char c Returns TRUE 1 if c is an ASCII character representing a TTT F rt aem FETTE OT Ren punctuation mark otherwise it returns FALSE cg E d L ene SSPACZ l f L BOOL isspace c i D char i t l i Returns TRUE 1 if c is an ASCII character representing a d space a tab or a newline otherwise it returns FALSE i This function is iocluded for comoatability with BDS C the standard UNIX C function is iswhite However see K amp R i D 156 i i H t RSE 7 N x Ka ISUPPER BOOL isupoer c char er 1 if c is an ASCII upper case alphabetical Returns TRUE returns FALSE 0 see KSR character otherwise it Ep 145 156 M m ON a MCS PA 2m Pe ia pn SuperSoft C Compiler User s Manual c 1983 SuperSoft a7 ISWHITE BOOL iswhite c char c Returns TRUE 1 if c is an ASCII character representing a Space a tab a newline or a formfeed otherwise i returns FALSE 4 BHIT LNK BOOL k5hit Tests whether a character has been typed on the console keyboard re
56. ULL 0 and does not create or open any file if I the file node is unrecognized 2 not enough user memory is available for new file descriptor 3 the fil specification given i invalid or 4 the file cannot 5e opened or created due to an error at the operating system level DI tw For mode you must specify one cf the following wii a or r Whichever you specify determines tne file s I O mode as indicated in the following table u write oniy mode a write only mode apoend output to end of file W a read only mode If a file s I O mode is either w or a it is said to D open for buffered output I a file s I O mode is r i is said to be open for buffered input t D The value you specify for buffer_size determines the size of the 1 9 buffer associated with the file This value is best set as a positive integral multiple of the system recors size A system record is the minimum unit of data transferred during file I O operations Under CP M the system record size is 128 bytes Under UNIX it is 512 bytes Consult your operating system s documentation for further information A pointer to the first byte in this I O buffer is stored in the file descriptor Thus only a pointer to this file descriptor need be passed to any of the other buffered file I O functions see K amp R po 151 167 7 K eE e E L i emm SuperSoft C Compiler User s Manual c 1983 SuperSoft FPRINTF Wi
57. a Unt 2 22 3980009 ae OT vc eme aas Rc ss H Seanad D l i Supersofe C Compiler Jser s Manual c 1933 Supersoft 63 ENOEXT char endext Returns a pointer to the byte immediately following the lass byte in your program s external data area This value should be identical to the initial value of CCEDATA Nae currently imolamented RNO int errno Not a function but an external variabi2 that will be sec ta an error code whenever an I O error occurs Note tnat it is not automatically cleared if no error occurs There is no zero error message so Clearing errno is the accectedl way t preset it for picking up error values erzror described later prints an error message on the consoles given a non zero error ek Reb SuperSoft C Compiler Jser s Manual c 1983 SuparSoft DOUBLE arithmetic The file DOUBLE C contains a double precision floating point aritmetic package These functions perform arithmetic on BCD numbers which are 8 bytes long Ail variables used by this oackage should be declared DOUBLE or LONG FLOAT The functions are passed tne address of each argument Usually the functions ceturn the destination address so that calis can be nested in the following manner d Badd amp d a mul amp a amp 5 ki amp e In this example J b c e See Appendix G for descriptions of these functions 62 es ee SuperSoft C Compiler Jserz s Mansal c 1383 SuperSof EVNBRK
58. a INCLUDE of STDIO H and many of the functions defined in STDIO C will return these values al l is bd E SuperSoft C Compiler User s Manual c 1983 Supersoft 49 bdos bios exit ccexit ecall ccalla comlen comline BUFFERED fciose fflush fgetc faets fopen fprintf Eoute fputs fdopen clearerr poutc cet22 fileno The SuperSoft C Built in Functions Grouped According to Use SYSTEM ACCESS inp outp inpl6 outpl Convert xmain lock nice freopen pcetc ferror put 22 STRING PROCESSING atoi index isprint isspace ispunct iswhite isalnum isalpha isascii iscntrl isdigit isupper islower isnumeric qsort Swab xrrrintf xrzscanf rindex sprintf sscanf strcat strcmp strcpy streg strien strncat strncmp strncpv substr tolower toupper CONTROL FLOW exec setjmp execl setexit longjmp sleep reset wait pause DIRECT FILE I O close rell creat seek cpen tell otell write read access chmod MEMORY INITIALIZATION init5 peek initw poke movmem getval setmem CONSOLE getchar gets k5hit scanf ugetchar GENERAL fabort unlink perror isfd mktemp NUMERI ads max rand ouble assert DYNAMIC MEMORY ALLOCATION alloc malloc calloc realloc brk sbrk ubrk wrdbrk evnbrk free xrev isheap topofmem 1 0 putchar putdec puts printf FILE rename link errno isatty C a gt svai min srand lonc qox Veto CR pe
59. al Since the Majority of the standard library functions are provided in SuperSoft C source code and the rest in assembly code you can discover the details of our implementation by examining that code l In presenting each of the functions below we have adopted a kind of shorthand for in icating the data types returned oy and passed as arguments tc each function The first few lines appearing before the description of each function are the first lines of its definition in SuperSoft C namely the declarations of the function itself and of its arguments The type of a function is the type of the valve it returns If the type of a function is not indicated then it does not return any defined value The type of each of its arguments will always be indicated The file STDIO H contains DEFINE statements establishing the following predefined symbolic return values the actual numeric values returned are shown in parentheses TRUE 1 FALSE 8 SUCCESS 8 ERROR l NOLL 8 The file STDIO H also contains DEFINE statements establishing the various data types that are used by library functions These include E T SuperSoft C Compiler User s Manual c 1983 SuperSoft 48 DATA TYPE DEFINITION EXPLANATION BOOL char l TRUE or FALSE RESULT int SUCCESS or FAILURE FILE struct filedesc file descriptor FILESPEC chap l filename STREAM FILE buffered file descriptor TYPE an arbitrary or varying type STDIO C contains
60. ammers from concerning themselves with the actual locations at which their prograss execute or fetch data It does this by generating obj code in which memory addresses appear as displacements fron some relative poiat These relative points can be either externally defined references or relative program origins An external reference uses a symbolic label referring to a location in another module For example an external reference in module A is a way to reference a location i3 module B without knowing the absolute address of thart location The relative program origin is the beginning of a particular 2 relativa to which all of its internal addresses are calculated Relative addresses are fixed wie the program is linked Assemblers will support some means of specifying the absolute or relative origin for your code In the case 27 CP M s absolute assembler ASM the ORG instruction accomplishes thi Funston The rgument of an ORS Statement is used by ASM as the origin for the code tnat it precedes up to tne next ORG statement or the end of the file The ORG instruction can also be used to establish different ralative and absolute origins for each progran segment or data area This capability is particularily important when you wish to load your program into ROM but your gata into RAM If a program you wisn to load into ROM requires writeaole data areas at least two ORG statements ust appear in your file one at the beginning of your program
61. anual c 1983 SuperSoft 170 double Bcheby res x coef n double res x coef nj BCDS int Returns in res the nth aporoximation of the function whose Chebyshev coefficients are in coef evaluated at x e se 1l t wee SuperSoft C Compiler User s Manual c 1983 SuperSoft LJ Apoendix H Long Integer Functions The following functions are available in the file celort a long a bs j Prints a in hexadecimal cclneq 2 long g 1 One operand negate d d ecilinc a long a One operand increment ta Tse ME c2ldec a long sa d One operand decrement e wm 3 eclcom a long sa E One operand complement LONG C ki f i Supersoft C cc2mov a 5 Two ecladd a b Two ce2com a 5 mee Ww Two cc2or a b Two cc2xor a b TwO SR MEN My e cc2emp a b5 Two Compiler long a t 4 N User s Manual c 1983 SuperSof long a YD operand copy a rb long a b operand addition ta Sa l ng a XD operand complement a Si i i long ay b4 operand logical or a 5 long a Sp operand xor a zz Sp b s E operand comparison Luft x Ee g if x ss ty l if otherwise Returns a a e o e SuperSoft C Compiler User s Manual c 1982 zuperzott 173 cc2mul pa pb l na za pb Two operand multiplication SEA R zD co2imul x 59 231 lon
62. ated by commas When called init converts each G decimal intejer value in the string beginning at s ina Sequence to a binary integer value and assigns that value E to the corresponding element in the integer array pointed t he by array RK If there are n integer values in the string and greater than n elements in the array only the first n elements of tha E array wiil be assigned values ma fe contents of tne remaining elements will be unaltered If ther2 are a E integer values in the string and less than n elements in the array bytes beyond the end of the array will be assigne x values as if they were eiements of the array and data may z overwritten in error It is the programmer s responsibili l to prevent or provide for these situations char inp port int port Returns the byte value present at the specified input port after execution of a byte IN machine instruction for that port This function is available only on machines for which the byte IN instruction or equivalent makes sense WI EC dab am 4 4 LH H E SuperSoft C Compiler User s Manual c 1383 Super Soft 33 ISASCII BOOL isascii c lt char c Returns TRUE 1 if c is an ASCII character otherwise it r returns FALSE Q0 l d i GATTY S E BOOL isatty i 5 FIDE fd E Returns TRUE l if tnis file descriptor is a terminal E otherwise FALSE 9 Returns TRUE 1f the file descriotor Ge refers to the co
63. both speed and space efficiency Not currently implementec is followed immediately by a character string which C2 C2186 under CP M 86 and MS DOS uses as a prefix for all the labeis it generates A prefix C is the default 2C Adi of ENDO ge N t he tates aspe gei A LITE H 1 H 4 L 4 D lt D E me M a D SuperSoft C Compiler User s Manual c 1983 SuperSoft 36 f THE COMPILER PREPROCESSOR DIRECTIVES All files input to the SuperSoft C Compiler pass through a preprocessor which scans them for lines beginning with Such lines which are not themselves compiled but instead direct the compilation process are known as compiler preprocessor directives These lines are terminated by newline characters rather than semicolons The preprocessor directives supported in SuperSoft C are z amp define endif Ze se inclu3e 61 Z E ifsef ifndef line unjef as c endasam Each of these directives is syntactically indeboendent of tne rest of the C syntax and may appear anywhere in a program The effects of all the directives extend to the end of a compilation Their effects ans uses are described in the paragraphs Gelow re E PPAR AER DL VARIUPRI LE 1 R 7 1958 LIP MER Super Soft C Compiler User s Manual c 1983 SuperSc t 37 THE DEF INE DIRECTIVE S If a line of the form 4 e define IDENTIFIER TOKENSTRING is found in source input it causes the prepr
64. c olock processing inval pseudo op type C2186 An invalid U code has been seen Either an invalid U code was read by C2186 or there is a memory proolem internal to C2186 Line too long CC source line is too long or a line becomes too long after bag pgreprocessinjg What the compiler sees is printed with the option Missing bracketing symbol e EC A bracketing symbol usually s oor Cy is missing The exact symbol is printed in the output file 1 e Missing C2 End of file was seen before the last was seen This is an insidious error as it can involve an extra or a missing that is other than the last J Check tne prooer closure of all previous compound Statements Nr Or Missing itt CC A s is missing while trying to parse the ternary if operator Missing Label CC A label was missing from a goto statement t ed LET Lati NR LSC Cp t SuperSoft C Compiler User s Manual c erSott t AL Ww lw ui c NZ Missing quote or apostropne CT A string is being read that bas no terminating quote or a character literal is being read that has no terminating apostrophe Missing CC A semicolon is expected at the end of a statement or declaration Missing while CC pe Missing while at end of a do statement Must be a constant Ce Expect
65. cluding assembly sanguage in a C sub expression which would cause problems Da ee x Ee Cni ke kk bi NI D A rs A UA SeN AA aas LB B CEP ewor en a Na w l w DI e om SuperSoft C Compiler User s Manual c 1983 Supersoft 42 a asm MVI H 9 endasm When calling C code from assembly language or from any other language it is best not to assume that any registers are preserved by the C coce although some registers are K preserved by some SuperSoft C code generators When calling K assembly language from C or when ralling through including assembly language lines be sure to preserve the register variable and the stack pointer Other primarily State registers may Nave to be preserved on various machines For instance the DS CS and SS registers must de preserved on the 8086 The following table summarizes the assignment of C registers Register 8082 280 8086 286 28842 28001 primary HL BX R4 RR secondary DE SI RS RR6 Stack pointer SP SP R15 RR14 reg variable LC Di R8 RR8 iE UNDEF DIRECTIVE This directive is of the former T E undef IDENTIFIER It forces the preprocessor to forget the named IDENTIFIER Alen TT R ad c Gu ae AA C1 1 CM A3 A MW T Ee SuperSoft C Compiler User s Manual c 1982 Supersofe 43 USING LIST FUNCTIONS SuperSoft C is able to handle functions without a EEN number of arguments This is done
66. conversion specification thera may appear 1 an optional minus sign which if present causes the converted value to be left adjusted in its field Right adjustment is the default 2 an optional string of decimal digits specifying the minimum number of characters in the field in which the value is to be written The converted value will never be truncated However if it has fewer characters than are here specified it will be padded on the left r right if left adjustment has been specified with spaces to the width specified If this digit string begins with a zero the converted value will be paddec with zeros instead of spaces H SuperSoft C Compiler User s Manual c 1983 Supersoft 93 3 another optional string of decimal digits which muse be preceded by a period specifying the maximum number of characters ES De copied fron a null terminated string 4 a character calied tne conversion character in dicating tne type of conversion to be performed Of the above only the conversion character must be present in a conversion specification All the others if present must be in the order they are listed The valid conversion characters and the types of conversions they specify are c the least significant byta of the argument is interpreted as a character That character is written only if it is printable d the argument which should be an integer is converted to decimal notation RN
67. d STREAM fd C n Returns the error value for the given stream The error value which is read from errno is set on error To clear it use clearerr described earlier Currently there is 3 only one error value D a H d Pi om SuperSoft C Compiler User s Manual c 1983 SuperSoft ab wes Tester L mene D I gt n FFLUSH De RESULT fflush fd STREAM fd Flushes or writes to file the current contents of tne I 9 buffer associated with a file opened for buffered output via fopen The file is specified by the pointer fd to its file descriptor The size of the I O buffer is set when the file is opened After a call to fflusn the file I O pointer will point to just past the last byte accessed as expected fflush returns SUCCESS 0 if the buffer was successfully written to file Calling fflush when the buffer is empty has no effect other than to return SUCCESS fflush returns ERROR 1 and does not flush the buffer if 1 the file was not opened for 5uffered output via Zanen 2 fd does not point to a valid file descriptor or 3 the entire contents of the buffer could not be written due to an error at the operating system level ses K amp R p 166 iat fgets fs STREAM fd Identical to getz described later Guaranteed t be a function rather than a greprocessor macro 69 mg gt mba mme fr we mr em FGETS FILEN wee D i DE ZE
68. d SUBMIT facility CC C DUM and C2 COM are the compiler executable files under CP M 890 A OC 0 d Anert non ung L REY Ei Ab te UEA IDT VES P EET EP TENTER Tee Poe vy Oe K BL H AH amm E aaa EE VE T 5 SuperSoft C Compiler User s Manual c 1983 SuperSof 3 ee UNDER THE CP M 36 OPERATING SYSTEM If you have the CP M 86 version of tne compiler you should find the following files on your working copy CC CMD first pass of tne compiler the parser COD2COD CMD second pass Code Optimizer C2186 CMD third pass Code Generator C2185 RH run time library header file used for ASM85 C2186 RT run time trailer file used for ASM86 C2PRE ASM run time header C2POST ASM run time trailer ASM various other run time sources MDEP C ASM ENDASM version of run time C SUB CP M SUBMIT file for compilation CBRACK H upper case defines for keyboards w o lower case CUSTOMIZ H C library compile time parameters STDIO H Standard 1 0 functions header STDIO C standard I O functions ALLOC S dynamic memory ailocation functions CRUNT2 C language parts of the run time i FUNC C auxiliary functions FORMATIO C printf scanf functions and so on LONG C long integer functions DOUBLE C double floating point functions SAMP C sample programs which test features of C CC CMD COO2COD CMD and C2185 CMD are the comoiler executable files under CP M 86 The second pass i
69. defined identifier has been redeclared This message will only appear if the new declaration is a different String than the old Registers have no address CC An attempt has been made to take the address amp operator of a register variable This error message will appear if and only if the register variable is a true register variable a or 99 SuperSoft C Compiler User s Manual c 1383 SuperSoft shli error C2 or COD2CO2 An invalid U code has been seen Either an invalid U code was read by C2186 or there is a memory pro5lem internal to C2186 String size exceeded i CC A string is larger than the compiler can handle The strinz may be unterminated Otherwise try using streat at run time l Too many amp s CC bech Attemot to take the address using the ei ecserator of an address Undefined struct CT The keyword struct has been followed by an identifier that has never been defined ons me D Unrecognized f CC A is followed by a directive that is not recognized Some valid directives ar if ifdef ifndef else endif include and define dos 7 j Variable or constant expected CC e l S H D U A variable or a constant was expected at this point in the program Most likely a badly farmed expression has deen used Sa ge em ee 1 HR 101 LT 8 814 Ir Sur BITE A ETT IIIT Supersoft C Compiler User s Manual c 1982 Supersoft Apoendix G
70. desired witn thre EXTERN storage class explicitly stated but must be deciared exactly once without the EXTERN storage class and outside of a function body A function must appear exactly once with function body and without the EXTERN Keyword fi i Of course variables must differ within the first fev characters to appear unique to an assembler or linker zi the case of M83 names are truncated at six or seve Characters depending upon the version In CP M 89 REL format names are limited to seven characters Also many assemblers inciuding M80 translate lower case characters in a name into upper case effectively towering the namoer of unique names For portability reasons at least zase should not be used to distingiisn variable or Eun Ken Ui TA C T KH y Wi mut LY 6n AP bi ATI a a aneor m aa re vm a 0 2 SuperSoft C Compiler User s Manual 2 1983 SuperSofr 126 names For example a program should not contain THeiog and TheLP as unique variable names IT IS HIGHLY RECOMMENDED THAT SUPERSOFT C BE USED WITH A RELOCATING ASSEMBLER rather than an absolute assemdier such as ASM or ASM86 Reiocation availadi2a to users with a relocating assemoler package such as Digital Research s RMAL package is by far the easiest and most usable method of incorporating both user and library functions into a final executa2le COM CMD or EXE file Linking is usually faster than compilation
71. e SuperSoft C Compiler User s Manual c 1983 SuperSoft 133 were U 5 Now you must edit the C2 RH file Your screen should show A gt ED C2 RH S BA F insert any user Z2Q0lt insert any user code here rcrunt2 lib l 3 te e e This will cause the editor to read in the CRUNT2 LI3 d file After exiting the editor with the E command all of the functions contained in CRUNT2 C will have been moved into the system runtime file C2 RH This means that you will nc longer have to use the INCLUDE CaUNT2 C directive However since you will always be loading these functions even if they are not needed tner2 may De a need for a different C2 RH for different programs 4 SuperSoft C Compiler User s Manual c 1983 Super 52 You are again faced with the choic of how to in corporate the files you have created into your program You may use any one of the methods previously described for incorporating the SuperSoft C standard library function files Your programs will now contain only the data and function definitions they require Another option is to use your editor to insert the definitions you have created into your program art appropriate places H E E E E E E E E E E E b d sl S i i a d SuperSoft C Compiler User s Manual c 1982 Supersoft r HOW TO REORIGIN THE CODE GENERATED BY THE COMPILER A relocating assembler frees progr
72. e commands listed below in sequence This procedure also produces REL modules and links them together as in the M80 and L8 example above Below is the procedure LEM CC SAMP1 C C2 SAMP1 COD OFILESAMP1 Mac RMAC SAMPI LINK SAMPl C2PRE LISC S C2POST SAMPI C2POST musz be specified as shown last module Alternatively the LINKS line can be replaced by using SuperSoft s ELINK i ELINK BC SAMP1 C2PRE SAMPi SR LISC IN C2POST EN C2POST must be specified last Each of the above commands Causes a new file to be created on the currently loggec in disk These are output from CC output from C2 output from RMAC SAMP1 COD SAMPlI MAC SAMPI REL mag an T4 We SAMP1 COM output from LINKS or ELINK Using the above procedure will require the availability of the following files in RMAC REL format C2PRE REL from run time library C2PRE ASM C2POST REL run time trailer from C2POST ASM LIBC REL the C library i LIBC REL is a library created from the recompilation of the following sources ALLOC C STDIO C CRUNT2 C FUNC C anc FORMATIO C de Sn fk RS Sai L k Lt aT ales 2 vr d TN ries Ri Maly t ae e s pap e o sa oe e SuperSot C Compiler User s Manual c 1983 SuperSoft 26 78 COMPILATION USING AS A RELOCATING ASSEMBLER f To transform SAMP1 C into an executable command file so that it can be used under UNIX you sho
73. e the oresence non zero or absence zero vid a particular error condition reset and set2sxit while they resembdi functions in usaje and syntax are imslemented as Gompller Oreprocessear directives rather than as functions Thus you will net find them in any of the standard library function files INDEX e char rindex s c char S Ci m Returns a pointer to the last occurrence of the character in the string beginning at s rindex returns a null pointer value 80 if c does not occur in the string See index described earlier in this chapter n N I Ca d N D H st L MIT VVT A2 D bry D SEN Ia g oh RS LO AC S att i nf Caer Super Bot C Compl wer User s Manual c 1983 Supersofe 126 RTELL unsigned int rtell fi FILE fc Returns the offset in 512 byte blocks from the beginning of a file of the 5l2 byte file block within which the next file I O operation on that file will begin rtell does nor indicate the offset into that block at which tne I1 9 operation will begin The file is specified by the pointer fd to its file descriptor See otell and tell Nc BRK 1 char sbrk n int n Adds n bytes t5 user memory increments CTESATA by n sbrk if successful returns a pointer to the first byta n the block added sbrk returns a value of ERROR 1 anc adds no bytes t user memory if a block of the s
74. ealloc returas 3 pointer to the new size region Ve SAME i RESULT rename fname fspec l FILESPEC fname FILESPEC fspec Renames the file specified in fspec giving it the nane contained in the null terminated string pointed to by fname A string constant such as newnane is also valid zor fname since it evaluates to a pointer to a null terminated string The drive nans and tae number if any are unchanged Ri N 0 2 Ca Ut La SuperSoft C Compiler User s Manual c 1983 SuperSof reset n int n Causes program execution to return to the point set by prior call to setexit This transfer has the appearance o a return from setexit The parameter n passed t rese appears as the value returned by setexit j th D caset and setexit together allow simpler and cleaner coding of repeated exits to a common Benq eee eee wnen such transfers require unraveling a number of levels of function calls For example in writing an interactive editor you could call setaxit at the top of the command Loop and tast whether or not its apparent return value was equal to zero 8 Each non zero valas could be used t indicate a different error condition The error number couid be printed and command loop execution could continue Calls to reset wolla be sorinkled in appropriata places throughost tne loop In each instance the parameter passei to raset wojld indicat
75. earaea should 5e 6 bytes long on botn tne 8080 and 8086 series The orogram stat2 includes aill register variables thea retuarzn program counter and the Stack pointer Upon a call to 1ongjm see earlier description with the same savearea the state is restored effectively appearing as if a return rom satjm gt has occurred with the return value being supplied by tlongjmp setjmp is a generalized version of setexit c 1933 SuserSoft 112 Supersoft C Comailer Jser s Manual SETMEM ui x SLEEP setmem p n Di TYPE p unsijned n char b Sets the n contiguous bytes beginning at p to the val specified in b You can use setmem to initialize a variety of buffers and arrays slseo n unsigned n maa tentas of a second on a Z3d cas tail r this function to a rat2 by changing the vaiue of one function s code Suspends execution for n running ac 4 Mhz You differents CPU and or clock or two constants located in Cha aT pe t SuperSoft C Compiler Jser s Manual z 1983 SuperSo ttc il SPRINTFE Sprintt s formas argl ar32 char Se format TYPE argl TYPE ar32 Identical to printf except that it writes its formatted output into the string beginning at s Contrast this with printf which writes its output to the standard output an forintf which writes its output to a file sprintf appen a null character to the formatted output string see Ks D l590 sprin
76. ee e ee ee e 6 e How to Reorigin the Code Generated by the Compiler APPENDIX A The Differences between SuperSoft C and Standard C APPENDIX B Currently Available Machine and Operating System Configurations of the Supersoft C Compiler Tenn APPENDIX C Some Common Problems and Solutions A APPENDIX D i Locations of Supplied Functions and Externals APPENDIX E Using Overlays under CP M 893 APPENDIX F Error Messages APPENDIX G a 9 e pe 9 ee ee e 929 e e e e 6 e e e e 49 ee ee ae ee ee e eee D EI Double Floating Point Functions 42 e APPENDIX H Long Integer Functions See e ee ee e ee ee e ee ee ee ee e e geeeee eege e SC i 45 47 49 ER H EA Ut err 121 134 136 138 RN 171 a t A C To d Lo c TO U ri Li O th 1 SuperSofc C Compiler User s Manual z 13 CHAPTER 1 I Introduction i The SuperSoft C Compiler is a seif compiling optimizinz compiler generating a final output file in assembly source code It accepts essentially the full C language with the few exceptions detailed in Appendix A of this manual Under CP M the compiler requires two passes under CP M 86 and MS DOS the optimization and code generation are split into individual phases effectiveiy making it a three oass compiler SuperSoft C is adastable for a variety o Operating systems and central
77. er C2 RTM run time trailer for RMAC and M86 C2PRE ASM run time header for L83 C2POST ASM run time trailer for L86 MDEP C gt ASM ENDASM version of run time a CUSTOMIZ H header for the C library A CSRACK H header for keyboards w o lowercase STOIO H header for STDIO C STDIO C standard UNIX style I O functions ALLOC C Cynamic memory allocation functions 3 CRUNT2 C auxiliary common run time functions LONG C long integer functions DOUBLE C doudle floating point functions BC280 C assembly language support for DOUBLE C FUNC C auxiliary functions FORMATIO C printf scanf et al UNDER CP M 86 K C2186 RH run time library header C2186 RT run time library trailer MDEP C gt ASM ENDASM version of run time 2 CUSTOMIZ H header for the C library Fi CBRACK H header for keyboards w o lowercase STDIO H header for STOIO C Zz STOIO C Standard UNIX style I O functions a ALLOC C dynamic memory allocation functions CRUNT2 C auxiliary common run time functions LONG C long integer functions DOCBLE C double floating point functions FUNC C auxiliary functions FORMATIO C printf scanf et al iu SuperSoft C Compiler User s Manual c 1933 SuperSoft UNDER MS 208 AND PC DOS C2PRE ASM run time header for LINK C2POST ASM run time trailer for LINK C2186 873 run time header file for MASM C2186 8TM run time trailer file for MASM MDEP C gt ASM ENDASM vers
78. er Ee awi a E inet bjos z 39 char c int Aer return z ailia 5 3 6 c de The C function listed above is clearly an impienmentanio1 of the function BOOS in terms of ccalla This is at the a BDOS is implemented Both ccail ani ccalia may aiso 32 asad to invoke assendly language subroutines of your 24n creation SF 6 U da e na ne ee SuperSoft C Compiler User s Manual 2 19 0 kel Lo C 3 a Ue uw at cn rr we Ju KE LE ccexit i int i Returns to the operatinj system i is the return code i should be if the program is 25aDieted successfully i should be between I and 255 otierwise These values can be arbitrarily assijned to error codes ccexit does not close any open files HM22 i SUCCESS chmod mode unsigned mode Sets the filemode TF tnd 0x87 bit is set sets R O mo e under CP M and C2 M 86 clearerr d STREAM fd Sets the file error state to be clear Currently there is just one global error state variable errno desctribdes later CLOSE IJEN IW Ci ui Xi Ui Supetsofrt EE CS RESULT close Edi FILE fd Closes tha file specified by the pointer fd to its fils descriptor close cetaurns SUCCESS 3 if the file specifie was successfully closed close returns ERROR 1 and doves not close the fiie if 1 4 does not poiat t a 7ali3 the File could not be closed dus to System level file 3Jesctibo oc or 2 an error a
79. es It would save considerable time if you could cause this entire procedure to be carried out by means of a single command Under MS DOS the BATCH command and BATCH files provide the means of accomplishing this An appropriate BATC file with filename C BAT would contain the following command lines CC 41 COD2COD 1 COD C2186 1 0 ASM 5505 MASM 3 1 ASM LINK C2PRE t 1 C2POST 11 NUL LISC 1 where tl is a symbolic parameter to be repiace later by the first actuai parameter of a BATCH command j th after you have created such a ile on your disk type C SAMPI Then hit RZT7URN For further information about BATCH files consult the documentation or one of the several MS DOS manua available 1 1 L en re E A 22 a l 7 SPS SuperSoft C Compiler User s Manual c 1983 SuperSoft 23 COMPILATION USING M80 A RELOCATING ASSEMBLER I To transform SAMP1 C into an executable command file so that it can be used under CP M 80 you should type each of the commands listed below in sequence This procedure is the same as those described above with the exception that relocatable modules are produced and modules are linked together Type CC SAMP1 C C2 SAMP1 COD HBD SAMP1 ASM L80 C2PRE SAMPl LIBC S C2POST SAMPl1 N E XY SAMP1 4 C2POST must be specified as shown last module Alternatively the L amp 2 line can be replaced by using SuperSof
80. ever it may 5e essential in some applications that your programs max2 the most efficient ossible use of the available memory The size of some programs alone mav approach or exceed the memory capacity of your syscem while others may require correspondingly large amounts of data storage during execution H p ind yourself repeatedly using a p ssoset of the standard library functions mingled wi functions of your own In this situation vou co this method as a first step toward creating y customized sec of SuperSoft C standard library funct You may also fin i You should not attempt to use this method unless you are quite familiar with C and with your own operating systen wnat follows is only a very general outline of the steps de necessary t5 the cut and paste metnod l Make a copy on disk of each file containing data Gr function definitions that you wish to incorporate into your program 2 Using your editor delete from each file those data and function definitions you do not wish to incorporate into your program Be careful not to delete the definitions of those functions called by tha functions your program calls or any of tne data definitions required by any function that you intend to incorporate 3 If you now have more than one file containing the definitions of interest you may leave them as separate files or concatenate them as you choose E ES ween ew zc o LE EA ett ale u
81. for your processor the compiler will not function properly In what follows jflag int size and pad size all refer to the names of variables within the compiler J sets jflag equal to one l Whenever a single byte representing a char is passed as a local perameser t2 a function it is widened to an int A setting of ones 1 for jfia3 causes such a byte to be stored in the rightmost 5yte of its assigned storage location This is the proper setting for the 28000 The default condition is to set flag equal to zero 8 which Causes tne same byte representing a char to be stores in the leftmost byte of its assigned storage location This is tne proper setting for the 3833 series CPUs 1 is followed immediately by an integer specifying the size of an int int_size in bytes Default is two bytes P is followes immediately by an integer spe cifying the approoriate mocuius pac size tor all integer addresses Since each integer address will De a multiple cf the value of pac size each integer ad3ress moduio the value of pad size will be equal to zero 2 Default is a mo3ulus of one 1l Tne values for the three above options required to tailor this compiler for a particular target processor may De set in one operation through use of one of the composite flazs defined below 18080 sets jfiag 0 int size 2 pad size l Target processors are the Intel 84282 8085 8086 8088 186 188 and 286 Z8G sets the same val
82. g Supersoft C Compiler Table Of Contents CHAPTER 1 s EREECHEN aN KN ModudlabltW EE Intermediate Output J c3de auod RR RRR RR M RTE oe N N R eee Ping Outpuc AssomoO v Cogs A444 RRR os ewe EO CE WC R ee R Execution Time vs Compilation Time ee VR dcn WU mecomnend d Reading dines o9 aee LACER rue AES Bo ACER aes Organization eor This MADBal s242 eig 9 y dom do RR s fae Un P wd NN I7 CHAPTER 2 Using tie Sipes Sats Como ber Lubeke E ib ees Gere Gu V ERREUR TODISS E hoe E6389 orks EE ee ee ew a Piles Supplied 2545332523423 3 B ee Cae heb ee eee we ees Under P M 8U 25 4 ee va EE Under GPZMeBB usc pere oe b RR VC wes EE Under MS DOS Ane PC DOS 229 LX VU arene dS ECRIRE MORE Under ZMOS i 49 909 we Ae ep oe elds HS See cR RAO es Files Needed Ttor Comat Atl 4 06 EC A ACE S CEU EC EC Command Formats and Sedguences esseesssssesososoesoooso Compilation USIAS ASM da aw RR ach Porc RR Ee Comorlatri ou Using MAJ e wb Vx Rue I Rea 4087 4 eects rege a Comollation Using ASBB sesers EX EEN oim S se Comoilatioon USl329 MASM wu AU EG IO WE E Roes4 A ACE AE ot Compilation Using M89 xus 1 CX WM Een E RUE wee 29 Compilation USi0g RMAS 44k eis SW ee CA SOR oec wo een 925 cComoillation USING AS ws neu ee Ee E S s Comsilatlon Using RASM 22 059 EPOCS Wer vk M Rep Re e Comnans Line lt OOE LORS e 65 650 SEER AGEN UAE RUN ECRIRE RUE RUNE NOE 3 78 CC Machine Independent Command Line Options
83. gister In addition calls 27 and 31 set the giosal variable ESS to the value returned in register ES call 52 returns a word identical to the contents of the ES register and also sets the global variable BXX to the value returned in BX and call 9 returns a word identical to the contents of the AX 94 tejister For information about call 50 see BIOS which is descrioed later Under MS DOS bdos loads machine register AH with fn anc machine register DX with parm then performs an INT 0x21 instruction It returns as an integer a single byte identical to the contents of the AL register except under BDOS function call 6 when it returns AL plus 0x480 if the zero flag was set Other exceptions under MS DOS function calls 12 and 31 through 40 will return invalid results calls 24 and 28 through 32 are not defined under this system A summary of BOOS exceptions under CP M CP M 86 and MS 20S follows eo oo oam mA v vse pa to 49 rr Pe veee ra vne n s on WER mm E Con DEEN on i La W uc CTET hs n do 7 SuperSoft C Compiler User s Manual c 1983 SuperSoft 53 CP M B860 All return A except BDOS Function Call Returns K 12 Return Version Number HL 24 Return Login Vector HL 27 Get Addr A1102 HL 29 Set R O Vector HL 31 Get Addr Disk Parms HL CP M 86 All return AL except i BOS Function Call Returns Sets 12 Return Version Number 3X i S 24 Return Login Vecto
84. h that it c contain tne longest input line you could ressonaniy expect ib em SuperSoft C Compiler User s Manual c 1983 Supersoft int getw f3 STREAM d Returns one integer in sequence from a file opened for buffered input via fopen The file is specified by the pointer fd to its file descriptor Carriage returns and linefeeds are returned explicitly getw returns ERROR 1 if 1 the file was not opened for buffered input or 2 the end of the file has been reached or 3 if the intecer equal to ERROR l appears in the input file Thus errno should be checked for trua error conditions Calls to geste may be intersoersed with calls to getw Information read by getc and getw may be written by putc and putw There need not 5e any particular alignment of information in tne input file 23 int get2b f3 Returns a two byte quantity from a buf ered input stream EX get2b is similar to derw and fread except that it is invariant with respect to byte ordering i SuperSoft C Compiler Jset s Manual z 1933 SugerSoft 33 INDEX char index s c char S C St occurrence of the character c index returns a null pointer E in the string See rindsx E k Returns a pointer to the in the string beginning a value 8 if c does not o described later in this c OQ ct rn 2 Q A D NITB init2 array s char array s Permits relatively convenient initialization of character arrays It snou
85. hat is its entire contents are written to the file The file is specified by the pointer fd to its file descriptor putw returns ERROR 1 and does not write the integer if 1 d does not point to a valid file descriptor 2 the file was not opened Car Suffered output via fcpen or 3 wo the buffer could not be written due to an error at the operating system level Otherwise putw writes the integer to the file s I O buffer and returns SUCCESS 9 However due t3 the buffering of file I O operations such a Catia value does not guarantee that that same integer will be successfully written to tne file since errors resultins from and affecting the outcome 52 a particular call to putw may not become apparent until some later function call causes that file s I O buffer to be flushed Calis to putc and putw may be interspersed Files written with putc and putw may ba read using gets and gjetw wy UT28 f int put2b 1 4 int i STREAM fd Outputs d two byte quantity to a buffered output stream put25 is similar to putw and fwrite except that it 15 invariant with respect to byte ordering H T1 Gat T Pr L WU K A HEINS KE s d Ks uhh s R CK D nfe g hy T a LA Six dc 0 Ate FR ed a La fe NZ i z 4 4 l exe l SuperSoft C Compiler Jser s Manual t2 1983 Supersof 102 QSORT Wi ND int qsort tol nrecs reclen emp char t51 l unsigned nregs
86. hat will create the standard SuperSoft C library This is not an ordinary SUBMIT file but requires recursive capability The SuperSoft program SH COM supplied with the C compiier under CP M 82 will allow recursion and must be used wita LIBC SUB SH is similar to but more powerful than SUBMIT SUBMIT allows nine arguments 1 through S9 SH allows an indefinite number of arguments 3 contains the name of the SUBMIT file and 1 2 3 9 S10 Sll contain TITR 78 1519 PIE ge ECL PPS mg TTS mmn STE T R S HE7 E TT TC CM NV C Dx ue NECS SuperSoft C Compiler User s Manual c 1983 Supersofs l the arguments As a cesult S11 woald be interpreter differently by SH and SUSMIT SH interprets it as tne eleventh argument and SUBMIT interorets it as the first argument followed by a 1 An SH file may contain other lines invoking SH Each time SH is invoked it stacks the old 53 SUB file by renaming it as Snn SUB where nn is replaced by a unique decimal number Then it places at the end of the SUBMIT file a line of the form SH E S nn SUB which unstacks the old Saz Sg file 2y erasing S S SUB and renaming nn SUB to be S SS SUB Additional features of SH 1 the SHIFT operator shifts the argument list down by one 1 becomes 90 2 becomes 1 and so on 2 SH Strips comments lines preceded Dy from the SSS SUSB file to allow larger SSS SUB files Ca work S in a SUB file expands to be the argumen
87. he input string t this Soine This is an escape Sequence no assignment is performed c the input value is interpreted as a character The corresponding argument should be a character pointer The normal skip over space cnaracters is suppresseai To read the next non space character use ils I a field width is aiso specified the corres0ondisy rgument should be a pointer to an array of characters and tne specified number of characters will be reac S the input value is interpreted as a character st The corresponding argument should be a pointer to array of characters large enough to hoid the string addition to a terminal null cnaracter added by sc The inout field is terminated either by a space o newline or when the maximum number of characters has been read whichever comes first the input value is interpreted as a character string The corresponding argument should 5e a pointer to a character array large enough to hold the string plus a terminal null character added by scanf Where the input field is terminated is determined as follows The left bracket above is followed by a set of characters and a right bracket If tne first character in that set is not a circumflex the input Ciel is terminated by the first character not in the sect within the brackets If the first character is a circumflex the input field is terminated by the first Character in the set within the brackets the excluded d the
88. i Bsub dest argl arg2 double dest argl ar32 Three operand subtraction A dest argl arg32 i dou sle L Bdiv dest argl argjg2 douse F dest argl rz2 Thr2e operand division dest s argl ar32 double Y Bmul dest aral ar32 double dest argl arg2 Three operand multiplication N w S double Bnodulo dest argl arg2 double dest argl arg2 Three operand modulus rdest f argl arg2 Bmodulo assumes arg2 is positive L PE ER PUPE GR LANZ Aal ERE QUUM lalala A9 A A N SARR RTTA S no m cen rur vrare or LFS TELE T RY PAR ROC UE O PIER NETER PTS rT Rene eR PTET patna IC HP aa A SuperSoft C Compiler User s Manual c 1983 Supersoft double axta2fy dest arzl ar22 double dest argl arg2 Three operand exponentiation arg2 dest argl 163 NEUSS Lidl o IT 1 una LE LE E hp N yo WEE edidi URP URANA NI a LL ee A N Super Soft C Compiier User s Manual c 1323 SuperSoft 164 Group 2 douple s28cd ddest strsource double ddest char strsource string to doubla ddest is the address of a double variable in which is placed the value of number in the string strsource char Bcd2s strdest dsource char strdest double dsource Gouble to string This function is the inverse of s2bcd where Strdest must ba long enough to fit the representation of the given dsource number The maximum size for a double number is rrently
89. ined Array Or pointer being lengthened CC This declaration increases the stated size of the array being referenced In the case of a pointer this means that the object that it points to will appear bigger than before causing any pointer arithmetic to multiply or divide by the new size This is not always in error as it is common to declare externs with arbitrary size extern char arr and then elsewhere declare a specific size v char arr 99 LAE RA AAR ZA 26 12 4E 2 EI 12821 18 9 1 Rimm RE OF RES LIB 1 STUER PT NR w Bad Bad Bad di i 3ac Bad Can Can SuperSoft C Compiler User s Manual c 1983 Supersoft 15 break l CC A oreak was encountered outside of all loops for while do or Switch register op C2 or COD2COD U code error A register is used on an opcode that does mt have a register mode register struct or union CC A register variable may be a struct or a union but its size currently must be no larger than an int resister type CC Too complex a declaration is being applied to a register For instance register int arrz 99 is not possible usage CC This usage of a variable is inconsistent with ifs declaration t open include file CC A tinclude preprocessor directive has been encountered but the specified file does not exist t subscript CC Attempt to subscript any expression including a variable that is not az ar
90. ing a constant in an array declaration Currently Sizeof is not allowed in array declarations Paranthesized expressions are not currently allowed Variables never wili Z be allowed Must be lvalue CC A valid left hand side is expected at tris point A left hand side must have an address and must be abie t Do 2 a variable value Note that an array name may not De X assigned to and thus is not a good left hand side V z i CN e Nonsensical pointer operation CC The pointer operation you are performing would not normaily be considered valid or sensible but it will be performea anyway No symbol table room l CC The compiler s heap is filled up or has been overwritten Add more memory to your system or decrease the number of declarations in this compile for instance by splitting the f E Not Not Not Not Supersoft C Compiler User s Manual c 1983 Supersoft 15 program into more files each separately compiled Also see the bufsiz option for decreasing the compiler s I O buffer sizes a label CT Attempt to perform a goto to something that is not a label an array or pointer _ CC Attemot to subscript a variabla that is not an array or pointer a pointer or array l CC An attempt to use the indirection operator on something other than a pointer ar array a pointer to a function CC A call to a function is being attemoted but the called
91. ing the compiler s I O puffer sizes D mi aor si in 2 rt N w ui nternal error extra free Co An expression left a sub exo2ression dangling Should nev happen Perhaos means that the compiler s heap has be Overwritten Add more memory to your system or decrease th number of declarations in this compile for instance 95 splitting the program into more files each separately compiled Also see the bufsiz option for decreasing the compiler s I O buffer sizes tr aD De Won internal error missing free CC An expression contained a spurious sub expression Shouig never happen Perhaps means that the compiler s heao nes been overwritten Add more memory to your system Or decrease the number of declarations in this compile for instance by splitting the program into more files eacn separately compiled Also see the bufsiz option for decreasing the compiler s I O buffer sizes C2 or COD2COD An attempt was made to delete a U code from an invalid location in the internal memory of the ootimizer This should never hapoen May mean a memory overrun has happened Reduce the size of the largest function or use the o option Also see the bufsiz option for decreasing the compiler s I O buffer sizes a Ss nn a PP bh Ka Ut VI SuperSoft C Compiler User s Manual c 1983 Supersoft Internal warning basic block C2 or COD2COD Ignore this warning indicates a minor inconsistency in the optimizer basi
92. input value is interpreted as a decimal int2yer and is converted to a binary integer The corresponding argument should be an integer pointer dae 2 d wa A PAL D a C2 Supersoft T Compiler Jser s Mansal c 1983 Supers5f 9 o the input value is interoreted as an octal integer and converted to a binary integer The corresponding argument should be an intejer pointer x the input value is interpreted as a hexadecimal integer and is converted t5 a binary integer The Corresponding argument should be an integer pointer The central task of scanf is to determine the boundaries of the input fields in its input string which contain the insut values to be converted and assigned To find these substrings scanf scans the characters in its input string comparing each of them with the corresponding characters in the string pointed to by LEAR If a character in ths inout string matches the corresoonding character in the format string it is distarded and tne next character in tas input string is read I the corresponding characters do not maton scanf returns immeciately Nore that any amount of whitespace in the input string matches any amount of whitespace in the format string whitesoace in the format string is ootional it is ignorej while in the input String it can delimit input fields Thus c orressondiaa characters are not simply those characters that are the same numoer of bytes from the beginni
93. ion for decreasing the compiler s I O buffer sizes Optout empty C2 or OUD20235 Sut ka A a Es na 3 5 Attempt to emit a Yecoda from the internal memory of t optimizer but none was found This should never happen a even if it does it should Have no effect on the correctne of the code that is generated of heap CC This usually means that the compiler s heap is out of room Or has been overwritten Add more memory to your system r decrease the number of declarations in this compile for instance by splitting the program into more files eacn separately compiled Also see the bufsiz option for decreasing the compiler s I O buffer sizes ut a SuperSoft C Compiler User s Manual c 1983 SuperSoft 159 Psu err t4 C2186 An invalid U code has been seen Either an invalid U code was read by C2186 or there is a memory problem internal to C2186 psu err t5 C2136 D An invalid U code has been seen Either an invalid U cods was read by C2186 or there is a memory problem internal to C2186 edeclaration of a label CC x A label has 5een declared more than once inside of a singis_ function Labels are declared just by following them by E ae You probably snouldn amp be using labels anyway H Redeclaration of struct type CC A struct type has been declared more than once Stouce x t struct x L ine i char j In the above x has been redezciared SE N Redefined CC A
94. ion of run time E CUSTOMIZ H header for the C library CBRACK H header for keyboards w o lowercase STOIO H header for STOIO C STDIO C Standard UNIX style I O functions ALDLOC C dynamic memory allocation functions CRUNT2 C7C auxiliary common run time functions LONG T long integer functions DOUBLE C dousle floxt135 point functions FUNC C gt auxiliary functions FORMATIO C printf scant et al y During its second pass or third pass in the case CP M 86 and MS DOS the compiler automatically incorporates certain precompiled oreootimized assembly code into your program This code is contained in the compiler s run time library files The other files contain the definitions of the remaining standarg library functions in SuoerSoft lt T source code There are various methods for combining your programs with the library functions These are described in Chapter 4 UJ cnn RG R LT Ae iea BSE hrar ddu i ks Aaa ked e SuperSoft C Compiler User s Manual c 1983 SuperSoft DESCRIPTIONS OF THE SUPERSOFT C STANDARD LIBRARY FUNCTIONS The rest of this chapter will consist of descriptions of each of the SuperSoft C standard library functions in alphabetical order The pages in The C Programming Language by Kernighan and Ritchie referred to under most of the functions do not provide details on our particular implementation of that function but are instead given as a guide to using such a function in gener
95. ize specified would l overlap a stored program 2 overlap the run time stack or 3 exceed the availabie mamorr gt ey IMPORTANT Do not cail sbrk with a negative argument between calls to alloc see K amp R p 23175 p ry Ten ue ve es gei R Ed Cw SuperSofc C Compiier User s Manual 1383 SuperSofr RESULT scanf format argl arg2 char format TYPE farjlj TYPE arg2 v e Reads a formatted input string from the standard input the CP M or MS DOS CON device usually the console keyboard Under control of the format string pointed to by its first argument format scanf extracts a series of substrings known as input fields from its input string converts the values represented in each of these fields known as inaut values and assigns these converted values in sequence 2 the objects pointed to by its remaining arguments argi ar32 aee scanf is a list function See USING LIST FUNCTIONS at the end of Chapter 2 d As its first argument scanf must be passed a pointer format to an appropriate null terminated format string A String constant is also valid for format since it evaiuacss to a pointer to a null terminated string A series of other arguments arjl arg2 may be passed to scanf all of wnich must be pointers The individual osjerts pointed ts by argl arg2 may be either characters character arrays Or integers The format string may contain ei
96. ld be passei two parameters the first array should be a pointer to an array of characters tne second s should De a pointer to a null terminated string of ASCII characters representing decimal intejer valses Seoarated by commas when called init5 converts gaz decimal integer value in tne string beginning at s ina sequence to a binary integer valiye and assigns tha least Significant 8 bits of that valye t the corresponding element in the character array pointed to by array If taere are n integer values in the string and greater than n elements in the array only the first n elements of the array will be assigned values and the contents of tne remaining 2lements will be unaltered If there are a integer values in the string and less than n elements in tne array bytes beyond the end of the array will be assigned values as if they were elamancts of tne array and data may De Overwritten in error It is the programmer s responsibility to prevent or provide for these situations WC ee C1 ka KAL L epa Supersoft C compiler User s Manual c 1933 SugerSoft 81 INITW initw array s int array char s l E Permits relatively conveniant initialization of integer arrays It should be passed two parameters the first EK array shouid be a pointer to an array of integers th E second s should 5e a pointer to a null terminated string ES of ASCII characters representing decimai integer values E separ
97. les from UNIX ANSI to CP M format l bu e S p Py 79 19 YT ee eS FEE U l SuperSofc C Compiler User s Manual 2 19383 Supersoft PRINT 77 r orintt format dr3l 8T92 54 char fformat TYPE ar3l TYPE arg2 Writes a formatted output string to the standard output the CP M or MS DOS CON de ice usualiy your console screen printf mus de passed the pointer format Es a null terminated string A string constant is also valida for format since it evaluates to a null terminated string This string controls the generation of the output string printf may be passed a series of otner arguments arsi arg2 The individual arguments in this series may be 3 S UY characters integers unsigned integers or string pointers Oniy the first argument format is required ali others are optional printf is a list function See USING LIST FUNCTIONS at the end of Chapter 2 The string pointed to by format nay contain either ordinary chacacters 3r special substrings beginnings wita the character that are called conversion specifications Each ordinary character when encountered by print as Le scans the string from right to left is simply written t2 the standard output Each conversion specification whan encountered causes the value of the next argument in tae series argl arg2 to be converted and formatted as Specified and written to the standard output Following the character in eacn
98. lid file descriptor CLOSE RESULT close rdi STREAM fd Closes a file opened for buffered output via fopen The file is specified by the pointer fd to its file descriptor fclose piaces an end of Lee dco character at the current before position in the file s I O buffer and calls fflus closing the file i zlose returns SUCCESS 8 if the file specified was successfully closed fclose returns ERROR 1 and does not close the file if l the file specified was not opened for buffered output via fopen 2 fd does not point to a valid file descriptor or 3 the file could not be closed due to an error at the operating system level see K amp R poe 151 er I c e PES H DP Rowe TRAM dA 19 e L AA wee ead wv du Ses t L M Ma N Mak den Bai d P U 4d TM SuperSoft C Compiler User s Manual c 1983 SuperSoft 68 SONG e FDOOPEN STREAM fdopen fd mode buffer size FILE f2 amp char mods C unsigned buffer size Converts from an unbuffered file descriptor FILE to a L STREAM butfered file descriptor mode must be compatible E with the read write attributes of fd buffer size is the size of the buffer to De used by the STREAM descriptor Note that if can be used CO change the size of a STREA descriptor if used in conjunction with fileno as in bu a strm f dopen fileno stsa mode buffer size Returns NULL if unsuccessful i RROR Lint f rror
99. many filenames in the command line as you desire separated by spaces The files specified need not contain complete functions since trey will all be parsed in the order listei as if they wera one file The U code output file will be assigned the First filename given You may specify only one filename wren executing the other passes Each pass emits a file wita tne Same name you specified but with a different extension By convention C source code files have the extension or suffix C although any extension is lezal ce automatically provides the extension COD for its U code output files The extension U is used for optimized U code The extension ASM is used for assembly language output Other passes have similar specifications These are em ane D Weg mge e amma oa gue SuperSoft C Compiler User s Manual C L955 aepc 2 OPERATING SYSTEM PASS NAME INPUT FILE OUTPUT FILE CP M 80 CP M 86 and MS OOS CC fc 5 D Seen CP M 80 C2 E SE gt f ASM CP M 86 MS DOS COD2COD f cOD gt U ZMOS C2273001 COD gt CASM RES UNIX C228002 COD zem A A SM UNIX C228002 U 2 ASM CP M 86 C2186 f U gt A 86 V MS DOS C2186 f COD gt ASM MS DOS C2186 f U E AS j After the SuperSoft C Compiler has done its work it leaves a file that should be run through an assembler The choice of assemblers is wide depending on the operating system anc your preference
100. me gt causes the optimizer to use the specified fiie as the run time trailer file Note there is no Space between RT and the filename Default is C2 RT C2186 8T under CP M B6 if ASM is specified for ASM C2 RTM C2186 RTM under MS DOS T generates and inserts code in output file that at run time causes the name of each function to be displayed each time it is entered This option useful in debugging allows the programmer to trace the control flow within a program Not currently implemented Default is T WBUFSIZ is followed immediately by a decimal integer This integer becomes the buffer size for output operations The larger this value the faster the compilation Smaller sizes use less memory A number cf 128 is aoout the minimum for most systems If this option 1S 1S9 05 Y bp H Q w L gs Bama ba bd EZ EIO e Her Sr RAA teh uerus dm Ag URB t jor AG U Ry ts 19 N SS A or bw H L I DAG tes ri Ms 4 9 Leg NINE yes NE Z SuperSoft C Compiler User s Manual c 1983 Supersoft used the selected value will be printed on the console Default is WB8UFrSIZ10241 causes generation of slightly smaller code at the expense of its speed of execution Optimization performed trades speed efficiency for space efficiency Defauit is to trade space efficiency for speed efficiency Tne difference is relatively slight because most Optimizations have a positive effect on
101. mpiler User s Manual c 1983 SuperSoft 34 0 turns off ovotimization Yecode to assembly code translation oniy is done Default is to ovoerforn optimization OC traces optimization process by writing information to the output file indicating each code change as it is made This option will slow execution of C2 or COD2COD and vastly increase the amount of output of particular use oniy to the optimizer author Default is OC l OFILE redirects the output file to any specified drive under any specified filename It is followed immediately by a filename which will be used for the output fires There must be no whitespace between OFILE and the filename ORG followed immediataiy by a decimal integer forces tne Output code to be ORGed at tne value specifies Default is 256 if ASM is specified no ORG at aii otherwise PRGL causes the name of the function currently beings Optimizes to be dispiaye d on tne console as an indication of where C2 or CO2272O0D is in its execution Default is PRGL Q is followed immediately by an integer specifying the optimizaticn Level Defaults is full optimization Not currently implemented RHKfilename causes the optimizer to use the specified file as the run time header file Note there 18 no Space between R and the filename Default is C2 RE C2186 8H under CP M 86 if ASM is soecifiec Fc ASM no file is prepended under CP M C2186 RTS 25 used under MS DOS RT lt filena
102. n of size u Since u is unsigned ubrk cannot give back any allocated memory It returns ERROR if it cannot locate a free region of proper size See sbrk evnbrk wrdbrk and brk also described ia this chapter SuperSoft C Compiler User s Manual c 1983 Supersoft UGETCHAR ugetchar c char c Causes the next call to getchar to return Cc Calling ugetchar more than once Setween successive calls to getchar will have no effect on the state of the standard input 3ETC RESULT ungetc c ij i char c i TREAM fd i Writes the character c into the most recently read byte of the I O buffar associated with a file opened for buffered input via fopen unget also decremencs the pointer to the next byte to be read from the file I O buffer so that it points to the byte that was just written ungetc if successful returns an undefined vaiue unget 2 returns ERROR 1 if it could not perform its function if the file specified was not opened for buffered input via lt 3 fopen for exampiae P To call ungetc for a file serves no purpose unless either fgets fscanf getc or getw the buffered file input functions has been previously called for the same file Only one call to ungetc between calls to the buffered file input functions for a given file can be guaranteed to have the desired effect see K amp R 9 156 29 Lf tee mee D ct H Nm SuperSof C Compiler Jser s Manual c 1983 Sugar 20 Z UNLINK RESUL
103. ng of tneir respective strings Whenever the character which introduces a conversion specification is encountered in the formas String the corresponding character in the input string is assumed to be the first byte of an input field An input field extends either until a space character is encountered in the input string or the number of bytes specified for the Fieid width has been read wnicnever comes first The conversion characters c and above are the oniy excedtions to this otherwise general rule Any inappropriate character in an input field causes scant to return immediate2iy scanf returns either the number of converted input values it assigned or if no input is present at the standard input the constant EOF see K amp R D 147 AWD A Tre Te jte DA ew t KA Want v rd U fw EA cet OR ATT ET Bat SE SuperSoft C Comp l r User s Manual c 1983 SugperSoft 113 int seek fd offset origin FILE fd int offset int origin Sets the value of the file I O pointer associated with an open file A file I O pointer must be between O and 3 megabytes The file is specified by the pointer fd to its file descriotor and may have Dean opened for either direct or buffered I O seek is primarily used in contunction wita teli and the direct fiie I 0 functions read and write Seex must De used with more cars in coniunction with the buffered file I O functions in order to prevent data loss
104. nly portions of tha code generator need be changed INTERMEDIATE OUTPUT U CODE The compiler s first pass CC accepts as input a SuperSoft C source code file and parses it As output it generates a file in an intermediate code known as Universal code or U code implying code not specific to any one system or machine Since one of the design specifications of our compiler was that the output of all of its passes be intelligible to a human being U code may be viewed and modified using an ordinary text editor A machine independent U code to U code optimizer is supplied with your compiler Under CP M 86 and MS DOS the optimizing process takes place in a separate pass COD2COD under CP M this process occurs during the code generation pass C2 The optimizer accepts as input the U code file generated by CC The input file undergoes a Complex M A N A la M ila Li E SuperSoft C Compiler User s Manual c 1983 SuperSc t optimization process involving global code rearrangemenc within functions as well as reiterative local code transformations within a oeephole or window of a certain number of lines of code The code generation process C2 or C2186 produces a final output file in assemdly Language FINAL OUTPUT ASSEMBLY CODE d Several benefits result from the choice of assembly code as the final output of the compiler some of particular value to the system Level
105. ns TRUE iff ptr points to a data area returned from malloc Must be called only after the first call to malloc S SuperSoft t f Q 3 M F Ead DI rt C Im a Pi Vi S f MA D b w pm nm r VO i7 v D KC TL it 1 vi o tt qt ps tv CHAPTER 4 Combining Sourze Code and Altering Assemsly Code METHOD l1 THE RELOCATING ASSEMBLERS MODULES AND LIBRARIES Tne C language is constructed so that variables and functions can be SE seoarately into relocatazle modules and Coen linke together to forn working orograms using features that are available with most linkers See Chapter 2 Using the SuperSoft C Comgiler SuperSof t C allows the C EXTERN storage class for external globally accessidle or global variables and functions In n2 Special case of functions those not previously declared ars automatically declared as external SuperSozc C translates the EXTERN storage class into the groper assenSler directive to allow the references t be resolved at link time There must b exactly ona definition of each glod5al accessisdlea variable or function Every external with the sane name will be bound to the same definition in tana program The various declarations should agree with tne definitions Althouga the C compiler will check all declarations in a given source file for consistency tne linker may not be able to check fully for consistency A variable may be declared as many times as
106. nsole CON E S SCNTRL l d ZS ao BOOL iscntrl c E S i Ka char c E ES Returns TRUE l if c is an ASCII control character E otherwise it returns FALSE g EI eo ei kal ql EN p d LI 4 A WW Mel we m 44i A i Le P a mam 61 IE 7 ERE SuperSoft C Compiler User s Manual c 1983 Supersoft 82 int inpl6 port Lit port inpl6 not available under CP M 83 returns the value present at the specified inout port after execution of a 16 bit IN machine instruction for that port This function is available only on machines for which the 1l6 bit IN instruction or equivalant makes sense SALNUM BOOL isalnum c char c Returns TRUE 1 if c is an ASCII alodnhanumeric character otherwise it returns FALSE 2 SALPHA BOOL isalona c char c Returns TRUE l if c is an ASCII alphabetical character otherwise it returns FALSE 0 see K amp R po 127 156 nhu owe SuperSoft C Compiler User s Manual c 1983 Supersoft 84 wun ISDLGIT Soot isdijit c char c Returns TRUE 1 if c is an ASCII character representing one of the decimal digits 0 3 otherwise it returns FALSE 3 see K amp R DD 127 156 l Nw D BOOL 1sfa fq FILLE 2 4 Returns TRUE if fd is a valid file descrigtor FALSE i otherwise 2 i P V dEAP g N BOOL isheap ptr c echar ptr Retur
107. nt cpmver Returns the value present in register HL after execution of a call to BOOS function number 12 See the CP M Interfaces Guide supplied by Digital Research Inc This return value which is not sign extended is if the callin program is running under CP M versions released prior to Version 2 0 0x0028 if it is running under CP M Version 2 2 in the range x9 21 to Ox 92F under versions subsequent tos 2 9 and x919 under MP M This function is useful in writing C programs to run under CP M or Mre M indeogenjent o version numoer Programs calling comver will not be portaole beyond CP M CP M 86 and MP M FILE creat fspec mode i FILESPELD fs unsigned mo ec gt de Creates a file on disk with the file specification given ina fspec and opens it for output If the value of mode has the 8x82 bit set then a readadle writeable file is created 6ther4ise a read only file is created Any existing ila with the same specification will be deietedc N creat if successful returns a pointer to a valid fil descriptor for the file specified You should store tnis pointer for subsequent use in your program creat returns ERROR 1 and does not create or open any file if 1 nc enough user memory is available to store a new fiie descriptor 2 the file specification given is invali3 of 3 the file could not be created and opened due to an error at the operating system level See K amp R p 162
108. nts to a function must be declared within that function That is func aa bpd cc int bb int aa cc ewe LS accepted but func aa bb cc eeeWill generat2 an error COM he Pn HB PR R Pe 777 301 SAP FINT RETO FUE PPE Er THR 751 PN TER EN iz PTT gr 9 SuperSoft C Compiler User s Manual c 1383 SupersSoft 139 The code generator does not yet attach any unique prefixes or suffixes to variable names Thus global identifiers in your C source code may conflict with the assembiar s names and keywords You must therefore avoid the use in your C Source code of any of your assemaler s reserved symbols or keywords This deficiency will be remedied in a future release Parameterized DEFINEs and amp IF with expression preprocessor directives are not yet supoorted Unlike standard C lines are only scanned once for amp DEFINE macro substitutions This means that there is no way to get into indefinite looping during preprocessing However this also means that the order of DEFINEs is significant For instance in define x y define y Z x will be replaced with y and y will 5e replaced with 2z However in define v z define x both y and x will be replaced with z In SugerSoft C there must be no intervening newline between a label and its associated Array declarations caa contain only limited expressions In particular SIZEOF and parenthesized expressions are not allowed Because of the way Su
109. ocessor to replace ail subsequent occurrences of the identifier Specified with the TOKENSTRING specified A token is a lexical unit in a programming language such as an identifier an operator a keyword etc This is the Simplest form of macro substitution If a DEFINE G identifier occurs within double or single quotes it wili not be replaced Each replacement string will be rescanned for other DEFINE d identifiers thus allowing nesting of DEFINE directives Redefining an identifier results in a compilation error A parameterized DEFINE is nos supported i The most common use of this directive is in defining a set in the of symbolic constants in a program s header for use functions that follow a far better practice than inserting literal constants in prosram statements An abbreviated example of tnis kind cf use is define BSIZ 0x109 char Bufl BSIZ Bu t 2 8S12 main register int 7 for i G i lt BSIZ Bufl i Buf2 i1 9 directive has many Macro substitution through the define refer to other uses For further examples and information pages 12 86 and 207 in Kernighan and Ritchie amp ld De Le Ze dp ee vod t IP S t K 7 diua baa H es e uc we Sede a dP ER Tm 5 la ib oua Pire c x K 7 EI as Lact i Ma woh ab b da m THE L id P L SuperSoft C Compiler User s Manual c 1983 Supersoft 38 LINE DIRECTIVE
110. oes not exist or was not created via creat or 4 tne file could not be penei due to an error at the operating system level For mode you must specify one of the following 0 1 or 2 Which one you do specify determines the file s I O mode as indicated in the following table g read only moje L write only mode 2 read write moce See K amp R p 162 PEEL be Vd IIT SuperSoft C Compiler vser s Manual c 1983 Supersoft 3 C2 unsigned int ote2il fd Elie f9 a Returns the byte offset from the beginning of the currentiy accessed 512 byte block of a file at which the next file I O operation on that file will begin The file is specified by the pointer fd to its file descriptor otell does not indicate within which Sl1l2 byte block the 1 0 Operation will begin See rtell and tell outp prt 5 int E p int 5 e Pi D Places 5 at the output port designated in pre and executes a byte QUT machine instruccion for that port This Op is availasl2 oniy on machines for which the Dwca OC instruction makes sense OUTPLIS outpl6 prt w int prt w Places the word w at the output port designated in prt and executes a word OUT machine instruction for that port This function is available oniy on machines for which tne word OUT instruction makes sense TRT RTT TTT t p RITT R ATERI ANAP YH ya CLIE ry mea WHY 1083 BD EE TTT Jser s Manca 5 13962 Saper5 9 it Lo C IS
111. of compilation Certain optimizations performed by the code optimizer require time proportional to the square of the size number of U code instructions of the largest C function to be optimized Optimization can be turned off for faster compilation This empnasis while increasing tne turn around time during program development does make our compiler useful for a far broader range of programming tasks The SuperSoft C Compiler is unique in that it aliows you to do efficient system level programming with and clarity on a relatively small hardware system structure neb me Al D de A as ow ap Le pi e ee fe ae lta ty a woe LKE ad n ake o S S F SuperSoft C Compiler User s Manual c 1383 SuperSof RECOMMENDED READING The standard reference for the C language is Brian W Kernighan and Dennis M Ritchie The C Programmin Language Englewood Cliffs NJ Prentice Hall Inc 1978 The programming manual that Dennis Ritchie the chi f designer of C and Brian Kernighan have written is a weil conceived and readable introduction to C and includes the C Reference Manual as an appendix It is indispensable to anv would be C programmer An article which touches on m the evolution and philosophy of the C language is D M Ritchie et al The G Programming Language The Bell Svsteam Technical Journal 57 6 July August 1978 1991 2213 A tutorial
112. oft and RMAC Digital Researcn Relocatable files may be gathered to Libraries and searched Larjye programs up to 64k may be linked even under CP Systems with iass than 64x memory Even larger programs may be divided into segments and overlayed Overiayed programs obviate many of the storage related limitations in your programs and do so without chaining or changing your code Creating overlays is a fairly automatic process The C source code does not have to be altered at all to take into account the differences between a call to a function in the same overlay and a call to a function in another overlay The structure of the overlay is defined exclusively by commanis to ELINK which separate modules into overlays anc a root executable COM fiie An overlay structure might look like this following the example in the ELINK documentation em oft m we em eg engt emp eg oe level root cmain rel l level L covl rel cov2 rel d level 2 cov2l rel cov22 rel dl SuperSoft C Compiler User s Manual c 1983 Supersoft 14 An overlay structure is a tree structure in which levels ara important Each overlay represented by a box in the above diagram can contain any number of local functions that will be accessible to itself and its children Each function in an overlay can call any number of functions in other everlays You can have up to 85 overlays with up to 255 levels deep
113. on C is Thomas Plum Learning t Program in C Cardiff NJ Plum Hall 1983 Also useful are Alan R Sever The C Puzzle Book Englewood Cliffs NO Prentice Hall Inz 12382 E Jean Yates and Rebecca Thomas A User Guide to the UNIX System Berkeley CA OSBSORNE McGraw Hill 1382 l Ann and Nico Lomuto A Unix Primer Englewood Cliffs NJ Prentice Hail Inc i983 in Zeit Wi B J xt CEES TPR TE SE p iret A NN uj ee sys HE TA MER E 11 4 d ey ed bZ KL HLS ms en d vam mA L Lae Y I p WAR DO playa Ai p peel a SL A 17T nH ore PRA T 1 rd W EARN P HERTS erbe MONI KTN 0 St i L EM DUM t NM esr 7 V E ina di SuperSoft C Compiler User s Manual c 1983 SuperSoft ORGANIZATION OF THIS MANUAL The chapters that follow provide the information you will need to use the SuperSoft C Compiler Chapter 2 presents instructions for invoking the compiler and tne preprocessor directives Descriptions of the standard library functions supplied with the compiler are given in Chapter 3 Chapter 4 describes how to insert code into the code generator s run time library The differences between SuperSoft C and Standard Version 7 UNIX C are listed in Appendix A The currently available machine and operating system configurations of the SuperSoft C Compiler are listed in Appendix B Appendix C describes
114. ovide the means of accomolishing this An appropriate SUBMIT file with filename C SUB would contain the following command lines Ce Sil ce S COD2COD S1 COD i C2186 S1 U ASMS6 S1 GENCMD Sl da a x12304 Sl where Sl is a symboli parameter to be later replaced by the first actual parameter of a SUBMIT command After you have created such a file on your disk type SCBMIT C SAMPI Then press RETURN If CP M finds C SUB on the current disk the following five commands will be executed SAMP1 has been Substituted for each occurrence of S1 Co Santer bac COD2COD SAMPI COD C2186 SAMP1 U ASMS6 SAMP1 GENCMD SAMPl1 0OATA X1090 SAMPIL For further information about SUBMIT CP M 86 documentation or one of the several CP M 86 manuals available files consult the TERRI Wo e RULL PIER A SuperSoft C Compiler User s Manual c 1983 SuperScft 21 COMPILATION USING MASM AN MS DOS PC DOS ASSEMBLER D I 3 To transform SAMP1 C into an executable command file so that it can be run under MS DOS you should type each of the commands listed beiow in sequence Type CC SAMPL C COD2COD SAMP1 COD l l C2186 SAMP1 U ASM MSDOS MASM SAMP1 ASM LINK C2PRE SAMP1 C2POST SAMP1 NUL LIBC SAMP 1 Eaz of the above comman s causes a new file to be created on the disk which contains SAM 1 C The names of these files are respectively SAMPICOD output from cC SAMP1 9 Output from COD2COD S
115. pa is split into COD2COD the optimizer and C2ZI386 tne co generator which we call a third pass 2t ss Ge For the CP M CP M 86 and MS DOS versions of the program the following C2PRE C2POST STDIO H STOIO C FORMATIO C ALLOC C FUNC C CRUNT2 C LONG C and DOUBLE C are the built in function files The other files on the disk with the extension C are programs in SuperSoft C source coda provided as examples 9 D aaa T AAP He P HZ HHHH WEILE Bug Po pr H PITT H PONT EN AAS rennen SuperSoft C Compiler User s Manual c 1983 Superacce Lu 3l UNDER THE ZMOS OPERATING SYSTEM l If you have the ZMOS version of the compiler you should find the following files on your working copy first pass of the compiler the parser second pass the Code Optimizer Generator run time library header file output by C2283381 CC IMAG C2Z8GG1 IMAG WHEADER REG ee ee og ep eg WTRAILER REG run time trailer file output by C228901 ZSTDIO REG standard I O functions ALLOC REG dynamic memory allocation functions CRUNT2 REG C language parts of the run time FUNC REG auxiliary functions FORMATIO REG printf scanf et al LONG REG long integer functions DOUBLE REG double floating point functions SAMP REG Sample programs which test features of C CC IMAG and C2289801 1MAG are the compiler executable files under ZMOS Files with the extension of REG contain header files library functions
116. perSoft C parses local declarations a variasia declared to be REGISTER will not truly refer to a ragister unless it is the first REGISTER declaration and it is declared by itself So the following will declara x as a true register variable but y will be declared as an ordinary local funct E register char x register char y The following will not succeed in declaring any true register variable WE EL E N a WL P e D e e SuperSoft C Compiler User s Manual c 1983 Super Saot lt 11e funct L register char x y Dup and fork as available under UNIX are not implemented mostly due to the inconvenience of single process operating systems Link operates differently than UNIX s link Fopen and fdopen have an additional parameter over the UNIX implementation allowing for clearer buffered 1 0 usage This poses no problems if the additional parameter is used in most UNIX C implementations since the final additional parameter is ignored Release 1 2 of SuperSoft C has fuller UNIX compatibility than the previous release 1 1 There are no longer any record size limitations on file 1 9 This has affected read and write Also there has been a mode parameter added to creat and an argjgd parameter added 5 execl to bring SuperSoft C into line with UNIX This release of C also contains a much fuller set of preprocessor directives i Ku vert D
117. program in the series Overiaying the memory image of the preceding progran Command line parameters may be passed to the invoked program in a series of null terminated strings pointed to by ar3i ar32 argn The last argument argn must be zero This is for compatibility with UNIX arad is ignored under CP M due to an unfortunate fature of that operating system exesl constructs a command line from the strings pointed to by its arguments under CP M and MS D2OS tnis means interleaving spaces between the arguments Data may aiso be passed from the invoking program to the invoked program within files or throug the external data area To pass data within a file the invoking progran Should close the file ans the invoked program should reopen it To pass data including open file descriptors through the external data area the origin of that area must be the same for Boch programs On CP M 86 aud MS 2OS this Cou d be accomplished by having both programs define the exec same set of a aale aes L urns E2BOR 1 since any return from execl is e error This will hapoen if the file fssec does not exist or could not be read for any reason preventing overiaying of the memory image of the invoking program and the execution of tne invoked program The invoked program can jump bac to the invoxing program via another call to execl avaat Fae 4 9 sa execl is a list function See Chapter 2 USING LIST FUNCTIONS
118. r BX E 27 Get Addr A110 2 BX ESS 29 Get Addr R O Vector BX 31 Get Addr Disk Parms ax ss 2 50 Direct BIOS Call See bios z 52 Get DMA Segment Base ES BXX E 59 Program Load AX z 5 MS DOS All return AL except d BDOS Function Cail Returns gt 6 Direct console 1 0 AL and x4 if zero flag was set 12 Character input with Invalid Function 1 buffer flush i 24 28 32 These functions not x defined under MS 2235 E 33 40 Invalid Functions S d NOTE The value that bdos returns is not sign extended K an BIOS SupecSoft C Compiler User s Manual c 1983 SuperSoft CP 929 CP dal DE int bios jmpnum bc de int bios jmpnum cx dx int jmpnum int jmpnum int c de int cx dt bios enables CP M users to incorporate direct BIOS ca into oae written in SuperSoft C Programs that c bios will not be portable beyond CP M systems bios S machine rejister pair BO CX under CP M 95 cto tie va given in bc cx under CP M 86 and register pair DE under CP M 86 to the value given in de dx under CP M 6 ani injitiat2s the aopro opriate BIOS call by transferring control to the BIOS jump vector entry point specified in jnpnum This entry point may be specified numerically or sym polieally The aporcoociate mnemonics or Symbolic names for Bari entisy point as given in the CP M Alteration Guide and lt 23 M 25 System Reference Guide supplied by Digital Research Inc ee a and the nuna3ric val
119. r bge bexdo bed2int EL EE cclcom CSZOr ec2imul cc2or cc3or cpmver faoort fopen getc open putc rtell unlink nice clearerr ferror get2b fscan sscan DOUBLE C Double Floating bsub bxtofy buneg bentier fac barctan bea btest bmov bcheoy cclneg ec2mov cc2xor ec2iadd cc2neg ec3xor Point See Appendix G creat fclose fputs getw otell putw seek write swab freooen fileno put2b printf xrprintf bdiv s25cd babs 2197 Dein bsign bne oseterrflg bround collne cc2add cc2cmo ec2and ec3add ccisub SuperSoft C Compiler User s Manual c 1983 Supersoft exec flush fread access pgetc read tell wait isatty fdopen fgetc chmod scanf xrscanf bmul Le Leg e SE buabs bsar bcos blt ole bmant int25e4d ecldec ce2com ec2mul ec2sub ec3and ec3div t Ut RST TTFRUR TTT AN CC UE UU ITALIE RUN ET Re LIP I in rtr OTT TTT SuperSoft C Compiler User s Manual c 1983 SuperSof 146 Appendix E Using Overlays under CP M 80 Le Supersoft s ELINK which is available as an additional cose option to the C Compiler allows the creation of overlayed programs from existing C and assembler relocatable modules ELINK is a disk based stand alone multiple Segment overlay linkage editor and loader ELINK produces executable segments which run under CP M 898 and is able to process relocatable files produced by various assemslers including M88 Micros
120. r library to a linker command line is the easiest and sanest method for adding functions to your C Library Note however it is not necessary to compile source files into libraries For many uses leaving tham as relocatasle modules is adequate The libraries are mainly useful for the selection of variables or funttions rather chan tna inclusion of whole relocatable mogules into a orogzram The SuperSoft C compiler contains a method for creatins Libraries in which each function can be separated and loaded only if needed In order to do this specify the 5U3M flas on the command line of both the first CC and second C2 or CO22COD passes 53 thea compiler The output of the secons pass is altered no longer is the output a singie file with the extension ASM Instead it is a file per function each file consisting of tne name of tne function ana tne extension MAC under CP M MS DOS and PC DOS these names have removed and are truncated to eight characters in order to be compatible with the native assemb5ler linker Systems Also a file is treated which contains directives to form the relocatable modules named REL under C P M 33 and 08J under MS DOS This file is named S3S SUB Under CP M this file is directly executable via SUBMIT and it will assemble the appropriate relocatable modules After executing the S SUB file the librarian must bs used ta collect the functions into a library The file LIBC SUB contains a SUBMIT file t
121. rSoft s C allows the user to add code to the generator s header file the file that is automatica D d placed at the becinning of C programs The header on necessary machine dependent functions Any function alrea in assemz2ly source and included in the header file need be recomoiled and re ootimized each time the rest of program is compiled This is particularly useful when us an absolute assemzler like CP M 80 s ASM or C2 M 86 s ASM n L WI dg tiu Dis b Co e d de On WI LN O LA TD ef To use this method the user compiles the necessarv routine s producing an assemdiy language file get assembly source file is then added into the header file Below is a detailed step by step description of how the CRUNT2 C file of subroutines can be moved into the runtime routines under CP M 80 thus eliminating the need to use a INCLUDE CRUNT2 C directive or a link of a CRUNT2 oberr file 1 We are ready to compile the CRUNT2 C Issue the following commands E E k E E t I f 2 3 4 SuperSoft C Compiler User s Manual c 1983 Supersoft 132 A CC CRUNT2 C A C2 CRUNT2 COD ASM ZA RH RT The ZA options tells the code generator to start all labels with the letter A This avoids any conflict with the code produced by normal compilations which start each label with a C The RT and RH options Orevent the inclusion of the header and trailer files Next REName the file to CRUNT2 LIS
122. ray or a pointer 7 CA deenen AE E BT NER 1 ELEY ba Aa A SuperSoft C Compiler User s Manual c 1983 Supersoft 151 Can t take address CC Attempt to tare the address of an expression Can t write to output file CC C2 or COD2COD Attemot to write to the output file but an I O error has occurred Usually indicates that the output file system is full Sea the ofile option for a remedy Cast CC io An attempt to use casts May not work Continue without matching loop CC A continue has been encountered outside of an enclosing for while or do statement Declaration mismatca CC A redeclaration of a variable is different from a previous declaration This message will not appear if a variable is redeclared identicaily to previous declarations Divide by g C2 or COD2COD i l I EE During optimization constant folding a divide 5y zero was P detected Your algorithm should not require a divide by zero Don t add pointers CC An attempt to add a pointer or array to a pointer or array This is not an appropriate use of pointer arithmetic which expects one side of the binary operator to be a pure value d SuperSoft C Compiler User s Manual c Don t negate pointers A subexpression of the form int pointer was found you meant pointer int Duplicate default More than one default label has appeared in the CC CC 1983 Supersoft 152 Perhaps
123. red strcmp returns a positive integer zero 3 or a negative inteser depending on whether the string beginning at sl is respectively grasatar than equal to or less taan the String beginning at s2 see K amp R p 191 ae char Sei s2 Copies the string beginning at s2 into the string beginning at sl stooping after a null character has been copied If the length of the string beginninj at s2 is greater than the length of the string beginning at sl data in the byte following the latter may be overwritten in error see K amp R p 108 vi ET TY 5 wa wan te CM UT TACKI ATTI A stat us KI BEP LJ OE Byte voc AMO ow gt UM l t Hte N sn OP ee mm Bd d bam gdatia 16 p daa da mm arm rh ae ln e d vn t w li v watt om ew 17 iae STREQ N D n e ci ee tr DV Super Sot C Compiler User s Manual c 1983 Supersof int streq sl s2 char 1 52 Compares the characters in the strings beginning at sl and s2 wharen is the number of characters excluding thre terminal null in the string beginning at S2 streq returns n if the corresponding characters in the two strings are identical otherwise it returns zero J Like substr described later exceot that it returns end of string instead of beginning int strlan s char Cer characters excluding the terminal Returns the number of po 36 95 null in the st
124. ring beginning at s see K amp R 98 STRNCAT char strcat sl s2 n char sl s2 int a Identical to strcat except that strncat appends at most n characters from the string beginning at s2 truncating from the right to the end of the string beginning at sl D x r E S T t RA Bir ada Ae em Aen be Rb A alee An aa ie ea PON l2 E f E t a Lo C NS 9 Fr Uu o kn ct Q Oo 3 O amd b V t1 User s Manual c 1983 SuperSof STRNCMP ist strnoenmp s E m char s char es unsigned n Compares the strings pointed to by s and t The comparison stops at first o like strcmp or after n characters ara scanned whichever comes first Ww PRN BY l char strnesy si 52 n i char sl s2 int 0n Identical to stropy except that strzncpy copies exactly n characters into the string beginning at sl truncating or mullepadding the string beginning at s2 if necessary The resolting string may not be null terminated if the string beginning at s2 contains n or more characters sw tas lm GE S UB8STR char substr pa 29 char pa char pb the beginning of the first occurrence of the substring pointed to by pa in the string pointed to by p Returns NULL if pa is not found in pb See strcmp strec and index also described in this chapter for similar string functions Locates 4 as Ra MU Y 7 D D
125. ring fcc each argument i If the command line and I O redirection code is not desired or if a ifferant action is required a program can be specified with its top level procedure being xmain rather than main 23 SuperSoft C Comaiiar User s Manual c 1983 Supersoft i2 TYPE xrev nar3 TYPE nargs Reworks the parameters in list functions Under SuperSoft C the count of pointers is assumed to be in nargs 2 and an array of parameters starts at amp nar3Ss 1 xrev returns a pointer to the argument list Turn to Chapter 2 USING LIST FUNCTIONS to see xrav in use NN PR L NE xrpriatf line args i char line l TYPE args i e Does all the work for printf et al See printf descrived earlier It expects a char array line to write its outset String t2 an array of arsumants args The first elananc of args should be a formar string See orintt descrines earlier M N RSCANE S xrscanf kind u kind where args int kind u kind where TYPE ar3s l Does all the work for scanf et al See scanf described earlier in this chapter xrscanf expects to be passed two functions kiad where should return a byte from the input u kind c where should push back a byte into the input arjs is a format string see scanf followed by an array of addresses xrscanf cannot be called recursively because it makes use of a global static for some inter function comm
126. rporating Standard Library Functions Also see Appendix D for a summary of which supplied C functions are in which files Since the final output of this compiler is in your machine s assemaly source code you will also need an assembler compatible witn your operating system and hardware plus ihe software required to load anc run programs on your system New onek C file will be needed only D hk H Li D 2 H D t o a Er n PA d ma bu 0 24 i SupecSoft C Compiler User s Manual lt 1383 Supersoft l COMMAND FORMATS ANO SEQUENCES To compile a SuperSoft C source program each of the passes must be invoked with a sequence something like the following 4 i passname filename ext options 1 v Filename refers to the prefix portion of the file specification required by your operating system Passnama refers to the name of a pass of the C compiler Command line options for each pass should be separated by Spaces No options need be Listed since the deau lt conditions specify the normaily desired mode of operation for the compiler However if you are running the compiier On a CPU other than an 8080 8085 8086 or 286 tne 3432 series or are targetting for a different machine than the host machine you may have to set tne macnine dependant options J I and P described on page 3l to their oroper values for your processor When invoxing CC you may list as
127. s split into COD2COD the optimizer and C2186 the code generator which we call a third pass x E E S 3 LEa t gt mM at O T OS nn Al AL A7 e i SuperSoft C Compiler User s Manual c 1983 Super Sot C UNDER THE MS DOS AND PC DOS OPERATING SYSTEMS If you have the MS DOS or PC DOS versions of the compiler you will find these files on your working copy C2186 R7M run time library trailer file for MASM MDE P C ASM ENDASM version of run time C BAT gt MS DOS BATCH file for compilation CBRACK H gt upper case defines for keyboards w o lower case CUSTOMIZ H C library comoile time parameters STOIO A standard I O functions header STOIO C standard I O functions ALLOC C dynamic memory allocation functions CRUNT2 C C language parts of the run time EUN G auxiliary functions CC EXE first pass of the compiler the parser COD2COD EXE second pass Code Optimizer C2186 EXE third pass Code Generator C2PRE SM run time header for LINK i C2POST ASM run time trailer for LINK C2186 87TB run time Library header file for MASM FORMATIO C printf scanf functions and so on LONG C long integer functions DOUBLE C double floating point functions SAMP C sample programs which test features of C LIBC BAT ATCH file to compile the library functions LISC CIB C library in relocatasle format CC EXE COD2COD EXE and C2186 EX are the como executable files under MS DOS and PC DOS The second
128. sembly language lines ar used D A ws e RADIX 13 decimal radix 18232 8080 mnemonics CSES code segment C globals may de referencec in included assembly lanzva3e and aiso in linked assemoiy lanaJ2age and assembly symbdtis may be referenced by C Currently C globals will maczci assemoler symbols by the same name This will not always 5e the case In a subsequent version of the compiler an extr postfix character will be adGe3 toa C symbol for it to match an assembler global Also STATICS wil not have a readily avallab5ie assem2ler symczol tu C makes use of these registers primary register the current sub expression secondary register the Drevious sub expression stack pointer register variable base pointer only in some impiementations C expects the register variable to be osreserved at all times the primary register to be set to the return vaiaes on function returns an3 the primary and secondary registers to De preserved within the computation of any Sub expression The stack pointer should also be preserved across function calls and included assembly language The secondary register is more transitory it is not expected to be preserved across function calls However it is expected to be preserved within most sub expressions and during the vectoring into a switch case It is not normally desira2ie or useful to impose included assembly language inside of a C sub expression An example of in
129. some common prooiems and their solutions Appendix D consists of a list of supplied functions organized according to the file in which they reside Aooendix E discusses the use of overlayed prograns The program s error messages are listed in Appendix E Appendix G describes the Double Floating Point Functions Appendix H the Long Integer Functions er NS NEL i We hope that the SuperSoft C Compiler becomes one of your most useful Programming tools We welcome any comments you may have about the compiler or its documentation d SuperSoft C Compiler User s Manual c 1383 SuperSoft CHAPTER 2 l Using the SuperSoft C Compiler TOPICS DISCUSSED This chapter presents the information you will need to make the best use of tne SuperSoft C Compiler The topics discussed are the files supplied on the compiler disk which of those files you will need to compile your programs other software you will need the syntax of the compiler s commana lines the use of our compiler in a specific Operating system environment the command line options available for each pass and the comoiler preprocessor directives supported in SuperSoft C bre MO IK Ai hii a m ny e SuperSoft C Compiler User s Manual c 1983 SugerSofc 7 FOR YOUR OWN PROTECTION make a copy of your SuperSofst C Compiler disk when you first receive it Store the originai in a safe place as a master disk and for all subsequent work use oni
130. specifying its absolute origin in ROM and another at the beginning of the writeasle data area specifying its absolute origin in RAM The final assembly code output generated by this compiler contains two ORG statements appearing at the beginning of the program and data areas respectively as follows ORG REORIGIN PROGRAM HERE REORIGIN DATA HERE Qe x 20 C The argument signifies the current location but the ORG Statement is not activated until you insert the values for these arguments appropriate to your situation On OA oe Supersoft C Compiler Jser s Manual c 1983 Supersoft L A NOTE ON THE GENERATEO CODE The code produced Sy tne compiler requires that the heap and stack grow toward each other This usually means that the stack will be at larger numbered locations than the heap This relationship should be maintained even if the code produced by the compiler is going to De ROMmed Lee t w Ut superSoft C Compiler User s Manual c 1983 Superso ISLOWER 300L islower c char c Returns TRUE 1 if c is an ASCII lower case alphabetical charactar otherwise it returns FALSE see K amp R p 156 S eds jNUMERIC EN BOOL isnumeric c radix char c int radix Returns TRUE l if c is an ASCII character representing a valid digit in the number system with the base specified in radix otherwise it returns FALSE 0 For exampis isnumeric A 15 returns
131. stituted for each occurrence of S 1 CC SAMPL C C2 SAMP1L COD ASM ASM SAMPI LOAD SAP L SAMP1 For further information about SUBMIT files consult the CP M documentation or one of the several CP M manuals available SW SaperSo ce C Compi asr User s Manual C 1945 super uic COMPILATION USING MAC THE DIGITAL RESEARCH MACRO ASSEMBLER To transform SAMPl C into an executable command file using the Digital Research Assembler MAC and actually execute that file under CP M 82 you should type each of the commands listed below in sequence This procedure is similar to tha procedure for ASM Maka sure that the files C2 RH and C2 537 are on the defauit disk usually the same disk as C2 COM Execution of each of these CP M commands begins as soon as you hit RETURN at the end of the line Type Z CC SAMP1L C C2 SAMP1 COO ASM Mac SAMPL LOAD SAMP1 SAMPl Each of the above commands causes a new file to be creat d on the disk which contains SAMPI1 C The names of these files are r2spectively output from CC SAMPl COD SAMPli ASM Outout from C2 SAMP1 HEX output from MAC SAMPI COM Qgutpuc from LOAD The last file created is the executable command file for your program This is the only form in which your program can be run under CP M Tne others may be deleted Once this file is created you need only type SAMPI Then hit RETURN and execution of your program will begin CC C2 and MAC may also
132. t list each argument separated by a space and S expands to be the argument list each argument separated by a Tei 3 Blank Lines partial last lines and large SUBMIT flies cause SUBMIT to execute in an uneexz2zected manner there is no such problem with SH 4 SH can be used from any drive SUBMIT can be used only from drive A 0 2 SuperSoft C Compiler User s METHOD 2 THE INCLODE DIRECT The INCLUDE preprocessor directive is able to entire file containing ions into your program the funzt any INCLUDS directives for the files in your program s external data definitions The samol2 programs given out with SuperSoft C make programs this ma2thod of building assumed that you ar2 using an CP M 8d s ASM The use of the least common denominator tne will work with either an abso assembler At the top of the oream5le Manual c 1983 Super Sot C l IVE incorporate the desired variables or A good practice is to place Standard library function immediately after any use of from functions It is absolute assem2ier such as INCLUDE directive is the Sample programs as supolied ute assembier or a relocating sample programs are INCLUDE Statements for the appropriate library modules For example SAMPl C inciu des CRUNT2 C and FUNC C i A disadvantage to INCLUDEing ali necessary library files into your program is that the time to compile your DEES will includ2 the time to compile all
133. t s ELINK ELINK BC SAMP1 C2PRE SAMF1 SR LIBC IN C2POST EN Each of the above commands causes new files to be created on the current disk These are SAMP1 COO Cutout from CC SAMP1 A SM output from C2 SAMPl REL output from M89 SAMP1 COM Output from L80 or ELINK Using the above procedure will require the availability of the following files in relocatable format run time header from C2PRE ASM C2PRE REL C2POST REL run time trailer from C2POST ASM LIBC REL the C library Cu ATH LIBC REL is a library created from the recompilation of the following sources ALLOC C STDIO C CRUNT2 C FUNC C and FORMATIO C disk An appropriate SUBMIT file for relocating assemblers using L80 is You will also need the file C2 RTM present on m al a i L J L a L M hee A a L SuperSoft C Compiler User s Manual c 1983 SuperSoft CC 1 C C2 S1 COD M8G S1 ASM L83 C2PRE 1 LIBC S C2POST 1 N E Y l es Or if ELINK is used CC SE C2 1 COD M33 1 ASM ELINK 8BC S1 C2PREZ S1 SR LIBC IN C2POST EN Sil eN 0 r3 sd Meee Mba FERRE 1 Y SR EPIRI DPI BIR arpent RITE TY YE VET arre Adel paT TERR RT EE PTT UIT SVP UT UIT UOETEPY SuperSoft C Compiler User s Manual c 1982 SuperScft 25 COMPILATION USING RMAC A RELOCATING ASSEMBLER To transform SAMP1 C into an executable command file so that it can be used under CP M 80 you should type each of th
134. t the ooecatin j 21052 does not place an end of file EOF character in the uffer if Easa is One asso l1ated witn the file and does nat cail Zosen Th vos cas close for a file aaen Za puaffered outaut via fooen without first 2aliing ffigsn y wilt lose any data renainin in tnac file s I O buffer See K amp R D 163 i el char cocend Coden3 returns a pointer to the byte inmnesiately followin the eni of the code for tie root sagmant of your 29pco2j a Jnless vou have re orisinead your progcam s external date area the value retucne oy coletd will poiat to the bezinning of that area Not current implementez 1355 SunecSo e 53 WA D Zeen e ds s d dy vivo Bst ANR Pk Ad Win 0 Za HS ME Be L T i SAU Pe M i NL 0 Ad zd 3 RON are 920 A A es GE NR SONA CTS t X 7 err L DANA TTE GA j Si usnm iL das IN Tg COM Ww F N SS N e e t3 s Manual c 1983 Supersoft 6 DIT ib t3 Super Soft 7 Tonoilerc J int conlen Returns the lenjin of the Jamaa Jine Avyailaole only on Systens that have the command line available as an array of characters NEZ char comiine Returns the agaress of cas command line Available sniy on Svstens that have the connaad lios available as an array of Sins a Ze es S wi T oum v d i SuperSoft C Compiler User s Manual c 1332 Supersoft 6 CPMVER i
135. ter Alignment is of no concern Also see write described later int getc 4 STREAM d Returns one character bytea as an integer Setween d an 255 inclusively in sequence from a file opened for buffere input via fopen The file is specified by the pointer fd to its file descriptor Carriage returns and linefeeds are Ca U returned explicitly getc returns ERROR 1 i 1 the file was not opened for buffered input or 2 the end of the file has been reached see K amp R Sp 52 166 La Y4V v DW ran roel 241 MW E i pee e wbs Supersoft C Compiler User s Manual c 1983 Suoersoft 73 GETCHAR ba char getchar l l l Returns the next character from standard input the CP M or MS DOS CON device usually the console keyboard If getchar encounters a Control 2 CP M s EOF marker arf returns an error l See K amp R po 13 40 144 152 161 162 4 2 t S x I l i H 1 ETS l gets s char s ae U Reads tne next line from standard input tne CP M r MS D2Os CON device usually the consale keyboard into the strins beginning at S gets replaces tne newline character n or the carziase return newline comnsination Nzn that terminates the input line witn a null character to craat a null terminated string Since gets doas not test whetner the string beginning at s is Lang enough to contain E input line you should define tnis string suc
136. tf is a lise function Se Srand seed int seed Initializes tne return value of rand to the value passed in seed perd v 2A yw t i H i TY l F lsa pam A usaten ama am pan ia Aion re nee he ar A Hee Pai Ama rmt Si RUM w SuperSofe C Comoilert User s Manual c 1983 Supersoft 114 SSCANF sscanf s format argl ar32 char ee format TYPE ar31 TX Ps arg2 Identical to scanf and scanf except that its formatts input string is read from the null terminated string beginning at s rather than from tna standard input sscant does not read the terminal null character see KSR op 152 A sscanf is a list function char Tel g2 appends a copy of tne string beginning at s2 to the end of the string beginning at sl creating a single fg nulle terminated string Note that the resulting string begins at sl and contains a single terminai null character N A c strcat returns a pointer to the resulting string identical to the parameter sl that it was passed see K amp R D 43 een SuperSoft C Compiler User s Manual c 1983 SuperSo f od STRCMP ist stromo sl s char sl s2 Compares the string beginning at sl with the Serins beginning at s2 This comparison is similar to an alohavetical comparison exceot that it is based on the numerical values of corresponding characters in the two strings This comparison ends when the first null character in either string is encounte
137. ther whitespace characters that is spaces tabs and newlines ordinary characters or special substrings beginning witn the character known as conversion specifications The first conversion Specification in the format string corresponds to and determines the boundaries of the first input field in the input string It also determines the tyde of conversion Co be performed on the input value represented in that fiaid Each successive pair of conversion specifications and input fields bears this same relationship Following Che character in each conversion specification there may appear l an optional assignment suppression character P which if present causes the corresponding input fiid t be skipped k Bai lamb ab igo ap inti i AAJ L a LA E at d d a x sam C L pes go Ki Buper bot C Compiler Zser s Manual c 1383 SuperSofit L s 2 an optional string of decimal digits sgogecifying the maximum numoer of characters in the corresponding input field 3 a character called the conversion character in dicating the type of conversion to be performed on the corresponding input value Of the above only the conversion character must be present in a conversion specification All the others if present must be in the order they are listed above The valid conversion characters and the types cf conversions they specify are a single character is expected in t
138. turning true if it has FALSE if it has not More precisely kbnit returns true non zero if a cnaracter is present at the standard input the CP M or MS DOS CON device usually the console keyboard otherwise it returns FALSE 8 This functiona is not availasle on Systems that do not Nava ston a function such as UNIX link ofspec nfspec FILESPEC ofspec FILESPEC nfspec Makes nfspec into a synonym for the filename nsfspec Not possible under CP M or MS DOS Under these systems link operates just like rename described later SuperSoft C Compiler Jser s Manual c 1333 SupersSofcz 88 LOCK lock Locks a process in fast memory A no op under CP and MS DOS ING arithmetic 1 The file LONG C contains a machine independent LONG inteser arithmetic package These functions perform arithmetic on 32 bit two s complement integers All variasles used dy this package snould be declared LONS or UNSIGNED LONG The functions ars passed the address of each argument Usually the functions return no value See Appendix H for descriptions of the long integer ne SuperSoft C Compiler User s Manual c 1383 SuperSoft LONGJMP longjmp savear2sa i int savearea int i Restores the program state from the savearea savearae should De 6 bytes long on the 8038 and 8086 series The program stats includes ail register variables the return program counter and the stack pointer savearea shoul3 have been
139. twenty one bytes This includes 2 exponent ani tne two signs plus an extra te for null termination Snes dest argl double dest argl Two operand negation MN i fu D t E 3jast ul ae double d BUneg dest double dest c One operand negation dest des double Babs dest argl double dest argl Two operand absolute value Jest argl e Ro gt me vm e te e ee E E k E p E E E MAAR Lele Temm A Phat OLE A Mi BSG AL 3114 LR TPE put Ul SuperSoft C Compiler Jser s Manual c 1983 SuperSof ES double BUabs dest double des One operand absolute vaiue dest z dest Bint dest argl double dest argl Returns the integer part of argl in gt dest towards Bentier dest argl double dest Yaral Returns the floor entier of Yaral into dest towards infinity double Y 3log dest argl double dest argl Returns the natural log of argl in dest Jest log ar31 e double Bsqr desct ar3i double dest arg H Vi Return the square root of argl in dest dest sqrt argl argl is tested against being negative double Bexp dest argl double dest argl Raises e e ss 2 7 to the argl power argl rdest e argl is tested against being too large f PASE TID A A Cap Lesen IASA NNT ti 19 Ce LMR geg c Ah a an cm Anan P at nt 9 mI mus
140. typing Control S and then Control C will work The linker dies halts your system or says that it is out of space Find more memory or switch linkers Under CP M 80 we suggest SuperSoft s ELINK a disk 5ased linker that should not run out of space A e R lt me ee T SuperSoft C Compiisr User s Manual Appendix D alloc free realloc ishead d C2 RH CiRT C2136 8H C2136 87 C2PRE ASM C2POST ASM C2 RTM bdos bios ecalta exit longjmp Qutp satexit setjmo comlen comline f CRUNT2 C i i evnpork getchar l lsdigit islowar mav S putcnar setmem strlen assert ugetchar FUNC C ry abs absval aS getval index isainum isas ii isprint ispunct min max poke putdec rindex sleep strcmp strcpy strncpy substr malloc dx 4 Supersoft l Locations of Supplied Functions and Externals MDEP C C2186 8T8 C2I36 2 brk ins outpls streg ccexit jets isupoec puts touooer wrizrk atoi inito iscnerl isspace pause qsort srand strncat tolower 0 mtr tx i 2 0 0 J9 fu OO Eat O 1 On ka isalona iswhite sork ubrzK x2ain perror initw isnumeric kbhit peek rand strcat strncmp topofmem Jt ary Ay STDIO C LONG C Long Integer Functions See Appendix H close execl fgets fwrite link pputc rename ungetc lock mK E em G isfd fputc TORMATIO C fprintf sprintf xrev badd omodulo bneg bint 5exp btan De
141. ue for each entry point are given below tatcy Points Unier CZP M 80 BOOT H SELDSK 9 WBOOT 1 SETTRK 12 CONST 2 SETSEC ll CONIN 3 SETDMA 12 CONOUT 4 READ L3 LIST 5 WRITE 11 PUNTH 6 CISTST 15 READER 7 SECTRAN 16 HOME 8 Under CP M if jmpnum is 2ither SELOSK 9 or SECTRAN 16 bios returns the value remaining in register HL after execution of the BIOS call otherwis2 if returns the vaiue remaining in register A without sign extension that is as a value between and 255 54 A Ais p N e Entry INIT ws00T CONST CONIN CONOUT LIST PUNCH ZADZR HOME SELDSK SETTRK oft 1 7 G SO OO J Oy Ut 4 WN Gi S W V vi DD te Un er CP M 86 SEzTSZzC SETOMA BECA Game WRITE LISTST SECTRAN SETDMAB GETSEG3 GETIOS SETIOB um is either SELDSK cs returns the ucion of the BIOs ising in recister the clobal varias S il 212 13 l4 43 16 17 18 19 20 G As 7 OW te a3 n 4 Os m oq oo 2 EE G ten D ci t TL tre AU f te b Lr J Wl HA ur ast dae 6 VEU TAN MU eL vef NEL eg Wt Se edd 4 HI TT MPR mi e le D Nam RIP R TTT STR 8976191 p RS SuperSof C Compiler User s Manual c 1983 SuserSofe 56 BRK brk sets the external variable name CCEDATAH to the memzzy byte pointed
142. ues as above Target processor is the Zilog 280 Note This is a CC option and not a C2 option so 8280 mnemonics are still output by C2 289000 sets jfiag l int size 4 pad size 2 Target processor is the Zilog 28001 31 x e M SuperSoft C Compiler User s Manual c 1983 Supersoft Z28001 sets jflag l int size 4 pad size 2 Target processor is the Zilog 28001 28002 sets jflag l int size 2 pad size 2 Target processor is the Zilog 289902 Default condition is identical to the result of 18080 or 280 Rame re oe A amp SIL 1393 ER DIY IUE TORE PTS eee we va AAA 2 7 E SuperSoft C Compiler User s Manual c 1983 SuperSoft TN i C2 COD2COD and C2186 COMMAND LINE OPTIONS ASM ASM eB UFSIZ is followed immediate f CO i is used to indicate that an absolute assembler is being used It includes the header file default C2 RH or C2186 RH 5efore any generated code and the trailer file default C2 RT or C2186 RT after any generated code These files should be on the default disk As is not used under MS DOS or PC DOS is the default and it indicates that a relocating assembler is being used Under CP M C2 RTM the default trailer file for relocating assemblers which is appended to the end of the file is used instead of C2 RT There is no header file Under MS DOS or PC DOS ASM uses C2186 RT8 and C2186 RTM as the heacer and
143. uld type each of the d commands listed below in sequence This procedure also am produces relocatable modules and links them together as in E the M80 and L80 example above Below is the procedure E CC SAMPL C COD2COD SAMP1 COD a e 3 C228002 SAMP1 U 3 AS SAMPl ASM O SAMP1 0 5 LO SAMP1 0 C2PRE O LIBC A C2POST O i G SAMPl pi C2POST O must be specified last Eacn of the above commands causes a new file to be created on the current logged in gt disk These are E i E SAMP1 COD output from CC SAMPI U output from COD2COD SAMP1 ASM output from C2280082 SAMP1 0 output from AS E SAM EOR BGR from LD 3 Using the above procedure will require the availability of 3 the following files in UNIX O format A K C2PRE O from run time library C2PRE ASM C2POST O run time trailer from C2POST ASM P LIBC A the C library Si LIBC A is a library created from the recompilation of the following sources ALLOC C STDIO C CRUNT2 C FUNC C anc FORMATIO C d d i 1 x 3 d SuperSoft C Compiler User s Manual c 1983 SuperSoft EK COMPILATION USING RASM To transform SAMPl C into an executable command file so that it can be uses under ZMOS you should type each of the commands listed below in sequence This procedure also produces IMAG modules and links them together as in the AS M example Below is the procedure CC SAMP1 C C228021 SAMP1 COD
144. unication SuperSoft C Compiler User s Manual c 1983 SuperSoft 138 Appendix A The Differences between SuperSoft C and Standard C SuperSoft is committed to implementing the full C language All purchasers of SuperSoft C will receive notice as updates are available The standard C language features not yet implemented are TYPEDEF declarations declaration and use of bit fields initializations TATIC declarations ara recognized however they have no initial value Otherwise EXTERN STATICS operate as expected and local STATICs do nos haze their values retained across function invocations LONG FLOAT DOUBLE and LONG FLOAT variables may be defined These data tyoes may De used in any declaration except as a function s formal argument This includes declaration of STRUCTs UNIONS and arrays The address operator is tne only available operator on these data types Note that there are library functions DOUBLE C and LONG C tnat operate on these data types functions to be pushed SuperSoft C expects Dparamerters to onto the stack in right to left order followed by the return address presumably by the call instruction of the Macnine Eit er righe f9 Lett order or left to right ordear ar2 allowed under the language as defined in K amp R however a number of compilers push arguments in the reverse order co SuperSoft C In particular the original DEC POP il implementation pushes left to right All the formal argume
145. ur assez et use Prooiem During assembly a P or gnase error is indicated Solution A variabla or function has been defined zore than once Proolem During assembly a symbol is indicated as being puolic and external at tha same time Solution This variable or function is misspelled and the assemoler is not catching it because tne difference is an upper lower case change or a difference beyond the truncation limit of the assembler For example TPuts and Touts may be the same to the assembler verylongname and verylongnanmel may be the same also Problem During linking a symbol that should be in a library is not found Solution Scan the library twice during linking If the Symbol is then found you need to reorder the library In the interim double scanning should be adequate If the symbol is still not found then the symbol is not in the library GC CH supersors C Compiler User s Manual c 1983 Supersoft 143 7 Proolem Solution 3 Problem Solution 9 Problem Solution alloc is undefined during Link You are calling functions without their matching precursor For instance you are calling fclose witnout fopen or free witnout malloc Execution of a C program cannot be terminated with Control C under CP M This is because CP M is usually not interrupt driven and cannot respond to characters fron the keyboard in an arbitrary circumstance However during output to the console
146. urns SUCCESS However due t tne buffering of file I O operations such return vaiue does not guarantee that that same characte will be successfully written t the file since error resulting from and affecting the outcome of a particular Call to puto may not become apparent until some later funstion call causes that file s I O buffer to be flushed see K amp R oo 152 166 UTCHAR S putchar c char c Writes the character c to the standard output the CP M or MS DOS CON device usually your console screen See K amp R PP 13 144 152 l baes RT TIN vm DTTCTER Baii duid TES TE ITI Pr Trae Uli a iii 1 3 i i SuperSozt C Comoiler User PUTDEC e rm er oa mmm deo 0 2 7 ej u putdec nn int nn Prints the decimal number nn on the console See Linte for a more elaborate function puts s char s i Writes the string beginning at s to the standard output the CP M or MS DOS CON device usually your console screen All carriage commands must appear explicitly in tnis sering VA Ie we kW C D gt pee cen P Z Ka s n Y D A bo M Ca t SuperSof C Compiler User s Manual c 1333 Supersoft S PUTW RESULT putw i 3 i iat is STREAM fi Writes the integer i to the I O buffer associated with a file opened for buffered output via fopen beginning at Che current location in that buffer Whenever that bufzer becomes full it is automatically flushed t
147. xecutable command file f your program This is the only form in which your progr Can be run under CP M 85 The others may De deleted On this file is created you need only type oc AT e t em a SAMP 1 Then hit RETURN and execution of your program will begin CC COD2COD C2186 and ASM86 may also generate error messages indicating defects in your program Although these messages are largely self explanatory a complete explanation of them can be found in Appendix F of this manual In addition the CP M 86 documentation provides information on the error messages generated by ASM86 Two types of messages from ASM86 can have roots in poorly formed C programs 1 Phase errors and multiply defined labels are usually caused by the redefinition of a C external including C functions Note that externals have only so many significant leading characters This number depends on the assembler and loader used 2 Undefined labels usually indicate undefined C externals including C functions In the course of developing programs you are likely to repeat the procedure just described with no change except in the filename specified an enormous number bac gen M9 wb o 0 1 SuperSoft C Compiler User s Mansal c 1983 SuperSoft 20 of times It would save considerasle time if you could cause this entire procedure to be carried out by means of a single command Under CP M 86 the SUBMIT comaand and SUBMIT files pr
148. y code directly into your C source code file This would appear as follows putchar y asm mvi a 88 e Call output endasm erlt All assembly language lines between ASM and ENDASM go through the passes of the compiler unchanged and are incorporated at the corresponding locations in the final output file Inside of a C function the lines will be executed as encountered outside of a function the lines must contain a label and must be explicitly called in order to be executed The type of assembler language lines thet are put outside of a C function are directives and equates No included assembly language lines are optimized or checked for errors Labels beginning with C in the inserted code WU M 1 A Wad RK lt i SuperSoft C Compiler User s Manual c 1983 SuperScf 41 should be avoided since labels with this prefix a generated by the compiler and may result in a dupiica label when the program is assembled Included assembly language lines may be used anywhere in a C source file If they occur outside of a C function or if the O option don t optimize option is used on the C2 or COD2COD pass then the amount of included assembly languaze is unlimited Otherwise the amount of assembiy language will be limited by the per procedure optimizations of C2 or COOZ2COD The following options are assumed by C2 under CFP M 80 an will affect how the included as
149. y the copy FILES SUPPLIED I x L UNDER THE CP M 8 OPERATING SYSTEM If you have the CP M 80 version of the compiler you should find the following files on your working copy i first pass of the compiler the parser CC COM 0 C2 COM second pass Code Optimizer Generator C2 RH run time library header file used for ASM 2 RT S run time trailer file used for ASM C2 RTM run time trailer for RMAC and M86 C2PRE ASM run time header source for L80 i C290ST ASM run time trailer source for L80 VC2PRE REL run time header for Lag ee qe 8 VC2POST REL run time trailer for L80 AS M various other run time sources MDEP C A amp SM ENDASM version of run time vw C SUB S CP M SUBMIT file for compilation CBRACK H gt upper case defines for keyboards w o lower case CUSTOMIZ H C library compile time parameters STOIO H standard I O functions header STDIO C standard I O functions ALLOC C dynamic memory allocation functions CRUNT2 C C language parts of the run time PUNC YC auxiliary functions O FORMATIO C printf scanf et al functions LONG C long integer functions DOUBLE C double floating point functions BCD860 C assembly language support for DOUBLE C SAMP C sample programs which test features of C VLIBC REL C library in relocatable format LIBC SUB SUBMIT file to compile the library functions r SUB various SUBMIT files V SH COM s enhance
150. z such that it Can contain at least n bytes U The file I 9 pointer will always point to the beginning of a System record After a call to read the file I 0 pointer will point to the beginning of the system record following the last one read If no errors occur read returns the actual number of read If those bytes are being read from a file returns either a muitiple of the system record size or 9 Zero will be returned only if the end of the file been reacned I bytes are being read from a serial dev such as the CP M or MS DOS CON or ROR devices opened a file read returns one 1 since only one byte per to read can be read from a serial device read ret ERROR 1 and does not attempt to read tne file if the file was not ogened for input 2 n is less than System record size or 3 the file could not de read due an error at the operating system level see K amp R Oo 16d a U D ke N COO o T t SOY t2 ltz fo 0 fu t Qu b t4 n t rn DN OD uU t7 Ui D Du Q u UR En LSM VAC 06 SuperSoft C Compiier User s Manual c 1383 Supersoft ca de REALLOC TYPE realloc s nbytes TYPE 5D unsigned n ytes Changes the size of the allocated region pointed t by p p must have been previously set by a call to malloc reall c preserves the Content of the region as best as can be done since the region may have a new size r

Download Pdf Manuals

image

Related Search

Related Contents

Guia do Usuário  裏表紙 (782KB)  LC-Power LC-1370WII computer case  Easy Interactive Tools Ver.3.0  DeLOCK 46179 LED lamp  Bruksanvisning för fishfinder Bruksanvisning for fishfinder  programme - port  スクリュウポンプ    LEDEM30221  

Copyright © All rights reserved.
Failed to retrieve file