IMD 1.18: 22/01/1996 7:48:40 micro cornucopia kaypro user group disk 36 small c library of 100 functions     36-DISK DOCCC COM CC COMe !CC DEF;"#$%&'()CC DOCN*+,-./0123CRC COM456CRCKLISTCRC7D COM89:DELBR COMg;<=>?@ABCDEFGREADME TXTHSCLIB1 LBRIJKLMNOPQRSTUVWXSCLIB1 LBRYZ[\]^_`abcdefghSCLIB1 LBR8ijklmnoSCLIB2 LBRpqrstuvwxyz{|}~SCLIB2 LBRSCLIB2 LBR ********* Welcome To Disk K36 -- Small C COMPILER & Library *********** Disk 36 contains a library of 105 C functions. Most of these are described in Jim Hendrix's "Small C Handbook". Fred Scacchitti designed the library to produce minimum size files by combining modules from Hendrix's library, a modified public domain library, and his own library. Many of the functions are written in assembly-language, and most are useable with any CP/M system. Two libraries -- SCLIB1.LBR AND SCLSCLIB2 LBRSCLIB2 LBRoUW C WC C IB2.LBR -- contain all the C functions. They're squeezed into libraries so you'll need to extract them to another disk. To use the files in the library type -- DELBR [filename] If you don't know about C or C libraries, read Hendrix's "Small C Handbook". Happy C'ing. ************************************************************  #eral enable/disable of the tran!9"!!"s(>w4"<2:g.!"!"!͟G i>͟ |>i>!> ús#r# 22<(2 {=ʝҝPGMNAMEC'̓!R!P%|C">ʐi !Rw#> C -6Mb úrw*F=+qN1,4Ocrtl: Unable to open output file$!R ʩ#~.Š#~C©2>!Fog*|:_*!}2 ú Aborted  $!"s( #" * Lr|" * !} !!{p" !!{p" !!{p" !" " " " " " " " " " "y ! !}!" " * " ! !"}!" " ͣ:S3! !{p"*!r" * #" * r| * !} *" !" !" ͮ_j ͽ_* too many command argumentsSmall-C Version 2.10 10/7/84 (fas) * | ! !>|ʏ ! ! =|ʵ !}2!!}2 !|  ! =| ( ! =| ̈́ !$ =| 6 [E|} ! E|!": ? *&""$"^#V"*~#ž!*G|ʇ!*s#r*"*^#Vr+s*#* s#r:*w&o*|":  *&*|!~ ^#~#CO|?'!""*n&*$"*M> 2*yʖ*~r":=2*"À*|!!} !U !5 !gkrhr!U !5 !gkrhr!U !5 !}hkrhr!U !5 !hkrhr!U  !jkr!5  !Qikr!U  !jkr!5  !.jkr!U !sjkr!5 ! ikr!U !jkr!5 !ikr!U !5 !gkrhr!U !5 !gkrhr!U !5 !]gkrhr!U !5 !lgkrhr!U !5 !}gkrhr!U !5 !gkrhr!U !5 !gkrhr!9* !͌r|ʩ!ʹ;0!92?* r!"͆r* r!<͆rqr|e!9!kr!9!9kr!ͦr|J!9* #" >!6!6!"" "|$"** s#r** ͣ*n&*~rzR£**!*s#r*~wʱW***!*s#r*!>w*!*"|.!"*!~ʄ!**$"*^#V"*" ** z`l{l*6#"L!*G|!"*!"**:@  :& ..&.! 6}.a{ -2?j externstatic#asm#include#define!9!kr* ͦr| !(re!9! kr!Or#| * !(rY,O9!9!(rgr!͆r* ͠rqr|ʷ ͙; !,ͥ:\ 9 :rr| !(r!yr:!(r!(riqO9͙;w!(rww!(re!9!kr!Or#|t!O9!Or!͙r!͆rqr|i͙;t!,ͥ:. DS * |ʏ!ʹ;no closing bracket!9!" " kr!" !}2}2}2}2}2}2!}2* " ![r* ͦr|! )$r"!(r! ͒r|+ !% !Q;!!(r" !9!kr!Or#|s ! ![r+)!9T]+r##kr+++rhr? !@ !.;!h !Q;!!{p"} *} " ! !{p"*" !!{p" ! !{p" !L!{p" * !r" *r}!r!"͆r!r!>͆rqr|7!9!krG![r+!r}!(r!}!9!9krp!9* kr!(r!%" |–!" !ʹ;0!9nested include files not allowedropen failure on include file!G!>|!!(rPw!!!L!>!(r!͆rqr|C!!(rPw!!!charint͍)|]!=!=qr|ʐ!9!kr!9!kræ!9!kr!9!kr!( !,|»ͯ)!( *|!( )!=|!=|!9!kr0!=..}#|-=} <=|L"!~]!*$"^#V"*~#*( >w!*G|ʱ: ±!*s#r*"*^#Vr+s*#* s#r*~*!~w!~o&*|$o&$! 2 *|M!P}"+V6+^6O *+^#6s#r# *33;;x’3"z$|ʽ*|}!}w# –6*z{$  * r!-͆r|* r͎-* rK.* r! ͙rr|f* r!0r" iå!}2!}2!}2!}2!}2!}2!!.;!2!.;!8!.;!q%LiAsM}PINOåusage: cc [file]...[-a] [-i] [-l#] [-m] [-n] [-p] [-o] !" * " * #" * ͦr|! * )$r" * r!-͆r||F* !%" |³!!.;* !Q;!!" 0F* #" +|!" !" 0ropen error: !U !5 !gkrhr  |0!9hr!͆r|%!ʹ;!9!kr!(r!͆r|M!( SaÄ!͌r|ʄ!9! (r!r!(r!(rhr!( ! (r!(r! !(r*! 9!=|R(**)()[declaration type not allowed,*y |!{ʹ;*3 |!ʹ;* #!ʹ;͍)|.!=|I!9!krT!9!kr!( !,|iͯ)!9!kr!=|!9hr|!9!kr!(r!͆r|!9!(r!rhr!9!kr!9!kr&!=|!9!kr&!(r!>|!w!"!!+!!>|<!w!"!* v* !͒r|Y* "1 * * r!f" !" !/!=|ʉͥ!"!!1!!>|ʧ̓"!" "!!4!!>|_#!" "!!:!!>|ͺ#!" "!!=!!>| .$! " "!!A!!>| %! " "!!H!!>|= R&! " "!!M!!>|[ &! " "!!U!!>|y '! " "!͎'|ʄ "!!Z!!>|ʥ G(w!!" "!!a!!>| s(w!!" "!!g!!>| ͩ(w!!" "!!p!=| !" "!!r!!͆r|!( )/!}!}T!( !!!! !*! 9!=|i!ʹ;6a*" !" !=|!!( !,|!( \*|ʯ!( )!( !!* ! !*! 9* " !ʹ;H)2?* !<|!=|!ʹ;͍)|!x!" * " * |ʃ!!>|U!*w!À! !>|u!*w!À!ʹ;Ã-!͌r|ʕ!e* |ʰ* -ͫ;!, illegal function or declaration(no open paren)illegal argument name),no(;;))!9!9*y kr!9*{ kr!9!9*} krhr! 9͇.* !r!kr!N&) #!P&)!"{ !"y !9-hr[e! 9$r[e!(r-d*} r|%!e!9T]+r##kr+++r-!,ͥ:!9T]+r##kr+++rO9͙;ç%!e!O9͙;*{ |&*{ [e! 9$r-6/"} !(r"{ !(r"y !9()*y |b&!&ʹ;*} * r|z&!&ʹ;*} ##"} ++-hr-*} ##"} ++p[!&)not in switchtoo many cases:*y |&*{ |&!&ʹ;&!'ʹ;!')-"{ -mu!͆r!͆rr|&!9!kr* " !( ! (r* * r! !*! 9e#!=|u#not allowed in switchnot allowed with gotomust declare first in block*[(),!" !(r|!9!kr!9!(rkr6a!=|o!=|V!(r|K!(r!(r!9!=|HK!)o!(r!(r!9!(r!͆r!(r͆rr|ʴ!! 9!kr6^!9!kr!(r, !(r!(r !(r={,}!9]|[!(r!͆r=|!(!" "! #w!!" * charint{ifwhiledoforswitchcasedefaultgotoreturnbreakcontinue;#asm!!=|!!!ʹ;Õ!!" ;no semicolon!9* kr!9* kr!" * #" !v"=|!* |!!x"ʹ;!!!* +" !f" " * * r|h"* *," * r|_"* * r|\"![r+* #" +r}5"e"* " "" !" }no final }!9-hr! Y!#!>|¿"-!9-hr* !͌r* ! ͌rr|"[e- commacharintwrong number of arguments!9* |=!9!=!=qr|e!9!krp!9!kr!9!( !,hr|ͯ)!=|ʚ!=|ʧ!=|-0!]͌r|͍)|ô!(r!͆r|!ʹ;!9!kr!(r|h!9!( \*hr|`!(r}! (r}* !Y,r!͵,h!ʹ;* !r" ͍)|ʃ!9!=|˜!ʹ;/!9(**)()[declaration type not allowednot an argument,no comma* !͆r* r|!&!ltiple defaultsnot in switch:*1 7'7'!f'ʹ;='!"3 !( !,|Z''[eb'!'ʹ;w!not allowed with block-localsbad label2?!9* kr!( !,|'/!:͆r|''-!* r/!!( \*" |(* r|(!;(ʹ;)(!( !!-! !*! 9" * !Y,not a label͍)|b( #!!fo(!!f!e!9* S/hr|‹(+r!f$r[e!9* kr!9S/hr|($r|((õ(+r!f$r[e!! (r!͌rqr|!ʹ;!(r!(r+r* !(rrrhr!(r!͆r|Xfì!9p[|ʬ!(r!͆r|ʃ!ʹ;! (r6^!(r!(r+r!rhrmust assign to char pointer or arraycannot assign to pointer!A=|!!9p[|!9!kr寴4!Cʹ;!9rkr!Y)]negative size illegal]!"3 "1 !" " -" *" :r|ʒ* !Q;!( !,|±!ʹ;0* |* -!" !9!( *hr|2r!͌r|!( )/r-else!9!9!99!9!9G$9* !,͌r|N#Y#!/#!9!9!9͇.!9$r-!9$r! Y!9$r[e!9$r-6/!9!9!9͇.!9-hr-!($)!9$r-!9$r! Y[e!9$r-6/w!! 9while!9!9͇.!9-hr!9-hr!%)!%=|m$ #w!-!%=|š$!9$r! Yw![e!9$r-!%=|$ #! %)[e-!9$r[e!9$r-6/! 9  " K0!<)=|)2)* |")2)* * Q;)0!" #endasmH)-0k.|k)* k.|h)/U)É)* k.|‰)* |ƒ)É)/k)2?2?* !)<* !͆rqr;!)ʹ;H)illegal symbol!)ʹ;already defined=|)!)ʹ;missing token!*ʹ;must be lvalue*!* !! 8! 9|X** !* !r" * *r|** * rr" * !=|ʫ** !r* !r!r" i*!!(r! ͆r|+! (r *" |** * |+!+ʹ;!* | 3t13t1#ifdef#ifndef#else#endif* !ͦr|R3* * #" !r};* |t3* " t1* |q33À3* " K03!" * |X6͉/|ʯ3! .3͉/|ʬ3/Þ3U6* !"͆r|64* .3/* !"͌r* !rr!\͆r* !rr!\͌rrqr|(4* |4!6ʹ;(4/.33/!".3U6* !'͆r|ʽ4!'.3/* !'͌r* !rr!\͆r* !rr!\͌rrqr|ʯ4* |¤4!6ʹ;ï4/.3P4/!'.3U6* !/͆r* !*͆rr|05!/* !*͆r* !/͆rr|% ++!(r![r+)$rhr.too many active loops* * r|R/* !r" * r|n/!z/ʹ;!!rout of context!p* r! ͆r|ʧ/!* r! ͆r|ʽ/!!!9* kr|/!/|/* " /* " * r" " |0* r" * !}!/* |G0* |A0!S3-0/* !͆r|_0:* |j0!9* kr!͆r|ʌ0!9* kr* !!(r0|0* !͌r|0!" 0!" 0!/M0;!9! (rkr!9!(r$!(r* kr|9*" * kr* !}!(r" |<9|N9j!9!9!kr!9!'kr! (r9! 9! (rrkr!-ͥ:!(r!͠r|_:!9!kr!9! (rkr!(rͽr|9![r!9+r! (rrhrù9!9!(r0}!r!0͌r! (r!͆rqr!(rqr|=:!9!kr!rͥ:! 9kr!9! (r! ͉qhrÎ9! 9r:͙;͢;:r! ͠r|ʤ:![r+rͥ::* |:* * ͆r|:!:ʹ;!* #" +!r}:!r* ;!rstaging buffe=+* *!rr|1+!,ʹ;!!(r+r" * ! r}* !r}* }!(r* !͵,* " " ! (rrk.|ʹ+* #" +![r+r}Í+!(r! ͆r|+* * * r}!(r* #" kr* global symbol table overflowlocal symbol table overflow!9!(rgr![r+r! ͠r|T,;,!9!(r!Orrhr!Or#|ʰ,!9!r! (r!(rr!rqrhrs,!Or#|,![r+!(r}!9!(r!rhrõ,;2?* -|-!35* |5!/"5t1* |"5%54!/U6* k.|M6!9!kr* k.!(r!ͦrr|ʀ5! ![r+* }/H5! !(r!}! * ! * L!d! 8! 9|6!9*  !Y,hr!9* ![r+r}|5!r.35* k.|6/5J6!9!kr!9! ![r+r}|J6!r.3 6U6/.3Æ3* !͠r|o6!6ʹ;!.3* " !/3no quoteno apostropheline too long!6ʹ;!" no matching #if...! !,|6ͯ)0!9!kr! * ! }!r! ͌r|&1!Or|&1!)1!|a1!r!͆r|F1!3! [r+!r!r}0! (r!}33K0* |ʀ1!3=|1* #" * |ʟ1t12?! !,! * ! * L!d! 8! 9|1* " t1!3=|F2* #" * |2t12?! !,! * ! * L!d! 8! 9|C2* " t1!!3=|ʊ2* |ʄ2* * ͆r|s2!" Á2* |2* " Ç2ͭ6t1!'3=|2* |ʾ2* * ͆r|ʴ2!" * +" 2ͭ6t1* |2t1* |3* * ͆r|2!;* ;* * Q;r overflow!r!(r!͆r|-;u;!(r!(r!!͆r|P;u;!(r!(r.;! !(r ;!;!!!output error ! ͥ:! ͥ:!:ͥ:* |ʿ;!" * !Q;!(r!W<:r|;!!:r|9/!!2?!9* ! (r! (r=hr|V>/* k.|Q>-0>>!!!"u 2?!"w !(rr! ͒r|ʡ>!9*w #"w +![r+r}m>!9*w !}* !9<"w |?* *w r!=͌r* *w r* *w !rr͌rr|͒r!(r!g͆r|(G!(rr!(r!g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* * r|.`* r!͆r| `* r!͆r| `!`!|!`* Sa* " _!9!` *hr|]`r!͆r|]`!``!|ʒ`!`Sa:r!͆r|ʊ`!`e:Ò`!`e:!`e:MAINULINKZZZCCP:: DB 1ZZZCCP:: DB 0END!a* ! * L!d! 8! 9|a|a!  TCH##!er::͙;CALL !*ee:RETyc!Re:͙;d!Vee:* " $+5PCHL!per:-͙;JMP !ee:!ee:!er:-͙;MOV A,HORA LJZ $r!$9!(r!(r!e!͆r|e!er:e!er:DB DW ! fe:DW $+2!9!(r* rhr|6f!(r寴f!ͦr|ʒf!r|ff!'ge:!Or#|ʊf!.ge:!9!rhrff!(r寴f!͒r|f!r|f!4ge:![r+|f!;ge:!9grf!(r!(r|fic[ DCX H CALL CCPINT##CALL CCDECI## DAD SP MOV D,H MOV E,L CALL CCGCHAR## INX H MOV A,L STAX DCALL CCINCC## DAD SP MOV D,H MOV E,L CALL CCGCHAR## DCX H MOV A,L STAX DCALL CCDECC## DAD D POP D CALL CCPINT##CALL CCDDPI## POP D CALL CCPINT##CALL CCPDPI##!%pe:!+pe:POP HPUSH H!Cpe:!Ipe:POP DPUSH D!kpe:!bp!qpe:POP BPUSH B{p!9+riq!͘pØp!9+r!>pr|p!9+r|p*!! 9+r>:q!9*kr*!9+r"!p;|k2p!9!(r(gr2kp!9!(r grãm!m<|ʗk !m<|{k!2pPp!9!(r(grÔk!pPp!9!(r grãm:r|ʏm!m<|k!ne:!9!(rgrÌm!n<|l!2ne:!9!(rgrÌm!@n<|/l!Xne:!9!(rgrÌm!fn<|^l!}ne:!9!(rgrÌm!n<|ʍl!ne:!9!(r?grÌm!n<|ʼl!oe:!9!(r?grÌm!%o<|l!goe:!9!(rBgrÌm!uo<|m! /* ** Small-C Compiler Version 2.10 ** ** Copyright 1982 J. E. Hendrix ** ** Modified version by F.A.Scacchitti 10/7/84 ** ** Upgrades are in chronological order. For more information regarding ** differences between this version and the one described in J.E.H.'s ** Small-C Manual, refer to CC.DOC. ** ** 2.06 ** -modified error pause to terminate on Control X ** CC22.C error() ** -increased all values to conform to 2.1 ** CC.DEF ** -added autext function per J.E.H.'s 2.1 (37) ** CC3!Bge:!Ige:!(r|gic!(rINX SPPOP BDCX SPPUSH BDAD SPSPHL!Wge:DAD H!fge:DAD D!ugeCCSUB##!geCCMULT##!geCCDIV##͏gic!geCCOR##!geCCXOR##!geCCAND##!geCCLNEG##!geCCASR##!heCCASL##!heCCNEG##!'heCCCOM##!Phe:!Or!ͦr|LhOh/hINX H!whe:!Or!ͦr|shvhVhDCX H!heCCEQ##!he:!he:!hr:-͙;MOV A,HORA LJNZ !heCCNE##!he:!ie:!ir:-͙;MOV A,!9!r|)q!9+r|$q!M!3!9!r33:q!9T]+r+kr#|hq!9T]+r#kr+!9+r}:qDM!ytqxGyOȯ{_zWnqDMzzqxq>)qʶqqq}o{_zW=ʿqßqqqz/W{/_x/Gy/O{_zW{zN#F#xr~#~#qq`i||g}or)rr##9~og+r##9~#fo##9T]r+}##9T]r#}}##9T]+r+kr##9T]+r#kr}|}o|g}o|g}o|gͬr+ͬr+ͬr+ͬr+ͬr+ͬr+|gz¹r{!r+r+r+r+zr{!{ozgr#|/g}/o|r.!oe:!9!(rBgrÌm!o<|Im!oe:!9!(rgrÌm!o<|xm!pe:!9!(rgrÌm![r+r* ;ãm![r+r* ;j LXI H,0 DAD SP CALL CCGINT## XCHG;; LXI H,2 DAD SP CALL CCGINT## XCHG;; DAD SP CALL CCGINT##CALL CCDSGI## DAD D CALL CCGINT##CALL CCDDGI## DAD SP CALL CCGCHAR##CALL CCDSGC## DAD D CALL CCGCHAR##CALL CCDDGC## DAD SP MOV D,H MOV E,L CALL CCGINT## INX H CALL CCPINT##CALL CCINCI## DAD SP MOV D,H MOV E,L CALL CCGINT##2.C primary() ** CC4.C *ccptr, *symtab ** CC41.C trailer() ** 2.07 ** -cleaned up and revised CC11.C to eliminate all that garbage ** mods include : ** -set M80 to always true (no -c option) ** CC11.C ask() ** -added -i option to command line to initialize ** storage areas to zeroes only when desired ** CC1.C int iflag; ** CC11.C ask() ** -redid initialization to default to DS instead ** DB or DW to speed up compile time ** CC11.C dumpzero() ** -removed FULL_C, C80, SMALHORA LJZ !ieCCLT##!Aie:!Gie:!Mir:-͙;XRA AORA HJP !ZieCCLE##!ie:!ie:!ie:!ie:!ie:!ir:-͙;MOV A,HORA LJZ $+8XRA AORA HJP !ieCCGT##!je:!je:! jr:-͙;!$je:!*jr:-͙;XRA AORA HJM ORA LJZ !7jeCCGE##!cje:!ije:!ojr:-͙;XRA AORA HJM !|jeCCULT##!jr:-͙;JMP !jeCCULE##!jeCCUGT##!jeCCUGE##r|ʦm!m<|5k !m<|gͬr+ͬr+ͬr+ͬr+ͬr+ͬr+|gz¹r{!r+r+r+r+zr{!{ozgr#|/g}/o|r.!  L_VM, PDS, #defines ** CC.DEF and everyplace else encountered ** -fixed minor bug in auto-external function causing erroneos ** defining of external nothings ** ** 2.08 ** -more cleanup of old garbage got rid of all unnecessary #def's ** including CMD_LINE and NEW_CMD_LN ** CC.DEF, CC11.C and all other places encountered ** -added ## suffixes to all CALL calls to eliminate the CALL ** externals from STDIO.H ** -upgraded peephole() to accomodate new ptr values ** CC41.C, CC42.C ** -remove Stay tuned folk for the following: ** ** >installed all fixes and pertinent upgrades per J.E.H.'s 2.1 ** (13, 14, 15, 16, 26, 27, 34, 36, 38, ) ** >added multi-dimensioned arrays ** >added arrays of pointers eg. *argv[], *num[i] ** >added multiple levels of indirection eg. **argv, ***ptr ** >added type longs ** >added floating point ** >added structures and unions ** >complete 'C' preprocessor external of compiler */ /* ** Macro Definitions */ /* ** compile options */ #define M80 compiler runstring to allow return to CP/M's ** CCP rather than return via warm boot ** CC1.C nbflg ** CC11.C ask() ** -added code generation for -n option ** CC4.C nbflg ** CC41.C trailer() ** -added static's to preprocessor to allow non-global definitions ** of static variables ** CC11.C parse() ** CC41.C trailer() ** -added or verified the following fixes to upgrade to J.E.H.'s 2.1 ** #1 - CC13.C, CC21.C ** #3 - CC12.C ** #7 - CC22.C ** #8 - CC12.C ** #9 - CC22.C ** #1 14 /* ** symbol table parameters */ #define NUMLOCS 25 #define STARTLOC symtab #define ENDLOC (symtab+(NUMLOCS*SYMAVG)) #define NUMGLBS 200 #define STARTGLB ENDLOC #define ENDGLB (ENDLOC+((NUMGLBS-1)*SYMMAX)) #define SYMTBSZ 3050 /* NUMLOCS*SYMAVG + NUMGLBS*SYMMAX */ /* ** System wide name size (for symbols) */ #define NAMESIZE 9 #define NAMEMAX 8 /* ** possible entries for "IDENT" */ #define LABEL 0 #define VARIABLE 1 #define ARRAY 2 #define POINTER 3 #dd all unnecessary external defines from CC1.C, CC2.C ** CC3.C and CC4.C (left in as comments) ** ** 2.09 ** -defined HASH ** -defined DYNAMIC ** -changed CCALLOC to calloc and upgraded to conform to J.E.H's 2.1 ** CC11.C ** -changed CCAVAIL to avail and upgraded to conform to J.E.H's 2.1 ** CC21.C ** -modified ifline() to properly nest #ifdef's per J.E.H's 2.1 ** CC22.C ** -modified trailer to autodeclare externals for both DYNAMIC and ** !DYNAMIC defines ** CC41.C ** -modified traile /* generate m80 compatable library calls */ #define PHASE2 /* 2nd and later compiles */ #define SEPARATE /* compile separately */ #define OPTIMIZE /* compile output optimizer */ #define NOCCARGC /* no calls to CCARGC */ #define HASH /* use hash search for macros */ #define DYNAMIC /* allocate memory dynamically */ /* #define POLL /* poll for operator interruptions */ #define COL /* terminate labels with a colon */ #define TAB 9 /* put out tabs of this value */ #define UPPER 0 - ** #11 - ** #16 - CC12.C ** #22 - C. A. L. L. ** #24 - CC33.C ** #25 - CC12.C ## #28 - CC41.C ** #30 - CC42.C ** #31 - CC21.C ** #35 - CC41.C ** #37 - CC.DEF, CC32.C, CC41.C ** #40 - CC12.C ** #41 - CC1.C, CC2.C, CC3.C, CC4.C ** ** -added the conditional operator {e1 ? e2 : e3 } ** CC31.C heir1(), ducond() ** -changed stdiol.h to stdio.h -CC1.C, CC2.C, CC3.C, CC4.C ** -problems occur when using the (*funct)() syntax. Consider ** this feature not installed. ** **efine FUNCTION 4 /* ** possible entries for "TYPE" ** low order 2 bits make type unique within length ** high order bits give length of object */ /* LABEL 0 */ #define CCHAR (1<<2) #define CINT (BPW<<2) /* ** possible entries for "CLASS" */ /* LABEL 0 */ #define STATIC 1 #define AUTOMATIC 2 #define EXTERNAL 3 #define AUTOEXT 4 /* ** "switch" table */ #ifdef PHASE2 #define SWSIZ (2*BPW) #define SWTABSZ (60*SWSIZ) #else /* PHASE2 */ #define SWr to link to ULINK (runtime module) if source ** contain a main() ** CC41.C ** -modified runtime module - refer to those modules for specifics ** CLIB.DOC ** -seperated modules into standard C functions and ** genrerated clib.rel ** -modified compiler runtime module to minimize size, eliminate ** redirected input and unnecessary routines ** CCRTL.MAC ** -added permission for *(funct)() syntax as arguments ** CC12.C declglb(), doargs() J.E.H.'s (3) ** ** 2.10 ** -added -n option to  /* force symbols to upper case */ #define LINK /* will use with linking loader */ /* ** machine dependent parameters */ #define BPW 2 /* bytes per word */ #define LBPW 1 /* log2(BPW) */ #define SBPC 1 /* stack bytes per character */ #define ERRCODE 7 /* op sys return code */ /* ** symbol table format */ #define IDENT 0 #define TYPE 1 #define CLASS 2 #define OFFSET 3 #define NAME 5 #define OFFSIZE (NAME-OFFSET) #define SYMAVG 10 #define SYMMAX   SIZ 4 #define SWTABSZ 100 #endif /* PHASE2 */ /* ** "while" statement queue */ #define WQTABSZ 30 #define WQSIZ 3 #define WQMAX (wq+WQTABSZ-WQSIZ) /* ** entry offsets in while queue */ #define WQSP 0 #define WQLOOP 1 #define WQEXIT 2 /* ** literal pool */ #define LITABSZ 800 #define LITMAX (LITABSZ-1) /* ** input line */ #define LINEMAX 127 #define LINESIZE 128 /* ** command line */ #define MAXARGS 32 /* maximum number of option arguments */ mende th use purchas hi manua fo mor complet treatmen o Smal C. Fo informatio regardin th content an structur o th Smal librar, refe t th fil CLIB.DOC and Hendrix's Manual. Thi compile wa originall obtaine fro Micr Cornucopi i Decembe 198 a versio 2.03A Th package a received wa pu togethe b Bil Randl an se u fo us wit ASM.COM I wa upgrade t us Microsoft' M80/L8 t tak advantag o th feature o thian retur t CP/ whe pause du t error Th compile ma b compile wit POL̠ define t allo operato interruptio an abortin durin compilation However ɠ personall fel thi woul slo dow compil tim an preferre simple abor feature wher coul abor i th erro encountere woul affec th res o th compilation. * - Global initialization option -i Thi featur decrease compilatio time especiall whe larg array ar declare globally /* ** output staging buffer size */ #define STAGESIZE 800 #define STAGELIMIT (STAGESIZE-1) /* ** macro (define) pool */ #ifdef HASH #define MACNBR 100 #define MACNSIZE 1100 /* 100*(NAMESIZE+2) */ #define MACNEND (macn+MACNSIZE) #define MACQSIZE 500 /* 100*5 */ #else /* HASH */ #define MACQSIZE 1100 #endif /* HASH */ #define MACMAX (MACQSIZE-1) /* ** statement types */ #define STIF 1 #define STWHILE 2 #define STRETURN 3 #define STBREAK 4 #define STCONT  packag an subsequentl i wa cleane up upgrade t us th has searchin functio an dynami memor scheme Refe t th fil CC.DE fo complet chronologica histor o change an detail regardin module o function changed I i assume th use i somewha familia wit th M80/L8 software. Thi compile contain mos o th function an improvement o J E Hendrix' Versio 2. compiler I additio t hi upgrade th followin hav bee instal Small - C Documentation Version 2.10 10/8/84 by F. A. Scacchitti 25 Glenview Lane Rochester, NY 14609 (716) 482 - 7159 Thi documen i intende t supplemen J E Hendrix' "Th Smal Handbook an wil onl discus th difference betwee thi versio o Smal an tha describe i th Manual I i recom Mos version o th compile (a leas th one I'v seen) b default initializ al globa variable t zer b generatin eithe D o D 0 Array ar initialize vi D 0 0 0 0 0 0 . Thi add significantl t compil tim i th use ha declare larg globa arrays Th compile no issue DӠ thu allocatin byte o uninitialize memory I th - switc i used memor wil b initialize t zeroe a before A furthu 5 #define STASM 6 #define STEXPR 7 #define STDO 8 /* compile "do" logic */ #define STFOR 9 /* compile "for" logic */ #define STSWITCH 10 /* compile "switch/case/default" logic */ #define STCASE 11 #define STDEF 12 #define STGOTO 13 /* compile "goto" logic */ led: * - Abort via Control-X when the -p option is used * - Global initialization option -i * - No boot option -n * - static Type Specifiers for global declarations * - Conditional operator {expr1 ? expr2 : expr3} * - 4k file buffers for input, output and include files * - Special runtime package for compiler support FEATURES and ENHANCEMENTS * - Abort via Control-X when the -p option is used Thi featur allow th use t abor th compile    exampl, th Eratosthene Prim Numbe Siev take 8 second t compil whe th - switc i use bu onl 1 second i i isn't A additiona 5 second i require wit eac fo assembl an linking. * - No boot option -n Thi featur allow rapi retur t th CP/ promp o progra completio a cos o 800 byte o cod space I i use i conjunctio wit th runtim packag i th librar (CLIB.REL) I th th - switc i use an th progra contain ml notice whe on start t compil an listen t th disk churn churn churn chur an then chur som more Obviously whe churning yo ain' compiling On wa t eliminat thi tim wastin activit i t increas th siz o th fil buffer suc tha large portion o sourc an outpu cod ma b handled A added bu unproven featur i les wea an tea o th dis drives. * - Special runtime package for compiler support Th Runtim Modul use wit an i i takin ful advantag o thi feature Th stati typ specifie implie tha th variabl shoul b memor resident ye know onl t th modul i i compile in Thi i accomplishe simpl b generatin singl colo fo type specifie a stati an th origina doubl colo fo thos tha ar not. * - Conditional operator {expr1 ? expr2 : expr3} Thi i jus anothe enhancemen t brin Smal close t Bi C Thi operato i describe quit thoroughl th necessar cod t caus module i CLIB.RE̠ t automaticall b linke whe i i searched by L80. USING THE COMPILER Th majo differenc betwee usin thi compile an Hendrix' i thi compile doe no creat defaul outpu file I n outpu fil i specified th outpu wil g t th consol wher i ma b stoppe an starte vi Contro an Contro Q I th outpu i suspende b Contro S Contro ma b use t abor th compile Th compile i invain( function D ZZZCC wil b generate b th compile prio t th EN statement I i isn' specifie th compile generate D  ZZZCCР 0 Th globa variabl ZZZCC determine wher th stac shoul b place an th retur pat t CP/M I short i th - optio i use th stac i place a th bas o th CC an th progra return t CP/ vi retur instruction I th - optio isn' specifie th stac i place a th bas o th BDO an retur i performe thi compile wa originall writte i an containe assembl languag enhancements.( thin ! Th presen modul CCRTL.MA contain mos o th routine require b th compile an i structure aroun th 4 fil buffers Limite I/Ϡ redirection argv/arg handlin an specia abor feature ar included Th resultan siz o th compile afte linkin CCRTL.REL CC1.REL CC2.REL CC3.REL CC4.REL an searchin CLIB.RE t pic u fe necessar functio i 29 i Kerniga Ritchie' "Th Programmin Language an work a specified Th use shoul tr th example i thie manual Th cod generate b thi operato i almos exactl th sam a a if- els statement howeve i doe lea t mor succinc an elegan cod a th sourc level. * - 4k file buffers for input, output and include files Anothe enhancemen whic reduce compil time Mos Smal compiler us 12 byt fil buffer fo fil I/O Thi i readioke b runnin th progra cc.co followe b th desire option (i th runstring) Som example follow: cc compile console input to console output cc test.c compile test.c direct output to console cc test.c -p -a -l2 compile test.c direct output and source to console pause on errors and sound bell cc test.c >test.mac compile test.c direct output and source to console pause on errors and sound bell cc test.c >tes vi war boot Refe t CLIB.DO an ULINK.MA fo detail regardin operatio o thi feature. * - static Type Specifiers for global declarations Globa variable ar mor rapidl accesse (bot fetchin an storing an requir les cod t acces tha loca variables Refe t Chapte 1 o Hendrix' manua fo ᠠ complet explanation Mos Smal compiler mak al globa declaration public Thi obviousl present proble (especiall fo th variable K Smaller than most. Thre submi file ar include wit th source CCM.SUB CCR.SU an CCC.SUB Thes file wil produc m8 sourc files(.mac) l8 sourc files(.rel an fina objec file(.com) respectively Th use i encourage t examin and/o modif thes file t mee hi o he ow particula needs. On fina note i cas yo haven' ha acces t Hendrix' manual I i no necessar t specif externa function i th source Th compile generate  t.mac -p -a compile test.c direct output to the file test.mac pause on errors and sound bell cc test.c new.c >test.mac -l2 -i compile test.c and new.c direct output to test.mac display source on screen initialize global variables to zero cc test.c >test.mac -o -n -l1 compile test.c direct output to test.mac optimize for size over speed generate no boot flag th file - ! ~T #M M 2 2 2 2 ! >2 3o: : @ ***No CRC Files found***$> ʉ ʉw#: <2 P6: .6@ Can not parse string ! ~ʽT #ñM ! > 6 #6^#6! ~T #! 4M #x] #e w~ T #>2 @ - s M@ File not found ! 4 >2 o: G: „: G: „@ *Match* 2 ! 4@ <-- is, was --> : ) > T : ) M 2 ! 4<2 ~# @ Not a space between CRC values<2 G-CATALOG??? t gro unti i reache hig leve o compatabilit wit a describe b R I it' presen form i i quit competetiv wit man o th CP/ 8 compiler presentl o th market. RROR++ <* |): o% |g}o" 2  ; 0T ~T #~A > T > _h : F{͇2h2|: ʲ !\   :\2 ! \  \ ! \  \! \  \<7=Ɓo&   ]  2h2|2   ~$#~# x  : F} *}= ">͇1 ].”#””͡”››tK››͸›* =: =͔="  ʳ ª~#.  ¿~  #~  .+~#0:0~#!A.O.Gy~#0M0 K MMɷ:m2 FSÄCRCKLIST$$$››tK›, › **}|!"*{z*~]*"Ü  DISK FULL: CRCFILE$!"*~#CRC.COM 5.0 6/18/82CRCKFILE???!9" 1 M @ CRC Ver 5.0 CTL-S pauses, CTL-C aborts :] O@ ++Searching for CRCKLIST file++@ Now searching for "CRCKFILE" file++ !  1 .) F!  ͡]͸! ͔0CRCKLIST???CRCKFILE???!9" M à*,*.}|ډ!".*,{z{** u*.".G*.",!".***,}>*.#".ɯ22)! ",". <  NO FILECRC FILE$!   >. @ Checking wi match - : ̓ : J M @ Quantity of lines failed parse test - : ̓ : ~ M @ Quantity of file(s) not found - : ̓ * d͔  ͔ 0T  Җ Wyʩ 0T 0ztiilogram Wha i differen tha norma i th linkin procedure Th fil CCRTL.RE ( Compile Ru Tim Library shoul b linke firs t ensur tha modul satisfie it entr point prio t searchin CLIB.REL. Th submi fil CCCC.SU provide a exampl o prope compiling assembling and linking of of this compiler. FUTURE OF THE COMPILER Needles t sa Smal ha com lon wa sinc Ro Cai firs presente i i Ma o 1980 I i m fir belie tha i wil continu*#"ɯ2i2}! "!"]]2 s : ~# ++FILE NOT FOUND++$: F*}’">͇†]<  CANNOT CLOSE CRCFILE$CRCKLISTCRCSK FULL: CRCFILE$  w# !]͐ DONE$!e S!]Q !eZ @ --> FILE: XXXXXXXX.XXX CRC = oS) \<‘@ ++OPEN FAILED++ !" !" * | ʹ) \!~2 #" Ý: ) > T : ) @ ++FILE READ E   --> FILE: SCLIB1 .LBR CRC = 30 D7 --> FILE: SCLIB2 .LBR CRC = D5 F9 --> FILE: D .COM CRC = 66 48 --> FILE: CRC .COM CRC = B2 07 --> FILE: 36-DISK .DOC CRC = 70 88 --> FILE: DELBR .COM CRC = EF 3A --> FILE: CC .COM CRC = EE D0 --> FILE: CC .DEF CRC = 9D CA --> FILE: CC .DOC CRC = 4E CB --> FILE: UW .C CRC = D2 4A --> FILE: WC .C CRC = DC 5C^#V"; *;  ͪ  *; q#pÝn* " ! p+q* )*= ^#V"; ! 6> ! i* &*; >OK : <2 E:/ *; ^#V*% DMf kK : *; Nf E*; ~ڻWK þE *; ~SK E = ! 6:! ':/ : = !: = : <2 * " !" >! .  * *&͵ "( * *&͵ > j*( #"( *DM*( V"( !" (   K!" }2 : <2 O:* * * "    >! = * DM** +" *( * " Ø* #" *&C 4Ø:!4:!5(  ! I3= : [= t:\a:\=_: :] t ?]\ : ҃! 6?Î : 2   ]Q  ?\\ : DM, Q ! "= *3 ##)*= "; */ &# "! *3 #"#  !! "% >!1 . 2' \: 2 : ʩ: ƀo&"* ~ʛ*# +"# ** DMY қ** DM  *; q#p* " . ** #DM*; -e**  *; w* #" )*= *; s#r*; "; : 2 !S 6!"V * "n >!S d*S &T ) ^#V"K O!l ^#V"M :S =2S M K  a*K "G *t !9~#fo+s#r!d ʶ!9~#fo##s#r^#V^!-) ʶ!9^#V^#V#!9s#rj!9~#fo#s#r+!9^#V~ʳ!9^#V^é!9^#V^! !!9s#rðh Y!9^#V!8 !! ! !3 !ͻ!@ !9s#rz!b !ͻ!9^#V^#V!9q,!!9,!9͞ ! 9!9!9!@!9a! 9!9s#r!) ʄ!9! !ͻ!!9͘!9s#r!9^#V!) !9! !ͻ!!9s#r!9~#fo#s#r+!9^#V!9~#foc !!9^#V!*( * " 3*1 #" " " *5 " > # R : B * +" ! +s#r( ! 6: " * ~2 * #" * +" > ʶ : 2 Ғ * +" : <2 O>ҳ ! 6* #" * ~2 p ̓: AOK = * Ͱ= * ͷ= * Ͱ= *# ͷ= * Ͱ= . g S -A >>!  ~?l W >#^ : /!:' —  ʑ #‹  W ʢ #™ i`N#FogDM!>))덑o|g =¼ DM!>)) = ^#V) ^#V|g}o M "I *K  )*= ^#V"O I G  *G )*= N#F*O ? J*G #"G (*I )*= ^#V*O DM? m*I +"I JI G  *G )*= ^#V"Q *I )*= *G )*= N#Fq#p*I )*= *Q s#r*G #"G *I +"I K I  G M   !M G  :S <2S O!T *G s#r*S &l ) *M s#r*I "M ^I K  X:S <2S O!T *K s#r*S &l ) *I s#r*G "K û!" "    #* #" )*= * #" )*= N#Fq#p   * )*= * ) *= ^#VN#F? H * #" )*= ^#V";  *; ^#V" * )*=  !9x!9s#r!) G!9^#V! !9! !ͻ!9^#V! !9! !!9^#V))!98.^.!9^#V$!9ͩ.¤! !ͻ!9!9^#V)!9^#V͜1#.0K.!98.ͩ.ʶ!98.#.@͐1!@!9s#r!91.@͊.8. /K.9!98.ͽ1!9s#r!91.K.!9^#V!9^#V!9^#V͝!9~#fo8 v! !ͻ!9^#V!9^#V!9^#V͌ !9~#fo8 ʳ!8 !ͻ!9^#V͎!_ !9^#V͎Illegal Option: '%c' delbr v%s 1.1 6 Hit Space: KK : k Used: /k Not used: k *% DMf : remain on 1 !9" ! J> # ->! . *ͪe> # < * v K  K  K !B r+s+p+qA ?  p*A *? :]$Ž l]Q !]6 !E 6!C 6 :C *C &l ~2D U¼:E 2 :D S:E 2:D F:E 2:D V:E 2:D P:E 2 :D N2E ! _{ozgO{ozgi`N#Fogo&og_{_z#W OK = Y -S {-_ ! s+p+q*  ͼ 2 <2 : ! ڗ  K ! 4Á ! 6: =! ڻ * & NK ! 4œ >3  03} Z; { ) #   -Jun-84 AztecUsage: delbr filename(.LBR assumed) Strip all files from a "Novosielski" archive. Not enough memory. ALLOC returned NULL .lbrTrouble getting directory from %s Cannot open %s. Cannot create %s. Extracting: %-12s Error seeking this entry - aborting. Error reading this entry - aborting. Error writing this entry - aborting. !l !49^#V% !9s#rzˆ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g'!>9^#V!d) '!29!J9~#fo##s#r++^#Vͪ1K.k(!>9^#V!l) H(!F9~#fo#s#r+^!>9s#r!29!J9~#fos#r8.K.k(!29!J9~#fo##s#r++^#V͜1K.!>9^#Vö)!9!!698.^.Z+!9!,9s#r)!298.#.r1(!9! !698.͙.^.*!9!,9s#r!-!.9~#fo+s#rs)!9! !698.  ,!9^#V#^#V#N#F,!9^#V#n~0-6-##-!|!9^#V#nR-#I-x0- +~R-6-!9~ ʇ- ʇ- ʇ-Ü-!9~Aڜ-[Ҝ-!}!9~aڜ-{ڇ-!!9~0ڜ-:Ҝ-Ç-!9~a-{- o&!9~A-[- o&! 9~G+~O!.+~W+~_+~+ng.{.x!.w# . x!.w+ .!*3<.!*3w#w#w#w*3~#~#~#~"-3*3V+^+V+^*-3"-3*3s#r#s#r*-3*3*3"3"3*3>w#Ÿ.*3~l1#®.a1=ɯ<*3*3###....ڻ.¿.+.*3*3  ##0123456789abcdef/333Z3_3d3i3n3s3z4PUTLIST MACy!\PUTS C ~?:READ C 'RENAME C REVERSE C PREWIND C SIGN C STDIO H STRCAT C STRCHR C STRCMP C STRCPY C W"STRLEN C STRNCAT C STRNCMP C 8STRNCPY C -#.*3*3#/*3*3#*/*3*3#?/*3*3#T/*3~/w#d/*3~?G*3^#V#~#fo))҉/#/DM*3s#r#q#p*3~?W*3###~/~w+²/®/7~w+//~#/O!93͜.*393/y273*3A3/:73273S093*3w#0:73.*393/y273*3A3/S0=3*3w#B0:73.!=3w#Y0> 283!93~w#j0O=3!A3#0yš0!934!835d0!8350!93~w#§0O=3!A3#º0yš0Î0=3!A3#0*3A3~#0*3=3~#0  ERATOS C FA C "FB C 6FC C $߿FFD C +b9FM C . ISPRINT C ISPUNCT C 9SISSPACE C W,ISUPPER C 5ISXDIGITC HITOA C ITOAB C /ITOD C $ITOO C *The files named .CPM are actually .COM files for CP/M. If you copy the files to a CP/M system without using 22DISK, just rename all *.CPM to .COM STRRCHR C ސTIME C HTOASCII C oTOLOWER C rTOPOFMEMMAC<TOUPPER C UALLOC C [ULINK MAC/+,UNGETC C UNLINK MAC*UTOI C WRITE C qXTOI C iZZBUF MACvZZFIO MACB !93w#1> 283!93~w#1B193!A3#+1B161!8351*393w#Q1.l1!.a1!<.l1a1.l1l1a1.a1l1.a1a1l1*3s#r#6#6*3s#r#z16#6*3^#V4ITOU C /pITOX C 5LCC SUB7DLEFT C :aLEXCMP C < LIBID C HAMALLOC C IȯMAX C LMIN C MbcNEWLIB SUBNOTOI C U2OUTP MACXPAD C [QPOLL C ]PRNTF C arPUTCHAR C wȸ   /* ** stdiol.h -- header for resident stdio/crtl/call ** -Set up for Version 2.08 compiler 8/4/84 (fas) */ #define stdin 0 #define stdout 1 #define stderr 2 #define stdport 3 #define stdlist 4 #define ERR -2 #define EOF -1 #define YES 1 #define NO 0 #define TRUE 1 #define FALSE 0 #define NULL 0 #define CR 13 #define LF 10 #include stdio.h /* ** itod -- convert nbr to signed decimal string of width sz ** right adjusted, blank filled; returns str ** ** if sz > 0 terminate with null byte ** if sz = 0 find end of string ** if sz < 0 use last byte for data */ itod(nbr, str, sz) int nbr; char str[]; int sz; { char sgn; if(nbr<0) {nbr = -nbr; sgn='-';} else sgn=' '; if(sz>0) str[--sz]=NULL; else if(sz<0) sz = -sz; else while(str[sz]!=NULL) ++sz; while(sz) { str[--s#define NOCCARGC /* no argument count passing */ /* ** itoa(n,s) - Convert n to characters in s */ itoa(n, s) char *s; int n; { int sign; char *ptr; ptr = s; if ((sign = n) < 0) /* record sign */ n = -n; /* make n positive */ do { /* generate digits in reverse order */ *ptr++ = n % 10 + '0'; /* get next digit */ } while ((n = n / 10) > 0); /* delete it */ if (sign < 0) *ptr++ = '-'; *ptr = '\0'; reverse(s); } turns str ** ** if sz > 0 terminate with null byte ** if sz = 0 find end of string ** if sz < 0 use last byte for data */ itou(nbr, str, sz) int nbr; char str[]; int sz; { int lowbit; if(sz>0) str[--sz]=NULL; else if(sz<0) sz = -sz; else while(str[sz]!=NULL) ++sz; while(sz) { lowbit=nbr&1; nbr=(nbr>>1)&32767; /* divide by 2 */ str[--sz]=((nbr%5)<<1)+lowbit+'0'; if((nbr=nbr/5)==0) break; } while(sz) str[--sz]=' '; return str; } /* ** return 'true' if c is a printable character ** (32-126) */ isprint(c) int c; { return (c>=32 && c<=126); } #define NOCCARGC /* no argument count passing */ /* ** return 'true' if c is a punctuation character ** (all but control and alphanumeric) */ ispunct(c) int c; { return (!isalnum(c) && !iscntrl(c)); } /* ** return 'true' if c is a white-space character */ isspace(c) int c; { /* first check gives quick exit in most cases *z]=(nbr%10+'0'); if((nbr=nbr/10)==0) break; } if(sz) str[--sz]=sgn; while(sz>0) str[--sz]=' '; return str; } /* ** itoo -- converts nbr to octal string of length sz ** right adjusted and blank filled, returns str ** ** if sz > 0 terminate with null byte ** if sz = 0 find end of string ** if sz < 0 use last byte for data */ ito#define NOCCARGC /* no argument count passing */ /* ** itoab(n,s,b) - Convert "unsigned" n to characters in s using base b. ** NOTE: This is a non-standard function. */ itoab(n, s, b) int n; char *s; int b; { char *ptr; int lowbit; ptr = s; b >>= 1; do { lowbit = n & 1; n = (n >> 1) & 32767; *ptr = ((n % b) << 1) + lowbit; if(*ptr < 10) *ptr += '0'; else *ptr += 55; ++ptr; } while(n /= b); *ptr = 0; reverse (s); }  /* ** itox -- converts nbr to hex string of length sz ** right adjusted and blank filled, returns str ** ** if sz > 0 terminate with null byte ** if sz = 0 find end of string ** if sz < 0 use last byte for data */ itox(nbr, str, sz) int nbr; char str[]; int sz; { int digit, offset; if(sz>0) str[--sz]=0; else if(sz<0) sz = -sz; el/ return(c<=' ' && (c==' ' || (c<=13 && c>=9))); } /* ** return 'true' if c is upper-case alphabetic */ isupper(c) int c; { return (c<='Z' && c>='A'); } /* ** return 'true' if c is a hexadecimal digit ** (0-9, A-F, or a-f) */ isxdigit(c) int c; { return ((c<='f' && c>='a') || (c<='F' && c>='A') || (c<='9' && c>='0')); } o(nbr, str, sz) int nbr; char str[]; int sz; { int digit; if(sz>0) str[--sz]=0; else if(sz<0) sz = -sz; else while(str[sz]!=0) ++sz; while(sz) { digit=nbr&7; nbr=(nbr>>3)&8191; str[--sz]=digit+48; if(nbr==0) break; } while(sz) str[--sz]=' '; return str; } #include stdio.h /* ** itou -- convert nbr to unsigned decimal string of width sz ** right adjusted, blank filled; re  se while(str[sz]!=0) ++sz; while(sz) { digit=nbr&15; nbr=(nbr>>4)&4095; if(digit<10) offset=48; else offset=55; str[--sz]=digit+offset; if(nbr==0) break; } while(sz) str[--sz]=' '; return str; } /* ** left -- left adjust and null terminate a string */ left(str) char *str; { char *str2; str2=str; while(*str2==' ') ++str2; while(*str++ = *str2++); } /* ** max.c by F.A.Scacchitti 9 - 10 - 84 */ max(a,b) int a, b; { if(a > b) return(a); return(b); } /* ** min.c by F.A.Scacchitti 9 - 10 - 84 */ min(a,b) int a, b; { if(a < b) return(a); return(b); } XSUB LIB80 NEWCLIB= ULINK LIBID UNGETC FFLUSH REWIND CTELL CTELLC CSEEK FILELIB FREAD READ FWRITE WRITE GRABUF GRABIO FREBUF FREEIO FPRINTF FSCANF PRNTF FPUTS FGETS GETS PUTS FPUTC FGETC PUTCHAR GETCHAR GETCHX CPMIO CPMDISK,096,097,098,099,100, /**** [ \ ] ^ U ` ****/ 055,056,057,058,059,060, /**** a-z ****/ 075,076,077,078,079,080,081,082,083,084,085,086,087, 088,089,090,091,092,093,094,095,096,097,098,099,100, /**** { | } ~ ****/ 061,062,063,064, /**** DEL ****/ 101 }; lexorder(c1, c2) char c1, c2; { return(Ulex[c1] - Ulex[c2]); }  ; outp(port#,data) ; added 2/84 (fas) OUTP:: INX SP ; Skip over return address INX SP POP H ; Load data in L POP B ; Load port # in C DB 0EDH, 069H ; Do instruction PUSH B ; Restore stack PUSH H DCX SP DCX SP ; All gone RET END #define NOCCARGC /* no argument count passing */ /* ** Place n occurrences of ch at dest. */ pad(dest, ch, n) char *dest, *#define NOCCARGC /* no argument count passing */ /* ** lexcmp(s, t) - Return a number <0, 0, or>0 ** as s is <, =, or > t. */ lexcmp(s, t) char *s, *t; { while(*s == *t) { if(*s == 0) return (0); ++s; ++t; } return (lexorder(*s, *t)); } /* ** lexorder(c1, c2) ** ** Return a negative, zero, or positive number if ** c1 is less than, equal to, or greater than c2, ** based on a lexicographical (dictionary order) ** colating sequence. ** */ char Ulex[128] PUTLIST CALLOC MALLOC UALLOC AVAIL FREE POLL ABS ATOI ATOIB DTOI ISALNUM ISALPHA ISASCII ISATTY ISCNTRL ISDIGIT ISGRAPH ISLOWER ISPRINT ISPUNCT ISSPACE ISUPPER ISXDIGIT ITOA ITOAB ITOD ITOO ITOU ITOX LEFT LEXCMP OTOI REVERSE SIGN STRCAT STRCHR STRCMP STRCPY STRLEN STRNCAT STRNCMP STRNCPY STRRCHR TOASCII TOLOWER TOUPPER UTOI XTOI PAD FEOF FERROR CLEARERR DELAY DOLDDR DOLDIR INP OUTP TOPOFMEM UNLINK MIN MAX ABORT BDOS CALL1 CALL2 CALL3 CALL4#include libid() { puts("\n\n This library created 11/24/84 by F. A. Scacchitti\n\n"); } #define NOCCARGC /* no argument count passing */ #include stdio.h /* ** Memory allocation of size bytes. ** size = Size of the block in bytes. ** Returns the address of the allocated block, ** else NULL for failure. */ malloc(size) char *size; { return (Ualloc(size, NO)); } n; int ch; { /* n is a fake unsigned integer */ while(n--) *dest++ = ch; } #define NOCCARGC /* no argument count passing */ #define ABORT 3 #define PAUSE 19 #include stdio.h /* ** Poll for console input or interruption */ poll(pause) int pause; { int i; i = bdos(6,255); if(pause) { if(i == PAUSE) { while(!(i = bdos(6,255))) ; if(i == ABORT) abort(0); return (0); } if(i == ABORT) abort(0); }  = { /**** NUL - / ****/ 000,001,002,003,004,005,006,007,008,009, 010,011,012,013,014,015,016,017,018,019, 020,021,022,023,024,025,026,027,028,029, 030,031,032,033,034,035,036,037,038,039, 040,041,042,043,044,045,046,047, /**** 0-9 ****/ 065,066,067,068,069,070,071,072,073,074, /**** : ; < = > ? @ ****/ 048,049,050,051,052,053,054, /**** A-Z ****/ 075,076,077,078,079,080,081,082,083,084,085,086,087, 088,089,090,091,092,093,094,095 CALL5 ZZFIO ZZBUF /E A: PIP A:=B:NEWCLIB.REL[v] #include stdio.h /* ** otoi -- convert unsigned octal string to integer nbr ** returns field size, else ERR on error */ otoi(octstr, nbr) char *octstr; int *nbr; { int d,t; d=0; *nbr=0; while((*octstr>='0')&(*octstr<='7')) { t=*nbr; t=(t<<3) + (*octstr++ - '0'); if ((t>=0)&(*nbr<0)) return ERR; d++; *nbr=t; } return d; }    return (i); }  /* ** prntf("format string"[, arg, arg, ...]) -- formatted print ** operates as described by Kernighan & Ritchie with ** the following exceptions: ** ** - only d, c, and s formats supported ** - maximum field-width specification of 9 ** - no field seperator specification ** ** Modified version of J. E. Hendrix's printf distributed ** with Small-C Versi len = -1; while(sptr[++len]); /* get length */ if(right) while(((width--) - len) > 0) putchar(pad); while(len) { putchar(*sptr++); --len; --width; } while(((width--) - len) > 0) putchar(pad); } } #define NOCCARGC /* no argument count passing */ /* * putchar() Normal console output via BDOS(2) */ #include l = *nxtarg; while(c = *ctl++) { if(c != '%') { putchar(c); continue; } if(*ctl == '%') { putchar(*ctl++); continue; } cx = ctl; right = 1; pad = ' '; if(*cx == '-') { right = 0; ++cx; } if(*cx == '0') { pad = '0'; ++cx; } width = *cx - '0'; if(width < 1 || width >9) width = 0; else cx++; sptr=str; c = *cx++; i = *(--nxtarg); switch(c) { case /* ** read.c by F. A. Scacchitti 11/24/84 */ #include extern int zzbuf; read(fd,buffer,cnt) int fd, cnt; char *buffer; { int i, n; char *tbuff, flag; tbuff = &zzbuf; n=0; while(cnt >0){ if((flag = bdos(20,fd)) != NULL) { *(fd + 40) = flag; return(n); }else i = 0; while(i <= 127 && cnt > 0){ buffer[n] = tbuff[i]; i++; cnt--; n++; } } return(n); } on 2.0. This version uses putchar for ** for output and is renamed to prntf to avoid mutiple ** global defines. It is designed to occupy minimum code ** space and can be used interchangeably with printf(),as ** long as the exceptions are taken into consideration. ** ** F. A. Scacchitti 10/7/84 */ #include /* ** Making the following variables static greatly reduces size ** while increasing speed. However, if static globals aren't ** available on your compiler, the prntf.mac fi putchar(c) char c; { bdos(2,c); if (c == CR) bdos(2,LF); }  ; ; putlist(c) ; ; F. A. Scacchitti 8/4/84 ; ; CBDOS EQU 5 ;/* bdos entry point */ LF EQU 10 EOL EQU 13 ; ; CP/M BDOS CALLS ; LSTOUT EQU 5 ;write character to list device ; ; Storage varibles found in ulink() or ulinq() ; EXTRN ZZTEMP ; ; PUTLIST:: POP B POP D PUSH D PUSH B SHLD ZZTEMP MVI C,LSTOUT ; cpm(LSTOUT,c); CALL CBDOS ; (mod to cb'd': sz = 7; if(i < 0) { i = -i; sgn='-'; } else sgn=' '; str[--sz] = NULL; while(sz) { str[--sz] = (i % 10 + '0'); if((i = i / 10) == 0) break; } if(sz) str[--sz] = sgn; while(sz > 0) str[--sz]=' '; break; case 'c': str[0] = i; str[1] = NULL; break; case 's': sptr = i; break; default : continue; } ctl = cx; /* accept conversion spec */ if(c == 'd') while(*sptr==' ') ++sptr; /* ** rename(old,new) char *old, *new; by F.A.Scacchitti 9/11/84 */ #define NOCCARGC #include rename(old,new) char *old, *new; { int fcbloc; if ((fcbloc = grabio()) == NULL) return(ERR); fcb(fcbloc, old); fcb(fcbloc + 16, new); freeio(fcbloc); if(bdos(23,fcbloc) >= 0) return(NULL); return(ERR); } #define NOCCARGC /* no argument count passing */ /* ** reverse string in place */ reverse(s) char *s; { char *j; intle must be ** edited to remove the additional colon generated by the ** compiler to ensure no problems occur with multiple global ** definitions. An alternative to this method would involve ** renaming all the static variable with some little used ** prefix. (eg. qqq, xxx, ppp) */ static int i, width, len, *nxtarg, sz; static char *ctl, *cx, c, right, str[7], *sptr, pad, sgn; prntf(argc) int argc; { i = CCARGC(); /* fetch arg count from A reg first */ nxtarg = &argc + i - 1; ctdos(fas)) LDA ZZTEMP CPI EOL ; if(c==EOL) JNZ PUTLS1 MVI E,LF ; cpm(LSTOUT,LF); MVI C,LSTOUT CALL CBDOS ; (mod to cbdos(fas)) PUTLS1: LHLD ZZTEMP ; return(c & 0377) MVI H,0 RET END #define NOCCARGC /* no argument count passing */ /* *puts(string) Print string to console via BDOS(9) */ puts(string) char *string; { int i; i = 0; while(string[i] != 0){ putchar(string[i]); i++; } }    c; j = s + strlen(s) - 1; while(s < j) { c = *s; *s++ = *j; *j-- = c; } }  /* ** rewind.c by F. A. Scacchitti 9/11/84 */ #define NOCCARGC #include rewind(fd) int fd; { return(cseek(fd, 0, 0)); } /* ** sign -- return -1, 0, +1 depending on the sign of nbr */ sign(nbr) int nbr; { if(nbr>0) return 1; if(nbr==0) re d = dest; while(n-- > 0) { if(*d++ = *sour++) continue; while(n-- > 0) *d++ = 0; } *d = 0; return (dest); } /* ** strrchr(s,c) - Search s for rightmost occurrance of c. ** s = Pointer to string to be searched. ** c = Character to search for. ** Returns pointer to rightmost c or NULL. */ strrchr(s, c) char *s, c; { char *ptr; ptr = 0; whi/* ** return length of s */ strlen(s) char *s; { char *t; t = s - 1; while (*++t) ; return (t - s); } /* ** concatenate n bytes max from t to end of s ** s must be large enough */ strncat(s, t, n) char *s, *t; int n; { char *d; d = s; --s; while(*++s) ; while(n--) { if(*s++ = *t++) continue; return(d); } *s = 0; return(d); }  /* ** ------------ Memory Allocation */ /* ** Allocate n bytes of (possibly zeroed) memory. ** Entry: n = Size of the items in bytes. ** clear = "true" if clearing is desired. ** Returns the address of the allocated block of memory ** or NULL if the requested amount of space is not available. */ #include extern char *zzmem; Ualloc(n, clear) char *n; int clear; { char *oldptr; if(n < avail(YES)) { if(clear) pad(zzmem, NULL, n); oldptr = zzmem; zzmem += turn 0; return -1; } /* ** concatenate t to end of s ** s must be large enough */ strcat(s, t) char *s, *t; { char *d; d = s; --s; while (*++s) ; while (*s++ = *t++) ; return(d); } /* ** return pointer to 1st occurrence of c in str, else 0 */ strchr(str, c) char *str, c; { while(*str) { if(*str ==le(*s) { if(*s==c) ptr = s; ++s; } return (ptr); } /* ** return ASCII equivalent of c */ toascii(c) int c; { return (c); } /* ** return lower-case of c if upper-case, else c */ tolower(c) int c; { if(c<='Z' && c>='A') return (c+32); return (c); } /* ** strncmp(s,t,n) - Compares two strings for at most n ** characters and returns an integer ** >0, =0, or <0 as s is >t, =t, or 0 aUording to ** st */ strcmp(s, t) char *s, *t; { while(*s == *t) { if(*s == 0) return (0); ++s; ++t; } return (*s - *t); } /* ** copy t to s */ strcpy(s, t) char *s, *t; { char *d; d = s; while (*s++ = *t++) ; return(d); } ; ; ; End of memory function ; Returns top memory location in HL CBDOS EQU 5 TOPOFMEM:: LDA CBDOS+2 ; Get base of BDOS (mod to cbdos (fas)) MOV H,A ; Save page in HL MVI L,0 RET END /* ** return upper-case of c if it is lower-case, else c */ toupper(c) int c; { if(c<='z' && c>='a') return (c-32); return (c); }   e Small-C compiler. ; ; This module contains the following routines: ; ; -ULINK entry point just like J. E. Hendrix Vers. 2.1 ; ; -Initialization of stack, memory buffers, and argument ; passing (argv, argc). ; ; ; call to main() ; links to main in user program ; ; -Cleans house and returns to CP/M ; ; ; ; ; Now then here's the starting code ; ; ; ; 1st - Save CPM's stack pointer, establish file i/o constructs set ; new default buffer and establish start of available memory. ; ; ; where do we put the stack ; LDA ZZZCCP ; let's check ORA A ; JZ SETSTK ; just below the BDOS MOV A,H SUI 8 ; just below the CCP MOV H,A ; SETSTK: SPHL ; set stack pointer ; MVI C,0 ; Init argc LXI H,ARGV ; Pointer to first entry of argv array ; ; CPM does not tell us what the first word of the command ; line was (the name of pgm), so we fake it by pointing it ; to an ascii string with '*' in it ; LXI D,PGM ; Pointer to 'pgmname' string CALL SVARG ; Save next argumenCLOSE EQU 16 ; FCBSIZE EQU 36 ;size, in bytes, of an FCB BUFFER EQU 6 ;offset to disk sector buf. in I/O struct. UNGOT EQU 5 ;offset to char ungotten by ungetc() FLAG EQU 33 ;file-type flag byte (in unused part of FCB) FREEFLG EQU 128 ;This I/O structure is available BUFSIZ EQU 1024 ;how long the sector buffer is NBUFS EQU 8 ;number of I/O buffers TBUFSZ EQU 128 ;size of default disk buffer ; EXTRN MAIN, ZZBUF, ZZZCCP ; ; ULINK:: ; LXI H,0 ; get CPM's stack pointer DAD SP SHLD ZZSTAK in procedure MVI A,2 ; Load up the argument count ; CALL MAIN ; Transfer to the C world.... ; ; anchors ; away ; my ; bo ; y ; y ; y ; y ; y ; EXIT:: MVI B,NBUFS ; Prepare to scan for open files MVI C,CLOSE LXI H,ZZBUF+TBUFSZ+FLAG LXI D,FCBSIZE+BUFFER+BUFSIZ SCANEM: MOV A,M ; Get free flag CPI FREEFLG ; Is it free ? JZ NOPEN ; Yes - not open, go get next PUSH B ; No - prepare to close PUSH D PUSH H LXI D,-FLAG DAD 2nd - Get the default disk and set stack at base of BDOS or CCP ; depending on the status ZZZCCP. 0 = bdos 1 = ccp ; ; 3rd - Parse the CPM input line and modify it so that we can pass ; the C program in the argc, argv form that it expects. ; HL = pointer to next argv entry ; DE = pointer to next character in command line ; B = number of characters left in line ; C = argument count (argc) ; ; 4th - Call MAIN to commence operation of the user program ; ; 5th - Work, work, work and thent ; ; Ok, now for the real stuff. Set DE pair to point to ; CPM command line and start searching for arguments LXI D,CPMARG ; Pointer to CPM arg line LDAX D ; Load # character in line MOV B,A ; Save it in B NXTSP: INX D ; Point to next character DCR B ; Decrement character count JM ENDCMD ; End of cmd line LDAX D ; Load next character in line CPI ' ' ; Space? JZ NXTSP ; Yes...continue searching CALL SVARG ; Nope, save starting point of this arg ; Loop looking for either end of li; save it for later ; MVI C,26 LXI D,ZZBUF CALL CBDOS ; Set the default buffer out there ; SETIO: MVI B,NBUFS LXI H,ZZBUF+TBUFSZ+FLAG LXI D,FCBSIZE+BUFFER+BUFSIZ MVI A,FREEFLG SETIO2: MOV M,A ;set all buffers to free DAD D ;on to next buffer DCR B JNZ SETIO2 ;if there is one... SHLD ZZMEM ;put it where it belongs ; MVI C,25 ; get logged-in disk CALL CBDOS INR A STA ZZDFLT ; save it ; LDA CBDOS+2 ; get base of BDOS MOV H,A ; save page in HL MVI L,0 D XCHG ; DE --> Start of FCB CALL CBDOS ; Close the file POP H ; Restore scan setup POP D POP B NOPEN: DAD D ; Point to next flag DCR B ; Last one ? JNZ SCANEM ; No - keep scanning until done ; MVI C,26 LXI D,80H CALL CBDOS ; Reset the default buffer ; LHLD ZZSTAK ; Load stack pointer SPHL LDA ZZZCCP ; How do we get back ? ORA A RNZ ; this way to CCP ; ; or ; ; this way to warm boot ; LDA ZZDFLT ; Grab orig. logged-in disk MOV E,A D return to here via exit(), abort() ; or normal return from program. ; ; 6th - Close any open files (buffers are not flushed) ; ; 7th - Restore CP/M's stack pointer, select the disk you entered ; with, reset the default buffer and return to CP/M either ; via a JMP 0 (ZZZCCP = 0) or RET (ZZZCCP = 1). ; ; CBDOS EQU 5 ;/* bdos entry point */ CPMARG EQU 128 ;/* CP/M command line */ MAXARG EQU 24 ;/* Maximum number of input args */ STDIN EQU 0 STDOUT EQU 1 STDERR EQU 2 STDLST EQU 4 CBDOS EQU 5 ne of a space NXTCH: INX D ; Point to next character DCR B ; Decrement character count JM ENDWRD ; End of cmd line, but need to end arg LDAX D ; Load next character in line CPI ' ' ; Space? JNZ NXTCH ; Nope...keep looking MVI A,0 ; Yes, replace it with a zero byte STAX D JMP NXTSP ; Look for start of next arg ENDWRD: MVI A,0 STAX D ENDCMD: MVI B,0 ; Zero B (BC now is 16 bit argc) PUSH B ; First arg to main procedure LXI H,ARGV ; Point to argv array PUSH H ; Second argument to ma  CR E ; (cvt. back to 0-n) MVI C,14 ; and log it in again CALL CBDOS ; (mod to cbdos (fas)) ; JMP 0 ; ; SVARG: MOV M,E ; Save pointer to start of string INX H MOV M,D INX H INR C ; Increment argc RET PGM: DB '*',0 ; ARGV: DS MAXARG*2 ; ZZDFLT:: DB 0 ; default disk ; ZZSTAK:: DW 0 ; CP/M's stack ; ZZMEM:: DW 0 ; useable memory pointer ; ZZTEMP:: DW 0 ; available to anyone ; ; ; END ULINK f(d<4) ++d; else return ERR; *nbr=*nbr<<4; *nbr=*nbr+(*hexstr++)-t; } return d; } ; ; ZZBUF.MAC by F. A. Scacchitti 9-18-84 ; ; Default Buffer for disk I/O ; ; Used to preserve standard CP/M buffer for input arguments ; and mark the end of the code space. ; ZZBUF:: NOP END  ; File i/o storage varibles ; ; ZZUNIT:: DS 2 ;I/O structure address to act on ZZIP:: DS 2 ;int *ZZIP; ZZCHP:: DS 2 ;ch t=*nbr;t=(10*t) + (*decstr++ - '0'); if ((t>=0)&(*nbr<0)) return ERR; d++; *nbr=t; } return d; } /* ** write.c by F. A. Scacchitti 11/24/84 */ #include extern int zzbuf; write(fd,buffer,cnt) int fd, cnt; char *buffer; { int i, n; char *tbuff, flag; tbuff = &zzbuf; n = fd + 33; /* prevents fcb buffer flush */ *n = NULL; n=0; while(cnt >0){ i = 0; while(i <= 127 && cnt > 0){ tbuff[i] = buffer[n]; i++; cnt--; efine MEM 65369 pointer to first time byte for the 820-I */ #define MEM 65366 /* pointer to first time byte for the 820-II */ char array[LINSIZ]; int num[6]; int lolim[] = { 1, 1, 84, 0, 0, 0}; int hilim[] = {31, 12, 99, 23, 59, 59}; main(argc,argv) int argc, *argv; { char *entry; argv++; /* point to option */ entry = *argv; /* set up 2nd indirect pointer *entry = **argv */ switch (*entry) { case 'P': if(!gudtim(gettim())) settim(); if(gud /* ** ungetc.c by fas 8/30/84 */ #include #define FCBSIZE 36 #define UNGOT 5 ungetc(c,fd) char c, *fd;{ if(fd[FCBSIZE+UNGOT] != EOF) return(EOF); fd[FCBSIZE+UNGOT] = c; return(c); } ; ; unlink(name) ; UNLINK:: DELETE:: POP B POP D PUSH D PUSH B PUSH D ; name ; /* open file to unlink in LXI H,"r" ; Mode ; order to get fcb for it. */ PUSH H CALL FOPEN ; unit = fopen(name,'r'); POP D POP D SHLD UNIT MVIar *ZZCHP; ZZDP:: DS 2 ;char *ZZDP; ZZFILE:: DS 2 ;file name ZZMODE:: DS 2 ;char *mode;(read or write) ZZCH:: DS 2 ;char ch; ZZT:: DS 2 ;int t; ZZFN:: DS 2 ;int ZZFN; i/o function (for cpmio) ZZNUBU:: DS 2 ;# TEMPORARY BUFFER STORAGE ZZMXSC:: DS 1 ;# SECTOR COUNTER ZZSVCH:: DS 2 ;char *ZZSVCH; saved character pointer END /* ** time.c Time set/display Program by F.A.Scacchitti 9/23/84 ** Copyright 1984 25 Glenview Lane ** All righn++; } if((flag = bdos(21,fd)) != NULL) { *(fd + 40) = flag; return(n); } } return(n); } #include stdio.h /* ** xtoi -- convert hex string to integer nbr ** returns field size, else ERR on error */ xtoi(hexstr, nbr) char *hexstr; int *nbr; { int d,t; d=0; *nbr=0; while(1) { if((*hexstr>='0')&(*hexstr<='9')) t=48; else if((*hexstr>='A')&(*hexstr<='F')) t=55; else if((*hexstr>='a')&(*hexstr<='f')) t=87; else break; itim()) prntim(); break; case 'S': if(settim()) prntim(); break; default: argc = 0; break; } if (argc != 2){ prntf(" usage: time p prints time and date\n"); prntf(" time s to set time and date\n"); } } prntim(){ /* Routine to print time and date */ char *clkmem; putchar(VERTAB); clkmem = MEM; clkmem++; switch (*clkmem){ case 1: prntf("January"); break; case 2: prntf("February"); break; case 3: prntf("M C,19 ; bdos(19,unit); CALL BDOS ; (mod to cbdos(fas)) LHLD UNIT ; freeio(unit); PUSH H CALL FREEIO POP D RET ; return; UNIT: DS 2 EXTRN BDOS EXTRN FOPEN EXTRN FREEIO END ;#include stdio.h /* ** utoi -- convert unsigned decimal string to integer nbr ** returns field size, else ERR on error */ utoi(decstr, nbr) char *decstr; int *nbr; { int d,t; d=0; *nbr=0; while((*decstr>='0')&(*decstr<='9')) { ts reserved Roch, NY 14609 ** ** Written in Small-C (Version 2.09) ** ** Time Utility for the Xerox 820 ** ** time p ---> prints current time and date ** time s ---> enter time set routine ** ** This program is designed to be used with an auxiliary printf routine ** (prntf) to minimize program size. (printf may be substituted for prntf) ** (fas) ** */ #include #define CLEAR 26 #define BACKSP 8 #define SPACE 32 #define VERTAB 11 #define LINSIZ 18 /*#d  arch"); break; case 4: prntf("April"); break; case 5: prntf("May"); break; case 6: prntf("June"); break; case 7: prntf("July"); break; case 8: prntf("August"); break; case 9: prntf("September"); break; case 10: prntf("October"); break; case 11: prntf("November"); break; case 12: prntf("December"); break; default: abort('?'); } clkmem--; prntf(" %d, 19%d %02d:%02d:%02d",*clkmem++,*++clkmem,*++clkmem, *++clkmem,*+1; } } } printf(" %d primes", count); }  /* ** fa.c File Append Program by F.A.Scacchitti 9/23/84 ** ** Written in Small-C Version 2.09 or later ** ** Appends one files on to another ** ** printf may be substituted for prntf (fas) */ #include int fdin, fdin2; main(argc,argv) int argc, argv[]; { int fdin, fdin2; char c; if (argc != 3) { prntf("\nfa usage: fa hilim[i]) return(FALSE); return(TRUE); } gettim(){ /* Routine to get time data from memory to an array */ int i; char *clkmem; clkmem = MEM; for (i = 0; i <=5; i++) num[i] = *clkmem++; } /* Eratosthenes Sieve Prime Number Program in C */ /* Uses local (automatic) Variables */ #include #define SIZE } if((fdin = fopen(argv[1],"r")) == NULL) { puts("\nUnable to open input file.\n"); exit(); } if((fdout = fopen(argv[2],"w")) == NULL) { puts("\nUnable to create output file.\n"); exit(); } while((count = read(fdin,inbuf,BUFSIZE)) == BUFSIZE) { write(fdout,inbuf,count); i += count; } i += count; write(fdout,inbuf,count); fclose(fdin); fclose(fdout); } +clkmem); } settim(){ /* Routine to set time and date */ int i; char c, *clkmem; clkmem = MEM; /* Display the time set header */ putchar(CLEAR); prntf("Enter the time and date as dd/mm/yy hh:mm:ss\n"); prntf("\n eg. for 1:45 P.M. on August 12, 1984\n"); prntf(" Enter ---> 12/08/84 13:45:00\n"); prntf(" dd/mm/yy hh:mm:ss"); prntf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"); /* Get the input string */ i = -1; while (((c = getchar()) != CR) && i++ < 17) if e> \n"); exit(); } if((fdin = fopen(argv[1],"a")) == NULL) { prntf("\nUnable to open file %s\n",argv[1]); exit(); } if((fdin2 = fopen(argv[2],"r")) == NULL) { prntf("\nUnable to create file %s.\n",argv[2]); exit(); } while((c = fgetc(fdin2)) != EOF) fputc(c,fdin); fclose(fdin); fclose(fdin2); }  8190 #define SIZEP1 8191 char flags[SIZEP1]; main() { int i, prime, k, count, iter; /* variables defined here are local */ printf("10 iterations :"); for (iter = 1; iter<=10; iter ++) { count = 0; for (i = 0; i<= SIZE; i++) flags[i] = TRUE; for (i = 0; i<= SIZE; i++) { if (flags[i]) { prime = i + i + 3; k = i + prime; while (k <= SIZE) { flags [k] = FALSE; k += prime; } count = count + /* ** fc.c File Copy Program by F.A.Scacchitti 9/23/84 ** ** Written in Small-C Version 2.09 or later ** ** Copies file from file to file ** Byte modifications may be made during transfer ** ** printf may be substituted for prntf (fas) ** */ #include main(argc,argv) int argc, argv[]; { int fdin, fdout; /* file i/o channel pointers */ char c; if (argc != 3) { prntf("\nfc usage: fc \n"); exit(); } if((fdin = fope(c == BACKSP) if (i == 0){ i = -1; putchar(SPACE);} else i = i - 2; else array[i] = c; /* Convert the characters to integer values */ for (i = 0; i <= 18; i = i + 3) num[i/3] = ((array[i] - '0') * 10) + (array[i+1] - '0'); prntf("\n\n"); /* Store the values to memory if they're valid */ if (gudtim()) { for (i = 0; i <=5; i++) *clkmem++ = num[i]; return(TRUE); }else{ prntf(" Incorrect data entered - time not updated"); return(FALSE); } /* ** fb.c File Copy (Bin) Program by F.A.Scacchitti 9/23/84 ** ** Written in Small-C Version 2.09 or later ** ** Copies file from file to file ** Byte modifications may be made during transfer */ #include #define BUFSIZE 8192 main(argc,argv) int argc, argv[]; { int fdin, fdout; /* file i/o channel pointers */ int i, count; char *inbuf; i = 0; inbuf = malloc(BUFSIZE); if(argc != 3) { puts("\nfc usage: fc \n"); exit();   n(argv[1],"r")) == NULL) { prntf("\nUnable to open file %s\n",argv[1]); exit(); } if((fdout = fopen(argv[2],"w")) == NULL) { prntf("\nUnable to create file %s.\n",argv[2]); exit(); } while((c = fgetc(fdin)) != EOF) /* ** Here's where we can modify the file */ fputc(c,fdout); fclose(fdin); fclose(fdout); } /* ** ffd.c formfeed Program by F.A.Scacchitti 11/26/84 ** Copyright 1984 25 Glenview Lane ** All rights CPMDISK MAC(CPMIO MACCSEEK C  [CTELL C CTELLC C #jDELAY MAC%d(DOLDDR MAC+4DOLDIR MAC.4DTOI C 1]EXIT MAC5FEOF C 9"FERROR C ;FFLUSH C =oFGETC MACB#jFGETS MACejFILELIB MAC|Jeto create output file\n"); exit(); } while((c = fgetc(fdin)) != EOF) /* ** Here's where we modify the file */ fputc((modify(c)),fdout); fclose(fdin); fclose(fdout); } /* this routine double spaces an ascii file */ modify(c) char c; { if( c == CR) { fputc(CR,fdout); return(LF); }else return(c); }  cc -a -p -l2 $1.c >$1.mac m80 $1=$1 l80 $1,$2,$3,$4,$5,$6,$7,$8,$9,clib/s,$1/n/e ; ; abort.mac by F. A. Scacchitti 11 - 24 - 84 ; ; abort(error code) ; EXTRN EXIT ; ABORT:: ; POP B ; throw away return address POP H ; get abort code ORA A ; code passed ? JZ ABORT2 ; no - leave it as is MOV A,L STA ABCODE ; yes - imbed it in the message ABORT2: LXI D,ABTMSG ; Load abort message MVI C,9 CALL 5 JMP EXIT ; ABTMSG: DB 0DH, 'Aborted ' ; ABCODE: DB 07,0D,'$' ; END reserved Roch, NY 14609 ** ** Written in Small-C (Version 2.10) ** ** ** ** ** ** */ #include int i; main() { for(i = 1; i <= 66; i++) putlist(LF); } /* ** fm.c File Modification Program by F.A.Scacchitti 9/23/84 ** ** Written in Small-C Version 2.09 or later ** ** Copies from source file to new file modifying on the fly. ** Mod. description is in modify routine. ** ** This program may be uFPRINTF C FPUTC MACEFPUTS MACFREAD C FREBUF C FREE C `IFREEIO MACFSCANF C  FWRITE C -C2GETCHAR C /GETCHX C 1GETS MAC3DGRABIO MACFGRABUF C NsINP MACPG1ISALNUM C S| [ABORT MACABS C  ATOI C 4kATOIB C oAVAIL C xBDOS MAC CALL1 MAC%1CALL2 MAC+CALL3 MAC9CALL4 MACA91CALL5 MACF.eECALLOC C tWCLEARERRC w>{CLIB DOCyt CLIB LST /* ** abs -- returns absolute value of nbr */ abs(nbr) int nbr; { if(nbr < 0) return (-nbr); return (nbr); } #define NOCCARGC /* no argument count passing */ /* ** atoi(s) - convert s to integer. */ atoi(s) char *s; { int sign, n; while(isspace(*s)) ++s; sign = 1; switch(*s) { case '-': sign = -1; case '+': ++s; } n = 0; while(isdigit(*s)) n = 10 * n + *s++ - '0'; return (sign * n); } sed as a shell for any ascii file ** modification utilities. */ #include int fdin, fdout; /* file i/o channel pointers */ char c; /* the byte we're modifying */ main(argc,argv) int argc, argv[]; { if (argc != 3) { puts("\nfm usage: fm \n"); exit(); } if((fdin = fopen(argv[1],"r")) == NULL) { puts("\nUnable to open input file\n"); exit(); } if((fdout = fopen(argv[2],"w")) == NULL) { puts("\nUnable ISALPHA C UISASCII C VISATTY C XuISCNTRL C ZԀISDIGIT C \ISGRAPH C ]AISLOWER C ^vISPRINT C _ISPUNCT C `9SISSPACE C bW,ISUPPER C d5ISXDIGITC eHITOA C gITOAB C k/   #define NOCCARGC /* no argument count passing */ /* ** atoib(s,b) - Convert s to "unsigned" integer in base b. ** NOTE: This is a non-standard function. */ atoib(s, b) char *s; int b; { int n, digit; n = 0; while(isspace(*s)) ++s; while((digit = (127 & *s++)) >= '0') { if(digit >= 'a') digit -= 87; else if(digit >= 'A') digit -= 55; else digit -= '0'; if(digit >= b) break; n = b * n + digit; } return (n); } L AND RETURN QUOTIENT IN HL, REMAINDER IN DE ;(SIGNED DIVIDE) ; CCDIV:: DIV: MOV B,H MOV C,L MOV A,D XRA B PUSH PSW MOV A,D ORA A CM CCDENEG MOV A,B ORA A CM CCBCNEG MVI A,16 PUSH PSW XCHG LXI D,0 CCDIV1: DAD H CALL CCRDEL JZ CCDIV2 CALL CCCMPBCDE JM CCDIV2 MOV A,L ORI 1 MOV L,A MOV A,E MOV H,A ; RET ; END  ;----- call1.mac Small-C arithmetic and logical library ; ; part 1 Multiply Routine ; ; ; ; ;MULTIPLY DE BY HL AND RETURN IN HL ;(SIGNED MULTIPLY) ; CCMULT:: MULT: MOV B,H MOV C,L LXI H,0 CCMLT1: MOV A,C RRC JNC CCMLT2 DAD D CCMLT2: XRA A E SUB C MOV A,D SBB B RET END ; ;----- call3.mac Small-C arithmetic and logical library ; ; ; part 3 switch routine ; ; ; EXECUTE "SWITCH" STATEMENT ; ; HL = SWITCH VALUE ; (SP) -> SWITCH TABLE ; DW ADDR1, VALUE1 ; DW ADDR2, VALUE2 ; ... ; DW 0 ; [JMP default] ;#define NOCCARGC /* no argument count passing */ /* ** Return the number of bytes of available memory. ** In case of a stack overflow condition, if 'abort' ** is non-zero the program aborts with an 'S' clue, ** otherwise zero is returned. */ external char *zzmem avail(aburt) int aburt; { char x; if(&x < zzmem) { if(aburt) abort('M'); return (0); } return (&x - zzmem); }  SUB C MOV E,A MOV A,D SBB B MOV D,A CCDIV2: POP PSW DCR A JZ CCDIV3 PUSH PSW JMP CCDIV1 CCDIV3: POP PSW RP CALL CCDENEG XCHG CALL CCDENEG XCHG RET ; ;NEGATE THE INTEGER IN DE ;(INTERNAL ROUTINE) ; CCDENEG: MOV A,D CMA MOV D,A MOV A,E CMA MOV E,A INX D RET ;  MOV A,B RAR MOV B,A MOV A,C RAR MOV C,A ORA B RZ XRA A MOV A,E RAL MOV E,A MOV A,D RAL MOV D,A ORA E RZ JMP CCMLT1 END ; ;----- call2.mac Small-C arithmetic and logical library ; ; ; part 2 divide routine ; ; ;DIVIDE DE BY H continuation ; CCSWITCH:: XCHG ;;DE = SWITCH VALUE POP H ;;HL -> SWITCH TABLE SWLOOP: MOV C,M INX H MOV B,M ;;BC -> CASE ADDR, ELSE 0 INX H MOV A,B ORA C JZ SWEND ;;DEFAULT OR CONTINUATION CODE MOV A,M INX H CMP E MOV A,M INX H JNZ SWLOOP CMP D JNZ SWLOOP MOV H,B ;;CASE MATCHED ; ; bdos.mac by F. A. Scacchitti 9 - 18 - 84 ; ; This assembly routine allows CPM calls from Small C. ; ; bdos(function,data) or cpm(function,data) ; ; NOTE - This function only returns what the bdos call ; placed in the accumulator ; BDOS:: ; CPM:: ; POP H ; Pop rtn address POP D ; Pop input parameter in DE register pair POP B ; Pop function code into C register PUSH B ; Restore stack PUSH D PUSH H CALL 5 MOV L,A ; Sign extend A into HL register pair RLC SBB A  ;NEGATE THE INTEGER IN BC ;(INTERNAL ROUTINE) ; CCBCNEG: MOV A,B CMA MOV B,A MOV A,C CMA MOV C,A INX B RET ; ;ROTATE DE LEFT ONE BIT ;(INTERNAL ROUTINE) ; CCRDEL: MOV A,E RAL MOV E,A MOV A,D RAL MOV D,A ORA E RET ; ;COMPARE BC TO DE ;(INTERNAL ROUTINE) ; CCCMPBCDE: MOV A,  MOV L,C SWEND: PCHL END  ; ;----- call4.mac Small-C arithmetic and logical library ; ; ; part 4 arithmetic shift routines ; ; ;SHIFT DE ARITHMETICALLY RIGHT BY HL AND RETURN IN HL ; CCASR:: XCHG DCR E RM MOV A,H RAL MOV A,H RAR MOV H,A MOV A,L RAR MOV L,A JMP INX H DAD SP MOV D,H MOV E,L CALL CCGINT INX H JMP CCPINT ; ; ; CCDDPI:: CDPDPI:: ; DAD D CCPDPI:: POP B ;;RET ADDR POP D PUSH B ; ;STORE A 16-BIT INTEGER IN HL AT THE ADDRESS IN DE ; CCPINT:: PINT:: MOV A,L STAX D INX D MOV A,H STAX D RET ; ;INCLUSIVE "OR" HL AND DE INTO HL H A FULL 16-BIT INTEGER FROM THE ADDRESS IN HL ;INTO HL ; CCGINT:: MOV A,M INX H MOV H,M MOV L,A RET ; CCDECC:: INX H INX H DAD SP MOV D,H MOV E,L CALL CCGCHAR DCX H MOV A,L STAX D RET ; CCINCC:: INX H INX H DAD SP MOV D,H MOV E,L CALL CCGCHAR INX H MOV A,L  ;TEST IF DE <= HL (SIGNED) ; CCLE:: CALL CCCMP RZ RC DCX H RET ; ;TEST IF DE >= HL (SIGNED) ; CCGE:: CALL CCCMP RNC DCX H RET ; ;TEST IF DE < HL (SIGNED) ; CCLT:: CALL CCCMP RC DCX H RET ; ;COMMON ROUTINE TO PERFORM A SIGNED COMPARE ; OF DE AND HL ;THIS ROUTINE PERFORMS DE - HL  CCASR+1 ; ;SHIFT DE ARITHMETICALLY LEFT BY HL AND RETURN IN HL ; CCASL:: XCHG DCR E RM DAD H JMP CCASL+1 ; END  ; ;----- call5.mac Small-C arithmetic and logical library ; ; ; part 5 main routine - multiply, divide, switch and ; shift routines in seperate modules ; CCDCAL:: PCHL CCDDGC:: DAD D JMP CCGCHAR ; CCDSGC::  ; CCOR:: MOV A,L ORA E MOV L,A MOV A,H ORA D MOV H,A RET ; ;EXCLUSIVE "OR" HL AND DE INTO HL ; CCXOR:: MOV A,L XRA E MOV L,A MOV A,H XRA D MOV H,A RET ; ;"AND" HL AND DE INTO HL ; CCAND:: MOV A,L ANA E MOV L,A MOV A,H ANA D MOV H,A RET ; ;IN STAX D RET ; ; ; CCDDPC:: CDPDPC:: ; DAD D CCPDPC:: POP B ;;RET ADDR POP D PUSH B ; ;STORE A SINGLE BYTE FROM HL AT THE ADDRESS IN DE ; CCPCHAR:: PCHAR:: MOV A,L STAX D RET ; CCDECI:: INX H INX H DAD SP MOV D,H MOV E,L CALL CCGINT DCX H JMP CCPINT ; CCINCI:: INX H AND SETS THE CONDITIONS: ; CARRY REFLECTS SIGN OF DIFFERENCE (SET MEANS DE < HL) ; ZERO/NON-ZERO SET ACCORDING TO EQUALITY. ; CCCMP:: MOV A,H ;;INVERT SIGN OF HL XRI 80H MOV H,A MOV A,D ;;INVERT SIGN OF DE XRI 80H CMP H ;;COMPARE MSBS JNZ CCCMP1 ;;DONE IF NEQ MOV A,E ;;COMPARE LSBS CMP L CCCMP1: LXI H,1 ;;PRESET TRUE COND RET  INX H INX H DAD SP ; ;FETCH A SINGLE BYTE FROM THE ADDRESS IN HL AND ;SIGN EXTEND INTO HL ; CCGCHAR:: MOV A,M ; ;PUT THE ACCUM INTO HL AND SIGN EXTEND THROUGH H. ; CCARGC:: CCSXT:: MOV L,A RLC SBB A MOV H,A RET ; CCDDGI:: DAD D JMP CCGINT ; CCDSGI:: INX H INX H DAD SP ; ;FETC ALL THE FOLLOWING COMPARE ROUTINES, HL IS SET TO 1 IF THE ;CONDITION IS TRUE, OTHERWISE IT IS SET TO 0 (ZERO). ; ;TEST IF HL = DE ; CCEQ:: CALL CCCMP RZ DCX H RET ; ;TEST IF DE <> HL ; CCNE:: CALL CCCMP RNZ DCX H RET ; ;TEST IF DE > HL (SIGNED) ; CCGT:: XCHG CALL CCCMP RC DCX H RET ;    ; ;TEST IF DE >= HL (UNSIGNED) ; CCUGE:: CALL CCUCMP RNC DCX H RET ; ;TEST IF DE < HL (UNSIGNED) ; CCULT:: CALL CCUCMP RC DCX H RET ; ;TEST IF DE > HL (UNSIGNED) ; CCUGT:: XCHG CALL CCUCMP RC DCX H RET ; ;TEST IF DE <= HL (UNSIGNED) ; CCULE:: CALL CCUCMP RZ RCbrar followin specication describe i "Th à Programmin Language" Thi librar i combinatio o module obtaine fro Hendrix' library modifie publi domai runtim librar an module writte b myself Th followin sourc file contai th function describe i thi document: ABORT .MAC ABS .C ATOI .C ATOIB .C AVAIL .C BDOS .MAC CALL1 .MAC CALL2 .MAC CALL3 .MAC CALL4 .MAC CALL5. .MAC CALLOC .C #define NOCCARGC /* no argument count passing */ #include stdio.h /* ** Cleared-memory allocation of n items of size bytes. ** n = Number of items to allocate space for. ** size = Size of the items in bytes. ** Returns the address of the allocated block, ** else NULL for failure. */ calloc(n, size) char *n, *size; { return (Ualloc(n*size, YES)); } /* ** clearerr.c by F. A. Scacchitti 11/22/84 ** ** Clears errors and end of file marks in fd. ** */ #include C PUTCHAR .C PUTLIST .MAC PUTS .C READ .C RENAME .C REVERSE .C REWIND .C SIGN .C STRCAT .C STRCHR .C STRCMP .C STRCPY .C STRLEN .C STRNCAT .C STRNCMP .C STRNCPY .C STRRCHR .C TOASCII .C TOLOWER .C TOPOFMEM.MAC TOUPPER .C UALLOC .C ULINK .C UNGETC .C UNLINK .MAC UTOI .C WRITE .C XTOI .C ZZBUF .MAC  DCX H RET ; ;COMMON ROUTINE TO PERFORM UNSIGNED COMPARE ;CARRY SET IF DE < HL ;ZERO/NONZERO SET ACCORDINGLY ; CCUCMP:: MOV A,D CMP H JNZ CCUCP1 MOV A,E CMP L CCUCP1: LXI H,1 RET ; ;SUBTRACT HL FROM DE AND RETURN IN HL ; CCSUB:: MOV A,E SUB L MOV L,A MOV A,D SBB H MOV H,A RET ; ;FOR CLEARERR.C CPMDISK .MAC CPMIO .MAC CSEEK .C CTELL .C CTELLC .C DELAY .MAC DOLDDR .MAC DOLDIR .MAC DTOI .C FEOF .C FERROR .C FFLUSH .C FGETC .MAC FGETS .MAC FILELIB .C FPRINTF .C FPUTC .MAC FPUTS .MAC FREAD .C FREBUF .C FREE .C FREEIO .MAC FSCANF .C FWRITE .C GETCHAR .C GETCHX .C GETS .MAC GRABIO .MAC GRABUF .C INP .MAC I clearerr(fd) int fd; { *(fd + 40) = NULL; }  CLIB.DOC by F. A. Scacchitti 25 Glenview Lane Rochester, NY 14609 11 - 24 - 84 Thi 'C Librar contain mos o th function describe i J E Hendrix' "Th Small- Handbook" Thes function ar als describe i th Ma 198 Dr Dobb' Journal M intent a i his i t provid complet standar li ZZFIO .MAC Rathe tha tryin t provid Unix-lik environmen (an th resultin overhead) I'v attempte t pu packag togethe whic i mor conduciv to CP/M Thi Librar i designe t produc minimu siz file whil retainin th flavo o 'C' Man o th function ar writte i assemble and a tim permits mor function wil b optimize fo bot siz an speed Mos function containe i thi librar ar useabl wit an CP/ 8 sM THE TWO'S COMPLEMENT OF HL ; CCNEG:: CALL CCCOM INX H RET ; ;FORM THE ONE'S COMPLEMENT OF HL ; CCCOM:: MOV A,H CMA MOV H,A MOV A,L CMA MOV L,A RET CCLNEG:: MOV A,H ORA L JNZ $+6 MVI L,1 RET LXI H,0 RET ; ; END SALNUM .C ISALPHA .C ISASCII .C ISATTY .C ISCNTRL .C ISDIGIT .C ISGRAPH .C ISLOWER .C ISPRINT .C ISPUNCT .C ISSPACE .C ISUPPER .C ISXDIGIT.C ITOA .C ITOAB .C ITOD .C ITOO .C ITOU .C ITOX .C LEFT .C LEXCMP .C LIBID .C MALLOC .C MAX .C MIN .C OTOI .C OUTP .MAC PAD .C POLL .C PRNTF .  ystem however man o th I/ function interac wit eac othe a wel a th runtim routines Anyon adaptin an portion o thi librar shoul evaluat th sourc cod o th particula module(s i question A wit al libraries its valu manifest itsel whe use wit linking-loade tha ha searc capabilities (eg Microsoft M80/L80/LIB8 package) .pa FEATURES OF THE LIBRARY 104 function (5 aliases ar available includin mos standar 'C functions. Smalleloba ZZZCC place th stac a th bas o th BDO an return vi war boo. (jmp 0) Definin th globa ZZZCC place th stac a th bas o th CC an return t th CCP. ZZZCC ma b generate a compile functio vi switch o adde a th followin inlin cod t progra o heade file. #asm zzzccp:: db 1 #endasm I lef undefine i wil defaul t war boot nce However thes buffer ar no restricte t fil I/O The ma b allocate vi th grabuf( functio an deallocate vi frebuf() Cautio mus b use t insur tha an us o thes buffer doe no excee th K-byt limit Th result o failin t sta withi th limit i unpredictable. Sequentia젠 dynami㠠 memor allocation/deallocatio schem (calloc,malloc an free start a th en o th las buffe an end alloc./dealloc. schema along with the standards. .pa FUNCTIONS IN THE LIBRARY Onl th function no describe i J E Hendrix' Small- Manua, or those that differ from his, wil b described. abort(code) exit th progra displayin th "Aborted messag an optiona cod passe b th user I n cod i passe default code of control g (bell) is used. abs(nbr) int nbr atoi(str) char *str atoib(str,base) char *str; int base; avail(abort) progra siz tha mos - minimu progra siz i 25 bytes. This would be the result of the following 'C' code. #include main() { } Arg an arg ar handle b th runtim modul an alway passe t th use program maximu o 2 argument ma b passe wit 23 availabl t the user. File ma b opene i read writ o appen modes Read/writ (+ mode ar no supported. All I/O buffers are allocated outside program space including: Th linke wil indicat i a undefined wit n consequence CP/͠ integrit i maintaine b th runtim modul an restore a progra completion Also al ope file ar closed bu buffers are NOT flushed. prntf( i specia versio o print whic onl support th d c an specifications Fiel lengt specifier (whe used ar limite t siz o an fiel separato specification aren' allowe an shoul no b used Thi modul occupie 82 byte o co th stack Th use mus maintai th integrit o thi area I buffe i se fre belo on tha shoul b maintained, th schem wil indicat al memor abov an includin th release buffe i available Allocatin an usin anothe buffe a thi poin ma undesirabl wip ou dat whic should have been maintained. Optionall eliminat th war boo tha occur o progra termination Thi i accomplishe in the following manner: Definin th g int abort; bdos(fn,data) int fn, data; standar CP/ bdo cal f i th functio cod an dat i th settin o th d register Return whateve th cal places in the accumulator. calloc(nbr,sz) int nbr, sz; cfree(addr) char *addr; clearerr(fd) int fd; cpm(fn,data) same as bdos(fn,data) cpmdisk(nbr) int nbr; log in disk number nbr. cseek(fd,offset,mode) ctell(fd) int fd; ctellc(fd) int fd; delay(n) int n; dela fo millisecond, bas1 128 byte default disk I/O buffer 8 1 K byte file buffers (available for general use) Th defaul dis I/ buffe i se b th runtim modul t preserv th content o th ru strin residin a th CP/ defaul buffer Th standar defaul buffe (80h i restore a progra completion. Th堠 fil buffer ar automaticall allocate䠠 an deallocate b th fil handlin routine an th use needn' worr abou sequed space. getchx( i specia versio o getchar( whic use direc consol inpu rathe tha th standar consol input I doe no reflec character t th scree o tra th CP/͠ contro characters. grabuf( an frebuf( allo th use acces t sel managin memor allocatio scheme Eac buffe returne b grabuf( i 1 byte o memor an shoul no b exceeded Althoug thi isn' standard i doe provid somewha bom resistan (no proof memory a  e o Mh cloc (25 nanosecon cycl time). delete(name) char *name; dolddr(source, destination, n) int source, destination, n; perform z80 lddr instruction. doldir(source, destination, n) int source, destination, n; perform z80 ldir instruction dtoi(decstr, nbr) char *decstr; int nbr; exit(code) exit(); exits program and returns to CP/M fcb(fd,name) char *name; int fd; construct a file fcb on file name at location fd. (located in filel left(str) char *str; lexcmp(str1, str2) char *str1, *str2; libid() displays the date and originator of this library malloc(sz) int sz; max(a, b) int a, b; returns the greater of a or b min(a, b) int a, b; returns the lesser of a or b otoi(str,nbr) char *str; int nbr; outp(nbr,data) int nbr, data; transmits data out of port nbr. pad(dest, ch, n) char *dest, *n; int ch; poll(pause) int pause; printf(format[,arg1,arg2,...]) prntf(format[,arg1,arg2,...t I doe no reflec character t th scree o tra th CP/͠ contro characters. gets(str) char *str; grabio() return th addres o th firs availabl fil堠 I/ structure. If none is available NULL is returned. grabuf() return th addres o th firs availabl buffe i th file I/O structure. If none is available NULL is returned. inp(nbr) int nbr; returns the value read in at port nbr isalnum(c) char c; isalpha(c) chpofmem() returns base of system bdos toupper(c) char c; ualloc(n, clear) char *n; int clear; ungetc(c, fd) char c; int fd; unlink(name) same as delete(name) utoi(str, nbr) char *str; int nbr; write(fd,buffer,n) int fd, n; char *buffer; xtoi()(str, nbr) char *str; int nbr; .pa LIBRARY STRUCTURE Th clib.re Small-C syste librar module ar loade i th followin sequenc t avoi backwar referencin b L80: ULINK** LIBID* UNGETC RENAME FREAD READ FWRIib module) fclose(fd) int fd; (located in file lib module) feof(fd) int fd; ferror(fd) int fd; fflush(fd) int fd; fgetc(fd) int fd; fgets(str, sz, fd) char *str; int sz, fd; fopen(filename, mode) char *name, mode; (locate i fileli modul - onl r w an mode ) fprintf(fd, format[, arg1, ar2,...]) int fd; char *format; fputc(c, fd) char c; int fd; fputs(str, fd) char *str; int fd; fread(buffer, sz, n, fd) char *buffer; int fd, n, sz; frebuf(buff) int buf]) i specia versio o print whic onl support th d c an specifications Fiel lengt specifier (whe used ar堠 limite䠠 t siz o an䠠 fiel䠠 separato specification aren' allowe an shoul no b used putc(c, fd) same as fputc(c, fd) putchar(c) char c; putlist(c) char c; outputs character c to the list device. puts(str) char *str; read(fd, buff, n) int fd, n; char *buff rename(old,new) char *old, *new; reverse(strar c; isascii(c) char c; isatty(fd) int fd; iscntrl(c) char c; isdigit(c) char c; isgraph(c) char c; islower(c) char c; isprint(c) char c; ispunct(c) char c; isspace(c) char c; isupper(c) char c; isxdigit(c) char c; itoa(nbr, str) int nbr; char *str; itoab(nbr, str, base) int nbr, base; char *str; itod(nbr, str, sz) int nbr,sz; char *str; itoo(nbr,str,sz) int nbr,sz; char *str; itou(nbr,str,sz) int nbr,sz; char *str; itox(nbr,str,sz) int nbr,sz; char *str; TE WRITE FFLUSH REWIND CSEEK CTELL CTELLC FILELIB GRABUF* GRABIO* FREBUF* FREEIO* FPRINTF FSCANF PRNTF* FPUTS FGETS GETS PUTS FPUTC FGETC PUTCHAR GETCHAR GETCHX* CPMIO* CPMDISK* PUTLIST* CALLOC MALLOC UALLOC* AVAIL* FREE POLL* ABS ATOI ATOIB DTOI ISALNUM ISALPHA ISASCII ISATTY ISCNTRL ISDIGIT ISGRAPH ISLOWER ISPRINT ISPUNCT ISSPACE ISUPPER ISXDIGIT ITOA ITOAB ITOD ITOO ITOU ITOX LEFT LEXCf; fre th buffe buf allocate b grabuf( an mak i available for use. free(addr) same as cfree(addr) freeio(fd) int fd; fre th fil structur allocate b grabio( an mak i available for use. fscanf(fd, format, arg, arg, . . . ) fwrite(buff, sz, n, fd) char *buf; int sz, n, fd; getc(fd) same as fgetc(fd) getchar() getchx( i specia versio o getchar( whic use direc consol inpu rathe tha th standar consol inpu) char *str; rewind(fd) int fd; scanf(format, arg1, arg2, . . .) sign(nbr) int nbr; strcat(dest, sour) char *dest, *sour; strchr(str, c) char *str, c; strcmp(str1, str2) char *str1, *str2; strcpy(dest, sour) char *dest, *sour; strlen(str) char *str; strncat(dest, sour, n) char *dest, *sour; int n; strncmp(str1, str2, n) char *str1, *str2; int n; strncpy(dest, sour, n) char *dest, *sour; int n; strrchr(str, c) char *str, c; toascii(c) char c; tolower(c) char c; to  MP OTOI REVERSE SIGN STRCAT STRCHR STRCMP STRCPY STRLEN STRNCAT STRNCMP STRNCPY STRRCHR TOASCII TOLOWER TOUPPER UTOI XTOI PAD FEOF FERROR CLEARERR DELAY* DOLDDR* DOLDIR* INP* OUTP* TOPOFMEM* UNLINK MIN* MAX* CALL1** CALL2** CALL3** CALL4** CALL5** BDOS* ABORT ZZFIO** ZZBUF** * indicates a non standard function ** indicates a system function SYSTEM MODULES Refe t th sourc file o th.C #STRLEN.C #STRNCAT.C #STRNCMP.C #STRNCPY.C #STRRCHR.C #TOASCII.C #TOLOWER.C #TOPOFMEM.MAC #TOUPPER.C #UALLOC.C #ULINK.MAC #UNGETC.C #UNLINK.MAC #UTOI.C #WRITE.C #XTOI.C #ZZBUF.MAC #ZZFIO.MAC ; ; cpmdisk(disk) ; ; F. A. Scacchitti 8/4/84 ; CBDOS EQU 5 ;/* bdos entry point */ LF EQU 10 EOL EQU 13 ; ; CP/M BDOS CALLS ; SELECT EQU 14 ;log-in a drive ; ; CPMDISK:: POP D POP H PUSH H PUSH D MOV A,L ; if(d~=0) ORA H JZ  an serve t mar th startin poin fo I/ buffer an th dynami memor allocation scheme.  #ABS.C #ATOI.C #ATOIB.C #AVAIL.C #BDOS.MAC #CALL1.MAC #CALL2.MAC #CALL3.MAC #CALL4.MAC #CALL5.MAC #CALLOC.C #CPMDISK.MAC #CPMIO.MAC #CSEEK.C #CTELL.C #CTELLC.C #DELAY.MAC #DOLDDR.MAC #DOLDIR.MAC #DTOI.C #EXIT.MAC #FFLUSH.C #FGETC.MAC #FGETS.MAC #FILELIB.MAC #FPRINTF.C #FPUTC.MAC #FPUTS.MAC #FREAD.C #FREBUF.C #FREE.C #FREEIO.MAC #FSCANF.C #FWRITE.Clt cpm buffer LF EQU 10 EOL EQU 13 ; ; CP/M BDOS CALLS ; CLOSE EQU 16 ;close a file CPMSTR EQU 9 ;print '$' delimited string on console CREATE EQU 22 ;make a file DMA EQU 26 ;set DMA (I/O address) DELETE EQU 19 ;delete a file GETCH EQU 1 ;read character from console GETSTR EQU 10 ;read string from console LSTOUT EQU 5 ;write character to list device OPEN EQU 15 ;open a file PUTCH EQU 2 ;write character to console QUERY EQU 25 ;get logged-in drive id READ EQU 20 ;read a sector SELECT EQU 1es module fo mor detail regarding operation. ULINˠ (25 bytes contain th routine t stee th 'C progra fro CP/ t th use progra an bac agai t CP/M Thi modul i th onl on i th librar t hav a entr poin define a startin point therefor th progra wil alway star here CALL (3 bytes contain th cod t suppor th multipl operator. ( * ) CALL (9 bytes contain th cod t suppor th divid and modulus operators. ( / DISKIF1 XCHG ; cpm(SELECT,d-1); DCX D MVI C,SELECT CALL CBDOS ; (mod fas) DISKIF1: RET END ; ; cpmio(fn,unit) ; ; F. A. Scacchitti 9/4/84 ; CBDOS EQU 5 ;/* bdos entry point */ CPMARG EQU 128 ;/* CP/M command line */ MAXARG EQU 32 ;/* Maximum number of input args */ STDIN EQU 0 STDOUT EQU 1 STDERR EQU 2 STDLST EQU 4 CTRLZ EQU 26 ;control z NULL EQU 0 ;pointer to nothing FCBSIZE EQU 36 ;size, in bytes, of an FCB NEXTP EQU 0 ;offset to next-character pointer  #GETCHAR.C #GETCHX.C #GETS.MAC #GRABIO.MAC #GRABUF.C #INP.MAC #ISALNUM.C #ISALPHA.C #ISASCII.C #ISATTY.C #ISCNTRL.C #ISDIGIT.C #ISGRAPH.C #ISLOWER.C #ISPRINT.C #ISPUNCT.C #ISSPACE.C #ISUPPER.C #ISXDIGIT.C #ITOA.C #ITOAB.C #ITOD.C #ITOO.C #ITOU.C #ITOX.C #LEFT.C #LEXCMP.C #LIBID.C #MALLOC.C #MAX.C #MIN.C #OTOI.C #OUTP.MAC #PAD.C #POLL.C #PRNTF.C #PUTCHAR.C #PUTLIST.MAC #PUTS.C #READ.C #RENAME.C #REVERSE.C #REWIND.C #SIGN.C #STRCAT.C #STRCHR.C #STRCMP.C #STRCPY4 ;log-in a drive WRITE EQU 21 ;write a sector ; ; File i/o storage varibles found in ulink() ; EXTRN ZZUNIT EXTRN ZZIP EXTRN ZZCHP EXTRN ZZDP EXTRN ZZFILE EXTRN ZZMODE EXTRN ZZCH EXTRN ZZT EXTRN ZZFN EXTRN ZZNUBU EXTRN ZZMXSC ; ; Characteristics variable storage found in ulink() ; EXTRN ZZSVCH EXTRN ZZDFLT EXTRN ZZSTAK EXTRN ZZMEM ; EXTRN CPMDISK ; ; Default disk I/O buffer ; EXTRN ZZBUF ; CPMIO:: POP B POP D POP H SHLD ZZFN XCHG SHLD ZZUNIT PUSH D PUSH H PU % ) CALL (2 bytes contain th cod t suppor th switc statement. CALL (2 bytes contain th cod t suppor th righ an lef shif operators. ( >> << ) CALL (23 bytes contain th cod t suppor al othe arithmeti an logica operator a wel a memor an addres fetch and store operations. ZZFIϠ (23 bytes contain storag fo globa variable use b file I/O and fgetc, fputc, etc . . . ZZBUƠ ( byte i th las modul i th librarin I/O structure UNUSED EQU 2 ;offset to unused-positions-count in I/O structure BUFFER EQU 6 ;offset to disk sector buffer in I/O structure UNGOT EQU 5 ;offset to char ungotten by ungetc() FLAG EQU 33 ;file-type flag byte (in unused part of FCB) FREEFLG EQU 128 ;This I/O structure is available for the taking EOFFLG EQU 2 ;The end of this file has been hit WRTFLG EQU 1 ;This file open for writing BUFSIZ EQU 1024 ;how long the sector buffer is NBUFS EQU 8 ;number of I/O buffers TBUFF EQU 128 ;defau  SH B LHLD ZZUNIT ; cpmdisk(*unit); MOV L,M MVI H,0 PUSH H CALL CPMDISK POP H LHLD ZZUNIT ; ZZIP = unit+FCBSIZE; LXI D,FCBSIZE ; cpm(DMA,&ZZIP[BUFFER]); DAD D LXI D,BUFFER DAD D SHLD ZZNUBU ;# SAVE TO UPGRADE DURING LOOPING XCHG MVI C,DMA CALL CBDOS ; (mod fas) LHLD ZZFN ; t = cpm(ZZFN,unit); MOV C,L MVI A,8 ;# READ/WRITE UP TO 8 SECTORS STA ZZMXSC ;# SAVE IT LHLD ZZUNIT XCHG IOLOOP: PUSH H ;# NEW CONSTRUCT TO ACCOMODATE 1K BUFFERS PUSH D ;# SAVE IT A 1){ fcbdata[33] = 0; if(cpmio(20,fd) == EOF); if(zzmxsc == 8) return(EOF); unused = 1024 - (zzmxsc * 128); }else{ unused = 0; } *(fd + 38) = unused; *(fd + 36) = fd + 42; return (NULL); } getval(offset) int offset;{ zzzext = offset / 80; zzzrec = offset % 80; } gettof(fcbdata) char *fcbdata; { int tempofs; return(fcbdata[12] * 80 + fcbdata[32]); } #include stdio.h /* ** cseek(fd,offset,base) by F.A.Scacchitti 9/15/84 ** ** Position fd to the 128-byte record indicated by ** "offset" relative to the point indicated by "base." ** ** BASE OFFSET-RELATIVE-TO ** 0 first record ** 1 current record ** 2 end of file (last record + 1) ** ** Returns NULL on success, else EOF. */ extern char zzmxsc; char zzzext, zzzrec; cseek(fd, offset, base) int fd, offset, base; { char *fcbdata; int tempofs,  3997 cycles @ 250 nanosec per ; --------------------------- ; 0.99925 milliseconds ; ; ; Delay Loop set for 10 usec. per count based on 4 MHz clock ; DELAY2: DCX B ;# 5 ORA A ;# 4 ORA A ;# 4 MOV A,B ;# 5 ORA C ;# 4 JNZ DELAY2 ;# 10 RET ;# ;#------ ;# 32 cycles @ 250 nanosec per = 12.5 usec. END  ; lddr(source, dest, n) DOLDDR:: INX SP ; Skip over return address INX SP POP B ; Load n POP D ; Load destination LL FOR REPEAT PERFORMANCE PUSH B ; PUSH H ;# DON'T WRITE BLANKS MOV A,C CPI READ POP H JZ NOWRIT PUSH H LHLD ZZNUBU MOV A,M POP H CPI 1AH ;# END OF FILE CHAR ? JZ IOEXIT ; NOWRIT: CALL CBDOS ;# READ/WRITE A SECTOR PUSH PSW CALL CCSXT## SHLD ZZT POP PSW ORA A ;# CHECK FOR LAST SECTOR JNZ IOEXIT ;# IF LAST GET OUT OF HERE LDA ZZMXSC DCR A ;# CHECK FOR 8 SECTORS DONE JZ IOEXIT STA ZZMXSC LHLD ZZNUBU ;# GET BUFFER ADDRESS LXI D,128 DAD D ;# COMPUTE  /* ** ctell.c by F. A. Scacchitti 9/11/84 */ #define NOCCARGC #include ctell(fd) int fd; { char *fcb; int bsec, osec, t; fcb = fd; bsec = (*(fd + 36) - fd - 42) / 128 ; t = fcb[32]; if((osec = t % 8) == 0 && t != 0) osec = 8; if(t < 0) t = 128; return((fcb[12] * 128) + t - osec + bsec); }  /* ** ctellc.c by F. A. Scacchitti 9/11/84 */ #define NOCCARGC #include ctellc(fd) int fd; { return(( unused; fcbdata = fd; switch (base) { case 0: getval(offset); break; case 1: tempofs = gettof(fcbdata); if(tempofs >= 8) tempofs -= (8 - zzmxsc); getval(tempofs + offset); break; case 2: while(bdos(20, fd) == NULL); tempofs = gettof(fcbdata); getval(tempofs - offset); break; default: return (EOF); } fcbdata[12] = zzzext; fcbdata[32] = zzzrec; if(fcbdata[33] != POP H ; Load source DB 0EDH, 0B8H ; Do LDDR instruction PUSH H ; Restore stack PUSH D PUSH B DCX SP DCX SP RET END  ; doldir(source, dest, n) DOLDIR:: INX SP ; Skip over return address INX SP POP B ; Load n POP D ; Load destination POP H ; Load source DB 0EDH, 0B0H ; Do LDIR instruction PUSH H ; Restore stack PUSH D PUSH B DCX SP DCX SP RET NEW BUFFER ADDRESS SHLD ZZNUBU ;# SAVE TIL NEXT TIME XCHG MVI C,DMA CALL CBDOS ;# SET THE NEW BUFFER POP B POP D POP H JMP IOLOOP IOEXIT: POP B ;# CLEAN UP POP D POP H MVI C,DMA ; cpm(DMA,ZZBUF); LXI D,ZZBUF CALL CBDOS ; (mod fas) LHLD ZZT ; if(t~=0) return(-1); MOV A,H ; else return(0); ORA L JNZ CPMIF1 LXI H,0 JMP CPMIF2 CPMIF1: LXI H,-1 CPMIF2: RET ; END *(fd + 36) - fd - 42) % 128 ); } ; ; delay(n) ; int n; ; ; n = number of milliseconds to delay ; DELAY:: POP H ; Return address POP D ; Delay Value PUSH D ; Restore Stack PUSH H ; DELAY1: ;# 51 (overhead) 12.5 usec. LXI B,123 ;# 10 CALL DELAY2 ;# 3963 (17 + 10 + (123 X 32)) DCX D ;# 5 MOV A,D ;# 5 ORA E ;# 4 JNZ DELAY1 ;# 10 RET ;-------- ;    END #define NOCCARGC /* no argument count passing */ #include stdio.h /* ** dtoi -- convert signed decimal string to integer nbr ** returns field length, else ERR on error */ dtoi(decstr, nbr) char *decstr; int *nbr; { int len, s; if((*decstr)=='-') {s=1; ++decstr;} else s=0; if((len=utoi(decstr, nbr))<0) return ERR; if(*nbr<0) return ERR; if(s) {*nbr =U 4 CTRLZ EQU 26 ;control z NULL EQU 0 ;pointer to nothing FCBSIZE EQU 36 ;size, in bytes, of an FCB NEXTP EQU 0 ;offset to next-char. pointer in I/O struct. UNUSED EQU 2 ;offset to unused-pos.-count in I/O struct. BUFFER EQU 6 ;offset to disk sector buf. in I/O struct. UNGOT EQU 5 ;offset to char ungotten by ungetc() FLAG EQU 33 ;file-type flag byte (in unused part of FCB) FREEFLG EQU 128 ;This I/O structure is available for the taking EOF EQU 0FFH ;# END OF FILE BYTE FOR UNGOTTEN CHAR ID EOFFLG.h> ferror(fd) int fd; { char c; c = *(fd + 40); return(c == EOF ? FALSE : c); }  /* ** fflush.c by F. A. Scacchitti 9/15/84 */ #define WRITE 1 #define OPEN 15 #include fflush(fd) int fd; { int unused, charptr; char mode, record, extent; mode = *(fd + 33); if(mode != WRITE) return(NULL); charptr = *(fd + 36); unused = *(fd + 38); extent = *(fd + 12); record = *(fd + 32); if(fclose(fd) != NULL || bdZZDFLT EXTRN ZZSTAK EXTRN ZZMEM ; EXTRN GETCHAR EXTRN CPMIO ; FGETC:: GETC:: POP B POP H ; get args PUSH H PUSH B ; c=cget(unit); PUSH H CALL CGET POP D MOV A,L ; if(c=='\r') ANI 7FH ; /* mask parity in compare */ CPI EOL JNZ GETCRET PUSH H ; cget(unit); PUSH D ; /* to skip LF */ CALL CGET POP H POP H GETCRET: RET ; ; cget(unit) ; CGET:: POP D POP H PUSH H PUSH D MOV A,H ORA A ; if(unit < 256) { JNZ CGET1 ; /* assume stdin */  -*nbr; return ++len;} else return len; } ; exit.mac by F. A. Scacchitti 9 - 18 - 84 ; ; abort(error code) ; ; EXTRN ZZFINI ; EXIT:: ; ABORT:: ; POP B ; throw away return address POP H ; get abort code ORA A ; code passed ? JZ ABORT2 ; no - leave it as is MOV A,L STA ABCODE ; yes - imbed it in the message ABORT2: LXI D,ABTMSG ; Load abort message MVI C,9 CALL 5 JMP ZZFINI ; ABTMSG: DB 0 EQU 2 ;The end of this file has been hit WRTFLG EQU 1 ;This file open for writing BUFSIZ EQU 1024 ;how long the sector buffer is NBUFS EQU 8 ;number of I/O buffers TBUFF EQU 128 ;default cpm buffer LF EQU 10 EOL EQU 13 ; ; CP/M BDOS CALLS ; CLOSE EQU 16 ;close a file CPMSTR EQU 9 ;print '$' delimited string on console CREATE EQU 22 ;make a file DMA EQU 26 ;set DMA (I/O address) DELETE EQU 19 ;delete a file GETCH EQU 1 ;read character from console GETSTR EQU 10 ;read string from console LSos(OPEN,fd) < NULL) return(EOF); *(fd + 36) = charptr; *(fd + 38) = unused; *(fd + 12) = extent; *(fd + 32) = record; *(fd + 33) = mode; return(NULL); } ; ; ; fgetc(unit) by F. A. Scacchitti 11 - 24 - 84 ; ; getc(unit) ; ; CBDOS EQU 5 ;/* bdos entry point */ CPMARG EQU 128 ;/* CP/M command line */ MAXARG EQU 32 ;/* Maximum number of input args */ STDIN EQU 0 STDOUT EQU 1 STDERR EQU 2 STDLST EQ CALL GETCHAR ; getchar(); POP D ;/* return to caller of getc() POP D ; to bypass CR check */ RET ; return; } CGET1: SHLD ZZUNIT LXI D,FLAG ; if(unit[FLAG] & EOF_FL) DAD D MOV A,M ANI EOFFLG JZ GTCIF1 LXI H,-1 ; return(-1); RET GTCIF1: LHLD ZZUNIT ; ip = unit + FCBSIZE; LXI D,FCBSIZE DAD D SHLD ZZIP ; LXI D,UNGOT ;# CHECK FOR UNGOTTEN CHAR. DAD D MOV A,M CPI EOF ;# IS IT EOF ? JZ GTCCON ;# YES-CONTINUE WITH FGETC MOV B,A ;# NO-LET'S GET THE DH, 'Aborted ' ; ABCODE: DB 07,0D,'$' ; END /* ** feof.c by F. A. Scacchitti 11/22/84 ** ** Returns true only if end of file is reached. ** */ #include feof(fd) int fd; { char c; c = *(fd + 40); return(c == EOF ? TRUE : FALSE); } /* ** ferror.c by F. A. Scacchitti 11/22/84 ** ** Returns true only if a file error has occurred. ** */ #include 255 */ ORA A JZ FGETS3 POP D ; cp LHLD ZZSVCH ; if (cp<>save_cp) XCHG ; /* read something */ MOV A!  ; fcbsize() ; ; ; Now then here's the file i/o code ; CBDOS EQU 5 ;/* bdos entry point */ CPMARG EQU 128 ;/* CP/M command line */ MAXARG EQU 32 ;/* Maximum number of input args */ STDIN EQU 0 STDOUT EQU 1 STDERR EQU 2 STDLST EQU 4 CTRLZ EQU 26 ;control z NULL EQU 0 ;pointer to nothing FCBSIZE EQU 36 ;size, in bytes, of an FCB NEXTP EQU 0 ;offset to next-char. pointer in I/O struct. UNUSED EQU 2 ;offset to unused-pos.-count in I/O struct. BUFFER EQU 6 ;offset to disk sector buf. in I/O struc# CLEAR IT ; LHLD ZZIP ;ZZIP[NEXTP]=&ZZIP[BUFFER]; LXI D,BUFFER DAD D XCHG LHLD ZZIP LXI B,NEXTP DAD B MOV M,E INX H MOV M,D LHLD ZZUNIT ; fcb(unit,name); PUSH H LHLD ZZFILE PUSH H CALL FCB POP H POP H LHLD ZZUNIT ; cpmdisk(*unit); MOV L,M MVI H,0 PUSH H CALL CPMDISK POP H LHLD ZZMODE ;if(*mode=='R'||*mode=='A'){ MOV A,M ; ANI 5FH ;# CONVERT TO UPPERCASE CPI 'R' ;# MODE = R ? JNZ FOPIF1 ; FOPIF0: MVI C,OPEN ; if(cpm(OPEN,unit)<0){ ZZCHP EXTRN ZZDP EXTRN ZZFILE EXTRN ZZMODE EXTRN ZZCH EXTRN ZZT EXTRN ZZFN EXTRN ZZNUBU EXTRN ZZMXSC EXTRN ZZSVCH ; ; ; ; Characteristics variable storage found in ulink() ; ; EXTRN ZZDFLT EXTRN ZZSTAK EXTRN ZZMEM EXTRN ZZTEMP ; ; Start of file buffers found at end of program ; EXTRN GRABIO EXTRN FREEIO EXTRN CPMIO EXTRN CPMDISK ; ; Required to set buffer in append mode ; EXTRN PUTC ; ; Default disk I/O buffer ; EXTRN ZZBUF ; ; Storage variables used by append mode ; Cod to cbdos(fas)) ORA A JP FOPIF3 LHLD ZZUNIT ; freeio(unit); PUSH H CALL FREEIO POP H LXI H,NULL ; return(NULL); RET ; } FOPIF3: LHLD ZZIP ; ZZIP[UNUSED] = BUFSIZ; LXI D,UNUSED DAD D LXI D,BUFSIZ MOV M,E INX H MOV M,D LHLD ZZUNIT ; unit[FLAG] = WRITE_FL; LXI D,FLAG DAD D MVI A,WRTFLG ORA M MOV M,A JMP FOPIF4 ; } FOPIF5: LHLD ZZUNIT ; else{ freeio(unit); PUSH H CALL FREEIO POP H LXI H,NULL ; return(NULL); RET ; ; } FOPIF4: t. UNGOT EQU 5 ;offset to char ungotten by ungetc() FLAG EQU 33 ;file-type flag byte (in unused part of FCB) FREEFLG EQU 128 ;This I/O structure is available EOF EQU 0FFH EOFFLG EQU 2 ;The end of this file has been hit WRTFLG EQU 1 ;This file open for writing BUFSIZ EQU 1024 ;how long the sector buffer is NBUFS EQU 8 ;number of I/O buffers TBUFF EQU 128 ;default cpm buffer LF EQU 10 EOL EQU 13 ; ; CP/M BDOS CALLS ; CLOSE EQU 16 ;close a file CPMSTR EQU 9 ;print '$' delimited string on conso LHLD ZZUNIT XCHG CALL CBDOS ; (mod tocbdos (fas)) ORA A JP FOPIF2 LHLD ZZUNIT ; freeio(unit); PUSH H CALL FREEIO POP H LXI H,NULL ; return(NULL); RET ; } FOPIF2: LHLD ZZIP ; ZZIP[UNUSED] = 0; LXI D,UNUSED DAD D LXI D,0 MOV M,E INX H MOV M,D ; } JMP FOPIFX FOPIF1: ; else if(*mode=='W'){ LHLD ZZMODE MOV A,M ANI 5FH CPI 'W' ;# WRITE MODE ? JZ FOPIFA ;# YES - GO DO IT CPI 'A' ;# APPEND MODE ? JNZ FOPIF5 ;# NO - BACK TO CALLER OF FOPURREC: DB 0 CUREXT: DB 0 OLDREC: DB 0 OLDEXT: DB 0 ; ; fopen(name,mode) ; FOPEN:: ; POP B ;get args POP H ;mode SHLD ZZMODE POP D XCHG SHLD ZZFILE PUSH H PUSH D PUSH B CALL GRABIO ; unit = grabio(); SHLD ZZUNIT MOV A,H ; if(unit==NULL) ORA L ; return(NULL); RZ LXI D,FCBSIZE ; ZZIP = unit+FCBSIZE; DAD D SHLD ZZIP ; LXI D,UNGOT ;# OFFSET TO UNGOTTEN CHAR DAD D MVI M,0FFH ;# EOF TO AVOID EXTRA CHAR ; DCX H ;# POINT TO ERROR BYTE MVI M,0 ;; LHLD ZZMODE ;# MOV A,M ;# GET MODE ANI 5FH CPI 'A' ;# APPEND MODE ? JNZ FOPIFX ;# NO - RETURN NORMALLY ; AMSCRD: ; LDA CUREXT ;# SAVE EXTENT AND RECORD NUMBERS STA OLDEXT ;# TWO DEEP LDA CURREC STA OLDREC LHLD ZZUNIT LXI D,12 DAD D MOV A,M ;# GET CURRENT EXTENT # STA CUREXT LXI D,20 DAD D MOV A,M ;# GET CURRENT RECORD # STA CURREC ; LHLD ZZUNIT ;# YES - LET'S READ TO THE END XCHG ;# DE --> FCB MVI C,READ CALL CBDOS ;# READ A SECTOR ORA A le CREATE EQU 22 ;make a file DMA EQU 26 ;set DMA (I/O address) DELETE EQU 19 ;delete a file GETCH EQU 1 ;read character from console GETSTR EQU 10 ;read string from console LSTOUT EQU 5 ;write character to list device OPEN EQU 15 ;open a file PUTCH EQU 2 ;write character to console QUERY EQU 25 ;get logged-in drive id READ EQU 20 ;read a sector SELECT EQU 14 ;log-in a drive WRITE EQU 21 ;write a sector ; ; ; File i/o storage varibles found in ZZFIO.MAC ; ; EXTRN ZZUNIT EXTRN ZZIP EXTRN EN ; ;# NO MODES LEFT TO TRY ; MVI C,OPEN ;# FIRST LET'S SEE IF IT'S THERE LHLD ZZUNIT XCHG CALL CBDOS ORA A JP FOPIF3 ;# YES - SET IT UP FOR USE ; ;# NO - LET'S MAKE ONE LHLD ZZMODE ;# SET MODE TO 'W' ON NEW FILE MVI M,'W' ;# TO AVOID WASTING TIME AND CODE ;# SEARCHING AN EMPTY FILE ; FOPIFA: MVI C,DELETE ; cpm(DELETE,unit); LHLD ZZUNIT XCHG CALL CBDOS ; (mod to cbdos(fas)) MVI C,CREATE ; if(cpm(CREATE,unit)<0){ LHLD ZZUNIT XCHG CALL CBDOS ; (m"   JZ AMSCRD ;# READ TO PHYSICAL END OF FILE ; LHLD ZZUNIT LXI D,12 DAD D LDA OLDEXT MOV M,A ;# RESTORE LAST EXTENT # LXI D,20 DAD D LDA OLDREC MOV M,A ;# RESTORE LAST RECORD # ; LXI H,ZZBUF SHLD ZZTEMP ;# SAVE THE BUFF. WE'RE READING FROM AMCHRD: LHLD ZZTEMP ;# HL --> TEMPORARY BUFFER MOV A,M ; CPI 0AH ;# LINE FEED CHECK JNZ NOTLF INX H ;# INCREMENT POINTER SHLD ZZTEMP ;# AND GO ON TO NEXT CHARACTER JMP AMCHRD ; NOTLF: CPI 1AH ;# END OF FILE MARKER ? JZ case? */ JC FCBIF2 SUI 61H-41H ; A -= 'a'-'A' JMP FCBIF2 ; } FCBIF1: LDA ZZDFLT ; else A = default_drive; FCBIF2: STAX B ; *fp++ = A; INX B MVI H,' ' ; fp = fcbfill(fp,name,' ',8); MVI L,8 CALL FCBFILL MVI L,3 ; fp = fcbfill(fp,name,' ',3); CALL FCBFILL MVI H,0 ; fp = fcbpad(fp,0,4); MVI L,4 CALL FCBPAD LXI H,16 ; fp[16] = 0; DAD B MVI M,0 RET ; return; ; ; fcbfill(dest,name,pad,size) ; B D H L ; FCBFILL:: MOV A,L ; while(L>0 && (A= *D)~='. D SHLD ZZDP FCLWH1: ; while(cp='a' && A<='z') JC FILL1 CPI 7AH+1 ; 'z' 9 Jun 80 rj JNC FILL1 SUI 61H-41H ; A = A - 'a' + 'A'; FILL1: STAX B ; *B++ = A; INX B INX D ; D++; DCR L ; L--; JMP FCBFILL ; } FILL2: LDAX D ; while(*D~='.' && *D~=0) CPI '.' JZ FILL3 CPI 0 JZ FILL3 INX D ; D++; JMP FILL2 FILL3: CPI '.' ; if(*D=='.') JNZ FILL4 INX D ; D++; FILL4: ; fall into... ; ; fcbpad(dest,paNIT XCHG CALL CBDOS ; (mod tocbdos(fas)) ORA A JP FCLIF5 LXI H,0 ; t = 0; SHLD ZZT FCLIF5: LHLD ZZUNIT ; freeio(unit); PUSH H CALL FREEIO POP H LHLD ZZT ; return(NULL+t); RET ; ; fcb(fp,name) ; FCB:: POP H ;get args POP D ;name POP B ;fp PUSH B PUSH D PUSH H INX D ; if(name[1]==':'){ LDAX D DCX D CPI ':' JNZ FCBIF1 LDAX D ; A = *name - '@'; SUI 40H ; '@' 9 Jun 80 rj INX D ; name += 2; INX D CPI 61H-41H ; if(A>'a'-'A') /* lowerturn(Uprint(stdout, CCARGC() + &argc - 1)); } /* ** Uprint(fd, ctlstring, arg, arg, ...) ** Called by fprintf() and printf(). */ Uprint(fd, nxtarg) int fd, *nxtarg; { int arg, left, pad, cc, len, maxchr, width; char *ctl, *sptr, str[17]; cc = 0; ctl = *nxtarg--; while(*ctl) { if(*ctl!='%') {fputc(*ctl++, fd); ++cc; continue;} else ++ctl; if(*ctl=='%') {fputc(*ctl++, fd); ++cc; continue;} if(*ctl= MVI L,0 RZ ; return NULL; LXI H,1 ; t = 1; SHLD ZZT LHLD ZZUNIT ; if(unit[FLAG] & WRITE_FL){ LXI D,FLAG DAD D MOV A,M ANI WRTFLG JZ FCLIF1 LXI H,CTRLZ ; putc(CTRL_Z,unit); PUSH H LHLD ZZUNIT PUSH H CALL PUTC POP H POP H LHLD ZZUNIT ; ZZIP = unit + FCBSIZE; LXI D,FCBSIZE DAD D SHLD ZZIP LHLD ZZIP ; cp = ZZIP[NEXTP]; LXI D,NEXTP DAD D MOV E,M INX H MOV D,M XCHG SHLD ZZCHP LHLD ZZIP ; ZZDP = &ZZIP[BUFFER]+BUFSIZ; LXI D,BUFFER+BUFSIZ DADd,size) ; B H L ; FCBPAD:: MOV A,L ; while(L>0){ ORA A JZ PAD2 MOV A,H ; *B++ = H; STAX B INX B DCR L ; L--; JMP FCBPAD ; } PAD2: RET ; return; ; ; END #define NOCCARGC /* ** Yes, that is correct. Although these functions use an ** argument count, they do not call functions which need one. */ #include stdio.h /* ** fprintf(fd, ctlstring, arg, arg, ...) - Formatted print. ** Operates as described#  ='-') {left = 1; ++ctl;} else left = 0; if(*ctl=='0') pad = '0'; else pad = ' '; if(isdigit(*ctl)) { width = atoi(ctl++); while(isdigit(*ctl)) ++ctl; } else width = 0; if(*ctl=='.') { maxchr = atoi(++ctl); while(isdigit(*ctl)) ++ctl; } else maxchr = 0; arg = *nxtarg--; sptr = str; switch(*ctl++) { case 'c': str[0] = arg; str[1] = NULL; break; case 's': sptr = arg; break; U 21 ;write a sector ; ; File i/o storage varibles found in ulink() ; EXTRN ZZUNIT EXTRN ZZIP EXTRN ZZCHP EXTRN ZZDP EXTRN ZZFILE EXTRN ZZMODE EXTRN ZZCH EXTRN ZZT EXTRN ZZFN EXTRN ZZNUBU EXTRN ZZMXSC ; ; Characteristics variable storage found in ulink() ; EXTRN ZZSVCH EXTRN ZZDFLT EXTRN ZZSTAK EXTRN ZZMEM ; EXTRN PUTCHAR EXTRN PUTLIST EXTRN CPMIO ; FPUTC:: PUTC:: POP B ;rtn addr POP D ;unit POP H ;c PUSH H PUSH D PUSH B MOV A,D ORA A ; if(unit < 256) { JNZ PUU 2 ;offset to unused-positions-count in I/O structure BUFFER EQU 6 ;offset to disk sector buffer in I/O structure UNGOT EQU 5 ;offset to char ungotten by ungetc() FLAG EQU 33 ;file-type flag byte (in unused part of FCB) FREEFLG EQU 128 ;This I/O structure is available for the taking EOFFLG EQU 2 ;The end of this file has been hit WRTFLG EQU 1 ;This file open for writing BUFSIZ EQU 1024 ;how long the sector buffer is NBUFS EQU 8 ;number of I/O buffers TBUFF EQU 128 ;default cpm buffer LF EQU 10 EZZIP LXI D,NEXTP ; cp = ip[NEXTP]; DAD D MOV E,M INX H MOV D,M XCHG SHLD ZZCHP LHLD ZZIP ; if(ip[UNUSED]==0){ LXI D,UNUSED DAD D MOV A,M INX H ORA M JNZ PTCIF1 LXI H,WRITE ; if(cpmio(WRITE,unit)~=0) PUSH H LHLD ZZUNIT PUSH H CALL CPMIO POP D POP D MOV A,H ORA L JZ PTCIF2 LXI H,-1 ; return(-1); RET PTCIF2: LHLD ZZIP ; else { ip[UNUSED] = BUFSIZ; LXI D,UNUSED DAD D LXI D,BUFSIZ MOV M,E INX H MOV M,D LHLD ZZIP ; cp = &ip[BUFFER case 'd': itoa(arg,str); break; case 'b': itoab(arg,str,2); break; case 'o': itoab(arg,str,8); break; case 'u': itoab(arg,str,10); break; case 'x': itoab(arg,str,16); break; default: return (cc); } len = strlen(sptr); if(maxchr && maxchrlen) width = width - len; else width = 0; if(!left) while(width--) {fputc(pad,fd); ++cc;} while(len--) {fputc(*sptr++,fd); ++cc; } if(left) while(width--) {fputc(paTC4 ; /* assume stdout, stderr */ MOV A,E ; /* or stdlist. */ CPI STDOUT ; if(unit == stdout) { JNZ PUTC1 PUSH H CALL PUTCHAR ; putchar(c); POP H RET ; return;} PUTC1: CPI STDERR ; elseif(unit == stderr) { JNZ PUTC2 CALL PUTCHAR ; putchar(c); RET ; return;} PUTC2: CPI STDLST ; elseif(unit == stdlist) { JNZ PUTC3 PUSH H CALL PUTLIST ; putlist(c); POP H RET ; return;} PUTC3: JMP PTCER1 ; else goto putcerr; } PUTC4: PUSH H ; if(cput(c,unit)<0) PUSH DOL EQU 13 ; ; CP/M BDOS CALLS ; CLOSE EQU 16 ;close a file CPMSTR EQU 9 ;print '$' delimited string on console CREATE EQU 22 ;make a file DMA EQU 26 ;set DMA (I/O address) DELETE EQU 19 ;delete a file GETCH EQU 1 ;read character from console GETSTR EQU 10 ;read string from console LSTOUT EQU 5 ;write character to list device OPEN EQU 15 ;open a file PUTCH EQU 2 ;write character to console QUERY EQU 25 ;get logged-in drive id READ EQU 20 ;read a sector SELECT EQU 14 ;log-in a drive WRITE EQ]; LXI D,BUFFER DAD D SHLD ZZCHP ; } ; } PTCIF1: LHLD ZZIP LXI D,UNUSED ; ip[UNUSED]--; DAD D MOV E,M INX H MOV D,M DCX D MOV M,D DCX H MOV M,E LHLD ZZCHP ; ip[NEXTP] = cp+1; INX H XCHG LHLD ZZIP LXI B,NEXTP DAD B MOV M,E INX H MOV M,D LDA ZZCH ; return((*cp = c) & 0377); LHLD ZZCHP MOV M,A MVI H,0 MOV L,A RET END d,fd); ++cc;} } return(cc); }  ; ; putc(c,unit) ; ; CBDOS EQU 5 ;/* bdos entry point */ CPMARG EQU 128 ;/* CP/M command line */ MAXARG EQU 32 ;/* Maximum number of input args */ STDIN EQU 0 STDOUT EQU 1 STDERR EQU 2 STDLST EQU 4 CTRLZ EQU 26 ;control z NULL EQU 0 ;pointer to nothing FCBSIZE EQU 36 ;size, in bytes, of an FCB NEXTP EQU 0 ;offset to next-character pointer in I/O structure UNUSED EQ ; goto putcerr; CALL CPUT POP D MOV A,H ORA A JM PUTCERR MOV A,L ; if(c=='\r') CPI EOL JNZ PUTCRET LXI H,LF ; cput('\n',unit); PUSH H PUSH D CALL CPUT POP D POP D MOV A,H ORA A JM PUTCERR PUTCRET: POP H ; return(c); RET PUTCERR: ;putcerr: POP B ; return(-1); PTCER1: LXI H,-1 RET ; ; cput(c,unit) ; CPUT:: POP B POP D POP H PUSH H PUSH D PUSH B SHLD ZZCH XCHG SHLD ZZUNIT LXI D,FCBSIZE ; ip = unit + FCBSIZE; DAD D SHLD $   ; ; fputs(cp,unit) ; ; CBDOS EQU 5 ;/* bdos entry point */ CPMARG EQU 128 ;/* CP/M command line */ MAXARG EQU 32 ;/* Maximum number of input args */ STDIN EQU 0 STDOUT EQU 1 STDERR EQU 2 STDLST EQU 4 CTRLZ EQU 26 ;control z NULL EQU 0 ;pointer to nothing FCBSIZE EQU 36 ;size, in bytes, of an FCB NEXTP EQU 0 ;offset to next-character pointer in I/O structure UNUSED EQU 2 ;offset to unused-positions-count in I/O structure BUFFER EQU 6 ;offset to disk sector buffer in I/O structure UNGOT EQU); } #define NOCCARGC /* no argument count passing */ extern char *zzmem; /* ** free(ptr) - Free previously allocated memory block. ** Memory must be freed in the reverse order from which ** it was allocated. ** ptr = Value returned by calloc() or malloc(). ** Returns ptr if successful or NULL otherwise. */ free(ptr) char *ptr; { return (zzmem = ptr); } #asm cfreeXTRN ZZFILE EXTRN ZZMODE EXTRN ZZCH EXTRN ZZT EXTRN ZZFN EXTRN ZZNUBU EXTRN ZZMXSC ; ; Characteristics variable storage found in ulink() ; EXTRN ZZSVCH EXTRN ZZDFLT EXTRN ZZSTAK EXTRN ZZMEM ; EXTRN PUTC ; FPUTS:: POP B POP D ; unit POP H ; cp PUSH H PUSH D PUSH B FPUTS1: MOV A,M ; while((c=*cp++) <> NULL) { INX H ORA A JZ FPUTS3 PUSH H MOV C,A MVI B,0 PUSH B PUSH D CALL PUTC ; if(putc(c,unit)==EOF) POP D POP B MOV A,H ORA A JZ FPUTS2 POP B RETunt, they do not call functions which need one. */ #include stdio.h /* ** fscanf(fd, ctlstring, arg, arg, ...) - Formatted read. ** Operates as described by Kernighan & Ritchie. ** b, c, d, o, s, u, and x specifications are supported. ** Note: b (binary) is a non-standard extension. */ fscanf(argc) int argc; { int *nxtarg; nxtarg = CCARGC() + &argc; return (Uscan(*(--nxtarg), --nxtarg)); } /* ** scanf(ctlstring, arg, arg, ...) - Formatted read. ** Operates as described by Kernighan 5 ;offset to char ungotten by ungetc() FLAG EQU 33 ;file-type flag byte (in unused part of FCB) FREEFLG EQU 128 ;This I/O structure is available for the taking EOFFLG EQU 2 ;The end of this file has been hit WRTFLG EQU 1 ;This file open for writing BUFSIZ EQU 1024 ;how long the sector buffer is NBUFS EQU 8 ;number of I/O buffers TBUFF EQU 128 ;default cpm buffer LF EQU 10 EOL EQU 13 ; ; CP/M BDOS CALLS ; CLOSE EQU 16 ;close a file CPMSTR EQU 9 ;print '$' delimited string on console CREATE E equ free entry cfree #endasm ; ; freeio(unit) by F.A.Scacchitti 9/12/84 ; ; mark a buffer as free. ; ; ; NBUFS EQU 8 FCBSIZE EQU 36 ;size, in bytes, of an FCB BUFFER EQU 6 ;offset to disk sector buffer in I/O structure FLAG EQU 33 ;file-type flag byte (in unused part of FCB) FREEFLG EQU 128 ;This I/O structure is available for the taking BUFSIZ EQU 1024 ;how long the sector buffer is NULL EQU 0 ; return(EOF); FPUTS2: POP H JMP FPUTS1 ; } FPUTS3: LXI H,0 RET ; return(NULL); END FPUTS /* ** fread.c by F.A.Scacchitti 9/3/84 */ fread(buf, sz, n, fd) char *buf; int sz, n, fd; { return(read(fd, buf, n*sz)); }  /* ** frebufc.c by fas 8/30/84 */ #include frebuf(buffer) int buffer; { freeio(buffer-42); return(NULL & Ritchie. ** b, c, d, o, s, u, and x specifications are supported. ** Note: b (binary) is a non-standard extension. */ scanf(argc) int argc; { return (Uscan(stdin, CCARGC() + &argc - 1)); } /* ** Uscan(fd, ctlstring, arg, arg, ...) - Formatted read. ** Called by fscanf() and scanf(). */ Uscan(fd,nxtarg) int fd, *nxtarg; { char *carg, *ctl, *unsigned; int *narg, wast, ac, width, ch, cnv, base, ovfl, sign; ac = 0; ctl = *nxtarg--; while(*ctl) { if(isspace(*ctl)) {++ctl;QU 22 ;make a file DMA EQU 26 ;set DMA (I/O address) DELETE EQU 19 ;delete a file GETCH EQU 1 ;read character from console GETSTR EQU 10 ;read string from console LSTOUT EQU 5 ;write character to list device OPEN EQU 15 ;open a file PUTCH EQU 2 ;write character to console QUERY EQU 25 ;get logged-in drive id READ EQU 20 ;read a sector SELECT EQU 14 ;log-in a drive WRITE EQU 21 ;write a sector ; ; File i/o storage varibles found in ulink() ; EXTRN ZZUNIT EXTRN ZZIP EXTRN ZZCHP EXTRN ZZDP E ; EXTRN IOBUFS ; ; FREEIO:: ;Mod 6 May 80 rj POP B ;save rtn addr POP H ;get buffer addr PUSH H ;put the stack back together PUSH B LXI D,FLAG ;find flag byte DAD D MVI M,FREEFLG ;mark buffer as 'free' LXI H,NULL ;return something RET END #define NOCCARGC /* no argument count passing */ /* ** Yes, that is correct. Although these functions use an ** argument co%   continue;} if(*ctl++ != '%') continue; if(*ctl == '*') {narg = carg = &wast; ++ctl;} else narg = carg = *nxtarg--; ctl += utoi(ctl, &width); if(!width) width = 32767; if(!(cnv = *ctl++)) break; while(isspace(ch = fgetc(fd))) ; if(ch == EOF) {if(ac) break; else return(EOF);} ungetc(ch,fd); switch(cnv) { case 'c': *carg = fgetc(fd); break; case 's': while(width--) { if((*carg = fgetc(fd)) == EOF) number of input args */ STDIN EQU 0 STDOUT EQU 1 STDERR EQU 2 STDLST EQU 4 CTRLZ EQU 26 ;control z NULL EQU 0 ;pointer to nothing FCBSIZE EQU 36 ;size, in bytes, of an FCB NEXTP EQU 0 ;offset to next-character pointer in I/O structure UNUSED EQU 2 ;offset to unused-positions-count in I/O structure BUFFER EQU 6 ;offset to disk sector buffer in I/O structure UNGOT EQU 5 ;offset to char ungotten by ungetc() FLAG EQU 33 ;file-type flag byte (in unused part of FCB) FREEFLG EQU 128 ;This I/O structusigned; } ++ac; } return (ac); } /* ** fwrite.c by F.A.Scacchitti 9/3/84 */ fwrite(buf, sz, n, fd) char *buf; int sz, n, fd; { return(write(fd, buf, n*sz)); } #define NOCCARGC /* no argument count passing */ /* * getchar() Normal console input via BDOS(1) */ #include gnd in ulink() ; EXTRN ZZSVCH EXTRN ZZDFLT EXTRN ZZSTAK EXTRN ZZMEM ; EXTRN GETC ; GETS:: POP B POP H PUSH H PUSH B SHLD ZZCHP DCX H ; save = buff[-1]; save2 = buff[-2]; MOV D,M ; buff[-1] = 0; buff[-2] = 79; MVI M,0 DCX H MOV E,M MVI M,79 ;6 May 80 rj PUSH H PUSH D XCHG ; cpm(GETSTR,buff-2); MVI C,GETSTR CALL CBDOS ; (mod to cbdos(fas)) LHLD ZZCHP ; buff[buff[-1]] = 0; (9 Jun 80. Was cp) DCX H MOV E,M INX H MVI D,0 DAD D MVI M,0 POP D  break; if(isspace(*carg)) break; if(carg != &wast) ++carg; } *carg = 0; break; default: switch(cnv) { case 'b': base = 2; sign = 1; ovfl = 32767; break; case 'd': base = 10; sign = 0; ovfl = 3276; break; case 'o': base = 8; sign = 1; ovfl = 8191; break; case 'u': base = 10; sign = 1; ovfl = 6553; break; case 'x': base = 16; sign = 1; ovfl = 4095; break; default: returnre is available for the taking EOFFLG EQU 2 ;The end of this file has been hit WRTFLG EQU 1 ;This file open for writing BUFSIZ EQU 1024 ;how long the sector buffer is NBUFS EQU 8 ;number of I/O buffers TBUFF EQU 128 ;default cpm buffer LF EQU 10 EOL EQU 13 ; ; CP/M BDOS CALLS ; CLOSE EQU 16 ;close a file CPMSTR EQU 9 ;print '$' delimited string on console CREATE EQU 22 ;make a file DMA EQU 26 ;set DMA (I/O address) DELETE EQU 19 ;delete a file GETCH EQU 1 ;read character from console GETSetchar(){ char c; c = bdos(1,0); if(c == 26) return(-1); else return(c); } /* ** getchx() Direct console input via BDOS(6) */ #include getchx() { char c; while(!(c = bdos(6,255))); return(c); }  ; ; gets(buff) ; ; CBDOS EQU 5 ;/* bdos entry point */ CPMARG EQU 128 ;/* CP/M command line */ MAXARG EQU 32 ;/* Maximum ; buff[-1] = save; buff[-2] = save2; POP H MOV M,E INX H MOV M,D INX H MVI C,PUTCH ; putchar('\n'); MVI E,LF CALL CBDOS ; (mod to cbdos(fas)) LHLD ZZCHP ; return(buff); RET ; } END GETS ; ; grabio() by F.A.Scacchitti 9/18/84 ; ; find an input buffer, and return its address. ; if there isn't one, return a NULL. ; ; NBUFS EQU 8 FCBSIZE EQU 36 ;size, in bytes, of an FCB BUFFER EQU 6 ;offset to disk sector buffer in I/O structure  (ac); } *narg = unsigned = 0; while(width-- && !isspace(ch=fgetc(fd)) && ch!=EOF) { if(!sign) if(ch == '-') {sign = -1; continue;} else sign = 1; if(ch < '0') return (ac); if(ch >= 'a') ch -= 87; else if(ch >= 'A') ch -= 55; else ch -= '0'; if(ch >= base || unsigned > ovfl) return (ac); unsigned = unsigned * base + ch; } *narg = sign * unTR EQU 10 ;read string from console LSTOUT EQU 5 ;write character to list device OPEN EQU 15 ;open a file PUTCH EQU 2 ;write character to console QUERY EQU 25 ;get logged-in drive id READ EQU 20 ;read a sector SELECT EQU 14 ;log-in a drive WRITE EQU 21 ;write a sector ; ; File i/o storage varibles found in ulink() ; EXTRN ZZUNIT EXTRN ZZIP EXTRN ZZCHP EXTRN ZZDP EXTRN ZZFILE EXTRN ZZMODE EXTRN ZZCH EXTRN ZZT EXTRN ZZFN EXTRN ZZNUBU EXTRN ZZMXSC ; ; Characteristics variable storage fou&   FLAG EQU 33 ;file-type flag byte (in unused part of FCB) FREEFLG EQU 128 ;This I/O structure is available for the taking BUFSIZ EQU 1024 ;how long the sector buffer is NULL EQU 0 TBUFSZ EQU 128 ; Default buffer size ; EXTRN ZZBUF ; GRABIO:: ;6 May 80 rj MVI B,NBUFS LXI H,ZZBUF+TBUFSZ+FLAG LXI D,FCBSIZE+BUFFER+BUFSIZ MVI A,FREEFLG GRAB2: CMP M ;flag byte == freeflg? JZ GRAB3 ;if so, found a free buffer DAD D ;on to next buffer DCR B JNZ GRAB2 ;if there is one... L/* ** return 'true' if c is a decimal digit */ isdigit(c) int c; { return (c<='9' && c>='0'); } /* ** return 'true' if c is a graphic character ** (33-126) */ isgraph(c) int c; { return (c>=33 && c<=126); } /* ** return 'true' if c is lower-case alphabetic */ islower(c) int c; { return (c<='z' && c>='a'); } /* ** return 'true' if c is a printable character ** (32-126) */ isprint(c) int c; { return (c>=32 && c<=126); } ) || (c<='9' && c>='0')); } /* ** return 'true' if c is alphabetic */ isalpha(c) int c; { return ((c<='z' && c>='a') || (c<='Z' && c>='A')); } /* ** return 'true' if c is an ASCII character (0-127) */ isascii(c) char *c; { /* c is a simulated unsigned integer */ return (c <= 127); }  n; { int sign; char *ptr; ptr = s; if ((sign = n) < 0) /* record sign */ n = -n; /* make n positive */ do { /* generate digits in reverse order */ *ptr++ = n % 10 + '0'; /* get next digit */ } while ((n = n / 10) > 0); /* delete it */ if (sign < 0) *ptr++ = '-'; *ptr = '\0'; reverse(s); } #define NOCCARGC /* no argument count passing */ /* ** itoab(n,s,b) - Convert "unsigned" n to characters in s using base b. XI H,NULL ;there ain't RET ;give up ; GRAB3: MVI M,0 ;mark buffer as taken LXI D,-FLAG ;back up to buffer start DAD D RET ;and hand it back ; END  /* ** grabufc.c by fas 8/30/84 */ #include grabuf() { int buf; if((buf = grabio) != NULL) return(buf+42); return(NULL); } #define NOCCARGC /* no argument count passing */ /* ** return 'true' if c is a punctuation character ** (all but control and alphanumeric) */ ispunct(c) int c; { return (!isalnum(c) && !iscntrl(c)); } /* ** return 'true' if c is a white-space character */ isspace(c) int c; { /* first check gives quick exit in most cases */ return(c<=' ' && (c==' ' || (c<=13 && c>=9))); } /* ** Return "true" if fd is a device, else "false" */ #include isatty(fd) int fd; { if(fd >255) return(FALSE); else return(TRUE); } /* ** return 'true' if c is a control character ** (0-31 or 127) */ iscntrl(c) char *c; { /* c is a simulated unsigned integer */ return ((c <= 31) || (c == 127)); } ** NOTE: This is a non-standard function. */ itoab(n, s, b) int n; char *s; int b; { char *ptr; int lowbit; ptr = s; b >>= 1; do { lowbit = n & 1; n = (n >> 1) & 32767; *ptr = ((n % b) << 1) + lowbit; if(*ptr < 10) *ptr += '0'; else *ptr += 55; ++ptr; } while(n /= b); *ptr = 0; reverse (s); }  ; inp(port#) ; Added 2/84 (fas) INP:: INX SP ; Skip over return address INX SP POP B ; Load port # into C DB 0EDH, 068H ; Do instruction PUSH B ; Restore stack DCX SP DCX SP MOV A,L ; Data was returned in L RLC ; Sign extend HL SBB A ; MOV H,A ; That's it RET END /* ** return 'true' if c is alphanumeric */ isalnum(c) int c; { return ((c<='z' && c>='a') || (c<='Z' && c>='A'/* ** return 'true' if c is upper-case alphabetic */ isupper(c) int c; { return (c<='Z' && c>='A'); } /* ** return 'true' if c is a hexadecimal digit ** (0-9, A-F, or a-f) */ isxdigit(c) int c; { return ((c<='f' && c>='a') || (c<='F' && c>='A') || (c<='9' && c>='0')); } #define NOCCARGC /* no argument count passing */ /* ** itoa(n,s) - Convert n to characters in s */ itoa(n, s) char *s; int'  /* ** uw.c File Copy & UW(Bin) Program by F.A.Scacchitti 9/23/84 ** ** Written in Small-C Version 2.09 or later ** ** Copies file from file to file ** Un-wordstars as it goes */ #include #define BUFSIZE 8192 main(argc,argv) int argc, argv[]; { int fdin, fdout; /* file i/o channel pointers */ int i, j, count; char *inbuf; i = 0; inbuf = malloc(BUFSIZE); if(argc != 3) { puts("\nfc usage: fc \n"); exit(); } if((fdin ars, hi_totchars, totwords, totlines; main(argc,argv) int argc, argv[]; { if(argc == 1) { prntf("\n\nUsage: wc . . . \n\n"); exit(); } else prntf("\n\t\tchars\twords\tlines\n\n"); while (--argc) dofile(*++argv); /* process the files */ prntf("\nTotals:"); /* print the results */ if (hi_totchars) prntf("\t\t%d%04d",hi_totchars,lo_totchars); else prntf("\t\t%d",lo_totchars); prntf("\t%d\t%d\n",totwords,totlines); } dofile(nam= fopen(argv[1],"r")) == NULL) { puts("\nUnable to open input file.\n"); exit(); } if((fdout = fopen(argv[2],"w")) == NULL) { puts("\nUnable to create output file.\n"); exit(); } while((count = read(fdin,inbuf,BUFSIZE)) == BUFSIZE) { for(j = 0; j < BUFSIZE; j++) inbuf[j] = inbuf[j] & 127; write(fdout,inbuf,count); i += count; } i += count; for(j = 0; j < count % BUFSIZE; j++) inbuf[j] = inbuf[j] & 127; write(fdout,inbuf,coe) char *name; { char inword; int c; int lo_tch, hi_tch, twords, tlines; ibuf = (fopen(name,"R")); if (ibuf == NULL) { prntf("Can't open %s\n",name); return; } prntf("%s:\t",name); if (strlen(name) < 7) putchar('\t'); inword = lo_tch = hi_tch = twords = tlines = 0; while ((c =fgetc(ibuf)) != EOF ) { if (++lo_tch == 10000) { lo_tch = 0; hi_tch++; } if (isspace(c)) { if (inword) { inword = 0; twords++; } } else if (!inwor/* ** WC.C ** Written by Leor Zolman, 3/16/82 ** ** Modified for Small-C by F.A.Scacchitti ** 9/23/84 ** ** ** Text analysis utility. Given a list of text files, WC prints ** out total number of characters, words and lines in each file ** and in all files together. "Words", here, are simply delimited ** by blanks, tabs or newlines. ** ** Maximum number of words and lines are each 32767, but the char ** count is virtually unlimited. ** */ #include int ibuf, lo_totchunt); fclose(fdin); fclose(fdout); } d) inword = 1; if (c == '\n') tlines++; } if (hi_tch) prntf("%d%04d",hi_tch,lo_tch); else prntf("%d",lo_tch); prntf("\t%d\t%d\n",twords,tlines); if ((lo_totchars += lo_tch) >= 10000) { lo_totchars -= 10000; hi_totchars++; } hi_totchars += hi_tch; totwords += twords; totlines += tlines; fclose(ibuf); }