home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1994 June / NEBULA_SE.ISO / PC / c / PCC.DOC < prev    next >
Encoding:
Text File  |  1993-08-08  |  172.4 KB  |  5,611 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.                                        PCC
  18.  
  19.  
  20.  
  21.                               A Personal C Compiler
  22.  
  23.  
  24.  
  25.  
  26.  
  27.                             Version 2.1c  (June 1989)
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.                              U S E R's  M A N U A L
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.                         Manufactured and Distributed by:
  84.  
  85.  
  86.  
  87.  
  88.  
  89.                                C Ware Corporation
  90.  
  91.                                   P.O. Box 428
  92.  
  93.                               Paso Robles, CA 93446
  94.  
  95.  
  96.  
  97.  
  98.  
  99.                              (805) 239-4620 [Voice]
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.             Copyright 1989 by C Ware Corporation and DeSmet Software
  110.  
  111.                                All Rights Reserved
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.                                         1
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.                                TABLE OF CONTENTS
  134.  
  135.  
  136.  
  137.  
  138.  
  139.                        T A B L E   O F   C O N T E N T S 
  140.  
  141.  
  142.  
  143.           1. The Legal Stuff............................................1
  144.  
  145.              1.1. License...............................................2
  146.  
  147.              1.2. Support Policy........................................2
  148.  
  149.              1.3. DISCLAIMER............................................3
  150.  
  151.              1.4. FOREIGN RESHIPMENT LIABILITY..........................3
  152.  
  153.              1.5. LIMITED WARRANTY                                                              ......................................3
  154.  
  155.              1.6. LIMITATIONS OF REMEDIES...............................3
  156.  
  157.              1.7. General...............................................4
  158.  
  159.              1.8. TRADEMARKS............................................4
  160.  
  161.              1.9. ORDERING INFORMATION..................................4
  162.  
  163.              1.10. Use by Educational Institutions......................5
  164.  
  165.              1.11. Corporate, Business, Government and Commercial Use...5
  166.  
  167.  
  168.  
  169.           2. Preface....................................................7
  170.  
  171.  
  172.  
  173.           3. An Introduction To PCC.....................................8
  174.  
  175.              3.1. Using Text, Book, Magazine or Download source code....8
  176.  
  177.              3.2. Getting Started.......................................9
  178.  
  179.              3.3. PCC Files.............................................9
  180.  
  181.              3.4. Basic System.........................................10
  182.  
  183.              3.5. Setting Up DOS 2.xx, 3.xx, ..........................10
  184.  
  185.              3.6. RAM DISK.............................................11
  186.  
  187.              3.7. Completion Codes.....................................11
  188.  
  189.  
  190.  
  191.           4. PCC -- The Personal C Compiler............................13
  192.  
  193.              4.1. Introduction.........................................13
  194.  
  195.              4.2. Examples.............................................14
  196.  
  197.              4.3. The C Language.......................................15
  198.  
  199.                   4.3.1. Preprocessor directives.......................15
  200.  
  201.                   4.3.2. Data Types....................................15
  202.  
  203.              4.4. Extensions...........................................16
  204.  
  205.                   4.4.1. Forward References............................18
  206.  
  207.                   4.4.2. Externs.......................................18
  208.  
  209.                   4.4.3. Macros........................................20
  210.  
  211.                   4.4.4. Strings.......................................20
  212.  
  213.  
  214.  
  215.           5. The PCCA 8088 Assembler...................................21
  216.  
  217.              5.1. Introduction.........................................21
  218.  
  219.              5.2. Invocation...........................................21
  220.  
  221.              5.3. Example..............................................21
  222.  
  223.  
  224.  
  225.           6. The PCCL Object File Linker...............................23
  226.  
  227.              6.1. Introduction.........................................23
  228.  
  229.              6.2. Invocation...........................................23
  230.  
  231.              6.3. Examples.............................................24
  232.  
  233.              6.4. Space Considerations.................................25
  234.  
  235.              6.5. Overlays.............................................25
  236.  
  237.              6.6. Libraries............................................27
  238.  
  239.  
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265.                                TABLE OF CONTENTS
  266.  
  267.  
  268.  
  269.  
  270.  
  271.           7. The PCCS.S Standard Library...............................28
  272.  
  273.              7.1. Introduction.........................................28
  274.  
  275.              7.2. Names................................................28
  276.  
  277.              7.3. Program Initialization...............................28
  278.  
  279.              7.4. Calling Conventions..................................29
  280.  
  281.              7.5. LIBRARY CONVENTIONS..................................31
  282.  
  283.              7.6. Disk Input/Output Routines...........................32
  284.  
  285.              7.7. Math Routines........................................33
  286.  
  287.              7.8. IBM-PC Screen and Keyboard Interface.................34
  288.  
  289.              7.9. Standard Library Functions...........................34
  290.  
  291.                   7.9.1. abs().........................................34
  292.  
  293.                   7.9.2. atoi()........................................34
  294.  
  295.                   7.9.3. atof()........................................35
  296.  
  297.                   7.9.4. atol()........................................35
  298.  
  299.                   7.9.5. ceil()........................................36
  300.  
  301.                   7.9.6. chain().......................................36
  302.  
  303.                   7.9.7. close().......................................37
  304.  
  305.                   7.9.8. creat().......................................37
  306.  
  307.                   7.9.9. dates().......................................37
  308.  
  309.                   7.9.10. doint()......................................37
  310.  
  311.                   7.9.11. exec().......................................38
  312.  
  313.                   7.9.12. exit().......................................39
  314.  
  315.                   7.9.13. exp()........................................39
  316.  
  317.                   7.9.14. fabs().......................................40
  318.  
  319.                   7.9.15. fclose().....................................40
  320.  
  321.                   7.9.16. fgetc()......................................40
  322.  
  323.                   7.9.17. fgets()......................................40
  324.  
  325.                   7.9.18. floor()......................................41
  326.  
  327.                   7.9.19. fopen()......................................41
  328.  
  329.                   7.9.20. fputc()......................................41
  330.  
  331.                   7.9.21. fputs()......................................42
  332.  
  333.                   7.9.22. frand()......................................42
  334.  
  335.                   7.9.23. fscanf().....................................42
  336.  
  337.                   7.9.24. getc().......................................42
  338.  
  339.                   7.9.25. getchar()....................................43
  340.  
  341.                   7.9.26. gets().......................................43
  342.  
  343.                   7.9.27. getw().......................................44
  344.  
  345.                   7.9.28. in().........................................44
  346.  
  347.                   7.9.29. index()......................................44
  348.  
  349.                   7.9.30. log()........................................44
  350.  
  351.                   7.9.31. lmove()......................................45
  352.  
  353.                   7.9.32. longjmp()....................................45
  354.  
  355.                   7.9.33. open().......................................46
  356.  
  357.                   7.9.34. os().........................................46
  358.  
  359.                   7.9.35. out()........................................46
  360.  
  361.                   7.9.36. peek().......................................46
  362.  
  363.                   7.9.37. poke().......................................47
  364.  
  365.                   7.9.38. pow()........................................47
  366.  
  367.                   7.9.39. putc().......................................47
  368.  
  369.                   7.9.40. putchar()....................................47
  370.  
  371.                   7.9.41. puts().......................................48
  372.  
  373.                   7.9.42. putw().......................................48
  374.  
  375.                   7.9.43. qsort()......................................48
  376.  
  377.                   7.9.44. rand().......................................49
  378.  
  379.                   7.9.45. rename().....................................49
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.  
  394.  
  395.  
  396.  
  397.                                TABLE OF CONTENTS
  398.  
  399.  
  400.  
  401.  
  402.  
  403.                   7.9.46. rindex().....................................49
  404.  
  405.                   7.9.47. scanf()......................................50
  406.  
  407.                   7.9.48. scr_aputs()..................................52
  408.  
  409.                   7.9.49. scr_ci().....................................52
  410.  
  411.                   7.9.50. scr_co().....................................52
  412.  
  413.                   7.9.51. scr_clr()....................................52
  414.  
  415.                   7.9.52. scr_clrl()...................................52
  416.  
  417.                   7.9.53. scr_cls()....................................53
  418.  
  419.                   7.9.54. scr_csts()...................................53
  420.  
  421.                   7.9.55. scr_cursoff()................................53
  422.  
  423.                   7.9.56. scr_curson().................................53
  424.  
  425.                   7.9.57. scr_rowcol().................................53
  426.  
  427.                   7.9.58. scr_scdn()...................................54
  428.  
  429.                   7.9.59. scr_scrdn()..................................54
  430.  
  431.                   7.9.60. scr_scrup()..................................54
  432.  
  433.                   7.9.61. scr_scup()...................................54
  434.  
  435.                   7.9.62. scr_setmode()................................54
  436.  
  437.                   7.9.63. scr_setup()..................................55
  438.  
  439.                   7.9.64. scr_sinp()...................................55
  440.  
  441.                   7.9.65. setjmp().....................................56
  442.  
  443.                   7.9.66. sqrt().......................................56
  444.  
  445.                   7.9.67. srand()......................................56
  446.  
  447.                   7.9.68. sscanf().....................................57
  448.  
  449.                   7.9.69. strcat().....................................57
  450.  
  451.                   7.9.70. strcmp().....................................57
  452.  
  453.                   7.9.71. strcpy().....................................57
  454.  
  455.                   7.9.72. strlen().....................................58
  456.  
  457.                   7.9.73. strncat()....................................58
  458.  
  459.                   7.9.74. strncmp()....................................58
  460.  
  461.                   7.9.75. strncpy()....................................59
  462.  
  463.                   7.9.76. times()......................................59
  464.  
  465.                   7.9.77. ungetc().....................................59
  466.  
  467.                   7.9.78. unlink().....................................59
  468.  
  469.  
  470.  
  471.  
  472.  
  473.         
  474.  
  475.         Appendices
  476.  
  477.  
  478.  
  479.           A. Messages..................................................60
  480.  
  481.              A.1. PCC Compiler Messages................................60
  482.  
  483.                   A.1.1. Banner and Termination Messages...............60
  484.  
  485.                   A.1.2. Messages......................................60
  486.  
  487.                          A.1.2.1. PCC Fatal Errors.....................60
  488.  
  489.                          A.1.2.2. PCC Errors...........................62
  490.  
  491.                          A.1.2.3. PCC Warnings.........................66
  492.  
  493.                          A.1.2.4. PCCA Errors ( from PCC Execution )...67
  494.  
  495.              A.2. PCCA Assembler Messages..............................67
  496.  
  497.                   A.2.1. Banner and Termination Messages...............67
  498.  
  499.                   A.2.2. Messages Produced by PCCA.....................67
  500.  
  501.                          A.2.2.1. Fatal Errors From PCCA...............68
  502.  
  503.                          A.2.2.2. Errors from PCCA.....................68
  504.  
  505.              A.3. PCCL Messages........................................71
  506.  
  507.                   A.3.1. Banner and Termination Messages...............71
  508.  
  509.                   A.3.2. Warnings from PCCL............................71
  510.  
  511.                   A.3.3. Fatal Errors from PCCL .......................72
  512.  
  513.  
  514.  
  515.  
  516.  
  517.  
  518.  
  519.  
  520.  
  521.  
  522.  
  523.  
  524.  
  525.  
  526.  
  527.  
  528.  
  529.                                TABLE OF CONTENTS
  530.  
  531.  
  532.  
  533.  
  534.  
  535.  
  536.  
  537.           B. Order Form................................................74
  538.  
  539.  
  540.  
  541.           C. User Comments.............................................75
  542.  
  543.  
  544.  
  545.              index.....................................................76
  546.  
  547.  
  548.  
  549.  
  550.  
  551.  
  552.  
  553.  
  554.  
  555.  
  556.  
  557.  
  558.  
  559.  
  560.  
  561.  
  562.  
  563.  
  564.  
  565.  
  566.  
  567.  
  568.  
  569.  
  570.  
  571.  
  572.  
  573.  
  574.  
  575.  
  576.  
  577.  
  578.  
  579.  
  580.  
  581.  
  582.  
  583.  
  584.  
  585.  
  586.  
  587.  
  588.  
  589.  
  590.  
  591.  
  592.  
  593.  
  594.  
  595.  
  596.  
  597.  
  598.  
  599.  
  600.  
  601.  
  602.  
  603.  
  604.  
  605.  
  606.  
  607.  
  608.  
  609.  
  610.  
  611.  
  612.  
  613.  
  614.  
  615.  
  616.  
  617.  
  618.  
  619.  
  620.  
  621.  
  622.  
  623.  
  624.  
  625.  
  626.  
  627.  
  628.  
  629.  
  630.  
  631.  
  632.  
  633.  
  634.  
  635.  
  636.  
  637.  
  638.  
  639.  
  640.  
  641.  
  642.  
  643.  
  644.  
  645.  
  646.  
  647.  
  648.  
  649.  
  650.  
  651.  
  652.  
  653.  
  654.  
  655.  
  656.  
  657.  
  658.  
  659.  
  660.  
  661.                                TABLE OF CONTENTS
  662.  
  663.  
  664.  
  665.  
  666.  
  667.                          L I S T   O F   F I G U R E S 
  668.  
  669.  
  670.  
  671.          7-1: Initial Memory Layout....................................29
  672.  
  673.  
  674.  
  675.  
  676.  
  677.  
  678.  
  679.  
  680.  
  681.  
  682.  
  683.  
  684.  
  685.  
  686.  
  687.  
  688.  
  689.  
  690.  
  691.  
  692.  
  693.  
  694.  
  695.  
  696.  
  697.  
  698.  
  699.  
  700.  
  701.  
  702.  
  703.  
  704.  
  705.  
  706.  
  707.  
  708.  
  709.  
  710.  
  711.  
  712.  
  713.  
  714.  
  715.  
  716.  
  717.  
  718.  
  719.  
  720.  
  721.  
  722.  
  723.  
  724.  
  725.  
  726.  
  727.  
  728.  
  729.  
  730.  
  731.  
  732.  
  733.  
  734.  
  735.  
  736.  
  737.  
  738.  
  739.  
  740.  
  741.  
  742.  
  743.  
  744.  
  745.  
  746.  
  747.  
  748.  
  749.  
  750.  
  751.  
  752.  
  753.  
  754.  
  755.  
  756.  
  757.  
  758.  
  759.  
  760.  
  761.  
  762.  
  763.  
  764.  
  765.  
  766.  
  767.  
  768.  
  769.  
  770.  
  771.  
  772.  
  773.  
  774.  
  775.  
  776.  
  777.  
  778.  
  779.  
  780.  
  781.  
  782.  
  783.  
  784.  
  785.  
  786.  
  787.  
  788.  
  789.  
  790.  
  791.  
  792.  
  793.  
  794.  
  795.  
  796.  
  797.  
  798.  
  799.                                Personal C Compiler
  800.  
  801.  
  802.  
  803.                                     PCC 1.2c 
  804.  
  805.  
  806.  
  807.  
  808.  
  809.                          A Product of C WARE CORPORATION
  810.  
  811.  
  812.  
  813.                    Copyright (c) 1988, 1989 C WARE CORPORATION
  814.  
  815.                                All Rights Reserved
  816.  
  817.  
  818.  
  819.         PCC is a fully operational and tested 'C' Compiler.  This is NOT 
  820.  
  821.         cripple-ware.  As a reward for registration, you will receive a 
  822.  
  823.         disk with several utilities to enhance the compiler:
  824.  
  825.  
  826.  
  827.         1. Clist -     reads C source files and produces a listing file 
  828.  
  829.                        with a symbol cross-reference.
  830.  
  831.  
  832.  
  833.         2. Lib88 -     object code librarian.  Reads object files and 
  834.  
  835.                        other library files and produces library files.
  836.  
  837.  
  838.  
  839.         3. Profile -   C program execution profiler.  Monitors program 
  840.  
  841.                        execution and shows where time is spent in the 
  842.  
  843.                        program.
  844.  
  845.  
  846.  
  847.         4. Xarray -    A library of memory access functions to use the 
  848.  
  849.                        entire 640K RAM space.  With source.
  850.  
  851.  
  852.  
  853.         Registered users are also eligible to purchase several useful 
  854.  
  855.         utilities to further enhance the capabilities of the compiler.  
  856.  
  857.  
  858.  
  859.  
  860.  
  861.         1. The Legal Stuff
  862.  
  863.  
  864.  
  865.         This version of the documentation, software and copyright 
  866.  
  867.         supersedes all previous versions of PCC.
  868.  
  869.  
  870.  
  871.         PCC software copyright (C) 1988, 1989 by C WARE CORPORATION. All 
  872.  
  873.         rights reserved.
  874.  
  875.  
  876.  
  877.         This document copyright (C) 1988, 1989 C WARE CORPORATION.  All 
  878.  
  879.         rights reserved.
  880.  
  881.  
  882.  
  883.         Specifications subject to change without notice.
  884.  
  885.  
  886.  
  887.         Most of the hardware names in this manual are trademarks or trade 
  888.  
  889.         names of specific manufactures.
  890.  
  891.  
  892.  
  893.  
  894.  
  895.  
  896.  
  897.  
  898.  
  899.  
  900.  
  901.  
  902.  
  903.  
  904.  
  905.  
  906.  
  907.  
  908.  
  909.  
  910.  
  911.  
  912.  
  913.  
  914.  
  915.  
  916.  
  917.  
  918.  
  919.  
  920.  
  921.  
  922.  
  923.  
  924.  
  925.         Legal Stuff                                         Page 2
  926.  
  927.  
  928.  
  929.  
  930.  
  931.         1.1. License
  932.  
  933.  
  934.  
  935.         This PCC is NOT public domain or free software, but is being 
  936.  
  937.         distributed as "shareware".
  938.  
  939.  
  940.  
  941.         PCC is copyright (C) 1988, 1989 by C WARE CORPORATION.
  942.  
  943.  
  944.  
  945.         Non-registered users of this software are granted a limited 
  946.  
  947.         license to make an evaluation copy for trial use on a private, 
  948.  
  949.         non-commercial basis, for the express purpose of determining 
  950.  
  951.         whether PCC is suitable for their needs.  At the end of this trial 
  952.  
  953.         period of THIRTY DAYS you MUST either register your copy or 
  954.  
  955.         discontinue using PCC.
  956.  
  957.  
  958.  
  959.         A PCC registration entitles you to use the program on any and all 
  960.  
  961.         computers available to you, as long as you use the program on 
  962.  
  963.         only one computer at a time with the following restriction:
  964.  
  965.  
  966.  
  967.         All users are granted a limited license to copy PCC only for the 
  968.  
  969.         trial use of others.  This license does NOT include distribution 
  970.  
  971.         or copying of this software package:
  972.  
  973.  
  974.  
  975.              1. In connection with any other product or service except as 
  976.  
  977.                 noted below.
  978.  
  979.              2. For general use within a company or institution.
  980.  
  981.              3. Distribution in modified form. This license information 
  982.  
  983.                 MUST be included, along with the full PCC documentation 
  984.  
  985.                 and all PCC files as released by C WARE CORPORATION.
  986.  
  987.  
  988.  
  989.         Operators of electronic bulletin board systems (SYSOPS) are 
  990.  
  991.         encouraged to post PCC for downloading by users.
  992.  
  993.  
  994.  
  995.         If you are the distributor of a public domain or user-supported 
  996.  
  997.         software library, you may be distribute copies of PCC. A fee of 
  998.  
  999.         not to exceed $5.00 perdisk may be charged for copy service, 
  1000.  
  1001.         handling and materials.  The files MUST be distributed in 
  1002.  
  1003.         "archived' form so users may be able to adequately varify the 
  1004.  
  1005.         integrity of the files.
  1006.  
  1007.  
  1008.  
  1009.         The additional utilities available to registered users shall NOT 
  1010.  
  1011.         be distributed by any individual or organization other than C 
  1012.  
  1013.         WARE CORPORATION.
  1014.  
  1015.  
  1016.  
  1017.         1.2. Support Policy
  1018.  
  1019.  
  1020.  
  1021.         The nature of this product and the pricing makes it necessary for 
  1022.  
  1023.         us to NOT provide telephone support for users excepting as noted 
  1024.  
  1025.         in the pricing schedule below.  We will have to refuse to answer 
  1026.  
  1027.         questions unless you have registered the product AND paid for 
  1028.  
  1029.         phone support.  Every attempt will be made to address questions 
  1030.  
  1031.         left on our support BBS in an appropriate and timely manner. 
  1032.  
  1033.         However, this support will be on a when-time-is-available basis 
  1034.  
  1035.         and C WARE CORPORATION is NOT responsible to provide support in 
  1036.  
  1037.         any form for non-registered or registered users.  Information 
  1038.  
  1039.         will be posted on our support BBS when it becomes available as 
  1040.  
  1041.  
  1042.  
  1043.  
  1044.  
  1045.  
  1046.  
  1047.  
  1048.  
  1049.  
  1050.  
  1051.  
  1052.  
  1053.  
  1054.  
  1055.  
  1056.  
  1057.         Legal Stuff                                         Page 3
  1058.  
  1059.  
  1060.  
  1061.  
  1062.  
  1063.         well as bug fixes or patches.  Upgrades to PCC will be made when 
  1064.  
  1065.         appropriate to improve, enhance or correct the product.
  1066.  
  1067.  
  1068.  
  1069.         1.3. DISCLAIMER
  1070.  
  1071.  
  1072.  
  1073.  
  1074.  
  1075.         The author has taken due care in preparing this manual and the 
  1076.  
  1077.         programs and data on the electronic media accompanying this book 
  1078.  
  1079.         including research, development, and testing to ascertain their 
  1080.  
  1081.         effectiveness.  The author and the publisher make no expressed or 
  1082.  
  1083.         implied warranty of any kind with regard to these programs nor 
  1084.  
  1085.         the supplemental documentation in this book.  In no event shall 
  1086.  
  1087.         the author or C Ware Corporation be liable for incidental or 
  1088.  
  1089.         consequential damages in connection with or arising out of the 
  1090.  
  1091.         furnishing, performance or use of any of these programs.
  1092.  
  1093.  
  1094.  
  1095.  
  1096.  
  1097.         1.4. FOREIGN RESHIPMENT LIABILITY
  1098.  
  1099.  
  1100.  
  1101.         THIS LICENSE AGREEMENT IS EXPRESSLY MADE SUBJECT TO ANY LAWS, 
  1102.  
  1103.         REGULATIONS, ORDERS OR OTHER RESTRICTIONS ON THE EXPORT FROM THE 
  1104.  
  1105.         UNITED STATES OF AMERICA OF SOFTWARE, OR OF INFORMATION ABOUT 
  1106.  
  1107.         SUCH SOFTWARE, WHICH MAY BE IMPOSED FROM TIME TO TIME BY THE 
  1108.  
  1109.         GOVERNMENT OF THE UNITED STATES OF AMERICA.  NOTWITHSTANDING 
  1110.  
  1111.         ANYTHING CONTAINED IN THIS AGREEMENT TO THE CONTRARY, YOU MAY NOT 
  1112.  
  1113.         EXPORT, DIRECTLY OR INDIRECTLY, ANY SUCH SOFTWARE OR INFORMATION 
  1114.  
  1115.         PERTAINING THERETO TO ANY COUNTRY FOR WHICH SUCH GOVERNMENT OR 
  1116.  
  1117.         AGENCY THEREOF REQUIRES AN EXPORT LICENSE OR OTHER SUCH 
  1118.  
  1119.         GOVERNMENT APPROVAL AT THE TIME OF EXPORT WITHOUT FIRST OBTAINING 
  1120.  
  1121.         SUCH LICENSE OR APPROVAL.
  1122.  
  1123.  
  1124.  
  1125.         1.5. LIMITED WARRANTY                                                           
  1126.  
  1127.  
  1128.  
  1129.         PCC IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 
  1130.  
  1131.         EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
  1132.  
  1133.         WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
  1134.  
  1135.         PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF 
  1136.  
  1137.         PCC IS WITH YOU.
  1138.  
  1139.  
  1140.  
  1141.         SOME STATES DO NOT ALLOW THE EXCLUSION OF IMPLIED WARRANTIES, SO 
  1142.  
  1143.         THE ABOVE EXCLUSIONS MAY NOT APPLY TO YOU.  THIS WARRANTY GIVES 
  1144.  
  1145.         YOU SPECIFIC LEGAL RIGHTS AND YOU MAY ALSO HAVE OTHER RIGHTS 
  1146.  
  1147.         WHICH VARY FROM STATE TO STATE.
  1148.  
  1149.  
  1150.  
  1151.         C Ware does not warrant that operation of PCC will be 
  1152.  
  1153.         uninterrupted or error free.
  1154.  
  1155.  
  1156.  
  1157.         1.6. LIMITATIONS OF REMEDIES
  1158.  
  1159.  
  1160.  
  1161.         If C Ware is unable to deliver a copy of PCC that is 
  1162.  
  1163.         satisfactory, then you may obtain a full refund by returning all 
  1164.  
  1165.         PCC materials and documantation within thirty days of delivery to 
  1166.  
  1167.         you as evidenced by a copy of your receipt.
  1168.  
  1169.  
  1170.  
  1171.  
  1172.  
  1173.  
  1174.  
  1175.  
  1176.  
  1177.  
  1178.  
  1179.  
  1180.  
  1181.  
  1182.  
  1183.  
  1184.  
  1185.  
  1186.  
  1187.  
  1188.  
  1189.         Legal Stuff                                         Page 4
  1190.  
  1191.  
  1192.  
  1193.  
  1194.  
  1195.         This refund is the entire extent of C Ware's liability and your 
  1196.  
  1197.         exclusive remedy.
  1198.  
  1199.  
  1200.  
  1201.         IN NO EVENT WILL C WARE BE LIABLE TO YOU FOR ANY DAMAGES, 
  1202.  
  1203.         INCLUDING ANY LOST PROFITS, LOST SAVINGS OR OTHER INCIDENTAL OR 
  1204.  
  1205.         CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE 
  1206.  
  1207.         PCC EVEN IF C WARE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH 
  1208.  
  1209.         DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY.
  1210.  
  1211.  
  1212.  
  1213.         SOME STATES DO NOT ALLOW THE LIMITATION OR EXCLUSION OF LIABILITY 
  1214.  
  1215.         FOR INCIDENTAL OR CONSEQUENTAIL DAMAGES SO THE ABOVE LIMITATION 
  1216.  
  1217.         OR EXCLUSION MAY NOT APPLY TO YOU.
  1218.  
  1219.  
  1220.  
  1221.         1.7. General
  1222.  
  1223.  
  1224.  
  1225.         This Agreement will be governed by the laws of the State of 
  1226.  
  1227.         California.
  1228.  
  1229.  
  1230.  
  1231.         Should you have any questions concerning this Agreement, you may 
  1232.  
  1233.         write to C Ware Corporation, PO Box 428, Paso Robles, CA 93447.
  1234.  
  1235.  
  1236.  
  1237.         YOUR CONTINUED USE OF PCC BEYOND THE THIRTY DAY TRIAL PERIOD, 
  1238.  
  1239.         WITH OR WITHOUT REGISTRATION, ACKNOWLEDGES THAT YOU HAVE READ 
  1240.  
  1241.         THIS AGREEMENT, UNDERSTAND IT AND AGREE TO BE BOUND BY ITS TERMS 
  1242.  
  1243.         AND CONDITIONS.  YOU FURTHER AGREE THAT IT IS THE COMPLETE AND 
  1244.  
  1245.         EXCLUSIVE AGREEMENT BETWEEN US WHICH SUPERSEDES ANY PROPOSAL OR 
  1246.  
  1247.         PRIOR AGREEMENT, ORAL OR WRITTEN, ANY ANY OTHER COMMUNICATIONS 
  1248.  
  1249.         BETWEEN US RELATING TO THE SUBJECT MATTER OF THIS AGREEMENT.
  1250.  
  1251.  
  1252.  
  1253.         1.8. TRADEMARKS
  1254.  
  1255.  
  1256.  
  1257.         MS-DOS is a registered trademark of Microsoft Corporation.
  1258.  
  1259.         PC-DOS is a registered trademark of IBM Corporation.
  1260.  
  1261.         Compaq is a registered trademark of Compaq Inc.
  1262.  
  1263.         Tandy 1000 is a registered trademark of Tandy Corporation.
  1264.  
  1265.  
  1266.  
  1267.  
  1268.  
  1269.         1.9. ORDERING INFORMATION
  1270.  
  1271.  
  1272.  
  1273.         A PCC registration licenses you to use the product on a regular 
  1274.  
  1275.         basis.  Users need register only one version of PCC, registration 
  1276.  
  1277.         includes licensed use of all upgrades.  Registered users can 
  1278.  
  1279.         always get the most current version of the program at a nominal 
  1280.  
  1281.         fee ($5.00 as of this writing) by calling or writing C WARE 
  1282.  
  1283.         CORPORATION.  The latest version will also be available on the 
  1284.  
  1285.         following "official distribution BBSs":
  1286.  
  1287.  
  1288.  
  1289.         1. PYSMATIC BBS, Sunnyvale, CA  (408)-992-0372 
  1290.  
  1291.  
  1292.  
  1293.  
  1294.  
  1295.         If you purchased PCC through a distributor of public domain or 
  1296.  
  1297.         user-supported software, you did NOT pay for the license.  The 
  1298.  
  1299.         fee ($5.00 max per disk) was to cover the costs of copying the 
  1300.  
  1301.         disk(s), the media and handling overhead.  You paid for the 
  1302.  
  1303.         vendors service.
  1304.  
  1305.  
  1306.  
  1307.  
  1308.  
  1309.  
  1310.  
  1311.  
  1312.  
  1313.  
  1314.  
  1315.  
  1316.  
  1317.  
  1318.  
  1319.  
  1320.  
  1321.         Legal Stuff                                         Page 5
  1322.  
  1323.  
  1324.  
  1325.  
  1326.  
  1327.  
  1328.  
  1329.         Registration for PCC costs $30 and assumes you have already 
  1330.  
  1331.         received a copy of the program from whatever source.  We will 
  1332.  
  1333.         also send you the next major upgrade of PCC when it is released OR 
  1334.  
  1335.         if you ask, we will send you a certified copy of the current 
  1336.  
  1337.         version of the program and you must download, purchase or send us 
  1338.  
  1339.         $5.00 to get the next version. 
  1340.  
  1341.  
  1342.  
  1343.         1.10. Use by Educational Institutions
  1344.  
  1345.  
  1346.  
  1347.         Educational institutions wishing to use PCC for courses involving 
  1348.  
  1349.         C MUST obtain a site license.  State or city operated 
  1350.  
  1351.         institutions shall pay $10.00 per student using the program.  
  1352.  
  1353.         Private or commercial institutions shall pay $15.00 per student 
  1354.  
  1355.         using the program.  All reproduction of documentation and media 
  1356.  
  1357.         shall be done by the licensed site institution.  The additional 
  1358.  
  1359.         utilities offered to registered users may be purchased at 66% off 
  1360.  
  1361.         for state or city operated institutions and 50% off for private 
  1362.  
  1363.         or commercial institutions.    
  1364.  
  1365.               
  1366.  
  1367.         Students using the program via this method are NOT registered 
  1368.  
  1369.         users and must register their copy as per the licensing agreement 
  1370.  
  1371.         for an indivdual if they use the program after completion or 
  1372.  
  1373.         termination of the course.
  1374.  
  1375.  
  1376.  
  1377.         1.11. Corporate, Business, Government and Commercial Use
  1378.  
  1379.  
  1380.  
  1381.         Corporate, business, government or other commercial uses of PCC is 
  1382.  
  1383.         PROHIBITED.  We offer an excellent C Development Package for such 
  1384.  
  1385.         commercial users.  Please contact C WARE CORPORATION directly for 
  1386.  
  1387.         information and pricing. The intent of PCC is to provide a low 
  1388.  
  1389.         cost base for persons interested in learning C or using C 
  1390.  
  1391.         primarily for programs for self used programs.  If you find you 
  1392.  
  1393.         wish to sell a program developed with PCC, you must do the 
  1394.  
  1395.         following:
  1396.  
  1397.  
  1398.  
  1399.              1. The program and documentaion must prominently indicate 
  1400.  
  1401.                 the code was compiled with PCC (c) 1988, 1989 C WARE 
  1402.  
  1403.                 CORPORATION.
  1404.  
  1405.  
  1406.  
  1407.              2. Get written permission ( which is no big problem ) by 
  1408.  
  1409.                 sending us a copy of the program as it is to be sold or 
  1410.  
  1411.                 distributed.  A letter granting permission will be sent 
  1412.  
  1413.                 promptly, if your package meets the requirements of 
  1414.  
  1415.                 paragraph 1 above.
  1416.  
  1417.  
  1418.  
  1419.  
  1420.  
  1421.                 ALL PRICES ARE SUBJECT TO CHANGE WITHOUT NOTICE.
  1422.  
  1423.  
  1424.  
  1425.  
  1426.  
  1427.         Please use the order form in Appendix C when placing an order.
  1428.  
  1429.  
  1430.  
  1431.  
  1432.  
  1433.  
  1434.  
  1435.  
  1436.  
  1437.  
  1438.  
  1439.  
  1440.  
  1441.  
  1442.  
  1443.  
  1444.  
  1445.  
  1446.  
  1447.  
  1448.  
  1449.  
  1450.  
  1451.  
  1452.  
  1453.         Legal Stuff                                         Page 6
  1454.  
  1455.  
  1456.  
  1457.  
  1458.  
  1459.         You can also register/order your copy of PCC by phone, using your 
  1460.  
  1461.         MasterCard or VISA.  Phone (805)-239-4620, 9:00 - 4:00 p.m. PST 
  1462.  
  1463.         or PDT only.
  1464.  
  1465.  
  1466.  
  1467.         Sorry, C.O.D. orders will NOT be accepted.
  1468.  
  1469.  
  1470.  
  1471.         ORDERS OUTSIDE THE US: Please use your Mastercard or VISA when 
  1472.  
  1473.         ordering,  or  send checks drawn on US banks in US dollars.   All 
  1474.  
  1475.         checks must have US bank magnetic routing symbols.  Please 
  1476.  
  1477.         include an additional $5 to cover postage on orders to be sent 
  1478.  
  1479.         outside of the US.
  1480.  
  1481.  
  1482.  
  1483.         Full-time students can apply a 10% discount on all prices. You 
  1484.  
  1485.         MUST include your a photo-copy of your most recent registration 
  1486.  
  1487.         slip and student ID card.
  1488.  
  1489.  
  1490.  
  1491.         PRICE SCHEDULE AND INFORMATION ( November 1988 )
  1492.  
  1493.  
  1494.  
  1495.              1. Individual Registration              -        $30.00
  1496.  
  1497.                 - Copy of program sent if requested
  1498.  
  1499.                 - Utility package sent automatically
  1500.  
  1501.  
  1502.  
  1503.            *** Below items only available to registered users. ***
  1504.  
  1505.  
  1506.  
  1507.              2. Editor                               -        $10.00
  1508.  
  1509.  
  1510.  
  1511.              3. Debugger                             -        $15.00
  1512.  
  1513.  
  1514.  
  1515.              4. MS DOS Linker compatability utility  -        $ 5.00
  1516.  
  1517.  
  1518.  
  1519.              5. Special utilities package            -        $ 5.00
  1520.  
  1521.  
  1522.  
  1523.              6. Five phone support calls (5-min).    -        $15.00
  1524.  
  1525.                 - Total 25 minutes of help time
  1526.  
  1527.  
  1528.  
  1529.          
  1530.  
  1531.  
  1532.  
  1533.         NOTES:
  1534.  
  1535.           
  1536.  
  1537.              1. The above prices include CA sales tax.
  1538.  
  1539.  
  1540.  
  1541.              2. Sorry, we do not have a printed manual available.
  1542.  
  1543.  
  1544.  
  1545.              3. For fastest service please send Money Order or use Visa 
  1546.  
  1547.                 or MasterCharge.  We must wait 10 days for personal 
  1548.  
  1549.                 checks to clear.
  1550.  
  1551.  
  1552.  
  1553.              4. Please allow 30 days for delivery.  Money order, Visa and 
  1554.  
  1555.                 MasterCharge should ship in two(2) working days but 
  1556.  
  1557.                 things do get hectic at times.  Drop us a line if you 
  1558.  
  1559.                 haven't got your order in 15 days.
  1560.  
  1561.  
  1562.  
  1563.              5. Please use the form in appendix F to order.
  1564.  
  1565.  
  1566.  
  1567.  
  1568.  
  1569.  
  1570.  
  1571.  
  1572.  
  1573.  
  1574.  
  1575.  
  1576.  
  1577.  
  1578.  
  1579.  
  1580.  
  1581.  
  1582.  
  1583.  
  1584.  
  1585.         Preface                                             Page 7
  1586.  
  1587.  
  1588.  
  1589.  
  1590.  
  1591.         2. Preface
  1592.  
  1593.  
  1594.  
  1595.  
  1596.  
  1597.         The PCC package would not exist but for the tireless work of 
  1598.  
  1599.         L. B. Neal.  He has called us, badgered us, sent us manuals and 
  1600.  
  1601.         materials, jumped up and down about the virtues of Shareware, and 
  1602.  
  1603.         in general demanded that we transform the DeSmet C package into 
  1604.  
  1605.         PCC.
  1606.  
  1607.  
  1608.  
  1609.         The PCC package also owes everything to the incredible work of 
  1610.  
  1611.         Mark DeSmet.  At a time when most programmers couldn't spell 'C', 
  1612.  
  1613.         Mark wrote a compiler, assembler, linker and library for not one 
  1614.  
  1615.         operating system, but two.  The fact that it is still the fastest 
  1616.  
  1617.         C compiler in the current benchmarks further attests to Mark's 
  1618.  
  1619.         skills.
  1620.  
  1621.  
  1622.  
  1623.         This manual describes the C Ware Personal C Compiler for the IBM-
  1624.  
  1625.         PC personal computer and the other MS-DOS based personal 
  1626.  
  1627.         computers.  It is based on the DeSmet C Development Package.  If 
  1628.  
  1629.         you are unfamiliar with the C language or UNIX, the book The C 
  1630.  
  1631.         Programming Language (First edition -- the Second edition contains 
  1632.  
  1633.         features and enhancements of ANSI C not found in PCC) by Brian 
  1634.  
  1635.         Kernighan and Dennis Ritchie is available.  If you plan on coding 
  1636.  
  1637.         in assembly language, it is advisable to get a manual on the 
  1638.  
  1639.         Intel 8086 microprocessor.   Books such as Intel's ASM86 Language 
  1640.  
  1641.         Reference Manual or The 8086 Family User's Guide are good 
  1642.  
  1643.         choices.  These manuals fully describe the architecture and the 
  1644.  
  1645.         instruction set of the 8086/8088 family of microprocessors.
  1646.  
  1647.  
  1648.  
  1649.  
  1650.  
  1651.  
  1652.  
  1653.  
  1654.  
  1655.  
  1656.  
  1657.  
  1658.  
  1659.  
  1660.  
  1661.  
  1662.  
  1663.  
  1664.  
  1665.  
  1666.  
  1667.  
  1668.  
  1669.  
  1670.  
  1671.  
  1672.  
  1673.  
  1674.  
  1675.  
  1676.  
  1677.  
  1678.  
  1679.  
  1680.  
  1681.  
  1682.  
  1683.  
  1684.  
  1685.  
  1686.  
  1687.  
  1688.  
  1689.  
  1690.  
  1691.  
  1692.  
  1693.  
  1694.  
  1695.  
  1696.  
  1697.  
  1698.  
  1699.  
  1700.  
  1701.  
  1702.  
  1703.  
  1704.  
  1705.  
  1706.  
  1707.  
  1708.  
  1709.  
  1710.  
  1711.  
  1712.  
  1713.  
  1714.  
  1715.  
  1716.  
  1717.         An Introduction to PCC                              Page 8
  1718.  
  1719.  
  1720.  
  1721.  
  1722.  
  1723.         3. An Introduction To PCC
  1724.  
  1725.             
  1726.  
  1727.         Now that we made it through all of the formalities lets take a 
  1728.  
  1729.         look at what PCC contains.
  1730.  
  1731.  
  1732.  
  1733.              PCC is a fast powerful C compiler.  It is fully compatable 
  1734.  
  1735.              with code written for DeSmet Ver: 2.51. Code for earlier 
  1736.  
  1737.              versions of DeSmet should work with minimal adjustment.
  1738.  
  1739.  
  1740.  
  1741.              This compiler is NOT full of bells and whistles it just 
  1742.  
  1743.              makes fast tight compact programs.
  1744.  
  1745.  
  1746.  
  1747.              Some of the terms and conventions of PCC a bit different than 
  1748.  
  1749.              what you may find in a text or book on the C language, so we 
  1750.  
  1751.              will first do a quick run through the terms used in 
  1752.  
  1753.              PCC12B.DOC.
  1754.  
  1755.  
  1756.  
  1757.              TEXT OR BOOK NAME        PCC NAME         COMMENT
  1758.  
  1759.  
  1760.  
  1761.              LINK                     PCCL             Builds .EXE file
  1762.  
  1763.  
  1764.  
  1765.              filename.obj             filename.o       Basis for .EXE file
  1766.  
  1767.  
  1768.  
  1769.              filename.asm             filename.a       Assembly source file
  1770.  
  1771.  
  1772.  
  1773.              MASM or ASM              PCCA             8088/8086 Assembler
  1774.  
  1775.  
  1776.  
  1777.              CC or CPP                PCC              Main Compiler 
  1778.  
  1779.                                                        (First Pass)
  1780.  
  1781.              CC1                      PC2              Compiler Second Pass
  1782.  
  1783.  
  1784.  
  1785.         3.1. Using Text, Book, Magazine or Download source code
  1786.  
  1787.  
  1788.  
  1789.         Many C compilers are around and so are an almost equal number of 
  1790.  
  1791.         variations of interpretation of what C syntax should be.  And 
  1792.  
  1793.         then there are the extensions to support I/O, machine specific 
  1794.  
  1795.         functions, etc. Source NOT written for PCC or DeSmet Ver: 2.51 
  1796.  
  1797.         will have to have minimally minor adjustments made to be accepted 
  1798.  
  1799.         by the PCC compiler and to run properly.
  1800.  
  1801.  
  1802.  
  1803.         In fact finding, compiling and modifying source code is an 
  1804.  
  1805.         excellent way to learn any language or compiler.  Just be careful 
  1806.  
  1807.         to not adopt bad habits from exposure to poorly written code, 
  1808.  
  1809.         i.e. keep your eyes open.
  1810.  
  1811.  
  1812.  
  1813.  
  1814.  
  1815.         *****************************************************************
  1816.  
  1817.  
  1818.  
  1819.         CAUTION: PCC will accept any valid code you supply to it, as will 
  1820.  
  1821.         any compiler.  The code may well be valid, but the result of the 
  1822.  
  1823.         code may well be dangerous to the health and safety of your 
  1824.  
  1825.         computer, monitor or contents of your Hard Drive or floppies ( 
  1826.  
  1827.         and it WILL be at one time or another ).  Guard and maintain 
  1828.  
  1829.         uptodate copies of all files on your system.  If your program or 
  1830.  
  1831.         the compiler starts to act erratic: i.e. screen goes blank, funny 
  1832.  
  1833.  
  1834.  
  1835.  
  1836.  
  1837.  
  1838.  
  1839.  
  1840.  
  1841.  
  1842.  
  1843.  
  1844.  
  1845.  
  1846.  
  1847.  
  1848.  
  1849.         An Introduction to PCC                              Page 9
  1850.  
  1851.  
  1852.  
  1853.  
  1854.  
  1855.         video display, noises from hardware, or any strange unexpected 
  1856.  
  1857.         actions., IMMEDIATELY TURN OFF THE POWER to the computer and 
  1858.  
  1859.         investigate carefully after you have the system rebooted.
  1860.  
  1861.  
  1862.  
  1863.         ******************************************************************                   
  1864.  
  1865.  
  1866.  
  1867.         THE REST IS UP TO YOU
  1868.  
  1869.  
  1870.  
  1871.         C is a powerful and useful language, we hope you find PCC a help 
  1872.  
  1873.         to your learning and use of the C language.
  1874.  
  1875.  
  1876.  
  1877.         Your comments and suggestions on how to improve our product are 
  1878.  
  1879.         welcome.
  1880.  
  1881.  
  1882.  
  1883.         Enjoy your adventure into the land of C and we hope your programs 
  1884.  
  1885.         help you in your computing.
  1886.  
  1887.  
  1888.  
  1889.         3.2. Getting Started
  1890.  
  1891.  
  1892.  
  1893.         First things first.  Copy all of the files from the distribution 
  1894.  
  1895.         disks onto a set of working floppy diskettes or hard disk.  The 
  1896.  
  1897.         package is not copy-protected so the MS-DOS copy command can be 
  1898.  
  1899.         used to copy the files.  The package is distributed on a single 
  1900.  
  1901.         double-sided (360KB) diskette.  The distribution diskette should 
  1902.  
  1903.         never be used, it should be kept as the backup copy of PCC.
  1904.  
  1905.  
  1906.  
  1907.         Lets make sure the compiler files are intact.  A source program 
  1908.  
  1909.         called DUMP.C has been provided in this package.  Place the files 
  1910.  
  1911.         from PCC12B.DWC in a directory of your choice or on floppy disks 
  1912.  
  1913.         per the later documentation.  To compile DUMP.C enter
  1914.  
  1915.  
  1916.  
  1917.              >PCC DUMP
  1918.  
  1919.  
  1920.  
  1921.         This will compile DUMP.C into an object module DUMP.O.  To link 
  1922.  
  1923.         DUMP.O with the required library functions in PCCS.S enter
  1924.  
  1925.  
  1926.  
  1927.              >PCCL DUMP
  1928.  
  1929.  
  1930.  
  1931.         This will produce a file DUMP.EXE.  To run DUMP.EXE enter
  1932.  
  1933.  
  1934.  
  1935.              >DUMP DUMP.C
  1936.  
  1937.  
  1938.  
  1939.         This will produce a hex and ascii dump of DUMP.C on your screen.  
  1940.  
  1941.         If DUMP runs correctly, then the compiler should be in good 
  1942.  
  1943.         working order.
  1944.  
  1945.  
  1946.  
  1947.         3.3. PCC Files
  1948.  
  1949.  
  1950.  
  1951.         The package is distributed as an archive file -- PCC.DWC -- so 
  1952.  
  1953.         that integrity checks may be run.  PCC.DWC contains the following 
  1954.  
  1955.         files:
  1956.  
  1957.  
  1958.  
  1959.         BUF128.A       Source code for BUF128.EXE.
  1960.  
  1961.         BUGS!.EXE      Arcade game (use 'BUGS!   c' for color displays).
  1962.  
  1963.         CTYPE.H        Include file for character typing macros.
  1964.  
  1965.  
  1966.  
  1967.  
  1968.  
  1969.  
  1970.  
  1971.  
  1972.  
  1973.  
  1974.  
  1975.  
  1976.  
  1977.  
  1978.  
  1979.  
  1980.  
  1981.         An Introduction to PCC                              Page 10
  1982.  
  1983.  
  1984.  
  1985.  
  1986.  
  1987.         DUMP.C         Source code for DUMP.EXE.
  1988.  
  1989.         EXEC.O         The Exec() and Chain() functions.
  1990.  
  1991.         ISETUP.A       Run-time startup source code.
  1992.  
  1993.         LATER.C        Source code for a file modification date checking 
  1994.  
  1995.                        program.
  1996.  
  1997.         LIFE.C         Source code for LIFE.EXE.
  1998.  
  1999.         MATH.H         Include file for the Standard Math package.
  2000.  
  2001.         PC2.EXE        The second pass of the C compiler.
  2002.  
  2003.         PCC.DOC        This file
  2004.  
  2005.         PCC.EXE        The first pass of the C compiler.
  2006.  
  2007.         PCC7.S         The standard C function library with 8087 support.  
  2008.  
  2009.                        To use this library, rename it to PCCS.S.
  2010.  
  2011.         PCCA.EXE       The assembler and third pass of the C compiler.
  2012.  
  2013.         PCCL.EXE       The object file linker.
  2014.  
  2015.         PCCS.S         The standard C function library with software 
  2016.  
  2017.                        floating-point support.
  2018.  
  2019.         RAM.COM        RAM Disk driver for DOS 2.0 and later operating 
  2020.  
  2021.                        systems.
  2022.  
  2023.         PCIO.A         Source code for the PC screen functions.
  2024.  
  2025.         SETJMP.H       Include file for non-local jumps
  2026.  
  2027.         STDIO.H        Include file for the Standard I/O package.
  2028.  
  2029.  
  2030.  
  2031.  
  2032.  
  2033.         3.4. Basic System
  2034.  
  2035.  
  2036.  
  2037.         The minimum files you need from PCC.ARC are PCC.EXE, PC2.EXE, 
  2038.  
  2039.         PCCA.EXE, and PCCS.S.  The files STDIO.H and MATH.H contain 
  2040.  
  2041.         useful declarations.
  2042.  
  2043.  
  2044.  
  2045.         If you are developing in a directory other than the one that 
  2046.  
  2047.         contains the PCC files, be sure to set the PATH environment 
  2048.  
  2049.         variable to include the PCC directory.
  2050.  
  2051.  
  2052.  
  2053.         3.5. Setting Up DOS 2.xx, 3.xx, ...
  2054.  
  2055.  
  2056.  
  2057.         For systems utilizing DOS 2.x or later versions of the operating 
  2058.  
  2059.         systems, make sure that the ASCII text file CONFIG.SYS exists on 
  2060.  
  2061.         your boot disk.
  2062.  
  2063.           
  2064.  
  2065.         The file must contain the line:
  2066.  
  2067.  
  2068.  
  2069.                 FILES=20
  2070.  
  2071.  
  2072.  
  2073.         since PCC supports 20 open files Q stdin, stdout, stderr, and 17 
  2074.  
  2075.         other files.  The default number of eight is insufficient for the 
  2076.  
  2077.         PCCL program.
  2078.  
  2079.  
  2080.  
  2081.         If there is enough memory available, add the line:
  2082.  
  2083.  
  2084.  
  2085.                 BUFFERS=20
  2086.  
  2087.  
  2088.  
  2089.         to improve file performance in the operating system.  512 bytes 
  2090.  
  2091.         are allocated for each buffer specified.
  2092.  
  2093.  
  2094.  
  2095.  
  2096.  
  2097.  
  2098.  
  2099.  
  2100.  
  2101.  
  2102.  
  2103.  
  2104.  
  2105.  
  2106.  
  2107.  
  2108.  
  2109.  
  2110.  
  2111.  
  2112.  
  2113.         An Introduction to PCC                              Page 11
  2114.  
  2115.  
  2116.  
  2117.  
  2118.  
  2119.         3.6. RAM DISK
  2120.  
  2121.  
  2122.  
  2123.         If you have a system with more than 256 kilobytes of memory, then 
  2124.  
  2125.         the Ram Disk driver RAM.COM can be used to create an  extremely 
  2126.  
  2127.         fast disk.  To add a Ram Disk, copy the RAM.COM file from the 
  2128.  
  2129.         distribution diskette to the system disk and add the line:
  2130.  
  2131.  
  2132.  
  2133.                 DEVICE=RAM.COM   n
  2134.  
  2135.  
  2136.  
  2137.         to the CONFIG.SYS file.  The parameter, n, is a decimal number 
  2138.  
  2139.         from 32 to 650 indicating the size of the Ram Disk.  The value is 
  2140.  
  2141.         specified in units of one kilobyte (1024).  
  2142.  
  2143.  
  2144.  
  2145.         Re-boot the system to install the Ram Disk.  The drive letter 
  2146.  
  2147.         used for this 'disk drive' is dependent on the configuration of 
  2148.  
  2149.         the system.  DOS will install the Ram Disk at the first free 
  2150.  
  2151.         device "slot".  For an IBM PC with two floppies, this will 
  2152.  
  2153.         probably be drive C:.  For an XT, it will probably be drive D:.  
  2154.  
  2155.         Sanyo 550/5 reserves the first four slots for its floppies, so 
  2156.  
  2157.         the Ram Disk is drive E:.  To find where DOS has installed the 
  2158.  
  2159.         Ram Disk, use
  2160.  
  2161.  
  2162.  
  2163.                 chkdsk x:
  2164.  
  2165.  
  2166.  
  2167.         where x takes on the values c, d, ....  You will get either a 
  2168.  
  2169.         disk error, or a return showing the size of the Ram Disk.  Once 
  2170.  
  2171.         you find it, the Ram Disk will always be the same until you add 
  2172.  
  2173.         other device drivers before it in the CONFIG.SYS file.
  2174.  
  2175.  
  2176.  
  2177.         3.7. Completion Codes
  2178.  
  2179.  
  2180.  
  2181.         The PCC, PCCA, and PCCL programs set the completion code to:
  2182.  
  2183.  
  2184.  
  2185.                  zero  if no warnings or errors occurred,
  2186.  
  2187.                  one  if warnings were issued, and
  2188.  
  2189.                  two if errors occurred.
  2190.  
  2191.  
  2192.  
  2193.         Batch files can take advantage of these values to stop execution 
  2194.  
  2195.         or otherwise handle these exceptional cases.
  2196.  
  2197.  
  2198.  
  2199.         The following batch file will stop on a PCC or PCCL error:
  2200.  
  2201.  
  2202.  
  2203.              PCC %1
  2204.  
  2205.              if errorlevel 1 goto stop
  2206.  
  2207.              bind %1
  2208.  
  2209.              if errorlevel 1 goto stop
  2210.  
  2211.              %1
  2212.  
  2213.              :stop
  2214.  
  2215.  
  2216.  
  2217.         More complicated development situations can be handled with the 
  2218.  
  2219.         program LATER which is supplied in source form in the file 
  2220.  
  2221.         LATER.C.  LATER takes a list of filenames as arguments.  It sets 
  2222.  
  2223.         the errorlevel to one if the last file does not exist or if the 
  2224.  
  2225.         last file has an earlier modification date than any other file in 
  2226.  
  2227.         the list.  It can only be used on systems with a battery backup 
  2228.  
  2229.  
  2230.  
  2231.  
  2232.  
  2233.  
  2234.  
  2235.  
  2236.  
  2237.  
  2238.  
  2239.  
  2240.  
  2241.  
  2242.  
  2243.  
  2244.  
  2245.         An Introduction to PCC                              Page 12
  2246.  
  2247.  
  2248.  
  2249.  
  2250.  
  2251.         clock or where users are careful about setting the date and time 
  2252.  
  2253.         when the system is brought up.  Assume a program is composed of 
  2254.  
  2255.         the files moda.c, modb.c, modc.c and the include file mod.h.  The 
  2256.  
  2257.         following .BAT file can be used to regenerate the program 
  2258.  
  2259.         whenever a module changes:
  2260.  
  2261.  
  2262.  
  2263.              later moda.c mod.h moda.o
  2264.  
  2265.                   if errorlevel 1 PCC moda
  2266.  
  2267.                        if errorlevel 1 goto stop
  2268.  
  2269.              later modb.c mod.h modb.o
  2270.  
  2271.                   if errorlevel 1 PCC modb
  2272.  
  2273.                        if errorlevel 1 goto stop
  2274.  
  2275.              later modc.c mod.h modc.o
  2276.  
  2277.                   if errorlevel 1 PCC modc
  2278.  
  2279.                        if errorlevel 1 goto stop
  2280.  
  2281.              later moda.o modb.o modc.o mod.exe
  2282.  
  2283.                   if errorlevel 1 bind moda modb modc -omod
  2284.  
  2285.              :stop
  2286.  
  2287.  
  2288.  
  2289.         This provides a service similar to the UNIX MAKE program.  Only 
  2290.  
  2291.         those files that need to be compiled will be compiled.
  2292.  
  2293.  
  2294.  
  2295.  
  2296.  
  2297.  
  2298.  
  2299.  
  2300.  
  2301.  
  2302.  
  2303.  
  2304.  
  2305.  
  2306.  
  2307.  
  2308.  
  2309.  
  2310.  
  2311.  
  2312.  
  2313.  
  2314.  
  2315.  
  2316.  
  2317.  
  2318.  
  2319.  
  2320.  
  2321.  
  2322.  
  2323.  
  2324.  
  2325.  
  2326.  
  2327.  
  2328.  
  2329.  
  2330.  
  2331.  
  2332.  
  2333.  
  2334.  
  2335.  
  2336.  
  2337.  
  2338.  
  2339.  
  2340.  
  2341.  
  2342.  
  2343.  
  2344.  
  2345.  
  2346.  
  2347.  
  2348.  
  2349.  
  2350.  
  2351.  
  2352.  
  2353.  
  2354.  
  2355.  
  2356.  
  2357.  
  2358.  
  2359.  
  2360.  
  2361.  
  2362.  
  2363.  
  2364.  
  2365.  
  2366.  
  2367.  
  2368.  
  2369.  
  2370.  
  2371.  
  2372.  
  2373.  
  2374.  
  2375.  
  2376.  
  2377.         PCC -- The Personal C Compiler                      Page 13
  2378.  
  2379.  
  2380.  
  2381.  
  2382.  
  2383.         4. PCC -- The Personal C Compiler
  2384.  
  2385.  
  2386.  
  2387.         4.1. Introduction
  2388.  
  2389.  
  2390.  
  2391.         PCC is the C compiler for the 8088/8086 family of 
  2392.  
  2393.         microprocessors.  It accepts C source programs as input and 
  2394.  
  2395.         produces object files. The model employed by the compiler 
  2396.  
  2397.         efficiently utilizes the 8088/8086 architecture but limits a 
  2398.  
  2399.         program to 64KB code and 64KB of data.
  2400.  
  2401.  
  2402.  
  2403.  
  2404.  
  2405.         Invocation
  2406.  
  2407.  
  2408.  
  2409.            PCC <filename> [options]
  2410.  
  2411.  
  2412.  
  2413.         <filename> is the name of the file containing the C source. If it 
  2414.  
  2415.                    does not include an extension, the extension '.C' is 
  2416.  
  2417.                    assumed.
  2418.  
  2419.  
  2420.  
  2421.         Options: The case of the option is not significant. Each option 
  2422.  
  2423.         should be separated from other options by blanks.  Options may be 
  2424.  
  2425.         preceded with the dash (-) character.
  2426.  
  2427.  
  2428.  
  2429.         A          - assembly output.  This option indicates that the 
  2430.  
  2431.                    compiler should produce an assembly language source 
  2432.  
  2433.                    file instead of an object file.  The name of the 
  2434.  
  2435.                    assembly language file will be the same as the name of 
  2436.  
  2437.                    the source file but will have the extension '.A'.
  2438.  
  2439.  
  2440.  
  2441.         D<name>    - compiler drive specification.  The compiler assumes 
  2442.  
  2443.                    that the files GEN.EXE and ASM88.EXE are in the 
  2444.  
  2445.                    default directory on the current drive.  This option 
  2446.  
  2447.                    is used to inform the compiler that the files are on a 
  2448.  
  2449.                    different drive.  For example, if the compiler is on 
  2450.  
  2451.                    drive 'M', then the option 'DM' is needed.
  2452.  
  2453.  
  2454.  
  2455.                    Under MS-DOS 2.0 and later versions of the operating 
  2456.  
  2457.                    system, this option is rarely  needed as the system 
  2458.  
  2459.                    PATH variable is also used to find the other passes of 
  2460.  
  2461.                    the compiler.
  2462.  
  2463.  
  2464.  
  2465.         I<name>    - include path name.  This option overrides the 
  2466.  
  2467.                    default drive/directory for files included with the 
  2468.  
  2469.                    #include control. The directory name must end with a 
  2470.  
  2471.                    trailing backslash (\) character  (e.g. -
  2472.  
  2473.                    ic:\src\include\).  See section 4.4.1 for #include 
  2474.  
  2475.                    details.
  2476.  
  2477.  
  2478.  
  2479.         N<defname>=<defvalue> - specify #define  name and value.  Used to 
  2480.  
  2481.                    set debugging switches or constant values without 
  2482.  
  2483.                    editing the file.  This option is equivalent to
  2484.  
  2485.  
  2486.  
  2487.                         #define defname defvalue
  2488.  
  2489.  
  2490.  
  2491.                    at the begining of the program.
  2492.  
  2493.  
  2494.  
  2495.  
  2496.  
  2497.  
  2498.  
  2499.  
  2500.  
  2501.  
  2502.  
  2503.  
  2504.  
  2505.  
  2506.  
  2507.  
  2508.  
  2509.         PCC -- The Personal C Compiler                      Page 14
  2510.  
  2511.  
  2512.  
  2513.  
  2514.  
  2515.                    To set <defname> to one, enter n<defname>, which is 
  2516.  
  2517.                    equivalent to
  2518.  
  2519.  
  2520.  
  2521.                         #define defname 1
  2522.  
  2523.  
  2524.  
  2525.                    Spaces are not allowed.
  2526.  
  2527.  
  2528.  
  2529.         O<filename> - output filename.  The compiler will produce an 
  2530.  
  2531.                    object file with the specified name.  If the name 
  2532.  
  2533.                    lacks an extension, the extension '.O' will be added.  
  2534.  
  2535.                    The default object name is the same as the source name 
  2536.  
  2537.                    with the extension of '.O'.
  2538.  
  2539.  
  2540.  
  2541.         T<drive>   - specifies the drive that the compiler should use for 
  2542.  
  2543.                    its temporary files.  If not specified, the compiler 
  2544.  
  2545.                    will build its temporary files on the default drive.  
  2546.  
  2547.                    If this drive is close to being full, the 'T' option 
  2548.  
  2549.                    should be used to change the drive for the 
  2550.  
  2551.                    temporaries.  Also, if the RAM Disk has been 
  2552.  
  2553.                    installed, placing the temporary files there will 
  2554.  
  2555.                    drastically cut the amount of time needed to compile a 
  2556.  
  2557.                    program.
  2558.  
  2559.  
  2560.  
  2561.  
  2562.  
  2563.         4.2. Examples
  2564.  
  2565.  
  2566.  
  2567.         PCC blip
  2568.  
  2569.                    compiles the file named blip.c.  The object file will 
  2570.  
  2571.                    be named blip.o.
  2572.  
  2573.  
  2574.  
  2575.         m:PCC b:blip.ccc tm dm
  2576.  
  2577.  
  2578.  
  2579.                    runs the compiler from drive M on the file b:blip.ccc.  
  2580.  
  2581.                    Temporary files are also written on drive M.  Note the 
  2582.  
  2583.                    use of the D option to indicate the location of the 
  2584.  
  2585.                    other passes of the compiler.  The object file will 
  2586.  
  2587.                    also be named blip.o.
  2588.  
  2589.  
  2590.  
  2591.         PCC blip -ic:\inc\ -a -nNewVersion -nNYear=1985
  2592.  
  2593.  
  2594.  
  2595.                    compiles the file named blip.c.  Include files are 
  2596.  
  2597.                    taken from the directory c:\inc\.  An assembly 
  2598.  
  2599.                    language file is generated named blip.a.  The 'N' 
  2600.  
  2601.                    options are equivalent to adding
  2602.  
  2603.  
  2604.  
  2605.                         #define NewVersion 1
  2606.  
  2607.                         #define NYear       1985
  2608.  
  2609.  
  2610.  
  2611.                    to the start of blip.c
  2612.  
  2613.  
  2614.  
  2615.  
  2616.  
  2617.  
  2618.  
  2619.  
  2620.  
  2621.  
  2622.  
  2623.  
  2624.  
  2625.  
  2626.  
  2627.  
  2628.  
  2629.  
  2630.  
  2631.  
  2632.  
  2633.  
  2634.  
  2635.  
  2636.  
  2637.  
  2638.  
  2639.  
  2640.  
  2641.         PCC -- The Personal C Compiler                      Page 15
  2642.  
  2643.  
  2644.  
  2645.  
  2646.  
  2647.         4.3. The C Language
  2648.  
  2649.  
  2650.  
  2651.         PCC compiles C programs that conform to the standard definition 
  2652.  
  2653.         of the C language as described in the book The C Programming 
  2654.  
  2655.         Language  by Brian W. Kernighan and Dennis M. Ritchie.  The 
  2656.  
  2657.         following documentation describes the implementation.
  2658.  
  2659.  
  2660.  
  2661.         4.3.1. Preprocessor directives
  2662.  
  2663.  
  2664.  
  2665.         #define    defines a macro with or without parameters. 
  2666.  
  2667.  
  2668.  
  2669.         #undef, #ifdef and #ifndef - tests the status of the #defined 
  2670.  
  2671.                    macros 
  2672.  
  2673.  
  2674.  
  2675.         #include   includes other files into the program. #include's 
  2676.  
  2677.                    can be nested to a maximum depth of 3.
  2678.  
  2679.  
  2680.  
  2681.                    #include "filename" will search the default directory 
  2682.  
  2683.                    for the file filename.  #include <filename> will first 
  2684.  
  2685.                    search the default directory for filename.  If the 
  2686.  
  2687.                    file was not found, the environment (see DOS 2.X/3.X 
  2688.  
  2689.                    SET command) is searched for the variable INCLUDE .  
  2690.  
  2691.                    If the variable is found, it is assumed to contain a 
  2692.  
  2693.                    set of directory prefixes separated by semi-colons.  
  2694.  
  2695.                    For example, if INCLUDE is set as follows
  2696.  
  2697.                 
  2698.  
  2699.                         C>set include=c:\;c:\usr\include\
  2700.  
  2701.  
  2702.  
  2703.                    then the line
  2704.  
  2705.  
  2706.  
  2707.                         #include <world.h>
  2708.  
  2709.  
  2710.  
  2711.                    would cause PCC to search for
  2712.  
  2713.  
  2714.  
  2715.                         world.h
  2716.  
  2717.                         c:\world.h
  2718.  
  2719.                         c:\usr\include\world.h
  2720.  
  2721.  
  2722.  
  2723.         #if, #else, #endif - conditionally includes or excludes source 
  2724.  
  2725.                    statements.
  2726.  
  2727.  
  2728.  
  2729.         4.3.2. Data Types
  2730.  
  2731.  
  2732.  
  2733.         char       Unsigned byte with a range of 0 to 255.
  2734.  
  2735.  
  2736.  
  2737.         int
  2738.  
  2739.         short      Signed Integer with a range of -32768 to 32767.
  2740.  
  2741.  
  2742.  
  2743.         unsigned   Unsigned integer with a range of 0 to 65535.
  2744.  
  2745.  
  2746.  
  2747.         long       Signed integer with a range of -2147483648 to 
  2748.  
  2749.                    2147483647.
  2750.  
  2751.  
  2752.  
  2753.         float      Four byte floating point value.  A float number has 
  2754.  
  2755.                    about 7 digits of precision and has a range of about 
  2756.  
  2757.  
  2758.  
  2759.  
  2760.  
  2761.  
  2762.  
  2763.  
  2764.  
  2765.  
  2766.  
  2767.  
  2768.  
  2769.  
  2770.  
  2771.  
  2772.  
  2773.         PCC -- The Personal C Compiler                      Page 16
  2774.  
  2775.  
  2776.  
  2777.  
  2778.  
  2779.                    1.E-36 to 1.E+36. The floating point formats are 
  2780.  
  2781.                    defined by the IEEE floating-point standard.
  2782.  
  2783.  
  2784.  
  2785.         double     Eight byte floating point value.  A double number has 
  2786.  
  2787.                    about 13 digits of precision and a range of about 1.E-
  2788.  
  2789.                    303 to 1.E+303.
  2790.  
  2791.  
  2792.  
  2793.         (pointer)  pointers are two bytes, limiting total data space to 
  2794.  
  2795.                    64KB.
  2796.  
  2797.  
  2798.  
  2799.         To take advantage of the 8088/8086 instruction set, expressions 
  2800.  
  2801.         involving only char  types are not coerced to int before 
  2802.  
  2803.         evaluation.  The sum of a char equal to 255 and a char equal to 1 
  2804.  
  2805.         is 0 rather than 256.  Constants are considered to be int values 
  2806.  
  2807.         so that constant plus char is a two byte integer operation.
  2808.  
  2809.  
  2810.  
  2811.         4.4. Extensions
  2812.  
  2813.  
  2814.  
  2815.         The UNIX Version 7 extensions -- enumerated types, extended 
  2816.  
  2817.         member name-space, and structure assignment are fully supported.
  2818.  
  2819.  
  2820.  
  2821.         Enumerated types provide a convenient method of declaring an 
  2822.  
  2823.         ordered set of named constants.  Values start with zero, and may 
  2824.  
  2825.         be reassigned with a name = value expression.  The same value may 
  2826.  
  2827.         be assigned to several names.  For example
  2828.  
  2829.  
  2830.  
  2831.                 enum color {red, blue=4, green} ca, *cp;
  2832.  
  2833.                 enum color cb;
  2834.  
  2835.                 if(ca == red)
  2836.  
  2837.                         cb = green;
  2838.  
  2839.         is equivalent to
  2840.  
  2841.  
  2842.  
  2843.                 #define red   0
  2844.  
  2845.                 #define blue  4
  2846.  
  2847.                 #define green 5
  2848.  
  2849.                 int ca, *cp;
  2850.  
  2851.                 int cb;
  2852.  
  2853.                 if(ca == red)
  2854.  
  2855.                         cb = green;
  2856.  
  2857.  
  2858.  
  2859.  
  2860.  
  2861.         Extended member name-space relaxes the K&R requirement that if a 
  2862.  
  2863.         member name appeared in more than one structure or union, then it 
  2864.  
  2865.         had to have the same data type and offset in every appearance.  
  2866.  
  2867.         Now, the only restriction is that the member name must be unique 
  2868.  
  2869.         within the structure or union.  If a member name is used that is 
  2870.  
  2871.         not in the referenced structure, the warning
  2872.  
  2873.  
  2874.  
  2875.                 member not in structure
  2876.  
  2877.  
  2878.  
  2879.         is issued.  As a loophole, a pointer to char may be used as an 
  2880.  
  2881.  
  2882.  
  2883.  
  2884.  
  2885.  
  2886.  
  2887.  
  2888.  
  2889.  
  2890.  
  2891.  
  2892.  
  2893.  
  2894.  
  2895.  
  2896.  
  2897.  
  2898.  
  2899.  
  2900.  
  2901.  
  2902.  
  2903.  
  2904.  
  2905.         PCC -- The Personal C Compiler                      Page 17
  2906.  
  2907.  
  2908.  
  2909.  
  2910.  
  2911.         anonymous pointer to any structure.
  2912.  
  2913.                 struct {int i, j, k;} zip;
  2914.  
  2915.                 struct {int j; char i;} zap, *zp;
  2916.  
  2917.                 char *cp;
  2918.  
  2919.  
  2920.  
  2921.                 zip.i = 1;      /* OK */
  2922.  
  2923.                 zap.i = 1;      /* OK */
  2924.  
  2925.                 zap.k = 1;      /* WARNING */
  2926.  
  2927.                 zp->i = 1;      /* OK */
  2928.  
  2929.                 zp->k = 1;      /* WARNING */
  2930.  
  2931.                 cp->k = 1;      /* OK, ANONYMOUS */
  2932.  
  2933.  
  2934.  
  2935.         Structures can be assigned, used as parameters, or returned from 
  2936.  
  2937.         a function.  CAUTION: this may create problems with existing 
  2938.  
  2939.         programs because previous versions of PCC converted the name of a 
  2940.  
  2941.         structure in a parameter list to a pointer to that structure, 
  2942.  
  2943.         while the current release pushes the entire structure.  To 
  2944.  
  2945.         highlight this potential problem, PCC will issue the following 
  2946.  
  2947.         warning
  2948.  
  2949.  
  2950.  
  2951.                 structure assignment
  2952.  
  2953.  
  2954.  
  2955.         when structures are passed by value, and the warning
  2956.  
  2957.  
  2958.  
  2959.                 returns structure
  2960.  
  2961.  
  2962.  
  2963.         when a function returns a structure.  These warnings will be 
  2964.  
  2965.         removed in a future release.
  2966.  
  2967.                 
  2968.  
  2969.                 struct z {int i, j;} zip, zap, zxax();
  2970.  
  2971.                 main(){
  2972.  
  2973.                         zip = zap;  /* structure assignment */
  2974.  
  2975.                         zap = zmax(zip, zap);
  2976.  
  2977.                         }
  2978.  
  2979.                 struct z zmax(a,b) /* func returns struct */
  2980.  
  2981.                         struct z a, b; {
  2982.  
  2983.                         if(a.i > b.i)
  2984.  
  2985.                                 return a;
  2986.  
  2987.                         return b;
  2988.  
  2989.                         }
  2990.  
  2991.  
  2992.  
  2993.         Variable names are significant to 31 characters instead of 8.
  2994.  
  2995.  
  2996.  
  2997.         A #asm directive has been included to allow in-line assembly 
  2998.  
  2999.         language code for time critical applications.  All lines 
  3000.  
  3001.         following a line starting with #asm are  passed through to the 
  3002.  
  3003.         assembler.  The next line beginning with the "#' character, ends 
  3004.  
  3005.         the in-line assembly code.
  3006.  
  3007.  
  3008.  
  3009.  
  3010.  
  3011.  
  3012.  
  3013.  
  3014.  
  3015.  
  3016.  
  3017.  
  3018.  
  3019.  
  3020.  
  3021.  
  3022.  
  3023.  
  3024.  
  3025.  
  3026.  
  3027.  
  3028.  
  3029.  
  3030.  
  3031.  
  3032.  
  3033.  
  3034.  
  3035.  
  3036.  
  3037.         PCC -- The Personal C Compiler                      Page 18
  3038.  
  3039.  
  3040.  
  3041.  
  3042.  
  3043.         For example:
  3044.  
  3045.  
  3046.  
  3047.                 _move(count, src, tar)
  3048.  
  3049.                 int count; char *src, *tar; {
  3050.  
  3051.                 #asm
  3052.  
  3053.                         MOV             CX,[BP+4] ;count
  3054.  
  3055.                         MOV             SI,[BP+6] ;src
  3056.  
  3057.                         MOV             DI,[BP+8] ;dst
  3058.  
  3059.                         MOV             AX,DS
  3060.  
  3061.                         MOV             ES,AX
  3062.  
  3063.                         CLD
  3064.  
  3065.                         REP MOVSB
  3066.  
  3067.                 #
  3068.  
  3069.                         }
  3070.  
  3071.  
  3072.  
  3073.         4.4.1. Forward References
  3074.  
  3075.  
  3076.  
  3077.         PCC is effectively a one pass compiler so forward references will 
  3078.  
  3079.         not work.  The following program:
  3080.  
  3081.  
  3082.  
  3083.               main() {
  3084.  
  3085.                   i=99;
  3086.  
  3087.                   }
  3088.  
  3089.              extern int i;
  3090.  
  3091.  
  3092.  
  3093.         will produce a warning that 'i' is undefined and is assumed to be  
  3094.  
  3095.         a local variable named 'i'.  The global variable 'i' will not be 
  3096.  
  3097.         changed.
  3098.  
  3099.  
  3100.  
  3101.         Structure tags must be defined before being referenced.  The only 
  3102.  
  3103.         exception is pointers, so that legal structure declarations 
  3104.  
  3105.         include structures of the form:
  3106.  
  3107.  
  3108.  
  3109.  
  3110.  
  3111.             struct a {
  3112.  
  3113.                 struct b *x;
  3114.  
  3115.                 }
  3116.  
  3117.  
  3118.  
  3119.             struct b {
  3120.  
  3121.                 struct a *y;
  3122.  
  3123.                 }
  3124.  
  3125.  
  3126.  
  3127.  
  3128.  
  3129.         4.4.2. Externs
  3130.  
  3131.  
  3132.  
  3133.         The rules for 'extern' declarations are:
  3134.  
  3135.  
  3136.  
  3137.         1.   Statements that are global to the source file, like 'int 
  3138.  
  3139.              blip;' may be in several different files that are linked 
  3140.  
  3141.              together.  The BINDer will allocate 2 bytes for the global 
  3142.  
  3143.              integer variable blip.  This is an extension to the standard 
  3144.  
  3145.              rule that restrict global declarations to a single file and 
  3146.  
  3147.              require all the other declarations to be extern.
  3148.  
  3149.  
  3150.  
  3151.  
  3152.  
  3153.  
  3154.  
  3155.  
  3156.  
  3157.  
  3158.  
  3159.  
  3160.  
  3161.  
  3162.  
  3163.  
  3164.  
  3165.  
  3166.  
  3167.  
  3168.  
  3169.         PCC -- The Personal C Compiler                      Page 19
  3170.  
  3171.  
  3172.  
  3173.  
  3174.  
  3175.         2.   A declaration that includes the keyword 'extern' may not 
  3176.  
  3177.              include initializers and does not allocate any memory.  Thus 
  3178.  
  3179.              a variable so declared must be declared somewhere else 
  3180.  
  3181.              without the 'extern' keyword in order to reserve memory for 
  3182.  
  3183.              the variable.  For example, if a file contains the 
  3184.  
  3185.              declaration extern int blip   then some other file must 
  3186.  
  3187.              contain the declaration   int blip to actually allocate 
  3188.  
  3189.              storage.  If this is not done, the binder will complain 
  3190.  
  3191.              about a reference to the unresolved symbol blip.  It is 
  3192.  
  3193.              permissible to have both an 'extern' and non-'extern' 
  3194.  
  3195.              declaration in a single file.  For example,
  3196.  
  3197.  
  3198.  
  3199.  
  3200.  
  3201.                 extern int blip;
  3202.  
  3203.                 int blip;
  3204.  
  3205.  
  3206.  
  3207.              is valid.
  3208.  
  3209.  
  3210.  
  3211.         To create include files containing data declarations -- if the 
  3212.  
  3213.         variable is not initialized (which means it will be initialized 
  3214.  
  3215.         with zeros) either include the declaration:
  3216.  
  3217.  
  3218.  
  3219.                 int blip;
  3220.  
  3221.  
  3222.  
  3223.         in every file or include the declaration:
  3224.  
  3225.  
  3226.  
  3227.                 extern int blip;
  3228.  
  3229.  
  3230.  
  3231.         in every file and add the declaration:
  3232.  
  3233.  
  3234.  
  3235.                 int blip;
  3236.  
  3237.  
  3238.  
  3239.         to one of the files to actually allocate the storage.
  3240.  
  3241.  
  3242.  
  3243.         If the variable needs initialization, the second approach must be 
  3244.  
  3245.         used.  Include the declaration:
  3246.  
  3247.  
  3248.  
  3249.                 extern int blip;
  3250.  
  3251.  
  3252.  
  3253.         in the include file.  Initialize the value in only one file:
  3254.  
  3255.  
  3256.  
  3257.                 int blip = 1985;
  3258.  
  3259.  
  3260.  
  3261.         These rules are about the same as Version 7 UNIX.  Extern rules 
  3262.  
  3263.         are an area of C that are currently controversial.  System V UNIX 
  3264.  
  3265.         tried to tighten up the rules but enough people complained that 
  3266.  
  3267.         5.2 is back to normal.
  3268.  
  3269.  
  3270.  
  3271.  
  3272.  
  3273.  
  3274.  
  3275.  
  3276.  
  3277.  
  3278.  
  3279.  
  3280.  
  3281.  
  3282.  
  3283.  
  3284.  
  3285.  
  3286.  
  3287.  
  3288.  
  3289.  
  3290.  
  3291.  
  3292.  
  3293.  
  3294.  
  3295.  
  3296.  
  3297.  
  3298.  
  3299.  
  3300.  
  3301.         PCC -- The Personal C Compiler                      Page 20
  3302.  
  3303.  
  3304.  
  3305.  
  3306.  
  3307.         4.4.3. Macros
  3308.  
  3309.  
  3310.  
  3311.         Macro arguments are not replaced within a quoted string.   For 
  3312.  
  3313.         example, in The C Puzzle Book by Alan Feuer the macros in 
  3314.  
  3315.         <defs.h> use the following construct to customize printf() calls.
  3316.  
  3317.  
  3318.  
  3319.                 #define PR(fmt,v)printf("value=%fmt%t",v);
  3320.  
  3321.  
  3322.  
  3323.         This does not work with the PCC compiler.  Instead add the 
  3324.  
  3325.         following defines to <defs.h>:
  3326.  
  3327.  
  3328.  
  3329.                 #define D "value = %d%t"
  3330.  
  3331.                 #define F "value = %f%t"
  3332.  
  3333.                 #define C "value = %c%t"
  3334.  
  3335.                 #define G "value = %g%t"
  3336.  
  3337.  
  3338.  
  3339.         and change the PR define to
  3340.  
  3341.  
  3342.  
  3343.                 #define PR(fmt,v)printf(fmt,(v));
  3344.  
  3345.  
  3346.  
  3347.         Statements of the type
  3348.  
  3349.  
  3350.  
  3351.             PRINT1(d,x);
  3352.  
  3353.  
  3354.  
  3355.         must be changed to
  3356.  
  3357.  
  3358.  
  3359.             PRINT1(D,x);
  3360.  
  3361.  
  3362.  
  3363.         in the programs.  Lower case D, F, C, and G's would allow the 
  3364.  
  3365.         programs to remain unchanged but variables c and g are used in 
  3366.  
  3367.         structure one and variable g is used in structures two and three.
  3368.  
  3369.  
  3370.  
  3371.  
  3372.  
  3373.         4.4.4. Strings
  3374.  
  3375.  
  3376.  
  3377.         Literal character strings delimited by quotes ('\"') cannot 
  3378.  
  3379.         contain the NUL character ('\0').  The compiler terminates the 
  3380.  
  3381.         string at the NUL character, even though it checks that the 
  3382.  
  3383.         string has a terminating quote character.  If you want NUL 
  3384.  
  3385.         characters in the string for initialization purposes, use an 
  3386.  
  3387.         array assignment.
  3388.  
  3389.  
  3390.  
  3391.                 char init1[]="abcdef@xyz@012", *ip=init1;
  3392.  
  3393.                 
  3394.  
  3395.                 while(ip = index(ip, '@'))
  3396.  
  3397.                         *ip = '\0';
  3398.  
  3399.  
  3400.  
  3401.  
  3402.  
  3403.  
  3404.  
  3405.  
  3406.  
  3407.  
  3408.  
  3409.  
  3410.  
  3411.  
  3412.  
  3413.  
  3414.  
  3415.  
  3416.  
  3417.  
  3418.  
  3419.  
  3420.  
  3421.  
  3422.  
  3423.  
  3424.  
  3425.  
  3426.  
  3427.  
  3428.  
  3429.  
  3430.  
  3431.  
  3432.  
  3433.         The PCCA 8088 Assembler                            Page 21
  3434.  
  3435.  
  3436.  
  3437.  
  3438.  
  3439.         5. The PCCA 8088 Assembler
  3440.  
  3441.  
  3442.  
  3443.         5.1. Introduction
  3444.  
  3445.  
  3446.  
  3447.         PCCA is the 8088/8086 assembler.  It reads assembly language 
  3448.  
  3449.         source files and produces linkable object files.
  3450.  
  3451.  
  3452.  
  3453.         5.2. Invocation
  3454.  
  3455.  
  3456.  
  3457.             PCCA <filename> [ options ]
  3458.  
  3459.  
  3460.  
  3461.         <filename> is the name of the assembly language source file.  If 
  3462.  
  3463.                    it does not include an extension Q the extension '.A' 
  3464.  
  3465.                    is assumed.
  3466.  
  3467.  
  3468.  
  3469.         Options: The case of the option is not significant. Each option 
  3470.  
  3471.         should be separated from other options by blanks.  Options may be 
  3472.  
  3473.         preceded with the dash (-) character.
  3474.  
  3475.  
  3476.  
  3477.         L[ <filename> ] -- The assembler will produce a listing from the 
  3478.  
  3479.                    assembly language input.  This listing includes the 
  3480.  
  3481.                    hex-values generated by the assembler as well as line 
  3482.  
  3483.                    numbers and pagination.  If no name is specified, then 
  3484.  
  3485.                    the name of the source file with the extension '.L' is 
  3486.  
  3487.                    used.  If the specified file does not have an 
  3488.  
  3489.                    extension, '.L' will be used.  Otherwise the listing 
  3490.  
  3491.                    is written to the specified file.  To generate a 
  3492.  
  3493.                    listing on the printer, use '-LPRN:'.
  3494.  
  3495.  
  3496.  
  3497.         O<filename> The assembler will produce an object file with the 
  3498.  
  3499.                    specified name.  If the name lacks an extension, then 
  3500.  
  3501.                    the extension '.O' will be appended to the name.  The 
  3502.  
  3503.                    default object file name is the name of the source 
  3504.  
  3505.                    file with the extension changed to '.O'.
  3506.  
  3507.  
  3508.  
  3509.         T<drive>   The 'T' option specifies the drive where the assembler 
  3510.  
  3511.                    temporary files will be created.  If a RAM Disk is 
  3512.  
  3513.                    available, redirecting temporary files to that drive 
  3514.  
  3515.                    will greatly speed development.  The assembler 
  3516.  
  3517.                    normally creates its temporary files on the default 
  3518.  
  3519.                    drive/directory.
  3520.  
  3521.  
  3522.  
  3523.         Pnn        Specifies page length, in lines.  The default is 66.
  3524.  
  3525.  
  3526.  
  3527.         Wnn        Specifies page width, in characters, for the list 
  3528.  
  3529.                    file. The value nn must be a number from 60 to 132.  
  3530.  
  3531.                    The default is 80.
  3532.  
  3533.  
  3534.  
  3535.         5.3. Example
  3536.  
  3537.  
  3538.  
  3539.  
  3540.  
  3541.         pcca blip
  3542.  
  3543.                    assembles the file named blip.a and produces an object 
  3544.  
  3545.                    file named blip.o.
  3546.  
  3547.  
  3548.  
  3549.  
  3550.  
  3551.  
  3552.  
  3553.  
  3554.  
  3555.  
  3556.  
  3557.  
  3558.  
  3559.  
  3560.  
  3561.  
  3562.  
  3563.  
  3564.  
  3565.         The PCCA 8088 Assembler                            Page 22
  3566.  
  3567.  
  3568.  
  3569.  
  3570.  
  3571.         M:pcca blip.asm -Ob:blip Lblip.lst
  3572.  
  3573.  
  3574.  
  3575.                    runs the assembler from drive M: on the file named 
  3576.  
  3577.                    blip.asm.  The output is an object file named blip.o 
  3578.  
  3579.                    on drive B: and a listing file named blip.lst on the 
  3580.  
  3581.                    default drive.
  3582.  
  3583.  
  3584.  
  3585.         pcca blip.a TM -oa:blip.o -lb:blip.lst
  3586.  
  3587.  
  3588.  
  3589.                    assembles the file named blip.a.  Temporary files are 
  3590.  
  3591.                    created on drive M:.  The output of the assembler is 
  3592.  
  3593.                    placed on drive A: in the file blip.o.  A listing file 
  3594.  
  3595.                    is generated and written to drive B: in the file 
  3596.  
  3597.                    blip.lst
  3598.  
  3599.  
  3600.  
  3601.  
  3602.  
  3603.  
  3604.  
  3605.  
  3606.  
  3607.  
  3608.  
  3609.  
  3610.  
  3611.  
  3612.  
  3613.  
  3614.  
  3615.  
  3616.  
  3617.  
  3618.  
  3619.  
  3620.  
  3621.  
  3622.  
  3623.  
  3624.  
  3625.  
  3626.  
  3627.  
  3628.  
  3629.  
  3630.  
  3631.  
  3632.  
  3633.  
  3634.  
  3635.  
  3636.  
  3637.  
  3638.  
  3639.  
  3640.  
  3641.  
  3642.  
  3643.  
  3644.  
  3645.  
  3646.  
  3647.  
  3648.  
  3649.  
  3650.  
  3651.  
  3652.  
  3653.  
  3654.  
  3655.  
  3656.  
  3657.  
  3658.  
  3659.  
  3660.  
  3661.  
  3662.  
  3663.  
  3664.  
  3665.  
  3666.  
  3667.  
  3668.  
  3669.  
  3670.  
  3671.  
  3672.  
  3673.  
  3674.  
  3675.  
  3676.  
  3677.  
  3678.  
  3679.  
  3680.  
  3681.  
  3682.  
  3683.  
  3684.  
  3685.  
  3686.  
  3687.  
  3688.  
  3689.  
  3690.  
  3691.  
  3692.  
  3693.  
  3694.  
  3695.  
  3696.  
  3697.         The PCCL Object File Linker                        Page 23
  3698.  
  3699.  
  3700.  
  3701.  
  3702.  
  3703.         6. The PCCL Object File Linker
  3704.  
  3705.  
  3706.  
  3707.         6.1. Introduction
  3708.  
  3709.  
  3710.  
  3711.         PCCL is the program that links together object and library  
  3712.  
  3713.         modules and forms an executable program.  For very long command 
  3714.  
  3715.         lines, see the -f option.
  3716.  
  3717.  
  3718.  
  3719.  
  3720.  
  3721.         6.2. Invocation
  3722.  
  3723.  
  3724.  
  3725.                 PCCL <filename> <filename> ...  [options]
  3726.  
  3727.  
  3728.  
  3729.         <filename> A sequence of filenames separated by blanks. The 
  3730.  
  3731.                    filenames should be the names of object (.O) or 
  3732.  
  3733.                    library (.S) files.  If a filename does not have an 
  3734.  
  3735.                    extension, '.O' is assumed.  PCCL automatically looks 
  3736.  
  3737.                    for the supplied library PCCS.S so its name should 
  3738.  
  3739.                    not be included in the list of filenames.
  3740.  
  3741.  
  3742.  
  3743.         Options: All options may be in upper or lower case.  Options must 
  3744.  
  3745.         be separated by  blanks and preceded by a hyphen to differentiate 
  3746.  
  3747.         them from <filename>s.  Note that this is different from other 
  3748.  
  3749.         commands where the hyphen is optional.
  3750.  
  3751.  
  3752.  
  3753.         -A         The assembler option keeps PCCL from generating the C 
  3754.  
  3755.                    initialization code.  Instead, execution begins at the 
  3756.  
  3757.                    beginning of the code rather than starting at the 
  3758.  
  3759.                    main_ public label.  ARGC and ARGV are not calculated 
  3760.  
  3761.                    and the stack is not set up.  Uninitialized variables 
  3762.  
  3763.                    are not filled with zero.  Library functions such as 
  3764.  
  3765.                    creat() and open() cannot be used as they depend on 
  3766.  
  3767.                    the zero initialization.  The 'A' and 'S' options are 
  3768.  
  3769.                    useful for a few cases but caution should be exercised 
  3770.  
  3771.                    in their use.
  3772.  
  3773.  
  3774.  
  3775.         -F<filename> identifies a file containing <filename>s and options 
  3776.  
  3777.                    to be used by PCCL.  This is used for very long lists 
  3778.  
  3779.                    of filenames and options.
  3780.  
  3781.  
  3782.  
  3783.         -L<name>   specifies the drive/directory containing the PCCS.S 
  3784.  
  3785.                    standard library.  If this option is not specified, 
  3786.  
  3787.                    the PCCS.S file must be on the default drive.  With 
  3788.  
  3789.                    MS-DOS 2.0 and later versions of the operating system,  
  3790.  
  3791.                    the PATH system parameter is used to locate the 
  3792.  
  3793.                    library.
  3794.  
  3795.  
  3796.  
  3797.         -Mn        Indicates that the object files following this control 
  3798.  
  3799.                    should be collected in the memory-based overlay 
  3800.  
  3801.                    indicated by the value n ( 1 to 39 ).  See the 
  3802.  
  3803.                    description on overlays below for details on the 
  3804.  
  3805.                    overlay mechanism.
  3806.  
  3807.  
  3808.  
  3809.         -O<filename> changes the name of the output file to 
  3810.  
  3811.                    <filename>.EXE.  If this option is not specified, the 
  3812.  
  3813.  
  3814.  
  3815.  
  3816.  
  3817.  
  3818.  
  3819.  
  3820.  
  3821.  
  3822.  
  3823.  
  3824.  
  3825.  
  3826.  
  3827.  
  3828.  
  3829.         The PCCL Object File Linker                        Page 24
  3830.  
  3831.  
  3832.  
  3833.  
  3834.  
  3835.                    name of the first object file in the list with the 
  3836.  
  3837.                    .EXE extension will be used.
  3838.  
  3839.  
  3840.  
  3841.         -P[<filename>] Generates a sorted list of publics and offsets.  C 
  3842.  
  3843.                    procedures and data declared outside of procedures are  
  3844.  
  3845.                    automatically public (or extern)  unless explicitly 
  3846.  
  3847.                    declared static.  Publics with names starting with an 
  3848.  
  3849.                    underline '_' are not listed unless the -_ option is 
  3850.  
  3851.                    also specified. The optional name is the destination 
  3852.  
  3853.                    for the publics list.  If omitted, the publics and 
  3854.  
  3855.                    offsets are listed on the console.  The size of 
  3856.  
  3857.                    overlays, if any, will also be displayed.
  3858.  
  3859.  
  3860.  
  3861.         -Shhhh     specifies the stack size.  hhhh is in hex.   Normally, 
  3862.  
  3863.                    PCCL will set the stack size as large as possible.  
  3864.  
  3865.                    The '-S' option can be used to limit this size for use 
  3866.  
  3867.                    with exec().
  3868.  
  3869.          
  3870.  
  3871.         -Vn        This option is used to create disk-based overlays.  
  3872.  
  3873.                    All object files following this option, until the end 
  3874.  
  3875.                    of the list or another overlay option, are collected 
  3876.  
  3877.                    into the overlay indicated by the value n (1 to 39).  
  3878.  
  3879.                    See the overlay section below for details.
  3880.  
  3881.  
  3882.  
  3883.         -_ (underscore) PCCL normally suppresses names that start with an 
  3884.  
  3885.                    underscore (usually internal names) from the publics 
  3886.  
  3887.                    list. The underscore option restores these publics to 
  3888.  
  3889.                    the listing.  This option is useful when you need to 
  3890.  
  3891.                    see all the modules bound to your program.
  3892.  
  3893.  
  3894.  
  3895.  
  3896.  
  3897.         6.3. Examples
  3898.  
  3899.  
  3900.  
  3901.  
  3902.  
  3903.  
  3904.  
  3905.         pccl blip
  3906.  
  3907.                    links the file blip.o with PCCS.S and produces the 
  3908.  
  3909.                    executable file blip.exe.
  3910.  
  3911.  
  3912.  
  3913.         pccl proga progb progc lib.s -p
  3914.  
  3915.  
  3916.  
  3917.                    links the files proga.o, progb.o, and progc.o with the 
  3918.  
  3919.                    user library lib.s  and the standard I/O library, 
  3920.  
  3921.                    PCCS.S, into the application file proga.exe.  The 
  3922.  
  3923.                    map is printed on the screen.
  3924.  
  3925.  
  3926.  
  3927.         pccl proga progb -V1 progc -V2 progd -Pmap -_ -Omyprog
  3928.  
  3929.  
  3930.  
  3931.                    links the files proga.o, progb.o with PCCS.S and 
  3932.  
  3933.                    creates the executable file myprog.exe and the overlay 
  3934.  
  3935.                    file myprog.ov which contains two overlays consisting 
  3936.  
  3937.                    of the object files progc.o and prod.o.  The publics 
  3938.  
  3939.                    map is sent to the file named map and will also list 
  3940.  
  3941.                    the internal names that begin with the underline ('_') 
  3942.  
  3943.                    character.
  3944.  
  3945.  
  3946.  
  3947.  
  3948.  
  3949.  
  3950.  
  3951.  
  3952.  
  3953.  
  3954.  
  3955.  
  3956.  
  3957.  
  3958.  
  3959.  
  3960.  
  3961.         The PCCL Object File Linker                        Page 25
  3962.  
  3963.  
  3964.  
  3965.  
  3966.  
  3967.         6.4. Space Considerations
  3968.  
  3969.  
  3970.  
  3971.         A program is restricted to a maximum of 64KB of code and 64KB of 
  3972.  
  3973.         data plus the stack.  PCCL calculates the size of code and data 
  3974.  
  3975.         and will report the size of each segment (in hex) when the -P 
  3976.  
  3977.         option is specified.  PCCL cannot calculate the actual stack 
  3978.  
  3979.         requirements.  If the 'stack' and 'locals' size reported by PCCL 
  3980.  
  3981.         seems small, the actual stack requirements should be calculated 
  3982.  
  3983.         by hand to make sure there is enough space.  The actual require-
  3984.  
  3985.         ments are the worst case of four bytes per call plus the size of 
  3986.  
  3987.         locals (including parameters) for all active procedures plus 
  3988.  
  3989.         about 500 bytes for the Operating System calls.  In practice, 2KB 
  3990.  
  3991.         plus the size of the local arrays simultaneously active should be 
  3992.  
  3993.         sufficient.
  3994.  
  3995.  
  3996.  
  3997.         If PCCL reports that the code limit is exceeded, look in the 
  3998.  
  3999.         publics map for the scanf() and printf() routines.  These are 
  4000.  
  4001.         relatively large routines (around 2KB each) and also link in the 
  4002.  
  4003.         floating-point routines.  Eliminating the use of these routines 
  4004.  
  4005.         can result in a large savings.  If scanf() and/or printf() are 
  4006.  
  4007.         necessary but no floating-point values will be used, try using 
  4008.  
  4009.         the PCC7.S instead of the standard PCCS.S library (Rename the 
  4010.  
  4011.         PCCS.S library to something else and rename the PCC7.S library to 
  4012.  
  4013.         PCCS.S).  This will assume the availability of the 8087 math chip 
  4014.  
  4015.         and will not bring in the software floating-point routines.
  4016.  
  4017.  
  4018.  
  4019.  
  4020.  
  4021.         6.5. Overlays
  4022.  
  4023.  
  4024.  
  4025.         Another way to solve the space problem is the use of overlays.  
  4026.  
  4027.         The overlay system provided by this package is very simple.  An 
  4028.  
  4029.         application is divided into a root portion that is always 
  4030.  
  4031.         resident and two or more overlays.  Only one overlay is resident 
  4032.  
  4033.         (executable) at any given time.
  4034.  
  4035.  
  4036.  
  4037.         There are two types of overlays, disk-based overlays and memory-
  4038.  
  4039.         based overlays.  The difference between the two types is the 
  4040.  
  4041.         location of the overlays.  Disk-based overlays, created with the 
  4042.  
  4043.         -V option, are stored in a separate file.  Memory-based overlays, 
  4044.  
  4045.         created with the -M option, are loaded into memory along with the 
  4046.  
  4047.         root code.  Memory-based overlays should only be used when there 
  4048.  
  4049.         is sufficient memory for the root and all of the overlays.  The 
  4050.  
  4051.         advantage of memory-based overlays over disk-based overlays is in 
  4052.  
  4053.         the amount of time needed to make an overlay resident, memory-
  4054.  
  4055.         based overlays being much faster to load.
  4056.  
  4057.  
  4058.  
  4059.         The application program is responsible for initializing the 
  4060.  
  4061.         overlay subsystem and ensuring that the correct overlay is 
  4062.  
  4063.         resident before calling any of the functions in the overlay.
  4064.  
  4065.  
  4066.  
  4067.         For disk-based overlays, the routine overlay_init() must be 
  4068.  
  4069.         called from the root with the name of the overlay file to 
  4070.  
  4071.         initialize the overlay system.  Overlays are loaded by calling 
  4072.  
  4073.         the routine overlay(n) where n is the number of the overlay to be 
  4074.  
  4075.         made resident.
  4076.  
  4077.  
  4078.  
  4079.  
  4080.  
  4081.  
  4082.  
  4083.  
  4084.  
  4085.  
  4086.  
  4087.  
  4088.  
  4089.  
  4090.  
  4091.  
  4092.  
  4093.         The PCCL Object File Linker                        Page 26
  4094.  
  4095.  
  4096.  
  4097.  
  4098.  
  4099.  
  4100.  
  4101.         For memory-based overlays instead of disk-based overlays, do not 
  4102.  
  4103.         call the overlay_init() routine and call the routine moverlay() 
  4104.  
  4105.         in place of the routine overlay().
  4106.  
  4107.  
  4108.  
  4109.         In the following example the root is composed of the file X.C.  
  4110.  
  4111.         The first overlay is the file Y.C and the second overlay is in 
  4112.  
  4113.         the file Z.C.
  4114.  
  4115.  
  4116.  
  4117.  
  4118.  
  4119.         File X.C:
  4120.  
  4121.                 main() {
  4122.  
  4123.                         overlay_init("X.OV"); /* initialize */
  4124.  
  4125.                         puts("this is the root program\n");
  4126.  
  4127.                         overlay(1); /* make 1st overlay resident */
  4128.  
  4129.                         zip();    /* call into 1st overlay */
  4130.  
  4131.                         overlay(2); /* make the second resident */
  4132.  
  4133.                         zap();    /* call into second overlay */
  4134.  
  4135.                         puts("bye\n");
  4136.  
  4137.                         }
  4138.  
  4139.  
  4140.  
  4141.         File Y.C:
  4142.  
  4143.                 zip() {
  4144.  
  4145.                         puts("  this is ZIP  ");
  4146.  
  4147.                         }
  4148.  
  4149.  
  4150.  
  4151.         File Z.C:
  4152.  
  4153.                 zap() {
  4154.  
  4155.                         puts("  this is ZAP  ");
  4156.  
  4157.                         }
  4158.  
  4159.  
  4160.  
  4161.  
  4162.  
  4163.         The files are compiled in the usual fashion:
  4164.  
  4165.  
  4166.  
  4167.                 PCC x
  4168.  
  4169.                 PCC y
  4170.  
  4171.                 PCC z
  4172.  
  4173.  
  4174.  
  4175.         Ordinarily, the files would be linked together using the command:
  4176.  
  4177.  
  4178.  
  4179.                 pccl x y z
  4180.  
  4181.  
  4182.  
  4183.         Instead, to create the two overlays, the command:
  4184.  
  4185.  
  4186.  
  4187.                 pccl x -V1 y -V2 z
  4188.  
  4189.          
  4190.  
  4191.         is used.  The -V option is followed by the overlay number.  This 
  4192.  
  4193.         number starts at 1 and runs in ascending order up to 39.  All 
  4194.  
  4195.         files following the -V or the -M option are included in the 
  4196.  
  4197.         overlay.  All library modules (from .S files) are included in the 
  4198.  
  4199.         root.  The result from the execution of the PCCL program with the 
  4200.  
  4201.         -V option is the executable root (.EXE) file and the overlay 
  4202.  
  4203.         (.OV) file which contains the overlays.  The result with the -M 
  4204.  
  4205.         option is an .EXE file containing both the root and the overlays.
  4206.  
  4207.  
  4208.  
  4209.  
  4210.  
  4211.  
  4212.  
  4213.  
  4214.  
  4215.  
  4216.  
  4217.  
  4218.  
  4219.  
  4220.  
  4221.  
  4222.  
  4223.  
  4224.  
  4225.         The PCCL Object File Linker                        Page 27
  4226.  
  4227.  
  4228.  
  4229.  
  4230.  
  4231.         The -P option of PCCL will also display the size of each overlay 
  4232.  
  4233.         as well as the overlay for each symbol.
  4234.  
  4235.  
  4236.  
  4237.  
  4238.  
  4239.         6.6. Libraries
  4240.  
  4241.  
  4242.  
  4243.         Libraries are just concatenated .O files. The .S extension tells 
  4244.  
  4245.         PCCL to only include modules that are referenced. If all of the 
  4246.  
  4247.         routines in a library are required, rename the .S file to a .O 
  4248.  
  4249.         file to force all of the modules in the library to be included.
  4250.  
  4251.  
  4252.  
  4253.         PCCL includes the entire .O module  from a library if any of its 
  4254.  
  4255.         public names have been selected by other object modules processed 
  4256.  
  4257.         by PCCL.  Thus, if a .O file contains several functions, all of 
  4258.  
  4259.         them will be bound into a program if any of them are called.
  4260.  
  4261.  
  4262.  
  4263.         PCCL searches a library once.  Thus if you have two modules, A 
  4264.  
  4265.         and B, and A calls B , the B must follow A in the library.  LIB88 
  4266.  
  4267.         attempts to order the library so that these inter-library 
  4268.  
  4269.         references are ordered so that PCCL will find them.  One way 
  4270.  
  4271.         around any circular dependencies (e.g., B  also calls A ) is to 
  4272.  
  4273.         include the library twice on the command line.
  4274.  
  4275.  
  4276.  
  4277.  
  4278.  
  4279.  
  4280.  
  4281.  
  4282.  
  4283.  
  4284.  
  4285.  
  4286.  
  4287.  
  4288.  
  4289.  
  4290.  
  4291.  
  4292.  
  4293.  
  4294.  
  4295.  
  4296.  
  4297.  
  4298.  
  4299.  
  4300.  
  4301.  
  4302.  
  4303.  
  4304.  
  4305.  
  4306.  
  4307.  
  4308.  
  4309.  
  4310.  
  4311.  
  4312.  
  4313.  
  4314.  
  4315.  
  4316.  
  4317.  
  4318.  
  4319.  
  4320.  
  4321.  
  4322.  
  4323.  
  4324.  
  4325.  
  4326.  
  4327.  
  4328.  
  4329.  
  4330.  
  4331.  
  4332.  
  4333.  
  4334.  
  4335.  
  4336.  
  4337.  
  4338.  
  4339.  
  4340.  
  4341.  
  4342.  
  4343.  
  4344.  
  4345.  
  4346.  
  4347.  
  4348.  
  4349.  
  4350.  
  4351.  
  4352.  
  4353.  
  4354.  
  4355.  
  4356.  
  4357.         The PCCS.S Standard Library                       Page 28
  4358.  
  4359.  
  4360.  
  4361.  
  4362.  
  4363.         7. The PCCS.S Standard Library
  4364.  
  4365.  
  4366.  
  4367.         7.1. Introduction
  4368.  
  4369.  
  4370.  
  4371.         This section describes the standard library, PCCS.S, for the 
  4372.  
  4373.         PCC C compiler and PCCA assembler.  This library includes 
  4374.  
  4375.         routines similar to routines available in UNIX with some 
  4376.  
  4377.         inevitable differences due to the MS-DOS Operating System.  
  4378.  
  4379.  
  4380.  
  4381.         All of the routines are in the PCCS.S library file provided on 
  4382.  
  4383.         the distribution disk.  This file must be on the default 
  4384.  
  4385.         drive/directory, in a directory listed in the PATH system 
  4386.  
  4387.         parameter,  or on the drive/directory referred to by the '-L' 
  4388.  
  4389.         option for PCCL to execute correctly.
  4390.  
  4391.  
  4392.  
  4393.         There is a PCC7.S library that has the same functions as the 
  4394.  
  4395.         PCCS.S libarary but assumes the availability of the 8087 math 
  4396.  
  4397.         chip to perform the floating-point operations.  To use the 8087, 
  4398.  
  4399.         rename PCC7.S to PCCS.S.
  4400.  
  4401.  
  4402.  
  4403.         7.2. Names
  4404.  
  4405.  
  4406.  
  4407.         Public names starting with the underline character ('_') are  
  4408.  
  4409.         reserved for PCC internal routines and should be avoided.  Names 
  4410.  
  4411.         of this form are also employed for user callable routines such as 
  4412.  
  4413.         _move() whose names might conflict with user names.
  4414.  
  4415.  
  4416.  
  4417.         PCC automatically appends the underline character ('_') to the 
  4418.  
  4419.         end of public names to avoid conflicts with assembly language 
  4420.  
  4421.         reserved words.  PCCA does not do this so the underline must be 
  4422.  
  4423.         manually appended to publics used to link with code generated by 
  4424.  
  4425.         PCC.  For example, the C puts() routine should be referred to as 
  4426.  
  4427.         puts_ from assembler.   PCCL ignores the case of publics, unlike 
  4428.  
  4429.         UNIX, so  puts_ matches the name PutS_.
  4430.  
  4431.  
  4432.  
  4433.         7.3. Program Initialization
  4434.  
  4435.  
  4436.  
  4437.         PCCL inserts a jmp _csetup as the first executable instruction in 
  4438.  
  4439.         the program.  _CSETUP performs the following initialization 
  4440.  
  4441.         functions:
  4442.  
  4443.  
  4444.  
  4445.         1. sets the data/stack segment size to the lower of: available 
  4446.  
  4447.            memory, 64K, or the size of the static data area plus the PCCL 
  4448.  
  4449.            -S option,
  4450.  
  4451.         2. Formats argc and argv[] from the Program Segment Prefix,
  4452.  
  4453.         3. Zeros the Uninitialized Data Area, and
  4454.  
  4455.         4. Calls main(argc, argv)
  4456.  
  4457.  
  4458.  
  4459.         Assembly language main programs that require normal 
  4460.  
  4461.         initialization should contain the following
  4462.  
  4463.  
  4464.  
  4465.                 PUBLIC MAIN_
  4466.  
  4467.                 MAIN_:
  4468.  
  4469.  
  4470.  
  4471.  
  4472.  
  4473.  
  4474.  
  4475.  
  4476.  
  4477.  
  4478.  
  4479.  
  4480.  
  4481.  
  4482.  
  4483.  
  4484.  
  4485.  
  4486.  
  4487.  
  4488.  
  4489.         The PCCS.S Standard Library                       Page 29
  4490.  
  4491.  
  4492.  
  4493.  
  4494.  
  4495.         The initialization code will set the SS, DS and SP registers so 
  4496.  
  4497.         that there is the largest possible stack unless the PCCL '-S' 
  4498.  
  4499.         option is used to restrict the stack size.  The stack grows 
  4500.  
  4501.         towards the unitialized data area.  The figure below shows the 
  4502.  
  4503.         memory layout after the initialization code has run:
  4504.  
  4505.  
  4506.  
  4507.              +-------------------+
  4508.  
  4509.              |     Stack         |
  4510.  
  4511.              +-------------------+<- SP,BP
  4512.  
  4513.              |                   |
  4514.  
  4515.              /     Heap          /
  4516.  
  4517.              +-------------------+<- _memory()
  4518.  
  4519.              |    Un-Init Data   |
  4520.  
  4521.              +-------------------+
  4522.  
  4523.              |    Init Data      |
  4524.  
  4525.              +-------------------+<- DS,SS
  4526.  
  4527.              |    Code           |
  4528.  
  4529.              +-------------------+<- CS
  4530.  
  4531.              |    PSP            |
  4532.  
  4533.              +-------------------+
  4534.  
  4535.  
  4536.  
  4537.         Fig. 7-1: Initial Memory Layout
  4538.  
  4539.  
  4540.  
  4541.         The memory between the end of the uninitialized area and the 
  4542.  
  4543.         stack is not normally used by PCC or the program (unless the 
  4544.  
  4545.         program needs an inordinate amount of stack).  This area is 
  4546.  
  4547.         considered to be free memory.  This memory area can be accessed 
  4548.  
  4549.         directly by using the _memory() and _showsp() routines to 
  4550.  
  4551.         calculate its extent.  Another way to access this memory is to 
  4552.  
  4553.         use the malloc() routine.  Do not use both methods.  Remember to 
  4554.  
  4555.         leave enough space for the stack to grow.
  4556.  
  4557.  
  4558.  
  4559.         The -A option of PCCL inhibits the call to _csetup.  Execution 
  4560.  
  4561.         commences with the first instruction of the first filename 
  4562.  
  4563.         specified to PCCL.  On entry, the registers have the following 
  4564.  
  4565.         values:
  4566.  
  4567.  
  4568.  
  4569.         CS      Address of Code Segment.  Execution starts at CS:0.
  4570.  
  4571.         SS      Address of Data Segment.
  4572.  
  4573.         ES,DS   Address of Program Segment Prefix
  4574.  
  4575.         SP      Stack size set by PCCL
  4576.  
  4577.  
  4578.  
  4579.         The source code for _csetup is in the file ISETUP.A. 
  4580.  
  4581.  
  4582.  
  4583.         7.4. Calling Conventions
  4584.  
  4585.  
  4586.  
  4587.         Arguments to a function are pushed on the stack, rightmost 
  4588.  
  4589.         argument first.  It is the responsibility of the calling function 
  4590.  
  4591.         to clean up the stack.  For example
  4592.  
  4593.  
  4594.  
  4595.                 int i;
  4596.  
  4597.  
  4598.  
  4599.                 zip(i, 6);
  4600.  
  4601.  
  4602.  
  4603.  
  4604.  
  4605.  
  4606.  
  4607.  
  4608.  
  4609.  
  4610.  
  4611.  
  4612.  
  4613.  
  4614.  
  4615.  
  4616.  
  4617.  
  4618.  
  4619.  
  4620.  
  4621.         The PCCS.S Standard Library                       Page 30
  4622.  
  4623.  
  4624.  
  4625.  
  4626.  
  4627.         would generate the following code
  4628.  
  4629.  
  4630.  
  4631.                 mov     ax,6
  4632.  
  4633.                 push    ax
  4634.  
  4635.                 push    word i_
  4636.  
  4637.                 public zip_
  4638.  
  4639.                 call    zip_
  4640.  
  4641.                 add     sp,4
  4642.  
  4643.  
  4644.  
  4645.         The word modifier is required because PCC allocates two bytes for 
  4646.  
  4647.         ints.  The add sp,4 removes the two words that were pushed as 
  4648.  
  4649.         parameters to zip_.  Note the PCC appended '_' on names.  If 
  4650.  
  4651.         there had been no local variables defined in the function, the 
  4652.  
  4653.         clean-up code would have been
  4654.  
  4655.  
  4656.  
  4657.                 mov     sp,bp
  4658.  
  4659.  
  4660.  
  4661.         which is faster.
  4662.  
  4663.  
  4664.  
  4665.         Data is pushed on the stack as follows:
  4666.  
  4667.  
  4668.  
  4669.                 
  4670.  
  4671.         char       pushed as a word, with high-order byte set to zero
  4672.  
  4673.  
  4674.  
  4675.                         mov  AL,data_
  4676.  
  4677.                         mov  AH,0
  4678.  
  4679.                         push AX
  4680.  
  4681.  
  4682.  
  4683.         int        pushed as a word
  4684.  
  4685.         unsigned
  4686.  
  4687.                         push WORD data_
  4688.  
  4689.  
  4690.  
  4691.         long       pushed with least-significant word pushed last
  4692.  
  4693.  
  4694.  
  4695.                         push WORD data_[2]
  4696.  
  4697.                         push WORD data_[0]
  4698.  
  4699.  
  4700.  
  4701.         float      Changed  to  double and pushed with  least-significant 
  4702.  
  4703.                    word pushed last
  4704.  
  4705.  
  4706.  
  4707.                         mov  si,offset data_
  4708.  
  4709.                         PUBLIC _FLOADE  ; load float
  4710.  
  4711.                         call _FLOADE
  4712.  
  4713.                         PUBLIC _FPUSH   ; push double
  4714.  
  4715.                         call _FPUSH
  4716.  
  4717.  
  4718.  
  4719.         double     pushed with least-significant word pushed last
  4720.  
  4721.  
  4722.  
  4723.                         push WORD data_[6]
  4724.  
  4725.                         push WORD data_[4]
  4726.  
  4727.                         push WORD data_[2]
  4728.  
  4729.                         push WORD data_[0]
  4730.  
  4731.  
  4732.  
  4733.  
  4734.  
  4735.  
  4736.  
  4737.  
  4738.  
  4739.  
  4740.  
  4741.  
  4742.  
  4743.  
  4744.  
  4745.  
  4746.  
  4747.  
  4748.  
  4749.  
  4750.  
  4751.  
  4752.  
  4753.         The PCCS.S Standard Library                       Page 31
  4754.  
  4755.  
  4756.  
  4757.  
  4758.  
  4759.         struct     push  (sizeof(struct)  + 1) >> 1  words,  with  least-
  4760.  
  4761.                    significant word pushed last.
  4762.  
  4763.  
  4764.  
  4765.                         mov  cx,nn    ; size in words
  4766.  
  4767.                         sub  sp,cx    ; make room on stack
  4768.  
  4769.                         mov  di,sp    ; target
  4770.  
  4771.                         mov  si,offset data_  ; source
  4772.  
  4773.                         mov  ax,ds    ; setup
  4774.  
  4775.                         mov  es,ax    ;    es
  4776.  
  4777.                         cld           ; set direction up
  4778.  
  4779.                 rep     movsw         ; copy to stack
  4780.  
  4781.  
  4782.  
  4783.  
  4784.  
  4785.         7.5. LIBRARY CONVENTIONS
  4786.  
  4787.  
  4788.  
  4789.         Called functions are responsible for preserving CS, DS, SS, SP, 
  4790.  
  4791.         and BP across the function call.  All other registers need not be 
  4792.  
  4793.         maintained.  The usual preamble for a called function is
  4794.  
  4795.  
  4796.  
  4797.                         PUBLIC fname_
  4798.  
  4799.                 fname_:
  4800.  
  4801.                         push bp      ; save old frame pointer
  4802.  
  4803.                         mov  bp,sp   ; establish local frame
  4804.  
  4805.  
  4806.  
  4807.         For functions that don't return structures, parameters begin in 
  4808.  
  4809.         the local frame at [bp+4], and continue upward based on the size 
  4810.  
  4811.         of each parameter.  Thus  for the fragment
  4812.  
  4813.  
  4814.  
  4815.                 blip(x, y, z)
  4816.  
  4817.                 int x;
  4818.  
  4819.                 long y;
  4820.  
  4821.                 double z;
  4822.  
  4823.  
  4824.  
  4825.         the parameters would be referenced in Assembler as
  4826.  
  4827.  
  4828.  
  4829.                 mov  cx,WORD [bp+4]  ; x_
  4830.  
  4831.                 mov     ax,WORD [bp+6]  ; lsw of y_
  4832.  
  4833.                 mov  dx,WORD [bp+8]  ; msw of y_
  4834.  
  4835.                 lea  si,[bp+10]      ; addr of z_
  4836.  
  4837.  
  4838.  
  4839.         For functions that do return structures, [bp+4] contains a 
  4840.  
  4841.         pointer to where the structure should be returned.  So if the 
  4842.  
  4843.         above fragment was
  4844.  
  4845.  
  4846.  
  4847.                 struct foo blip(x, y, z)
  4848.  
  4849.  
  4850.  
  4851.         the parameters would be
  4852.  
  4853.  
  4854.  
  4855.                 mov  cx,WORD [bp+06]  ; x_
  4856.  
  4857.                 mov     ax,WORD [bp+08]  ; lsw of y_
  4858.  
  4859.                 mov  dx,WORD [bp+10]  ; msw of y_
  4860.  
  4861.                 lea  si,[bp+12]       ; addr of z_
  4862.  
  4863.  
  4864.  
  4865.  
  4866.  
  4867.  
  4868.  
  4869.  
  4870.  
  4871.  
  4872.  
  4873.  
  4874.  
  4875.  
  4876.  
  4877.  
  4878.  
  4879.  
  4880.  
  4881.  
  4882.  
  4883.  
  4884.  
  4885.         The PCCS.S Standard Library                       Page 32
  4886.  
  4887.  
  4888.  
  4889.  
  4890.  
  4891.         Local variables are allocated below the current frame pointer, 
  4892.  
  4893.         regardless of what the function returns, so that the fragment
  4894.  
  4895.  
  4896.  
  4897.                 {
  4898.  
  4899.                 int aa[2];
  4900.  
  4901.                 long b;
  4902.  
  4903.  
  4904.  
  4905.         would be referenced as
  4906.  
  4907.  
  4908.  
  4909.                 sub  sp,8       ; allocate space for locals
  4910.  
  4911.                 mov  ax,[bp-4]  ; aa_[1]
  4912.  
  4913.                 mov     dx,[bp-8]  ; msw b_
  4914.  
  4915.  
  4916.  
  4917.         The standard exit sequence is
  4918.  
  4919.  
  4920.  
  4921.                 mov     sp,bp   ; reclaim any local space
  4922.  
  4923.                 pop     bp      ; old frame pointer
  4924.  
  4925.                 ret          ; caller will clean up stack
  4926.  
  4927.  
  4928.  
  4929.         Values  are  returned from functions as followings:
  4930.  
  4931.  
  4932.  
  4933.              char      returned  in AX.   char values are returned in  AL 
  4934.  
  4935.                        with AH
  4936.  
  4937.              int       set to zero
  4938.  
  4939.              unsigned
  4940.  
  4941.  
  4942.  
  4943.              long      returned in DX:AX.  (AX contains lsw)
  4944.  
  4945.  
  4946.  
  4947.              double    returned on floating point stack (s/w or 8087). 
  4948.  
  4949.              float
  4950.  
  4951.  
  4952.  
  4953.              struct    returned to address in [bp+4]
  4954.  
  4955.  
  4956.  
  4957.         7.6. Disk Input/Output Routines
  4958.  
  4959.  
  4960.  
  4961.         In this implementation of C I/O, procedures like getc() are 
  4962.  
  4963.         functions rather than macros and a file identifier FILE is simply  
  4964.  
  4965.         an integer containing the file number rather than a pointer to a 
  4966.  
  4967.         structure.  This change means that read() and getc() calls may be 
  4968.  
  4969.         intermingled and there is little difference between open() and 
  4970.  
  4971.         fopen() on a file.
  4972.  
  4973.  
  4974.  
  4975.         In UNIX there is a distinction between file and stream I/O.  
  4976.  
  4977.         Crudely stated, the functions that have 'f' as their first letter  
  4978.  
  4979.         (fopen(), fread() etc.) deal with streams, and other primitives 
  4980.  
  4981.         (open(),  read() etc.) access files.  These two forms of I/O are 
  4982.  
  4983.         compatible -- fopen() may be used to open a file a file and then 
  4984.  
  4985.         read() used to read it -- but it is best to use either the stream 
  4986.  
  4987.         or file primitives only for a particular file for portability.  
  4988.  
  4989.         The FILE type is defined in the stdio.h include file and is 
  4990.  
  4991.         simply an int type.  This int contains the file number, the same 
  4992.  
  4993.         number returned by open() and creat().  To use the stream 
  4994.  
  4995.         routines with a file opened with the open(), merely pass the file 
  4996.  
  4997.         number. 
  4998.  
  4999.  
  5000.  
  5001.  
  5002.  
  5003.  
  5004.  
  5005.  
  5006.  
  5007.  
  5008.  
  5009.  
  5010.  
  5011.  
  5012.  
  5013.  
  5014.  
  5015.  
  5016.  
  5017.         The PCCS.S Standard Library                       Page 33
  5018.  
  5019.  
  5020.  
  5021.  
  5022.  
  5023.         The stream style of I/O primitives are: fopen() to open a file, 
  5024.  
  5025.         fread(), fgets() or fgetc() [getc()] to read,  fwrite(), fputs() 
  5026.  
  5027.         or fputc() [putc()] to write, fseek() to seek, fflush() to write 
  5028.  
  5029.         out internal buffers, and fclose() to close.
  5030.  
  5031.  
  5032.  
  5033.         The file type I/O primitives are: open(), creat(), read(),  
  5034.  
  5035.         write(), lseek(), and close().
  5036.  
  5037.  
  5038.  
  5039.         The maximum number of files that can be open at one time is 
  5040.  
  5041.         either 20, or the number specified in CONFIG.SYS, whichever is 
  5042.  
  5043.         less. See section 2.3 for details about CONFIG.SYS.  New files 
  5044.  
  5045.         are creat()'d and old files are open()'d.
  5046.  
  5047.  
  5048.  
  5049.         A closed file may be rename()'d or unlink()'d (deleted).
  5050.  
  5051.  
  5052.  
  5053.         Three predefined file numbers may be used to read from or write 
  5054.  
  5055.         to the console.  To use them, include the following defines in 
  5056.  
  5057.         the program:
  5058.  
  5059.  
  5060.  
  5061.           #define stdin   0
  5062.  
  5063.           #define stdout  1
  5064.  
  5065.           #define stderr  2
  5066.  
  5067.  
  5068.  
  5069.  
  5070.  
  5071.         7.7. Math Routines
  5072.  
  5073.  
  5074.  
  5075.         If any of the transcendental or sqrt() functions are used, 
  5076.  
  5077.         include the file math.h or the equivalent declarations to specify 
  5078.  
  5079.         them as returning double's.
  5080.  
  5081.  
  5082.  
  5083.         math.h includes the statement 
  5084.  
  5085.  
  5086.  
  5087.                 extern int errno;
  5088.  
  5089.  
  5090.  
  5091.         errno is set to a non-zero value: on floating point stack errors,  
  5092.  
  5093.         if an argument to a math routine is out of range, or if the 
  5094.  
  5095.         result of a math routine would under/overflow.  Error codes and 
  5096.  
  5097.         names (defined in math.h) are:
  5098.  
  5099.  
  5100.  
  5101.         30 ESTK   F/P stack overflow.  The most probable cause is calling 
  5102.  
  5103.                   a function that returns a double without declaring it 
  5104.  
  5105.                   as such to the compiler.  After eight calls, the f/p 
  5106.  
  5107.                   stack will be full.
  5108.  
  5109.  
  5110.  
  5111.         33 EDOM   invalid argument, i.e., sqrt(-1.0).
  5112.  
  5113.  
  5114.  
  5115.         34 ERANGE invalid arg size, i.e., asin(2.0).
  5116.  
  5117.  
  5118.  
  5119.         The function  rerrno() is called by the floating point routines 
  5120.  
  5121.         whenever an error is detected.  rerrno() prints out an 
  5122.  
  5123.         appropriate error message and calls exit().  In order to bypass 
  5124.  
  5125.         this effect, install the following function in your program
  5126.  
  5127.  
  5128.  
  5129.                 rerrno() {;}  /* null function to suppress printing */
  5130.  
  5131.  
  5132.  
  5133.  
  5134.  
  5135.  
  5136.  
  5137.  
  5138.  
  5139.  
  5140.  
  5141.  
  5142.  
  5143.  
  5144.  
  5145.  
  5146.  
  5147.  
  5148.  
  5149.         The PCCS.S Standard Library                       Page 34
  5150.  
  5151.  
  5152.  
  5153.  
  5154.  
  5155.         7.8. IBM-PC Screen and Keyboard Interface
  5156.  
  5157.  
  5158.  
  5159.         A number of functions have been written to simplify the interface 
  5160.  
  5161.         between C programs and the IBM-PC and its clones.  These routines 
  5162.  
  5163.         are not in the standard PCCS.S library but are distributed in 
  5164.  
  5165.         source form in the file PCIO.A.  To use these routines, they must 
  5166.  
  5167.         be assembled and bound in.  For example:
  5168.  
  5169.  
  5170.  
  5171.                 A>asm88 b:pcio
  5172.  
  5173.                 A>bind b:blip b:pcio
  5174.  
  5175.  
  5176.  
  5177.         See the comments in the IBM Technical Reference Manual for 
  5178.  
  5179.         details on the BIOS interface used by PCIO.
  5180.  
  5181.  
  5182.  
  5183.  
  5184.  
  5185.         7.9. Standard Library Functions
  5186.  
  5187.  
  5188.  
  5189.  
  5190.  
  5191.         7.9.1. abs()
  5192.  
  5193.  
  5194.  
  5195.                   unsigned uval;
  5196.  
  5197.                   int y;
  5198.  
  5199.  
  5200.  
  5201.                   uval = abs(y);
  5202.  
  5203.  
  5204.  
  5205.         abs returns |y| (absolute value).
  5206.  
  5207.  
  5208.  
  5209.  
  5210.  
  5211.         7.9.2. atoi()
  5212.  
  5213.  
  5214.  
  5215.                   char *cp;
  5216.  
  5217.                   int ival;
  5218.  
  5219.  
  5220.  
  5221.                   ival = atoi(cp);
  5222.  
  5223.                 
  5224.  
  5225.         atoi converts the char array at cp to its corresponding int 
  5226.  
  5227.         value.  The first unrecognized character terminates the 
  5228.  
  5229.         conversion.
  5230.  
  5231.  
  5232.  
  5233.         WS is either a tab or a space.  A digit is an ASCII character '0' 
  5234.  
  5235.         through '9'.  [] delimit sequences that can occur zero or one 
  5236.  
  5237.         time.  {} delimit sequences that can occur zero or many times.
  5238.  
  5239.  
  5240.  
  5241.                 Valid character Sequences
  5242.  
  5243.  
  5244.  
  5245.                 {WS} [-] {DIGIT}
  5246.  
  5247.          
  5248.  
  5249.  
  5250.  
  5251.         SEE ALSO:scanf()
  5252.  
  5253.  
  5254.  
  5255.  
  5256.  
  5257.  
  5258.  
  5259.  
  5260.  
  5261.  
  5262.  
  5263.  
  5264.  
  5265.  
  5266.  
  5267.  
  5268.  
  5269.  
  5270.  
  5271.  
  5272.  
  5273.  
  5274.  
  5275.  
  5276.  
  5277.  
  5278.  
  5279.  
  5280.  
  5281.         The PCCS.S Standard Library                       Page 35
  5282.  
  5283.  
  5284.  
  5285.  
  5286.  
  5287.         NOTES: To guard against int overflow, or large unsigned values 
  5288.  
  5289.         being stored as negative integers, use atol and check that the 
  5290.  
  5291.         high-order word is the same as the high-order bit of the low-
  5292.  
  5293.         order word.
  5294.  
  5295.  
  5296.  
  5297.                 atoi(str)
  5298.  
  5299.                 char *str; {
  5300.  
  5301.                         long val, atol();
  5302.  
  5303.                         int sign, extn;
  5304.  
  5305.  
  5306.  
  5307.                         extn = (val = atol(str)) >> 16;
  5308.  
  5309.                         sign = val & 0x8000;
  5310.  
  5311.                         if((!sign && extn != 0) || (sign && extn != -1))
  5312.  
  5313.                                 overflowErr();
  5314.  
  5315.                         return val;
  5316.  
  5317.                         }
  5318.  
  5319.  
  5320.  
  5321.  
  5322.  
  5323.         7.9.3. atof()
  5324.  
  5325.  
  5326.  
  5327.                   char *cp;
  5328.  
  5329.                   double dval;
  5330.  
  5331.  
  5332.  
  5333.                   dval = atof(cp);
  5334.  
  5335.                 
  5336.  
  5337.         atof converts the char array at cp to its corresponding double 
  5338.  
  5339.         value.  The first unrecognized character terminates the 
  5340.  
  5341.         conversion.
  5342.  
  5343.  
  5344.  
  5345.         WS is either a tab or a space.  A digit is an ASCII character '0' 
  5346.  
  5347.         through '9'.  E is either an ASCII 'E' or 'e'.  [] delimit 
  5348.  
  5349.         sequences that can occur zero or one time.  {} delimit sequences 
  5350.  
  5351.         that can occur zero or many times.
  5352.  
  5353.  
  5354.  
  5355.                 Valid character Sequences
  5356.  
  5357.  
  5358.  
  5359.                 {WS} [-] {digit} ['.'] [{digit} [E [-] {digit}]]
  5360.  
  5361.          
  5362.  
  5363.         SEE ALSO:scanf()
  5364.  
  5365.  
  5366.  
  5367.  
  5368.  
  5369.         7.9.4. atol()
  5370.  
  5371.  
  5372.  
  5373.                   char *cp;
  5374.  
  5375.                   long lval, atol();
  5376.  
  5377.  
  5378.  
  5379.                   lval = atol(cp);
  5380.  
  5381.                 
  5382.  
  5383.         atol converts the char array at cp to its corresponding long 
  5384.  
  5385.         value.  The first unrecognized character terminates the 
  5386.  
  5387.         conversion.
  5388.  
  5389.  
  5390.  
  5391.  
  5392.  
  5393.  
  5394.  
  5395.  
  5396.  
  5397.  
  5398.  
  5399.  
  5400.  
  5401.  
  5402.  
  5403.  
  5404.  
  5405.  
  5406.  
  5407.  
  5408.  
  5409.  
  5410.  
  5411.  
  5412.  
  5413.         The PCCS.S Standard Library                       Page 36
  5414.  
  5415.  
  5416.  
  5417.  
  5418.  
  5419.         WS is either a tab or a space.  A digit is an ASCII character '0' 
  5420.  
  5421.         through '9'.  [] delimit sequences that can occur zero or one 
  5422.  
  5423.         time.  {} delimit sequences that can occur zero or many times.
  5424.  
  5425.  
  5426.  
  5427.                 Valid character Sequences
  5428.  
  5429.  
  5430.  
  5431.                 {WS} [-] {DIGIT}
  5432.  
  5433.          
  5434.  
  5435.  
  5436.  
  5437.         SEE ALSO:scanf()
  5438.  
  5439.  
  5440.  
  5441.                         }
  5442.  
  5443.  
  5444.  
  5445.  
  5446.  
  5447.         7.9.5. ceil()
  5448.  
  5449.  
  5450.  
  5451.                   #include <math.h>
  5452.  
  5453.  
  5454.  
  5455.                   double dval, x;
  5456.  
  5457.  
  5458.  
  5459.                   dval = ceil(x);
  5460.  
  5461.  
  5462.  
  5463.         ceil returns the smallest integer value not less than x.
  5464.  
  5465.  
  5466.  
  5467.  
  5468.  
  5469.         7.9.6. chain()
  5470.  
  5471.  
  5472.  
  5473.                   char *filename, *commandTail;
  5474.  
  5475.  
  5476.  
  5477.                   chain(filename, commandTail)
  5478.  
  5479.  
  5480.  
  5481.         chain will load and execute an arbitrary program Q filename is 
  5482.  
  5483.         the complete pathname of the program (including the .EXE or .COM 
  5484.  
  5485.         suffix).  commandTail  contains the arguments to the program.  
  5486.  
  5487.  
  5488.  
  5489.         chain functions like exec  except that control is not returned to 
  5490.  
  5491.         the calling program.  chain is in the file EXEC.O, in the 
  5492.  
  5493.         distribution. It should be bound in first to save memory since it 
  5494.  
  5495.         loads the called program immediately behind itself.  For example:
  5496.  
  5497.  
  5498.  
  5499.                 A>PCCL EXEC BLIP -OBLIP
  5500.  
  5501.  
  5502.  
  5503.         NOTE: To invoke a Batch file, or a DOS built-in command, use 
  5504.  
  5505.         COMMAND.COM with the '/c' switch as follows.
  5506.  
  5507.  
  5508.  
  5509.                 chain("\\command.com", "/cxxx");
  5510.  
  5511.  
  5512.  
  5513.         Where xxx is one of the DOS built-in commands ( 'dir', 'copy', 
  5514.  
  5515.         Remember that two backslashes are required to insert a single 
  5516.  
  5517.         backslash in a string.  Invoking COMMAND.COM with no parameters 
  5518.  
  5519.         will start another DOS shell.  To return type
  5520.  
  5521.  
  5522.  
  5523.                 exit
  5524.  
  5525.  
  5526.  
  5527.  
  5528.  
  5529.  
  5530.  
  5531.  
  5532.  
  5533.  
  5534.  
  5535.  
  5536.  
  5537.  
  5538.  
  5539.  
  5540.  
  5541.  
  5542.  
  5543.  
  5544.  
  5545.         The PCCS.S Standard Library                       Page 37
  5546.  
  5547.  
  5548.  
  5549.  
  5550.  
  5551.         7.9.7. close()
  5552.  
  5553.  
  5554.  
  5555.                   int handle, stat;
  5556.  
  5557.  
  5558.  
  5559.                   stat = close(handle);
  5560.  
  5561.  
  5562.  
  5563.         close writes any buffered data for the file fp to that file, and 
  5564.  
  5565.         closes the file. Returns -1 if fp is not open, or if an error 
  5566.  
  5567.         occurred writing the buffered data to that file.
  5568.  
  5569.                 
  5570.  
  5571.  
  5572.  
  5573.         7.9.8. creat()
  5574.  
  5575.  
  5576.  
  5577.                   int handle;
  5578.  
  5579.                   char *name;
  5580.  
  5581.  
  5582.  
  5583.                   handle = creat(name)
  5584.  
  5585.  
  5586.  
  5587.         creat creates the file name  and return an int that is used to 
  5588.  
  5589.         reference it in future file operations, or -1 if the file can't 
  5590.  
  5591.         be opened.  If the file name already exists, it is deleted before 
  5592.  
  5593.         it is opened. 
  5594.  
  5595.  
  5596.  
  5597.         NOTES: creat  opens a file in update mode so that after a file is 
  5598.  
  5599.         written,  a program can seek to the begining of the file and read 
  5600.  
  5601.         it without closing the file and reopening it.
  5602.  
  5603.  
  5604.  
  5605.         Any  of  the  functions can open the console ("CON")  or  printer 
  5606.  
  5607.         ("PRN").
  5608.  
  5609.  
  5610.  
  5611.  
  5612.  
  5613.         7.9.9. dates()
  5614.  
  5615.  
  5616.  
  5617.                   char *buf;
  5618.  
  5619.                 
  5620.  
  5621.                   dates(buf);
  5622.  
  5623.  
  5624.  
  5625.         dates formats the string buf with the current date as "mm/dd/yy".
  5626.  
  5627.  
  5628.  
  5629.  
  5630.  
  5631.         7.9.10. doint()
  5632.  
  5633.  
  5634.  
  5635.                   char inum;
  5636.  
  5637.                 
  5638.  
  5639.                   extern unsigned _rax, _rbx, _rcx, _rdx, _rsi, _rdi,
  5640.  
  5641.                                   _res, _rds;
  5642.  
  5643.                   extern char _carryf, _zerof;
  5644.  
  5645.  
  5646.  
  5647.                   _doint(inum);
  5648.  
  5649.  
  5650.  
  5651.         _rax - _rds contain the values of the corresponding 8088 internal 
  5652.  
  5653.         registers that are loaded and saved by _doint .  _carryf is the 
  5654.  
  5655.         carry flag; _zerof is the zero flag
  5656.  
  5657.  
  5658.  
  5659.  
  5660.  
  5661.  
  5662.  
  5663.  
  5664.  
  5665.  
  5666.  
  5667.  
  5668.  
  5669.  
  5670.  
  5671.  
  5672.  
  5673.  
  5674.  
  5675.  
  5676.  
  5677.         The PCCS.S Standard Library                       Page 38
  5678.  
  5679.  
  5680.  
  5681.  
  5682.  
  5683.         _doint will cause a software interrupt and may be used to call 
  5684.  
  5685.         whatever routines are available in the particular machine.  If 
  5686.  
  5687.         _rds is set to -1, the current value of the DS register is used.
  5688.  
  5689.  
  5690.  
  5691.         NOTE:  The following example, on an IBM-PC, would use interrupt 
  5692.  
  5693.         10H to print the string.
  5694.  
  5695.  
  5696.  
  5697.                 extern unsigned _rax, _rbx, _rds;
  5698.  
  5699.                 extern char _carryf;
  5700.  
  5701.                 char str[] = "Hello There!!";
  5702.  
  5703.                 int i;
  5704.  
  5705.  
  5706.  
  5707.                 for (i = 0; i < sizeof(str); i++) {
  5708.  
  5709.                         _rax = (14 << 8) + str[i];
  5710.  
  5711.                         _rbx = 0;
  5712.  
  5713.                         _rds = -1;
  5714.  
  5715.                         _doint(0x10);
  5716.  
  5717.                         }
  5718.  
  5719.  
  5720.  
  5721.  
  5722.  
  5723.         7.9.11. exec()
  5724.  
  5725.  
  5726.  
  5727.                   char *filename, *commandTail, Code;
  5728.  
  5729.  
  5730.  
  5731.                   Code = exec(filename, commandTail)
  5732.  
  5733.  
  5734.  
  5735.         exec will load and execute an arbitrary program.  Filename is the 
  5736.  
  5737.         complete pathname of the program (including the .EXE or .COM 
  5738.  
  5739.         suffix).  commandTail  contains the arguments to the program.  
  5740.  
  5741.         exec will return the completion code from the program or -1 if an 
  5742.  
  5743.         error occurred loading the program.  exec is in the EXEC.O file 
  5744.  
  5745.         provided in the distribution.
  5746.  
  5747.  
  5748.  
  5749.         NOTE: Completion codes are set for programs running under MS-DOS 
  5750.  
  5751.         2.0 or later versions of the operating system.  If a program 
  5752.  
  5753.         exits with
  5754.  
  5755.  
  5756.  
  5757.                 exit(n);
  5758.  
  5759.  
  5760.  
  5761.         the system ERRORLEVEL will be set to n.  A program that returns 
  5762.  
  5763.         from the main function other than by exit()sets ERRORLEVEL to 
  5764.  
  5765.         zero.  ERRORLEVEL can be tested with the DOS batch file IF 
  5766.  
  5767.         command.  See the section under 'BATCH' in the IBM 2.xx DOS 
  5768.  
  5769.         manual for details on the IF command.
  5770.  
  5771.  
  5772.  
  5773.         To invoke a Batch file, or a DOS built-in command, use 
  5774.  
  5775.         COMMAND.COM with the '/c' switch as follows.
  5776.  
  5777.  
  5778.  
  5779.                 exec("\\command.com", "/cxxx");
  5780.  
  5781.  
  5782.  
  5783.         Where xxx is one of the DOS built-in commands ( 'dir', 'copy', 
  5784.  
  5785.         Remember that two backslashes are required to insert a single 
  5786.  
  5787.         backslash in a string.  Invoking COMMAND.COM with no parameters 
  5788.  
  5789.         will start another DOS shell.  To return type
  5790.  
  5791.                 exit
  5792.  
  5793.  
  5794.  
  5795.  
  5796.  
  5797.  
  5798.  
  5799.  
  5800.  
  5801.  
  5802.  
  5803.  
  5804.  
  5805.  
  5806.  
  5807.  
  5808.  
  5809.         The PCCS.S Standard Library                       Page 39
  5810.  
  5811.  
  5812.  
  5813.  
  5814.  
  5815.  
  5816.  
  5817.         PCC normally allocates a stack as large as possible.  This is not 
  5818.  
  5819.         desirable when using exec , as little memory may be left for the 
  5820.  
  5821.         second program.  The -Shhhh option of the PCCL program should be 
  5822.  
  5823.         used to reduce the size of the stack and consequently the size of 
  5824.  
  5825.         the program.  Remember that the hhhh value of the option is in 
  5826.  
  5827.         hex and that it must be large enough for all parameters and 
  5828.  
  5829.         locals active at one time.  An extra 0x100 (256) bytes should 
  5830.  
  5831.         also be added for any system calls.
  5832.  
  5833.  
  5834.  
  5835.  
  5836.  
  5837.         7.9.12. exit()
  5838.  
  5839.  
  5840.  
  5841.                   char Code;
  5842.  
  5843.  
  5844.  
  5845.                   exit(Code)
  5846.  
  5847.  
  5848.  
  5849.         exit terminates the program with completion code Code.  A main() 
  5850.  
  5851.         procedure can also exit  with a completion code of zero by 
  5852.  
  5853.         returning or by "falling" through the end of the procedure.
  5854.  
  5855.  
  5856.  
  5857.         NOTE: Completion codes are set for programs running under MS-DOS 
  5858.  
  5859.         2.0 or later versions of the operating system.  If a program 
  5860.  
  5861.         exits with
  5862.  
  5863.  
  5864.  
  5865.                 exit(n);
  5866.  
  5867.  
  5868.  
  5869.         the system ERRORLEVEL will be set to n.  A program that returns 
  5870.  
  5871.         from the main function other than by exit()sets ERRORLEVEL to 
  5872.  
  5873.         zero.  ERRORLEVEL can be tested with the DOS batch file IF 
  5874.  
  5875.         command.  See the section under 'BATCH' in the IBM 2.xx DOS 
  5876.  
  5877.         manual for details on the IF command.
  5878.  
  5879.  
  5880.  
  5881.  
  5882.  
  5883.         7.9.13. exp()
  5884.  
  5885.  
  5886.  
  5887.                   #include <math.h>
  5888.  
  5889.  
  5890.  
  5891.                   double x, dval, exp(), exp10();
  5892.  
  5893.  
  5894.  
  5895.                   dval = exp(x);
  5896.  
  5897.                   dval = exp10(x);
  5898.  
  5899.  
  5900.  
  5901.         exp returns the exponential function of x; exp10 returns the 
  5902.  
  5903.         base 10 exponent.
  5904.  
  5905.  
  5906.  
  5907.         NOTE: exp returns a very large value when the result would 
  5908.  
  5909.         overflow; errno is set to ERANGE.  ERANGE is defined in math.h.
  5910.  
  5911.  
  5912.  
  5913.  
  5914.  
  5915.  
  5916.  
  5917.  
  5918.  
  5919.  
  5920.  
  5921.  
  5922.  
  5923.  
  5924.  
  5925.  
  5926.  
  5927.  
  5928.  
  5929.  
  5930.  
  5931.  
  5932.  
  5933.  
  5934.  
  5935.  
  5936.  
  5937.  
  5938.  
  5939.  
  5940.  
  5941.         The PCCS.S Standard Library                       Page 40
  5942.  
  5943.  
  5944.  
  5945.  
  5946.  
  5947.         7.9.14. fabs()
  5948.  
  5949.  
  5950.  
  5951.                   #include <math.h>
  5952.  
  5953.  
  5954.  
  5955.                   double dval, x;
  5956.  
  5957.  
  5958.  
  5959.                   dval = fabs(x);
  5960.  
  5961.  
  5962.  
  5963.         fabs returns |x| (absolute value).
  5964.  
  5965.  
  5966.  
  5967.  
  5968.  
  5969.         7.9.15. fclose()
  5970.  
  5971.  
  5972.  
  5973.                   #include <stdio.h>
  5974.  
  5975.                   FILE *fp;
  5976.  
  5977.                   int stat;
  5978.  
  5979.  
  5980.  
  5981.                   stat = fclose(fp);
  5982.  
  5983.  
  5984.  
  5985.         fclose writes any buffered data for the file fp to that file, and 
  5986.  
  5987.         closes the file. Returns -1 if fp is not open, or if an error 
  5988.  
  5989.         occurred writing the buffered data to that file.
  5990.  
  5991.                 
  5992.  
  5993.  
  5994.  
  5995.         7.9.16. fgetc()
  5996.  
  5997.  
  5998.  
  5999.                   #include <stdio.h>
  6000.  
  6001.                   FILE *fp;
  6002.  
  6003.                   int data;
  6004.  
  6005.  
  6006.  
  6007.                   data = fgetc(fp)
  6008.  
  6009.  
  6010.  
  6011.         fgetc returns the next character from the file fp, or -1 if an 
  6012.  
  6013.         error, or end of file was sensed.
  6014.  
  6015.  
  6016.  
  6017.         SEE ALSO: scanf(), fread()
  6018.  
  6019.  
  6020.  
  6021.  
  6022.  
  6023.         7.9.17. fgets()
  6024.  
  6025.  
  6026.  
  6027.                   #include <stdio.h>
  6028.  
  6029.                   FILE *fp;
  6030.  
  6031.                   char *cp, buf[], *fgets();
  6032.  
  6033.                   int len;
  6034.  
  6035.  
  6036.  
  6037.                   cp  = fgets(buf, len, fp);
  6038.  
  6039.  
  6040.  
  6041.         fgets reads the next line, but not more than len - 1 characters 
  6042.  
  6043.         from the file fp into buf.  The last character read into buf is 
  6044.  
  6045.         followed by a zero.  fgets returns buf, or 0 on end of file or an 
  6046.  
  6047.         error.
  6048.  
  6049.  
  6050.  
  6051.         SEE ALSO: fscanf(), fread()
  6052.  
  6053.  
  6054.  
  6055.         NOTE:  fgets returns the CR character.
  6056.  
  6057.  
  6058.  
  6059.  
  6060.  
  6061.  
  6062.  
  6063.  
  6064.  
  6065.  
  6066.  
  6067.  
  6068.  
  6069.  
  6070.  
  6071.  
  6072.  
  6073.         The PCCS.S Standard Library                       Page 41
  6074.  
  6075.  
  6076.  
  6077.  
  6078.  
  6079.         7.9.18. floor()
  6080.  
  6081.  
  6082.  
  6083.                   #include <math.h>
  6084.  
  6085.  
  6086.  
  6087.                   double dval, x;
  6088.  
  6089.  
  6090.  
  6091.                   dval = floor(x);
  6092.  
  6093.  
  6094.  
  6095.         floor returns the largest integer value not greater than x.
  6096.  
  6097.  
  6098.  
  6099.  
  6100.  
  6101.         7.9.19. fopen()
  6102.  
  6103.  
  6104.  
  6105.                   #include <stdio.h>
  6106.  
  6107.                   FILE *fp;
  6108.  
  6109.                   char *name, *method;
  6110.  
  6111.  
  6112.  
  6113.                   fp = fopen(name, method)
  6114.  
  6115.  
  6116.  
  6117.         fopen opens the file name and returns an FILE pointer that 
  6118.  
  6119.         identifies the file in future file operations.  Returns NULL 
  6120.  
  6121.         if the file can't be opened.
  6122.  
  6123.  
  6124.  
  6125.         method is a char string having one of the following values: "r" = 
  6126.  
  6127.         open for reading,"w" = open for writing, "a" = open for append -- 
  6128.  
  6129.         open for writing at end of file, or create for writing.
  6130.  
  6131.  
  6132.  
  6133.         NOTES: fopen for read access is the same as open for update; 
  6134.  
  6135.         write access is the same as creat for the file; append causes a 
  6136.  
  6137.         seek to the end of an existing file, or the creation of a new 
  6138.  
  6139.         file as required. 
  6140.  
  6141.  
  6142.  
  6143.         Any  of  the  functions can open the console ("CON")  or  printer 
  6144.  
  6145.         ("PRN").
  6146.  
  6147.  
  6148.  
  6149.  
  6150.  
  6151.         7.9.20. fputc()
  6152.  
  6153.  
  6154.  
  6155.                   #include <stdio.h>
  6156.  
  6157.                   FILE *fp;
  6158.  
  6159.                   char ch;
  6160.  
  6161.                   int data;
  6162.  
  6163.  
  6164.  
  6165.                   data = fputc(ch, fp);
  6166.  
  6167.  
  6168.  
  6169.         fputc writes ch to the file fp.  fp must have been opened 
  6170.  
  6171.         prior to the call.  The functions return ch, or -1 on error.
  6172.  
  6173.  
  6174.  
  6175.         SEE ALSO: printf(), fwrite()
  6176.  
  6177.  
  6178.  
  6179.  
  6180.  
  6181.  
  6182.  
  6183.  
  6184.  
  6185.  
  6186.  
  6187.  
  6188.  
  6189.  
  6190.  
  6191.  
  6192.  
  6193.  
  6194.  
  6195.  
  6196.  
  6197.  
  6198.  
  6199.  
  6200.  
  6201.  
  6202.  
  6203.  
  6204.  
  6205.         The PCCS.S Standard Library                       Page 42
  6206.  
  6207.  
  6208.  
  6209.  
  6210.  
  6211.         7.9.21. fputs()
  6212.  
  6213.  
  6214.  
  6215.                   #include <stdio.h>
  6216.  
  6217.                   FILE *fp;
  6218.  
  6219.                   char buf[];
  6220.  
  6221.                   int err;
  6222.  
  6223.  
  6224.  
  6225.                   err = fputs(buf, fp);
  6226.  
  6227.  
  6228.  
  6229.         fputs copies the null terminated string buf to the file fp.  
  6230.  
  6231.         fputs returns a -1 on error.
  6232.  
  6233.  
  6234.  
  6235.         SEE ALSO: fprintf()
  6236.  
  6237.  
  6238.  
  6239.         NOTE: On output, linefeed ('\n') is converted to carriage return 
  6240.  
  6241.         - linefeed ('\r\n').
  6242.  
  6243.  
  6244.  
  6245.  
  6246.  
  6247.         7.9.22. frand()
  6248.  
  6249.  
  6250.  
  6251.                   double dval;
  6252.  
  6253.  
  6254.  
  6255.                   dval = frand();
  6256.  
  6257.  
  6258.  
  6259.         frand returns the next pseudo-random number in the range from 
  6260.  
  6261.         0.0 to 1.0.
  6262.  
  6263.  
  6264.  
  6265.  
  6266.  
  6267.         7.9.23. fscanf()
  6268.  
  6269.  
  6270.  
  6271.                   #include <stdio.h>
  6272.  
  6273.                   FILE *fp;
  6274.  
  6275.                   char fcs[];
  6276.  
  6277.                   int num;
  6278.  
  6279.  
  6280.  
  6281.                   num = fscanf(fp, fcs [, ptr ] ... );
  6282.  
  6283.  
  6284.  
  6285.         fscanf reads from the file fp.
  6286.  
  6287.  
  6288.  
  6289.         Returns the number of items successfully scanned or -1 on end of 
  6290.  
  6291.         input or error.
  6292.  
  6293.  
  6294.  
  6295.         See scanf() for a how it works.
  6296.  
  6297.  
  6298.  
  6299.  
  6300.  
  6301.         7.9.24. getc()
  6302.  
  6303.  
  6304.  
  6305.                   #include <stdio.h>
  6306.  
  6307.                   FILE *fp;
  6308.  
  6309.                   int data;
  6310.  
  6311.  
  6312.  
  6313.                   data = getc(fp)
  6314.  
  6315.  
  6316.  
  6317.         getc  return the next character from the file fp, or -1 if an 
  6318.  
  6319.         error, or end of file was sensed.
  6320.  
  6321.  
  6322.  
  6323.  
  6324.  
  6325.  
  6326.  
  6327.  
  6328.  
  6329.  
  6330.  
  6331.  
  6332.  
  6333.  
  6334.  
  6335.  
  6336.  
  6337.         The PCCS.S Standard Library                       Page 43
  6338.  
  6339.  
  6340.  
  6341.  
  6342.  
  6343.  
  6344.  
  6345.         NOTE: getc is a function rather than the usual macro.
  6346.  
  6347.  
  6348.  
  6349.         getchar() will hangup reading redirected input under DOS 2.X and 
  6350.  
  6351.         higher.  Use getc(stdin) if the input could be redirected.
  6352.  
  6353.  
  6354.  
  6355.         SEE ALSO: scanf(), fread()
  6356.  
  6357.  
  6358.  
  6359.  
  6360.  
  6361.         7.9.25. getchar()
  6362.  
  6363.  
  6364.  
  6365.  
  6366.  
  6367.                   int data;
  6368.  
  6369.  
  6370.  
  6371.                   data = getchar();
  6372.  
  6373.  
  6374.  
  6375.         getchar  returns the next character from stdin, or -1 if an 
  6376.  
  6377.         error, end of file, or a CTRL-Z was found.
  6378.  
  6379.  
  6380.  
  6381.         NOTE: getchar is a function rather than the usual macro.
  6382.  
  6383.  
  6384.  
  6385.         getchar() will hangup reading redirected input under DOS 2.X and 
  6386.  
  6387.         higher.  Use getc(stdin) if the input could be redirected.
  6388.  
  6389.  
  6390.  
  6391.         SEE ALSO: scanf(), fread()
  6392.  
  6393.  
  6394.  
  6395.  
  6396.  
  6397.         7.9.26. gets()
  6398.  
  6399.  
  6400.  
  6401.                   char *cp, buf[], *gets();
  6402.  
  6403.                   int len, size;
  6404.  
  6405.  
  6406.  
  6407.                   cp  =  gets(buf);
  6408.  
  6409.                   len = _gets(buf, size);
  6410.  
  6411.  
  6412.  
  6413.         gets obtains a line-edited string from the console (stdin) into 
  6414.  
  6415.         buf.  During input, <ESC> means backup and start over, 
  6416.  
  6417.         <BACKSPACE> means delete the previous character and <RETURN> 
  6418.  
  6419.         means end of string.  <RETURN> is replaced in buf by a zero.  
  6420.  
  6421.         gets returns its argument, or 0 on end of file or an error.
  6422.  
  6423.  
  6424.  
  6425.         _gets obtains not more than size - 1 characters from the console 
  6426.  
  6427.         into buf.  Editing proceeds as with gets.  _gets returns the 
  6428.  
  6429.         number of characters obtained, or 0 on end of file or an error.
  6430.  
  6431.  
  6432.  
  6433.         SEE ALSO: fscanf(), fread()
  6434.  
  6435.  
  6436.  
  6437.         NOTE: gets and _gets don't return the CR character
  6438.  
  6439.  
  6440.  
  6441.  
  6442.  
  6443.  
  6444.  
  6445.  
  6446.  
  6447.  
  6448.  
  6449.  
  6450.  
  6451.  
  6452.  
  6453.  
  6454.  
  6455.  
  6456.  
  6457.  
  6458.  
  6459.  
  6460.  
  6461.  
  6462.  
  6463.  
  6464.  
  6465.  
  6466.  
  6467.  
  6468.  
  6469.         The PCCS.S Standard Library                       Page 44
  6470.  
  6471.  
  6472.  
  6473.  
  6474.  
  6475.         7.9.27. getw()
  6476.  
  6477.  
  6478.  
  6479.                   #include <stdio.h>
  6480.  
  6481.                   FILE *fp;
  6482.  
  6483.                   int data;
  6484.  
  6485.  
  6486.  
  6487.                   data = getw(fp)
  6488.  
  6489.  
  6490.  
  6491.         getw returns the next int from the file fp, or -1 if an error, or 
  6492.  
  6493.         end of file was sensed.
  6494.  
  6495.  
  6496.  
  6497.         SEE ALSO: scanf(), fread()
  6498.  
  6499.  
  6500.  
  6501.  
  6502.  
  6503.         7.9.28. in()
  6504.  
  6505.  
  6506.  
  6507.                   char ch;
  6508.  
  6509.                   unsigned port, wd;
  6510.  
  6511.  
  6512.  
  6513.                   ch = _inb(port);
  6514.  
  6515.                   wd = _inw(port);
  6516.  
  6517.  
  6518.  
  6519.         _inb  and _inw  read the byte ch  and word wd, respectively, from 
  6520.  
  6521.         the indicated port.
  6522.  
  6523.  
  6524.  
  6525.  
  6526.  
  6527.         7.9.29. index()
  6528.  
  6529.  
  6530.  
  6531.                   char *cp, *src, ch;
  6532.  
  6533.  
  6534.  
  6535.                   cp = index(src, ch);
  6536.  
  6537.  
  6538.  
  6539.         index works on null-terminated strings.  There is no test for 
  6540.  
  6541.         overflow.
  6542.  
  6543.  
  6544.  
  6545.         index returns a pointer to the first occurance of ch in src, 
  6546.  
  6547.         or 0 if ch doesn't occur.
  6548.  
  6549.  
  6550.  
  6551.  
  6552.  
  6553.         7.9.30. log()
  6554.  
  6555.  
  6556.  
  6557.                   #include <math.h>
  6558.  
  6559.  
  6560.  
  6561.                   double x, dval, log(), log10();
  6562.  
  6563.  
  6564.  
  6565.                   dval = log(x);
  6566.  
  6567.                   dval = log10(x);
  6568.  
  6569.  
  6570.  
  6571.         log  returns the natural logarithm of x;  log10 returns the base 
  6572.  
  6573.         10 logarithm.
  6574.  
  6575.  
  6576.  
  6577.         NOTE: log and log10 return zero when x is zero or negative; 
  6578.  
  6579.         errno is set to EDOM.  EDOM is defined in math.h.
  6580.  
  6581.  
  6582.  
  6583.  
  6584.  
  6585.  
  6586.  
  6587.  
  6588.  
  6589.  
  6590.  
  6591.  
  6592.  
  6593.  
  6594.  
  6595.  
  6596.  
  6597.  
  6598.  
  6599.  
  6600.  
  6601.         The PCCS.S Standard Library                       Page 45
  6602.  
  6603.  
  6604.  
  6605.  
  6606.  
  6607.         7.9.31. lmove()
  6608.  
  6609.  
  6610.  
  6611.                   char *sp, *tp;
  6612.  
  6613.                   unsigned  num, sseg, tseg;
  6614.  
  6615.  
  6616.  
  6617.                 _lmove(number, sp, sseg, tp, tseg);
  6618.  
  6619.  
  6620.  
  6621.         _lmove  moves num  bytes from the 8088 physical address at 
  6622.  
  6623.         sseg:sp  to tseg:tp .  For example, to move the color display 
  6624.  
  6625.         frame buffer at address 0xB800:0 to a local buffer ( _showds  
  6626.  
  6627.         provides the C program data segment  Q DS)
  6628.  
  6629.  
  6630.  
  6631.                 _lmove(4000, 0, 0xB800, buffer, _showds());
  6632.  
  6633.  
  6634.  
  6635.         NOTE:  _lmove  takes advantage of the 8088 instructions for a 
  6636.  
  6637.         fast data move.  It handles overlapping moves correctly so that
  6638.  
  6639.  
  6640.  
  6641.                 _lmove(3920, 0, 0xB800, 80, 0xB800);
  6642.  
  6643.  
  6644.  
  6645.         will move 0xB800:3919 to 0xB800:3999,  0xB800:3918 to 0xB800:3998 
  6646.  
  6647.         etc. rather than propagating 0xB800:0.
  6648.  
  6649.  
  6650.  
  6651.  
  6652.  
  6653.         7.9.32. longjmp()
  6654.  
  6655.  
  6656.  
  6657.                   #include <setjmp.h>
  6658.  
  6659.  
  6660.  
  6661.                   int val;
  6662.  
  6663.                   jmp_buf env;
  6664.  
  6665.  
  6666.  
  6667.                   longjmp(env, val);
  6668.  
  6669.  
  6670.  
  6671.         jmp_buf is defined in <setjmp.h> .  It creates an environment 
  6672.  
  6673.         used by setjmp for future use by longjmp .  jmp_buf is defined 
  6674.  
  6675.         as
  6676.  
  6677.                 typedef char jmp_buf[6];
  6678.  
  6679.  
  6680.  
  6681.         longjmp restores SP, BP, and return address from env and returns 
  6682.  
  6683.         val.  val cannot be zero.
  6684.  
  6685.  
  6686.  
  6687.         NOTE:   env  can be specified as zero,  for  compatibility  with 
  6688.  
  6689.         previous releases.  There can be only one "zero" env  active at 
  6690.  
  6691.         any time.
  6692.  
  6693.  
  6694.  
  6695.         If the environment stored in env  points into an overlay area, 
  6696.  
  6697.         then the overlay that called setjmp  must be resident when 
  6698.  
  6699.         longjmp  is called Q if another overlay is resident, then strange 
  6700.  
  6701.         things will happen.  It is best to call setjmp  from the root.
  6702.  
  6703.  
  6704.  
  6705.  
  6706.  
  6707.  
  6708.  
  6709.  
  6710.  
  6711.  
  6712.  
  6713.  
  6714.  
  6715.  
  6716.  
  6717.  
  6718.  
  6719.  
  6720.  
  6721.  
  6722.  
  6723.  
  6724.  
  6725.  
  6726.  
  6727.  
  6728.  
  6729.  
  6730.  
  6731.  
  6732.  
  6733.         The PCCS.S Standard Library                       Page 46
  6734.  
  6735.  
  6736.  
  6737.  
  6738.  
  6739.         7.9.33. open()
  6740.  
  6741.  
  6742.  
  6743.                   int handle;
  6744.  
  6745.                   char *name, mode;
  6746.  
  6747.  
  6748.  
  6749.                   handle = open(name, mode)
  6750.  
  6751.  
  6752.  
  6753.         open opens the file name and returns an int that identifies the 
  6754.  
  6755.         file in  future  file operations.  Returns -1 if the file can't 
  6756.  
  6757.         be opened.
  6758.  
  6759.  
  6760.  
  6761.         mode is a char having one of the following values: 0 = open for 
  6762.  
  6763.         reading, 1 = open for writing, 2 = open for update, and 3 = open 
  6764.  
  6765.         for reading (CTRLZ indicates EOF).
  6766.  
  6767.  
  6768.  
  6769.         NOTES: Any of the functions can open the console ("CON") or 
  6770.  
  6771.         printer ("PRN").
  6772.  
  6773.  
  6774.  
  6775.  
  6776.  
  6777.         7.9.34. os()
  6778.  
  6779.  
  6780.  
  6781.                   char inum, ival;
  6782.  
  6783.                   unsigned arg;
  6784.  
  6785.                 
  6786.  
  6787.                   ival = _os(inum, arg);
  6788.  
  6789.                 _doint(inum);
  6790.  
  6791.                 dates(buf);
  6792.  
  6793.                 times(buf);
  6794.  
  6795.  
  6796.  
  6797.         _os provides an elementary interrupt interface.  Under DOS, inum  
  6798.  
  6799.         goes into AH and arg into DX, and an int 21H, is executed.  The 
  6800.  
  6801.         value in AL is returned.
  6802.  
  6803.  
  6804.  
  6805.  
  6806.  
  6807.         7.9.35. out()
  6808.  
  6809.  
  6810.  
  6811.                   char ch;
  6812.  
  6813.                   unsigned port, wd;
  6814.  
  6815.  
  6816.  
  6817.                 _outb(ch, port);
  6818.  
  6819.                 _outw(wd, port);
  6820.  
  6821.  
  6822.  
  6823.         _outb and _outw write the byte ch  and word wd, respectively, of 
  6824.  
  6825.         data out to the indicated port.
  6826.  
  6827.  
  6828.  
  6829.         7.9.36. peek()
  6830.  
  6831.  
  6832.  
  6833.                   char ch, *sp;
  6834.  
  6835.                   unsigned  sseg;
  6836.  
  6837.  
  6838.  
  6839.  
  6840.  
  6841.                   ch = _peek(sp, sseg);
  6842.  
  6843.  
  6844.  
  6845.         _peek  is used to retrieve a byte ch  from the 8088 physical 
  6846.  
  6847.         address at sseg:sp .
  6848.  
  6849.  
  6850.  
  6851.  
  6852.  
  6853.  
  6854.  
  6855.  
  6856.  
  6857.  
  6858.  
  6859.  
  6860.  
  6861.  
  6862.  
  6863.  
  6864.  
  6865.         The PCCS.S Standard Library                       Page 47
  6866.  
  6867.  
  6868.  
  6869.  
  6870.  
  6871.         7.9.37. poke()
  6872.  
  6873.  
  6874.  
  6875.                   char ch, *tp;
  6876.  
  6877.                   unsigned  tseg;
  6878.  
  6879.  
  6880.  
  6881.                   _poke(ch, tp, tseg);
  6882.  
  6883.  
  6884.  
  6885.         _poke  is used to store the byte ch  of data to the 8088 physical 
  6886.  
  6887.         address at tseg:tp .
  6888.  
  6889.  
  6890.  
  6891.  
  6892.  
  6893.         7.9.38. pow()
  6894.  
  6895.  
  6896.  
  6897.                   #include <math.h>
  6898.  
  6899.  
  6900.  
  6901.                   double x, y, dval, pow();
  6902.  
  6903.  
  6904.  
  6905.                   dval = pow(x, y);
  6906.  
  6907.  
  6908.  
  6909.         pow  returns x ** y.
  6910.  
  6911.  
  6912.  
  6913.         NOTE: pow returns a very large value when the result would 
  6914.  
  6915.         overflow; errno is set to ERANGE.  pow returns zero and sets 
  6916.  
  6917.         errno to EDOM when the second argument is negative and not 
  6918.  
  6919.         integral, or when both arguments are zero.  EDOM and ERANGE are 
  6920.  
  6921.         defined in math.h.
  6922.  
  6923.  
  6924.  
  6925.  
  6926.  
  6927.  
  6928.  
  6929.         7.9.39. putc()
  6930.  
  6931.  
  6932.  
  6933.                   #include <stdio.h>
  6934.  
  6935.                   FILE *fp;
  6936.  
  6937.                   char ch;
  6938.  
  6939.                   int data;
  6940.  
  6941.  
  6942.  
  6943.                   data = putc(ch, fp);
  6944.  
  6945.  
  6946.  
  6947.         putc writes ch to the file fp .  fp must have been opened prior 
  6948.  
  6949.         to the call.  The functions return ch, or -1 on error.
  6950.  
  6951.  
  6952.  
  6953.         SEE ALSO: printf(), fwrite()
  6954.  
  6955.  
  6956.  
  6957.  
  6958.  
  6959.         7.9.40. putchar()
  6960.  
  6961.  
  6962.  
  6963.                   #include <stdio.h>
  6964.  
  6965.                   FILE *fp;
  6966.  
  6967.                   char ch;
  6968.  
  6969.                   int data;
  6970.  
  6971.  
  6972.  
  6973.                   data = putchar(ch);
  6974.  
  6975.  
  6976.  
  6977.         putchar writes ch  to stdout .  Linefeed ('\n') is converted to 
  6978.  
  6979.         carriage return - linefeed ('\r\n').  Output will stop if CTRL-S 
  6980.  
  6981.  
  6982.  
  6983.  
  6984.  
  6985.  
  6986.  
  6987.  
  6988.  
  6989.  
  6990.  
  6991.  
  6992.  
  6993.  
  6994.  
  6995.  
  6996.  
  6997.         The PCCS.S Standard Library                       Page 48
  6998.  
  6999.  
  7000.  
  7001.  
  7002.  
  7003.         is entered, and resume when any other key is pressed.  Each 
  7004.  
  7005.         output will check for a CTRL-C entry, and terminate  the program 
  7006.  
  7007.         if it was pressed.  putchar returns ch , or -1 on error.
  7008.  
  7009.  
  7010.  
  7011.         SEE ALSO: printf(), fwrite()
  7012.  
  7013.  
  7014.  
  7015.         NOTE:  putchar is a function rather than the usual macro.
  7016.  
  7017.  
  7018.  
  7019.  
  7020.  
  7021.         7.9.41. puts()
  7022.  
  7023.  
  7024.  
  7025.                   char buf[];
  7026.  
  7027.                   int err;
  7028.  
  7029.  
  7030.  
  7031.                   err = puts(buf);
  7032.  
  7033.  
  7034.  
  7035.         puts copies the null terminated string buf to the console 
  7036.  
  7037.         (stdout).  puts returns a -1 on error.
  7038.  
  7039.  
  7040.  
  7041.         SEE ALSO: printf()
  7042.  
  7043.  
  7044.  
  7045.         NOTE:  puts  doesn't append a newline.
  7046.  
  7047.  
  7048.  
  7049.         On output, linefeed ('\n') is converted to carriage return - 
  7050.  
  7051.         linefeed ('\r\n').  Output will stop if CTRL-S is entered, and 
  7052.  
  7053.         resume when any other key is pressed.  Each output will check for 
  7054.  
  7055.         a CTRL-C entry, and terminate  the program if it was pressed.
  7056.  
  7057.  
  7058.  
  7059.  
  7060.  
  7061.         7.9.42. putw()
  7062.  
  7063.  
  7064.  
  7065.                   #include <stdio.h>
  7066.  
  7067.                   FILE *fp;
  7068.  
  7069.                   int data, w;
  7070.  
  7071.  
  7072.  
  7073.                   data = putw(w, fp);
  7074.  
  7075.  
  7076.  
  7077.         putw writes the int w to the file fp .  fp must have been 
  7078.  
  7079.         opened prior to the call.  putw  returns w, or -1 on error.
  7080.  
  7081.  
  7082.  
  7083.         SEE ALSO: printf(), fwrite()
  7084.  
  7085.  
  7086.  
  7087.         There is no way to distinguish the return from putw(-1, fp) from 
  7088.  
  7089.         an error.
  7090.  
  7091.  
  7092.  
  7093.  
  7094.  
  7095.         7.9.43. qsort()
  7096.  
  7097.                   char array[];
  7098.  
  7099.                   int num, width, (*compare)();
  7100.  
  7101.  
  7102.  
  7103.                   qsort(array, num, width, compare);
  7104.  
  7105.  
  7106.  
  7107.         qsort is an implementation of C. A. R. Hoare's quicker-sort  
  7108.  
  7109.         algorithm.  It sorts an array of num elements, each width  bytes 
  7110.  
  7111.         wide.  compare is called with two arguments -- pointers to the 
  7112.  
  7113.  
  7114.  
  7115.  
  7116.  
  7117.  
  7118.  
  7119.  
  7120.  
  7121.  
  7122.  
  7123.  
  7124.  
  7125.  
  7126.  
  7127.  
  7128.  
  7129.         The PCCS.S Standard Library                       Page 49
  7130.  
  7131.  
  7132.  
  7133.  
  7134.  
  7135.         two elements being compared, and returns an integer less than, 
  7136.  
  7137.         equal to, or greater than zero accordingly as the first argument 
  7138.  
  7139.         is less than, equal to, or greater than the second argument.
  7140.  
  7141.  
  7142.  
  7143.         NOTE:  The usual function for compare is strcmp().  If you are 
  7144.  
  7145.         sorting anything other than strings, the following may serve as a 
  7146.  
  7147.         model:
  7148.  
  7149.  
  7150.  
  7151.                 int compare(left, right)
  7152.  
  7153.                 int *left, *right; {
  7154.  
  7155.                         return *left - *right;
  7156.  
  7157.                         }
  7158.  
  7159.  
  7160.  
  7161.                 #define TCARD    1024
  7162.  
  7163.                 #define ISIZE    sizeof(int)
  7164.  
  7165.  
  7166.  
  7167.                 int itab[TCARD];
  7168.  
  7169.  
  7170.  
  7171.                         qsort(itab, TCARD, ISIZE, compare);
  7172.  
  7173.  
  7174.  
  7175.         Remember that int, long, float, and double values are stored with 
  7176.  
  7177.         their low-order bytes first.  Thus string comparisons may not 
  7178.  
  7179.         produce the expected results.
  7180.  
  7181.  
  7182.  
  7183.  
  7184.  
  7185.         7.9.44. rand()
  7186.  
  7187.  
  7188.  
  7189.                   int ival;
  7190.  
  7191.  
  7192.  
  7193.                   ival = rand();
  7194.  
  7195.  
  7196.  
  7197.         rand returns the next pseudo-random number in the range from 0 
  7198.  
  7199.         to 2**15 - 1.
  7200.  
  7201.  
  7202.  
  7203.  
  7204.  
  7205.         7.9.45. rename()
  7206.  
  7207.  
  7208.  
  7209.                   char *oldFile, *newFile;
  7210.  
  7211.                   int stat;
  7212.  
  7213.  
  7214.  
  7215.                   stat = rename(oldFile, newFile);
  7216.  
  7217.  
  7218.  
  7219.         rename changes the file name oldFile to newFile.  Under DOS 2.X 
  7220.  
  7221.         and higher, oldFile may contain a path specification.  Returns -1 
  7222.  
  7223.         if oldFile is open, or if an error is detected.
  7224.  
  7225.  
  7226.  
  7227.  
  7228.  
  7229.         7.9.46. rindex()
  7230.  
  7231.  
  7232.  
  7233.                   char *cp, *src, ch;
  7234.  
  7235.  
  7236.  
  7237.                   cp = index(src, ch);
  7238.  
  7239.  
  7240.  
  7241.         rindex works on null-terminated strings.  There is no test for 
  7242.  
  7243.         overflow.
  7244.  
  7245.  
  7246.  
  7247.  
  7248.  
  7249.  
  7250.  
  7251.  
  7252.  
  7253.  
  7254.  
  7255.  
  7256.  
  7257.  
  7258.  
  7259.  
  7260.  
  7261.         The PCCS.S Standard Library                       Page 50
  7262.  
  7263.  
  7264.  
  7265.  
  7266.  
  7267.  
  7268.  
  7269.         rindex returns a pointer to the last occurance of ch in src or 0 
  7270.  
  7271.         if ch doesn't occur.
  7272.  
  7273.  
  7274.  
  7275.  
  7276.  
  7277.         7.9.47. scanf()
  7278.  
  7279.  
  7280.  
  7281.                   char fcs[];
  7282.  
  7283.                   int num;
  7284.  
  7285.  
  7286.  
  7287.                   num = scanf(fcs [, ptr ] ... );
  7288.  
  7289.  
  7290.  
  7291.  
  7292.  
  7293.         scanf reads from stdin.
  7294.  
  7295.  
  7296.  
  7297.         Returns the number of items successfully scanned.
  7298.  
  7299.  
  7300.  
  7301.         The format control string, fcs, contains: blanks or tabs, which 
  7302.  
  7303.         match optional whitespace (blanks, tabs, newlines, formfeeds, and 
  7304.  
  7305.         vertical tabs) in the input; a non-'%'  character which must 
  7306.  
  7307.         match the next character in the input, and conversion control 
  7308.  
  7309.         strings which describe the type and format of each *ptr.  
  7310.  
  7311.         Conversion control strings have the following format ([] enclose 
  7312.  
  7313.         optional entries):
  7314.  
  7315.  
  7316.  
  7317.                 %[*][width][parms]code
  7318.  
  7319.  
  7320.  
  7321.         where:  *  indicates  that  the field should be skipped  and  not 
  7322.  
  7323.         assigned  to a *ptr ,  width specifies the maximum field size  in 
  7324.  
  7325.         bytes.   Both parms and code are described below.   The  examples 
  7326.  
  7327.         have the following form:
  7328.  
  7329.  
  7330.  
  7331.                 | input string |  . function call . result 
  7332.  
  7333.  
  7334.  
  7335.         Character:  %[*][width]c
  7336.  
  7337.            String:  %[*][width]s
  7338.  
  7339.  
  7340.  
  7341.         width  specifies the number of characters to be read into the 
  7342.  
  7343.         array at *ptr .  The default is 1.  'c' whitespace is not 
  7344.  
  7345.         skipped, 's' whitespace is.
  7346.  
  7347.  
  7348.  
  7349.                 |  abc| . scanf("%3c", buf) . |  a|
  7350.  
  7351.                 |  abc| . scanf("%3s", buf) . |abc|
  7352.  
  7353.  
  7354.  
  7355.         Integer:  %[*][width][size]code
  7356.  
  7357.  
  7358.  
  7359.         size  equal to 'l' (lowercase 'L') specifies that *ptr  point to 
  7360.  
  7361.         a long, a 'h' specifies a short int .
  7362.  
  7363.  
  7364.  
  7365.  
  7366.  
  7367.  
  7368.  
  7369.  
  7370.  
  7371.  
  7372.  
  7373.  
  7374.  
  7375.  
  7376.  
  7377.  
  7378.  
  7379.  
  7380.  
  7381.  
  7382.  
  7383.  
  7384.  
  7385.  
  7386.  
  7387.  
  7388.  
  7389.  
  7390.  
  7391.  
  7392.  
  7393.         The PCCS.S Standard Library                       Page 51
  7394.  
  7395.  
  7396.  
  7397.  
  7398.  
  7399.         code  is one of: 'd' Q signed decimal format, 'u' Q unsigned 
  7400.  
  7401.         decimal format, 'o' Q unsigned octal, and 'x' Q unsigned 
  7402.  
  7403.         hexadecimal.
  7404.  
  7405.  
  7406.  
  7407.                 |  FF | . scanf("%x", &hex)  .  255
  7408.  
  7409.                 | 377 | . scanf("%o", &oct)  .  255
  7410.  
  7411.                 | 255 | . scanf("%u", &uns)  .  255
  7412.  
  7413.                 |-255 | . scanf("%ld", &lng) . -255L
  7414.  
  7415.  
  7416.  
  7417.         Floating Point:  %[*][width][size]code
  7418.  
  7419.  
  7420.  
  7421.         size  equal to 'l' (lowercase 'L') specifies that *ptr  points to 
  7422.  
  7423.         a double rather than a float.
  7424.  
  7425.  
  7426.  
  7427.         code  can be either 'e', 'f', or 'g' Q they all indicate floating 
  7428.  
  7429.         point.
  7430.  
  7431.  
  7432.  
  7433.                 | 123.45 | . scanf("%f", %flt)       . 123.45
  7434.  
  7435.                 | 123.45 | . scanf("%4lf%d", &d, &i) . 123.0  45
  7436.  
  7437.  
  7438.  
  7439.  
  7440.  
  7441.         Scanset:  %[*][width]scanset
  7442.  
  7443.  
  7444.  
  7445.         scanset  is specified by a sequence of characters enclosed by 
  7446.  
  7447.         brackets '[' ']'.  It reads a string, including the terminating 
  7448.  
  7449.         null character.  Leading whitespace is not skipped.
  7450.  
  7451.  
  7452.  
  7453.                 |123 ABC| . scanf("%[123 ]", str) . |123 |
  7454.  
  7455.  
  7456.  
  7457.         A range of contiguous characters can be specified by the first 
  7458.  
  7459.         and last element of the range, separated by a '-'.
  7460.  
  7461.  
  7462.  
  7463.                 |123 ABC| . scanf("%[1-3 ]", str) . |123 |
  7464.  
  7465.  
  7466.  
  7467.         If the first element of scanset  is a '^', then all characters 
  7468.  
  7469.         except  those specified will be read.
  7470.  
  7471.  
  7472.  
  7473.                 |123 ABC| . scanf("%[^A-C]", str) . |123 |
  7474.  
  7475.  
  7476.  
  7477.         To specify '-' or ']' in a scanset , specify it as the first 
  7478.  
  7479.         element.  Thus to read an integer, skip any interviening garbage, 
  7480.  
  7481.         and read another integer
  7482.  
  7483.  
  7484.  
  7485.                 scanf("%d%*[^-+0-9]%d", &dig1, &dig2);
  7486.  
  7487.  
  7488.  
  7489.  
  7490.  
  7491.  
  7492.  
  7493.  
  7494.  
  7495.  
  7496.  
  7497.  
  7498.  
  7499.  
  7500.  
  7501.  
  7502.  
  7503.  
  7504.  
  7505.  
  7506.  
  7507.  
  7508.  
  7509.  
  7510.  
  7511.  
  7512.  
  7513.  
  7514.  
  7515.  
  7516.  
  7517.  
  7518.  
  7519.  
  7520.  
  7521.  
  7522.  
  7523.  
  7524.  
  7525.         The PCCS.S Standard Library                       Page 52
  7526.  
  7527.  
  7528.  
  7529.  
  7530.  
  7531.         7.9.48. scr_aputs()
  7532.  
  7533.  
  7534.  
  7535.                   char *str, attr;
  7536.  
  7537.  
  7538.  
  7539.                   scr_aputs(str, attr);
  7540.  
  7541.  
  7542.  
  7543.         scr_aputs writes string str to the display with attribute attr.  
  7544.  
  7545.         '\r' moves to the begining of the line, and '\n' moves to the 
  7546.  
  7547.         next line.  Moving off the bottom line causes scrolling.
  7548.  
  7549.  
  7550.  
  7551.         NOTE:  scr_aputs is in the file PCIO.A.
  7552.  
  7553.  
  7554.  
  7555.  
  7556.  
  7557.         7.9.49. scr_ci()
  7558.  
  7559.  
  7560.  
  7561.                   char ch;
  7562.  
  7563.  
  7564.  
  7565.                   ch = scr_ci();
  7566.  
  7567.  
  7568.  
  7569.         scr_ci is like ci() but uses its own translation table for 
  7570.  
  7571.         command characters.  It returns the next character from the input 
  7572.  
  7573.         queue.
  7574.  
  7575.  
  7576.  
  7577.         NOTE:  scr_ci is in the file PCIO.A.
  7578.  
  7579.  
  7580.  
  7581.  
  7582.  
  7583.         7.9.50. scr_co()
  7584.  
  7585.  
  7586.  
  7587.                   char ch;
  7588.  
  7589.  
  7590.  
  7591.                   scr_co(ch);
  7592.  
  7593.         scr_co is the same as co() -- it writes a single character out to 
  7594.  
  7595.         the screen.
  7596.  
  7597.  
  7598.  
  7599.         NOTE:  scr_co is in the file PCIO.A.
  7600.  
  7601.  
  7602.  
  7603.  
  7604.  
  7605.         7.9.51. scr_clr()
  7606.  
  7607.  
  7608.  
  7609.                   scr_clr();
  7610.  
  7611.  
  7612.  
  7613.         scr_clr erases the entire screen and sets the cursor to the home, 
  7614.  
  7615.         (0,0) location.
  7616.  
  7617.  
  7618.  
  7619.         NOTE:  scr_clr is in the file PCIO.A.
  7620.  
  7621.  
  7622.  
  7623.  
  7624.  
  7625.         7.9.52. scr_clrl()
  7626.  
  7627.  
  7628.  
  7629.                   scr_clrl();
  7630.  
  7631.  
  7632.  
  7633.         scr_clrl erases everything from the cursor location to the end of 
  7634.  
  7635.         the line.
  7636.  
  7637.  
  7638.  
  7639.         NOTE:  scr_clrl is in the file PCIO.A.
  7640.  
  7641.  
  7642.  
  7643.  
  7644.  
  7645.  
  7646.  
  7647.  
  7648.  
  7649.  
  7650.  
  7651.  
  7652.  
  7653.  
  7654.  
  7655.  
  7656.  
  7657.         The PCCS.S Standard Library                       Page 53
  7658.  
  7659.  
  7660.  
  7661.  
  7662.  
  7663.         7.9.53. scr_cls()
  7664.  
  7665.  
  7666.  
  7667.                   scr_cls();
  7668.  
  7669.  
  7670.  
  7671.         scr_cls erases everything from the cursor location to the end  of 
  7672.  
  7673.         the screen.
  7674.  
  7675.  
  7676.  
  7677.         NOTE:  scr_cls is in the file PCIO.A.
  7678.  
  7679.  
  7680.  
  7681.  
  7682.  
  7683.         7.9.54. scr_csts()
  7684.  
  7685.  
  7686.  
  7687.                   char ch;
  7688.  
  7689.  
  7690.  
  7691.                   ch = scr_csts();
  7692.  
  7693.  
  7694.  
  7695.         scr_csts returns the next character from the queue, or 0 if no 
  7696.  
  7697.         character is available.  If a character is present, it is 
  7698.  
  7699.         equivalent to a csts() followed by a ci().
  7700.  
  7701.  
  7702.  
  7703.         NOTE:  scr_csts is in the file PCIO.A.
  7704.  
  7705.  
  7706.  
  7707.         Function keys return a zero.
  7708.  
  7709.  
  7710.  
  7711.  
  7712.  
  7713.         7.9.55. scr_cursoff()
  7714.  
  7715.  
  7716.  
  7717.                   scr_cursoff();
  7718.  
  7719.  
  7720.  
  7721.         scr_cursoff turns the cursor off.
  7722.  
  7723.  
  7724.  
  7725.         NOTE:  scr_cursoff is in the file PCIO.A.
  7726.  
  7727.  
  7728.  
  7729.  
  7730.  
  7731.         7.9.56. scr_curson()
  7732.  
  7733.  
  7734.  
  7735.                   scr_curson();
  7736.  
  7737.  
  7738.  
  7739.         scr_curson turns the cursor on.
  7740.  
  7741.  
  7742.  
  7743.         NOTE:  scr_curson is in the file PCIO.A.
  7744.  
  7745.  
  7746.  
  7747.  
  7748.  
  7749.         7.9.57. scr_rowcol()
  7750.  
  7751.  
  7752.  
  7753.                   int trow, tcol;
  7754.  
  7755.  
  7756.  
  7757.                   scr_rowcol(trow, tcol);
  7758.  
  7759.  
  7760.  
  7761.         scr_rowcol moves the cursor to row trow and column tcol.
  7762.  
  7763.  
  7764.  
  7765.         NOTE:  scr_rowcol is in the file PCIO.A.
  7766.  
  7767.  
  7768.  
  7769.  
  7770.  
  7771.  
  7772.  
  7773.  
  7774.  
  7775.  
  7776.  
  7777.  
  7778.  
  7779.  
  7780.  
  7781.  
  7782.  
  7783.  
  7784.  
  7785.  
  7786.  
  7787.  
  7788.  
  7789.         The PCCS.S Standard Library                       Page 54
  7790.  
  7791.  
  7792.  
  7793.  
  7794.  
  7795.         7.9.58. scr_scdn()
  7796.  
  7797.  
  7798.  
  7799.                   scr_scdn();
  7800.  
  7801.  
  7802.  
  7803.         scr_scdn scrolls the screen down one line, but leaves the top two 
  7804.  
  7805.         lines alone.
  7806.  
  7807.  
  7808.  
  7809.         NOTE:  scr_scdn is in the file PCIO.A.
  7810.  
  7811.  
  7812.  
  7813.  
  7814.  
  7815.         7.9.59. scr_scrdn()
  7816.  
  7817.  
  7818.  
  7819.                   int lines, frow, fcol, trow, tcol;
  7820.  
  7821.  
  7822.  
  7823.                   scr_scrdn(lines, frow, fcol, trow, tcol);
  7824.  
  7825.  
  7826.  
  7827.         scr_scrdn scrolls the given area down lines.  The area is defined 
  7828.  
  7829.         by the character locations (frow, fcol), (trow, tcol).
  7830.  
  7831.  
  7832.  
  7833.         NOTE:  scr_scrdn is in the file PCIO.A.
  7834.  
  7835.  
  7836.  
  7837.  
  7838.  
  7839.         7.9.60. scr_scrup()
  7840.  
  7841.  
  7842.  
  7843.                   int lines, frow, fcol, trow, tcol;
  7844.  
  7845.  
  7846.  
  7847.                   scr_scrup(lines, frow, fcol, trow, tcol);
  7848.  
  7849.  
  7850.  
  7851.         scr_scrup scrolls the area up lines.  The area is defined by the 
  7852.  
  7853.         character locations (frow, fcol), (trow, tcol).
  7854.  
  7855.  
  7856.  
  7857.         NOTE:  scr_scup is in the file PCIO.A.
  7858.  
  7859.  
  7860.  
  7861.  
  7862.  
  7863.         7.9.61. scr_scup()
  7864.  
  7865.  
  7866.  
  7867.                   scr_scup();
  7868.  
  7869.  
  7870.  
  7871.         scr_scup scrolls the screen up one line, but leaves the top two 
  7872.  
  7873.         lines alone.
  7874.  
  7875.  
  7876.  
  7877.         NOTE:  scr_scup is in the file PCIO.A.
  7878.  
  7879.  
  7880.  
  7881.  
  7882.  
  7883.         7.9.62. scr_setmode()
  7884.  
  7885.  
  7886.  
  7887.                   char newMode;
  7888.  
  7889.  
  7890.  
  7891.                   scr_setmode(newMode);
  7892.  
  7893.  
  7894.  
  7895.         scr_setmode  sets the mode of the color card.  newMode  must be 
  7896.  
  7897.         between 0 and 6.
  7898.  
  7899.  
  7900.  
  7901.         NOTE:  scr_setmode is in the file PCIO.A.
  7902.  
  7903.  
  7904.  
  7905.  
  7906.  
  7907.  
  7908.  
  7909.  
  7910.  
  7911.  
  7912.  
  7913.  
  7914.  
  7915.  
  7916.  
  7917.  
  7918.  
  7919.  
  7920.  
  7921.         The PCCS.S Standard Library                       Page 55
  7922.  
  7923.  
  7924.  
  7925.  
  7926.  
  7927.         scr_setmode manages the following global data.
  7928.  
  7929.  
  7930.  
  7931.                 char scr_cols;  /* number of character positions */
  7932.  
  7933.                 char scr_rows;  /* number of lines */
  7934.  
  7935.                 char scr_mode;  /* current screen mode:
  7936.  
  7937.                                 0 = 40 col. BW
  7938.  
  7939.                                 1 = 40 col. color
  7940.  
  7941.                                 2 = 80 col. BW
  7942.  
  7943.                                 3 = 80 col. color
  7944.  
  7945.                                 4 = 320 x 200 color graphics
  7946.  
  7947.                                 5 = 320 x 200 BW graphics
  7948.  
  7949.                                 6 = 640 x 200 BW graphics
  7950.  
  7951.                                 7 = 80 col. BW    */
  7952.  
  7953.                 char scr_page;  /* current active display page */
  7954.  
  7955.                 char scr_attr;  /* current character attribute.
  7956.  
  7957.                                 Normally 7 for white on black but
  7958.  
  7959.                                 can be set for any attributes
  7960.  
  7961.                                 see Technical Reference Manual */
  7962.  
  7963.  
  7964.  
  7965.  
  7966.  
  7967.         7.9.63. scr_setup()
  7968.  
  7969.  
  7970.  
  7971.                   scr_setup();
  7972.  
  7973.  
  7974.  
  7975.         scr_setup   must be called prior to any of the screen routines if 
  7976.  
  7977.         the screen is currently in 80 column mode or if scr_curson with a 
  7978.  
  7979.         monochrome display is used.
  7980.  
  7981.  
  7982.  
  7983.         NOTE:  scr_setup is in the file PCIO.A.
  7984.  
  7985.  
  7986.  
  7987.         scr_setup manages the same data as scr_setmode.
  7988.  
  7989.  
  7990.  
  7991.  
  7992.  
  7993.         7.9.64. scr_sinp()
  7994.  
  7995.  
  7996.  
  7997.                   char ch;
  7998.  
  7999.  
  8000.  
  8001.                   ch = scr_sinp();
  8002.  
  8003.  
  8004.  
  8005.         scr_sinp returns the character under the cursor on the screen.
  8006.  
  8007.  
  8008.  
  8009.         NOTE:  scr_sinp is in the file PCIO.A.
  8010.  
  8011.  
  8012.  
  8013.  
  8014.  
  8015.  
  8016.  
  8017.  
  8018.  
  8019.  
  8020.  
  8021.  
  8022.  
  8023.  
  8024.  
  8025.  
  8026.  
  8027.  
  8028.  
  8029.  
  8030.  
  8031.  
  8032.  
  8033.  
  8034.  
  8035.  
  8036.  
  8037.  
  8038.  
  8039.  
  8040.  
  8041.  
  8042.  
  8043.  
  8044.  
  8045.  
  8046.  
  8047.  
  8048.  
  8049.  
  8050.  
  8051.  
  8052.  
  8053.         The PCCS.S Standard Library                       Page 56
  8054.  
  8055.  
  8056.  
  8057.  
  8058.  
  8059.         7.9.65. setjmp()
  8060.  
  8061.  
  8062.  
  8063.                   #include <setjmp.h>
  8064.  
  8065.  
  8066.  
  8067.                   int val;
  8068.  
  8069.                   jmp_buf env;
  8070.  
  8071.  
  8072.  
  8073.                   val = setjmp(env);
  8074.  
  8075.  
  8076.  
  8077.         jmp_buf is defined in <setjmp.h> .  It creates an environment 
  8078.  
  8079.         used by setjmp  for future use by longjmp .  jmp_buf is defined 
  8080.  
  8081.         as
  8082.  
  8083.                 typedef char jmp_buf[6];
  8084.  
  8085.  
  8086.  
  8087.         setjmp  saves the current SP, BP, and return address in env.  It 
  8088.  
  8089.         returns a zero.
  8090.  
  8091.  
  8092.  
  8093.         NOTE:  env can be specified as zero, for compatibility with 
  8094.  
  8095.         previous releases.  There can be only one "zero" env  active at 
  8096.  
  8097.         any time.
  8098.  
  8099.  
  8100.  
  8101.         If the environment stored in env  points into an overlay area, 
  8102.  
  8103.         then the overlay that called setjmp  must be resident when 
  8104.  
  8105.         longjmp  is called -- if another overlay is resident, then 
  8106.  
  8107.         strange things will happen.  It is best to call setjmp  from the 
  8108.  
  8109.         root.
  8110.  
  8111.  
  8112.  
  8113.         setjmp's caller can tell by the returned value if control was 
  8114.  
  8115.         returned from setjmp(0), or from longjmp(!=0).
  8116.  
  8117.  
  8118.  
  8119.  
  8120.  
  8121.         7.9.66. sqrt()
  8122.  
  8123.  
  8124.  
  8125.                   #include <math.h>
  8126.  
  8127.  
  8128.  
  8129.                   double x, dval, sqrt();
  8130.  
  8131.  
  8132.  
  8133.                   dval = sqrt(x);
  8134.  
  8135.  
  8136.  
  8137.         sqrt returns the square root of x.
  8138.  
  8139.  
  8140.  
  8141.         NOTE: sqrt returns zero when x is negative; errno is set to EDOM.
  8142.  
  8143.         EDOM is defined in math.h.
  8144.  
  8145.  
  8146.  
  8147.  
  8148.  
  8149.  
  8150.  
  8151.         7.9.67. srand()
  8152.  
  8153.  
  8154.  
  8155.                   int seed;
  8156.  
  8157.  
  8158.  
  8159.                   srand(seed);
  8160.  
  8161.  
  8162.  
  8163.         srand sets the seed for the multiplicative congruential random 
  8164.  
  8165.         number generator to seed .
  8166.  
  8167.  
  8168.  
  8169.  
  8170.  
  8171.  
  8172.  
  8173.  
  8174.  
  8175.  
  8176.  
  8177.  
  8178.  
  8179.  
  8180.  
  8181.  
  8182.  
  8183.  
  8184.  
  8185.         The PCCS.S Standard Library                       Page 57
  8186.  
  8187.  
  8188.  
  8189.  
  8190.  
  8191.         NOTE:  The initial seed for the generator is a long.  srand  only 
  8192.  
  8193.         sets the low order word, so the initial generator cannot be 
  8194.  
  8195.         restarted.  Solution: seed the generator with your own integer 
  8196.  
  8197.         before any calls to rand or frand .
  8198.  
  8199.  
  8200.  
  8201.  
  8202.  
  8203.         7.9.68. sscanf()
  8204.  
  8205.  
  8206.  
  8207.                   char fcs[], buf[];
  8208.  
  8209.  
  8210.  
  8211.                   num = sscanf(buf, fcs [, ptr ] ... );
  8212.  
  8213.  
  8214.  
  8215.         sscanf reads from the string buf.
  8216.  
  8217.  
  8218.  
  8219.         Returns the number of items successfully scanned.
  8220.  
  8221.  
  8222.  
  8223.         See scanf() for a how it works.
  8224.  
  8225.  
  8226.  
  8227.  
  8228.  
  8229.         7.9.69. strcat()
  8230.  
  8231.  
  8232.  
  8233.                   char *cp, *src, *dst;
  8234.  
  8235.  
  8236.  
  8237.                   cp = strcat(dst, src);
  8238.  
  8239.  
  8240.  
  8241.         strcat works on null-terminated strings.  There is no test for 
  8242.  
  8243.         overflow.
  8244.  
  8245.  
  8246.  
  8247.         strcat appends a copy of src to the end of dst.
  8248.  
  8249.  
  8250.  
  8251.         Returns dst .
  8252.  
  8253.  
  8254.  
  8255.  
  8256.  
  8257.         7.9.70. strcmp()
  8258.  
  8259.  
  8260.  
  8261.                   char *s1, *s2;
  8262.  
  8263.                   int cmp;
  8264.  
  8265.  
  8266.  
  8267.                   cmp = strcmp(s1, s2);
  8268.  
  8269.  
  8270.  
  8271.         strcmp works on null-terminated strings.  There is no test for 
  8272.  
  8273.         overflow.
  8274.  
  8275.  
  8276.  
  8277.         strcmp  compares the two strings and returns +1, 0, or -1 
  8278.  
  8279.         accordingly as s1 is lexically greater than, equal to, or less 
  8280.  
  8281.         than s2.
  8282.  
  8283.  
  8284.  
  8285.         7.9.71. strcpy()
  8286.  
  8287.  
  8288.  
  8289.                   char *cp, *src, *dst;
  8290.  
  8291.  
  8292.  
  8293.                   cp = strcpy(dst, src);
  8294.  
  8295.  
  8296.  
  8297.         strcpy works on null-terminated strings.  There is no test for 
  8298.  
  8299.         overflow.
  8300.  
  8301.  
  8302.  
  8303.  
  8304.  
  8305.  
  8306.  
  8307.  
  8308.  
  8309.  
  8310.  
  8311.  
  8312.  
  8313.  
  8314.  
  8315.  
  8316.  
  8317.         The PCCS.S Standard Library                       Page 58
  8318.  
  8319.  
  8320.  
  8321.  
  8322.  
  8323.         strcpy copies src to dst , stopping after the null byte has been 
  8324.  
  8325.         transfered.
  8326.  
  8327.           
  8328.  
  8329.         Returns dst .
  8330.  
  8331.  
  8332.  
  8333.  
  8334.  
  8335.         7.9.72. strlen()
  8336.  
  8337.  
  8338.  
  8339.                   char *src;
  8340.  
  8341.                   unsigned len;
  8342.  
  8343.  
  8344.  
  8345.                   len = strlen(src);
  8346.  
  8347.  
  8348.  
  8349.         strlen works on null-terminated strings.  There is no test for 
  8350.  
  8351.         overflow.
  8352.  
  8353.  
  8354.  
  8355.         strlen returns the number of non-null characters in src.
  8356.  
  8357.  
  8358.  
  8359.  
  8360.  
  8361.         7.9.73. strncat()
  8362.  
  8363.  
  8364.  
  8365.                   char *cp, *src, *dst;
  8366.  
  8367.                   unsigned max;
  8368.  
  8369.  
  8370.  
  8371.                   cp = strncat(dst, src, max);
  8372.  
  8373.  
  8374.  
  8375.         strncat works on null-terminated strings.  There is no test for 
  8376.  
  8377.         overflow.
  8378.  
  8379.  
  8380.  
  8381.         strncat appends, at most, max  bytes of src  to the end of dst.
  8382.  
  8383.           
  8384.  
  8385.         Returns dst .
  8386.  
  8387.  
  8388.  
  8389.  
  8390.  
  8391.         7.9.74. strncmp()
  8392.  
  8393.  
  8394.  
  8395.                   char *s1, *s2;
  8396.  
  8397.                   int cmp;
  8398.  
  8399.                   unsigned max;
  8400.  
  8401.  
  8402.  
  8403.                   cmp = strncmp(s1, s2, max);
  8404.  
  8405.  
  8406.  
  8407.         strncmp works on null-terminated strings.  There is no test for 
  8408.  
  8409.         overflow.
  8410.  
  8411.  
  8412.  
  8413.         strncmp compares, at most, max  bytes of the two strings and 
  8414.  
  8415.         returns +1, 0, or -1 accordingly as s1 is lexically greater than, 
  8416.  
  8417.         equal to, or less than s2.
  8418.  
  8419.  
  8420.  
  8421.  
  8422.  
  8423.  
  8424.  
  8425.  
  8426.  
  8427.  
  8428.  
  8429.  
  8430.  
  8431.  
  8432.  
  8433.  
  8434.  
  8435.  
  8436.  
  8437.  
  8438.  
  8439.  
  8440.  
  8441.  
  8442.  
  8443.  
  8444.  
  8445.  
  8446.  
  8447.  
  8448.  
  8449.         The PCCS.S Standard Library                       Page 59
  8450.  
  8451.  
  8452.  
  8453.  
  8454.  
  8455.         7.9.75. strncpy()
  8456.  
  8457.  
  8458.  
  8459.                   char *cp, *src, *dst;
  8460.  
  8461.                   unsigned len;
  8462.  
  8463.  
  8464.  
  8465.                   cp = strncpy(dst, src, len);
  8466.  
  8467.  
  8468.  
  8469.         strncpy works on null-terminated strings.  There is no test for 
  8470.  
  8471.         overflow.
  8472.  
  8473.  
  8474.  
  8475.         strncpy copies exactly len bytes, from src to dst truncating or 
  8476.  
  8477.         null-padding as required; dst may not be null-terminated if the 
  8478.  
  8479.         strlen(src) >= len.
  8480.  
  8481.  
  8482.  
  8483.         Returns dst .
  8484.  
  8485.  
  8486.  
  8487.  
  8488.  
  8489.         7.9.76. times()
  8490.  
  8491.  
  8492.  
  8493.                   char *buf;
  8494.  
  8495.  
  8496.  
  8497.                 times(buf);
  8498.  
  8499.  
  8500.  
  8501.         times formats the string buf with the current time as "hh-mm-ss"
  8502.  
  8503.  
  8504.  
  8505.  
  8506.  
  8507.         7.9.77. ungetc()
  8508.  
  8509.  
  8510.  
  8511.                   #include <stdio.h>
  8512.  
  8513.                   FILE *fp;
  8514.  
  8515.                   char ch;
  8516.  
  8517.                   int data;
  8518.  
  8519.  
  8520.  
  8521.                   data = ungetc(ch, fp)
  8522.  
  8523.  
  8524.  
  8525.         ungetc pushes the character ch  back onto the file fp.  The next 
  8526.  
  8527.         call to getc or fgetc will return ch.  ungetc returns ch, or -1 
  8528.  
  8529.         if it can't push the character back.  fseek  clears all pushed 
  8530.  
  8531.         characters.  EOF (-1) can't be pushed.
  8532.  
  8533.  
  8534.  
  8535.  
  8536.  
  8537.         7.9.78. unlink()
  8538.  
  8539.  
  8540.  
  8541.                   char *oldFile;
  8542.  
  8543.                   int stat;
  8544.  
  8545.  
  8546.  
  8547.                   stat = unlink(oldFile);
  8548.  
  8549.  
  8550.  
  8551.         unlink deletes the file oldFile.  Under DOS 2.X and higher, 
  8552.  
  8553.         oldFile may contain a path specification.  Returns -1 if oldFile  
  8554.  
  8555.         doesn't exist, is open, or if an error is detected.
  8556.  
  8557.  
  8558.  
  8559.  
  8560.  
  8561.  
  8562.  
  8563.  
  8564.  
  8565.  
  8566.  
  8567.  
  8568.  
  8569.  
  8570.  
  8571.  
  8572.  
  8573.  
  8574.  
  8575.  
  8576.  
  8577.  
  8578.  
  8579.  
  8580.  
  8581.         Messages                                            Page 60
  8582.  
  8583.  
  8584.  
  8585.  
  8586.  
  8587.         A. Messages
  8588.  
  8589.  
  8590.  
  8591.         A.1. PCC Compiler Messages
  8592.  
  8593.  
  8594.  
  8595.         A.1.1. Banner and Termination Messages
  8596.  
  8597.  
  8598.  
  8599.         >PCC V2.1c  Copyright Mark DeSmet 1989
  8600.  
  8601.         end of PCC    001A code    0012 data     1% utilization
  8602.  
  8603.  
  8604.  
  8605.         OR
  8606.  
  8607.  
  8608.  
  8609.         >PCC V2.1c  Copyright Mark DeSmet 1989
  8610.  
  8611.              (various error messages)
  8612.  
  8613.  
  8614.  
  8615.             Number of Warnings = 2     Number of Errors = 5
  8616.  
  8617.  
  8618.  
  8619.         The first form of termination means the compile was successful.  
  8620.  
  8621.         The 'code' number is in hex and tells how many bytes of code were 
  8622.  
  8623.         produced.  The 'data' number is similar and tells how many bytes 
  8624.  
  8625.         of data were produced.  The utilization percentage is the worst 
  8626.  
  8627.         case of a number of compiler limits.  If it nears 100% it usually 
  8628.  
  8629.         means that the largest procedure should be broken into smaller 
  8630.  
  8631.         procedures.
  8632.  
  8633.  
  8634.  
  8635.         The second form means the compile failed.  Error messages are 
  8636.  
  8637.         explained in the following section.  If any errors were detected, 
  8638.  
  8639.         the compiler will stop trying to generate code and will stop as 
  8640.  
  8641.         soon as all the source has been read.  This 'syntax check' mode 
  8642.  
  8643.         is fast and allows the programmer to correct the program with a 
  8644.  
  8645.         minimum of delay.  If only warnings were detected, but no errors, 
  8646.  
  8647.         compilation will end normally and produce a .O file.
  8648.  
  8649.  
  8650.  
  8651.  
  8652.  
  8653.         A.1.2. Messages
  8654.  
  8655.  
  8656.  
  8657.         PCC produces four categories of messages: fatal errors, errors, 
  8658.  
  8659.         warnings and errors detected by the assembler.  Fatal errors are 
  8660.  
  8661.         usually caused by I/O errors but compiler errors are also in this 
  8662.  
  8663.         category.  When a fatal error is detected, the compiler will 
  8664.  
  8665.         print a message and quit.  Errors are caused by syntax errors.  
  8666.  
  8667.         PCC reports all such errors and then quits.  Warnings are 
  8668.  
  8669.         produced by correctable errors and the compiler continues.  Since 
  8670.  
  8671.         the compiler uses PCCA as pass 3, assembler detected errors are 
  8672.  
  8673.         possible but rare.  When they occur, the object module will not 
  8674.  
  8675.         be usable.
  8676.  
  8677.  
  8678.  
  8679.         It is easy to tell the category of an error.  After a fatal 
  8680.  
  8681.         error, the compiler stops without printing a termination message. 
  8682.  
  8683.         Errors and warnings have a distinctive format which includes the  
  8684.  
  8685.         word 'error' or 'warning'.  Assembler errors print the assembler 
  8686.  
  8687.         line that was found offensive.
  8688.  
  8689.  
  8690.  
  8691.  
  8692.  
  8693.         A.1.2.1. PCC Fatal Errors
  8694.  
  8695.  
  8696.  
  8697.  
  8698.  
  8699.  
  8700.  
  8701.  
  8702.  
  8703.  
  8704.  
  8705.  
  8706.  
  8707.  
  8708.  
  8709.  
  8710.  
  8711.  
  8712.  
  8713.         Messages                                            Page 61
  8714.  
  8715.  
  8716.  
  8717.  
  8718.  
  8719.         The pass 2 fatal errors like 'bad expression' are compiler  
  8720.  
  8721.         errors, but the error is usually in not detecting the problem in 
  8722.  
  8723.         pass 1 and printing a reasonable message.  If you get one of 
  8724.  
  8725.         these errors, please send your program to C Ware, but you can  
  8726.  
  8727.         probably find and eliminate the statement that caused the 
  8728.  
  8729.         problem.  Don't be frightened by seeing these errors listed; you 
  8730.  
  8731.         will probably never see any of them.
  8732.  
  8733.  
  8734.  
  8735.         bad  expression - this indicates a compiler error.   Printed by 
  8736.  
  8737.                         pass 2.
  8738.  
  8739.  
  8740.  
  8741.  
  8742.  
  8743.         bad GOTO target - attempt to goto something other than a label.
  8744.  
  8745.  
  8746.  
  8747.         break/case/continue/default not in switch - a case or default 
  8748.  
  8749.                         statement must be within a switch. A break 
  8750.  
  8751.                         statement must be in a while or do..while or for 
  8752.  
  8753.                         or switch. A continue statement must be in a 
  8754.  
  8755.                         while or do..while or for statement.
  8756.  
  8757.  
  8758.  
  8759.         cannot address  - illegal use of '&' operator.  Printed in pass 
  8760.  
  8761.                         2.
  8762.  
  8763.  
  8764.  
  8765.         cannot close <file> - the file could not be closed.   An I/O 
  8766.  
  8767.                         error occurred.
  8768.  
  8769.  
  8770.  
  8771.         cannot create <file> - the named file could not be created.  The 
  8772.  
  8773.                         name is a temporary name or the name of the 
  8774.  
  8775.                         object or assembler file.  This message usually 
  8776.  
  8777.                         means the drive is full (see 'T' option).
  8778.  
  8779.  
  8780.  
  8781.         cannot open <file> - the named source or include file could not 
  8782.  
  8783.                         be found.
  8784.  
  8785.  
  8786.  
  8787.         cannot read <file> - the named file could not be read.  Usually 
  8788.  
  8789.                         means an I/O error was detected.
  8790.  
  8791.  
  8792.  
  8793.         cannot unlink <file> - the temporary could not be deleted.  An 
  8794.  
  8795.                         I/O error occurred.
  8796.  
  8797.  
  8798.  
  8799.         cannot write <file> - the named file could not be written. An I/O 
  8800.  
  8801.                         error was detected.  Usually means the disk drive 
  8802.  
  8803.                         is out of space.
  8804.  
  8805.  
  8806.  
  8807.         error in register allocation - compiler error in pass 2. 
  8808.  
  8809.  
  8810.  
  8811.         divide by zero  - a constant expression evaluated to a divide by 
  8812.  
  8813.                         zero.  Should never happen.
  8814.  
  8815.  
  8816.  
  8817.         function too big - a function is too big for the compiler.  The 
  8818.  
  8819.                         'Utilization' number reflects this limit so there 
  8820.  
  8821.                         is normally plenty of warning.  The solution is 
  8822.  
  8823.                         to break large procedures into smaller ones.
  8824.  
  8825.  
  8826.  
  8827.         illegal initialization for <name> - only constant expressions and 
  8828.  
  8829.  
  8830.  
  8831.  
  8832.  
  8833.  
  8834.  
  8835.  
  8836.  
  8837.  
  8838.  
  8839.  
  8840.  
  8841.  
  8842.  
  8843.  
  8844.  
  8845.         Messages                                            Page 62
  8846.  
  8847.  
  8848.  
  8849.  
  8850.  
  8851.                         addresses plus or minus constant expressions can 
  8852.  
  8853.                         be used in initialization and the initialization 
  8854.  
  8855.                         must make sense.   For example
  8856.  
  8857.  
  8858.  
  8859.                         int a=b+2;
  8860.  
  8861.  
  8862.  
  8863.                         this error is fatal because it is not discovered 
  8864.  
  8865.                         until pass 2.
  8866.  
  8867.  
  8868.  
  8869.         no cases        - a switch must have at least one case.
  8870.  
  8871.  
  8872.  
  8873.         no input file   - PCC must be followed by the name of the source 
  8874.  
  8875.                         file when invoked.
  8876.  
  8877.  
  8878.  
  8879.         out of memory   - the compiler ran out of symbol space.  The 
  8880.  
  8881.                         'utilization' numbers warn when a program is 
  8882.  
  8883.                         about to exceed this or any other compiler limit.  
  8884.  
  8885.                         The compiler can use up to 100K, so adding memory 
  8886.  
  8887.                         may be a solution.  If not, the only remedy is 
  8888.  
  8889.                         the painful surgery required to reduce the total 
  8890.  
  8891.                         number of externals and locals defined at one 
  8892.  
  8893.                         time.
  8894.  
  8895.                         
  8896.  
  8897.         pushed          - compiler error in pass 2 code generation. It 
  8898.  
  8899.                         can be eliminated by simplifying the expression.
  8900.  
  8901.  
  8902.  
  8903.         too many cases  - currently, a switch statement can only contain 
  8904.  
  8905.                         128 case statements.
  8906.  
  8907.  
  8908.  
  8909.  
  8910.  
  8911.         too many fors/too many whiles - whiles, do-whiles, switches and 
  8912.  
  8913.                         for statements can only be nested 10 deep.
  8914.  
  8915.  
  8916.  
  8917.         stuck <register> - same as 'pushed'.
  8918.  
  8919.  
  8920.  
  8921.         too many externals - the compiler currently has a limit of 500 
  8922.  
  8923.                         static's or extern's.
  8924.  
  8925.  
  8926.  
  8927.  
  8928.  
  8929.         A.1.2.2. PCC Errors
  8930.  
  8931.  
  8932.  
  8933.         Errors are printed with the following format:
  8934.  
  8935.  
  8936.  
  8937.             23 if (i < 99 $$ {
  8938.  
  8939.                error:Need ()
  8940.  
  8941.  
  8942.  
  8943.         Or, if the error was detected in an include file:
  8944.  
  8945.  
  8946.  
  8947.             23 if (i < 99 $$ {
  8948.  
  8949.                file:<include file> error:Need ()
  8950.  
  8951.  
  8952.  
  8953.         The number preceding the source line is the line number.  To find 
  8954.  
  8955.         the line , edit the file and issue the command 'nnnJ' where nnn 
  8956.  
  8957.         is the number of the reported line.
  8958.  
  8959.  
  8960.  
  8961.  
  8962.  
  8963.  
  8964.  
  8965.  
  8966.  
  8967.  
  8968.  
  8969.  
  8970.  
  8971.  
  8972.  
  8973.  
  8974.  
  8975.  
  8976.  
  8977.         Messages                                            Page 63
  8978.  
  8979.  
  8980.  
  8981.  
  8982.  
  8983.         The '$$' shows how far into the line the compiler was before the 
  8984.  
  8985.         error was detected.  For example, the '$$' will print immediately 
  8986.  
  8987.         BEFORE an undefined variable.
  8988.  
  8989.  
  8990.  
  8991.         If you get a lot of errors on a compile, don't panic. A trivial 
  8992.  
  8993.         error probably caused the compiler to become confused.  Correct 
  8994.  
  8995.         the first few errors and re-compile.
  8996.  
  8997.  
  8998.  
  8999.         bad control     - the # control is illegal.
  9000.  
  9001.  
  9002.  
  9003.         bad declaration - the declaration of a variable was illegal.
  9004.  
  9005.  
  9006.  
  9007.         bad include     - the #include must be followed by "name" or 
  9008.  
  9009.                         <name>.
  9010.  
  9011.  
  9012.  
  9013.  
  9014.  
  9015.         bad label       - a colon is not preceded by a label name.
  9016.  
  9017.  
  9018.  
  9019.         bad member declare - the declaration of a member is illegal.
  9020.  
  9021.  
  9022.  
  9023.         bad member storage - an attempt was made to declare a member 
  9024.  
  9025.                         static or external.   Members have the storage 
  9026.  
  9027.                         type of their struct or union.
  9028.  
  9029.  
  9030.  
  9031.         bad parameter declare - an illegal declaration of an argument or 
  9032.  
  9033.                         the name of the argument was spelled differently 
  9034.  
  9035.                         in the procedure heading  and in the declaration.
  9036.  
  9037.  
  9038.  
  9039.         bad statement   - illegal statement.
  9040.  
  9041.  
  9042.  
  9043.         defines too deep - #define may reference another, but there is a 
  9044.  
  9045.                         limit. When #defines are expanded, the number of 
  9046.  
  9047.                         active #defines plus the number of #define 
  9048.  
  9049.                         arguments referenced by each cannot exceed 30.
  9050.  
  9051.  
  9052.  
  9053.         duplicate argument - an attempt was made to declare an argument 
  9054.  
  9055.                         twice.
  9056.  
  9057.  
  9058.  
  9059.         duplicate label - two labels have the same name.
  9060.  
  9061.  
  9062.  
  9063.         EOF within comment - end of file was found inside a comment. A 
  9064.  
  9065.                         '*/' is missing.
  9066.  
  9067.  
  9068.  
  9069.         field needs constant - the size of a bit field must be a constant 
  9070.  
  9071.                         expression with a value of 1 to 16.
  9072.  
  9073.  
  9074.  
  9075.         illegal address - attempt to use the '&' (take address of) 
  9076.  
  9077.                         operator on something that is not a lvalue.  
  9078.  
  9079.                         '&44' will generate this error.  An address can 
  9080.  
  9081.                         only be taken of a variable, procedure, string or 
  9082.  
  9083.                         label.
  9084.  
  9085.  
  9086.  
  9087.  
  9088.  
  9089.         illegal define  - a #define has unmatched parenthesis or the 
  9090.  
  9091.                         #define parameters are illegally specified.
  9092.  
  9093.  
  9094.  
  9095.  
  9096.  
  9097.  
  9098.  
  9099.  
  9100.  
  9101.  
  9102.  
  9103.  
  9104.  
  9105.  
  9106.  
  9107.  
  9108.  
  9109.         Messages                                            Page 64
  9110.  
  9111.  
  9112.  
  9113.  
  9114.  
  9115.  
  9116.  
  9117.         illegal external declaration - caused both by an illegal data or 
  9118.  
  9119.                         procedure declaration and improperly nested 
  9120.  
  9121.                         braces.  If the line is supposed to be part of a 
  9122.  
  9123.                         procedure (e.g. i=0;), the latter is the case.  
  9124.  
  9125.                         Check that every '{' outside of a comment or 
  9126.  
  9127.                         quoted string has a matching '}'.  Note: a prior 
  9128.  
  9129.                         error may have caused the compiler to lose track 
  9130.  
  9131.                         of a '{'.
  9132.  
  9133.  
  9134.  
  9135.         illegal indirection - caused by trying to use a char, int, 
  9136.  
  9137.                         unsigned, float or double as a pointer.  longs 
  9138.  
  9139.                         can be used as pointers but the other types 
  9140.  
  9141.                         cannot.
  9142.  
  9143.  
  9144.  
  9145.         include nesting too deep - includes can only be nested three deep
  9146.  
  9147.  
  9148.  
  9149.         illegal use of float - floating point numbers cannot be used as 
  9150.  
  9151.                         pointers.
  9152.  
  9153.  
  9154.  
  9155.         line must be constant - a #line control must be followed by a 
  9156.  
  9157.                         decimal constant.
  9158.  
  9159.  
  9160.  
  9161.         line too long   - the maximum line length is 128.
  9162.  
  9163.  
  9164.  
  9165.         missing ";", "(", ")", "[", "]", "{", "}", ":", "|" - the 
  9166.  
  9167.                         indicated "" character is needed at this point. A 
  9168.  
  9169.                         multitude of errors can cause these messages.  
  9170.  
  9171.                         The error might be fixed by sticking in the 
  9172.  
  9173.                         indicated character where the '$$' prints, but 
  9174.  
  9175.                         the item following the '$$' could be illegal.
  9176.  
  9177.  
  9178.  
  9179.         missing '       - a character constant (e.g. 'A','TEXT') can only 
  9180.  
  9181.                         contain one to four characters.
  9182.  
  9183.  
  9184.  
  9185.         missing argument - the argument list of a call had two adjacent 
  9186.  
  9187.                         commas.
  9188.  
  9189.  
  9190.  
  9191.         missing arguments - a #define was defined with arguments but used 
  9192.  
  9193.                         without arguments.
  9194.  
  9195.  
  9196.  
  9197.         missing dimension - an array dimension was missing in an 
  9198.  
  9199.                         expression or statement.  Either int x[][]; or 
  9200.  
  9201.                         x[]=1;.
  9202.  
  9203.  
  9204.  
  9205.         missing end of #asm - an #asm block was not ended with a #.
  9206.  
  9207.  
  9208.  
  9209.         missing expression - an expression is needed here. An example of 
  9210.  
  9211.                         a missing expression is i=;.
  9212.  
  9213.  
  9214.  
  9215.         missing operand - an operator without an operand was found.  An 
  9216.  
  9217.                         example of a missing operand is ++;
  9218.  
  9219.  
  9220.  
  9221.         missing while   - a 'do ... while' is missing the ending 'while'.
  9222.  
  9223.  
  9224.  
  9225.  
  9226.  
  9227.  
  9228.  
  9229.  
  9230.  
  9231.  
  9232.  
  9233.  
  9234.  
  9235.  
  9236.  
  9237.  
  9238.  
  9239.  
  9240.  
  9241.         Messages                                            Page 65
  9242.  
  9243.  
  9244.  
  9245.  
  9246.  
  9247.         must return float - a float or double function must end with a 
  9248.  
  9249.                         return statement that returns a value.
  9250.  
  9251.  
  9252.  
  9253.                         Note:  The compiler is too stupid to accept.
  9254.  
  9255.                 
  9256.  
  9257.                         double x(){if (1) return 1.;}.
  9258.  
  9259.  
  9260.  
  9261.         need ()         - the expression following an 'if' or 'switch' or 
  9262.  
  9263.                         'while' was not surrounded by parenthesis.
  9264.  
  9265.  
  9266.  
  9267.         need '{' for STRUCT initialization - the initial values used to 
  9268.  
  9269.                         initialize a structure must be surrounded by 
  9270.  
  9271.                         braces.
  9272.  
  9273.  
  9274.  
  9275.         need constant   - a 'case' prefix must be followed by an integer 
  9276.  
  9277.                         constant expression.
  9278.  
  9279.  
  9280.  
  9281.         need constant after #if - a #if control must be followed by a 
  9282.  
  9283.                         constant expression.
  9284.  
  9285.  
  9286.  
  9287.         need label      - a goto must reference a label.
  9288.  
  9289.  
  9290.  
  9291.         need lval       - a lvalue is needed here. An lvalue is, roughly, 
  9292.  
  9293.                         something that can be changed with an assignment.  
  9294.  
  9295.                         The statement: 2=4; will produce this error.
  9296.  
  9297.  
  9298.  
  9299.         need member     - the '.' or '->' operators were followed by 
  9300.  
  9301.                         something other than a member name.
  9302.  
  9303.  
  9304.  
  9305.         need structure  - the name prior to a '.' operator is not the 
  9306.  
  9307.                         name of a struct or union.
  9308.  
  9309.  
  9310.  
  9311.         not an identifier - #ifdef, #ifndef and #undef controls must 
  9312.  
  9313.                         reference a #define value;.
  9314.  
  9315.  
  9316.  
  9317.         not defined     - #undef controls must reference a #define 
  9318.  
  9319.                         value;.
  9320.  
  9321.  
  9322.  
  9323.         only STATIC and EXTERN allowed at this level - an attempt was 
  9324.  
  9325.                         made to declare an 'auto' outside of a procedure.
  9326.  
  9327.  
  9328.  
  9329.         parameters cannot span lines - the arguments to a #define must 
  9330.  
  9331.                         all be on the same line.
  9332.  
  9333.  
  9334.  
  9335.         return lacks argument - if a function is declared as returning a 
  9336.  
  9337.                         value then "return;" is illegal.  Use "return 0;" 
  9338.  
  9339.                         if the value is unimportant.
  9340.  
  9341.  
  9342.  
  9343.         sorry, must have dimension for locals - the compiler does not 
  9344.  
  9345.                         accept char a[]={1,2,3}; and similar  for auto 
  9346.  
  9347.                         variables.  Declare the variable static or 
  9348.  
  9349.                         include an explicit dimension.
  9350.  
  9351.  
  9352.  
  9353.         sorry, no string initialization of AUTO - the compiler cannot 
  9354.  
  9355.                         accept char a[]="abc"; and similar for auto 
  9356.  
  9357.  
  9358.  
  9359.  
  9360.  
  9361.  
  9362.  
  9363.  
  9364.  
  9365.  
  9366.  
  9367.  
  9368.  
  9369.  
  9370.  
  9371.  
  9372.  
  9373.         Messages                                            Page 66
  9374.  
  9375.  
  9376.  
  9377.  
  9378.  
  9379.                         variables.  Declare the variable static if 
  9380.  
  9381.                         possible, otherwise use _move.
  9382.  
  9383.  
  9384.  
  9385.         string too long - a string cannot exceed 200 characters.  Usually 
  9386.  
  9387.                         means that a '"' is missing.
  9388.  
  9389.  
  9390.  
  9391.         undefined structure - a  pointer to an undefined structure cannot 
  9392.  
  9393.                         be added to.
  9394.  
  9395.  
  9396.  
  9397.         unknown control - the word following a '#' is not a control word.  
  9398.  
  9399.                         '#while' would cause this error.
  9400.  
  9401.  
  9402.  
  9403.         unmatched "     - either the end of line or end of file was found 
  9404.  
  9405.                         in a string.  Usually means that a " is missing. 
  9406.  
  9407.                         if your string is too long for one line, continue 
  9408.  
  9409.                         with a \ (backslash) at the end of a line and 
  9410.  
  9411.                         continue in column one of the next.  If you want 
  9412.  
  9413.                         a new line in a string, use \n.
  9414.  
  9415.  
  9416.  
  9417.         wrong number of arguments - a #define was used with the wrong 
  9418.  
  9419.                         number of arguments.
  9420.  
  9421.  
  9422.  
  9423.  
  9424.  
  9425.         A.1.2.3. PCC Warnings
  9426.  
  9427.  
  9428.  
  9429.         There are currently only two warnings. Warnings indicate 
  9430.  
  9431.         suspicious code that is probably OK.
  9432.  
  9433.  
  9434.  
  9435.         conflicting types - an external or static was declared twice with 
  9436.  
  9437.                         different types.  Usually caused by an include 
  9438.  
  9439.                         file declaring a variable incorrectly or by a 
  9440.  
  9441.                         program such as:
  9442.  
  9443.  
  9444.  
  9445.                         main() {
  9446.  
  9447.                                 char ch;
  9448.  
  9449.          
  9450.  
  9451.                                 ch=zipit();
  9452.  
  9453.                                 }
  9454.  
  9455.          
  9456.  
  9457.                         char zipit(ch)
  9458.  
  9459.                         char ch; {
  9460.  
  9461.  
  9462.  
  9463.                                 return ch;
  9464.  
  9465.                                 }
  9466.  
  9467.  
  9468.  
  9469.                         the call of zipit implicitly declares it to be a 
  9470.  
  9471.                         function  returning an integer.  The line 'char 
  9472.  
  9473.                         zipit(ch)' would be flagged as an error.  The fix 
  9474.  
  9475.                         is to include:
  9476.  
  9477.  
  9478.  
  9479.                         char zipit();
  9480.  
  9481.  
  9482.  
  9483.                         above the call so the function is declared 
  9484.  
  9485.                         correctly before use.
  9486.  
  9487.  
  9488.  
  9489.  
  9490.  
  9491.  
  9492.  
  9493.  
  9494.  
  9495.  
  9496.  
  9497.  
  9498.  
  9499.  
  9500.  
  9501.  
  9502.  
  9503.  
  9504.  
  9505.         Messages                                            Page 67
  9506.  
  9507.  
  9508.  
  9509.  
  9510.  
  9511.         undefined variable - the variable has not been defined.  It is 
  9512.  
  9513.                         assumed to be an auto int.
  9514.  
  9515.  
  9516.  
  9517.  
  9518.  
  9519.  
  9520.  
  9521.         A.1.2.4. PCCA Errors ( from PCC Execution )
  9522.  
  9523.  
  9524.  
  9525.         In theory, any PCCA error message can be produced by a PCC 
  9526.  
  9527.         compile gone bonkers but I have only seen the 'cannot write 
  9528.  
  9529.         <name>' errors caused by lack of disk space.
  9530.  
  9531.  
  9532.  
  9533.  
  9534.  
  9535.  
  9536.  
  9537.  
  9538.  
  9539.         A.2. PCCA Assembler Messages
  9540.  
  9541.  
  9542.  
  9543.         A.2.1. Banner and Termination Messages
  9544.  
  9545.  
  9546.  
  9547.         >PCCA 8088 Assembler V1.3 (c) Mark DeSmet, 1982,83,84,85
  9548.  
  9549.  
  9550.  
  9551.             (various error messages)
  9552.  
  9553.  
  9554.  
  9555.         end of PCCA  0016 code  0000 data  1% utilization
  9556.  
  9557.  
  9558.  
  9559.         The 'code' number is in hex and tells how many bytes of code were 
  9560.  
  9561.         produced.  The 'data' number is similar and tells how many bytes 
  9562.  
  9563.         of data were produced.  The utilization percentage shows how full 
  9564.  
  9565.         the symbol table was.
  9566.  
  9567.  
  9568.  
  9569.         Sample of list output:
  9570.  
  9571.  
  9572.  
  9573.         PCCA Assembler    BLIP.A
  9574.  
  9575.                          1      ;TOUPPER.A convert a charcter to upper case
  9576.  
  9577.                          2
  9578.  
  9579.                          3      CSEG
  9580.  
  9581.                          4      PUBLIC TOUPPER
  9582.  
  9583.                          5
  9584.  
  9585.                          6      ;  character = toupper(character)
  9586.  
  9587.                          7
  9588.  
  9589.         0000 5A          8      TOUPPER:POP     DX      ;RETURN ADDRESS
  9590.  
  9591.         0001 58          9            POP       AX      ;CHARACTER
  9592.  
  9593.         0002 3C61       10            CMP       AL,'a'  ;IF LOWER THAN 'a'
  9594.  
  9595.                         11            JC        TO_DONE ;DO NOTHING
  9596.  
  9597.         0004 3C7B       12            CMP       AL,'z'  ;OR IF ABOVE 'z'
  9598.  
  9599.                         13            JNC       TO_DONE ;DO NOTHING
  9600.  
  9601.         0006 2C20       14            SUB       AL,'a'-'A' ;ELSE ADJUST
  9602.  
  9603.         0008 B400       15      TO_DONE:MOV     AH,0    ;RETURN AN INT
  9604.  
  9605.         000A FFE2       16            JMP       DX      ;RETURN
  9606.  
  9607.  
  9608.  
  9609.  
  9610.  
  9611.  
  9612.  
  9613.         A.2.2. Messages Produced by PCCA
  9614.  
  9615.  
  9616.  
  9617.         PCCA prints two categories of messages: fatal errors and errors.  
  9618.  
  9619.         As with PCC, the fatal errors are caused by I/O errors or 
  9620.  
  9621.  
  9622.  
  9623.  
  9624.  
  9625.  
  9626.  
  9627.  
  9628.  
  9629.  
  9630.  
  9631.  
  9632.  
  9633.  
  9634.  
  9635.  
  9636.  
  9637.         Messages                                            Page 68
  9638.  
  9639.  
  9640.  
  9641.  
  9642.  
  9643.         similar.  Errors are simply syntax errors in using the language.   
  9644.  
  9645.         When a fatal error is detected, PCCA prints a message and stops.  
  9646.  
  9647.         An error does not stop the assembler, but it stops writing the 
  9648.  
  9649.         object module to run faster.  If errors are detected, the object 
  9650.  
  9651.         module is never good.
  9652.  
  9653.  
  9654.  
  9655.  
  9656.  
  9657.         A.2.2.1. Fatal Errors From PCCA
  9658.  
  9659.  
  9660.  
  9661.         cannot close <file> - the file could not be closed. An I/O error 
  9662.  
  9663.                         occurred.
  9664.  
  9665.  
  9666.  
  9667.         cannot create <file> - the named file could not be created. The 
  9668.  
  9669.                         name is a temporary name or the name of the 
  9670.  
  9671.                         object or list file.  This message usually means 
  9672.  
  9673.                         the drive is full (see 'T' option).
  9674.  
  9675.  
  9676.  
  9677.         cannot open <file> - the named source or include file could not 
  9678.  
  9679.                         be found.
  9680.  
  9681.  
  9682.  
  9683.         cannot read <file> - the named file could not be read. Usually 
  9684.  
  9685.                         means an I/O error was detected.
  9686.  
  9687.  
  9688.  
  9689.         cannot unlink <file> - the temporary file could not be deleted. 
  9690.  
  9691.                         An I/O error occurred.
  9692.  
  9693.  
  9694.  
  9695.         cannot write <file> - the named file could not be written. An I/O 
  9696.  
  9697.                         error was detected.  Usually means the disk drive 
  9698.  
  9699.                         is out of space.
  9700.  
  9701.  
  9702.  
  9703.         internal error in jump optimization - the assembler became 
  9704.  
  9705.                         confused optimizing branches.
  9706.  
  9707.  
  9708.  
  9709.         no input file   - no filename followed the PCCA when invoked.
  9710.  
  9711.  
  9712.  
  9713.         too  many labels - only 1000 names and labels are allowed.
  9714.  
  9715.  
  9716.  
  9717.         too many symbols - the assembler ran out of symbol space.  The 
  9718.  
  9719.                         source program should be broken into smaller 
  9720.  
  9721.                         modules.
  9722.  
  9723.  
  9724.  
  9725.  
  9726.  
  9727.  
  9728.  
  9729.         A.2.2.2. Errors from PCCA
  9730.  
  9731.  
  9732.  
  9733.         Error messages have the form:
  9734.  
  9735.  
  9736.  
  9737.             44  mov  #44,a3
  9738.  
  9739.             error: illegal mnemonic
  9740.  
  9741.  
  9742.  
  9743.         or, if the error was found in an include file:
  9744.  
  9745.  
  9746.  
  9747.             44  mov  #44,a3
  9748.  
  9749.             file:2:SCREEN.A  error: illegal mnemonic
  9750.  
  9751.  
  9752.  
  9753.  
  9754.  
  9755.  
  9756.  
  9757.  
  9758.  
  9759.  
  9760.  
  9761.  
  9762.  
  9763.  
  9764.  
  9765.  
  9766.  
  9767.  
  9768.  
  9769.         Messages                                            Page 69
  9770.  
  9771.  
  9772.  
  9773.  
  9774.  
  9775.         The messages are:
  9776.  
  9777.  
  9778.  
  9779.  
  9780.  
  9781.         address must be in DSEG - address constants  can only be in DSEG, 
  9782.  
  9783.                         because constants in CSEG are not fixed up at run 
  9784.  
  9785.                         time.
  9786.  
  9787.  
  9788.  
  9789.         bad DS value    - a constant expression must follow the DS.
  9790.  
  9791.  
  9792.  
  9793.         bad include     - the correct form for an include statement is:
  9794.  
  9795.  
  9796.  
  9797.                         include "filename"
  9798.  
  9799.  
  9800.  
  9801.         bad LINE value  - the line statement should be followed by a 
  9802.  
  9803.                         constant.
  9804.  
  9805.  
  9806.  
  9807.         cannot label PUBLIC - a 'public' statement cannot have a label.
  9808.  
  9809.  
  9810.  
  9811.         data offset must be an unsigned - an attempt was made to use an 
  9812.  
  9813.                         offset in a byte or long constant.  
  9814.  
  9815.  
  9816.  
  9817.         DS must have label - storage cannot be reserved without a name.
  9818.  
  9819.  
  9820.  
  9821.         DS must be in DSEG - storage can only be reserved in DSEG.
  9822.  
  9823.  
  9824.  
  9825.         duplicate label - the label on the line was defined previously.
  9826.  
  9827.  
  9828.  
  9829.         equate too deep - an 'equ' may reference a prior one, but only to 
  9830.  
  9831.                         a depth of four.
  9832.  
  9833.  
  9834.  
  9835.         illegal expression - the expression had an illegal operator or is 
  9836.  
  9837.                         somehow invalid.
  9838.  
  9839.  
  9840.  
  9841.         illegal operand - an operand had a type that was not legal in 
  9842.  
  9843.                         that context.
  9844.  
  9845.  
  9846.  
  9847.         illegal reserved word - a reserved word was found in the wrong 
  9848.  
  9849.                         context.
  9850.  
  9851.  
  9852.  
  9853.         illegal ST value - the index to a floating point stack element 
  9854.  
  9855.                         must be in the range 0 to 7.
  9856.  
  9857.  
  9858.  
  9859.         incorrect type  - only 'byte', 'word', 'dword', and 'tbyte', are 
  9860.  
  9861.                         allowed following the colon to type a public.
  9862.  
  9863.  
  9864.  
  9865.         impossible arithmetic - an arithmetic operation has operands 
  9866.  
  9867.                         incompatible with the 8086 architecture.
  9868.  
  9869.  
  9870.  
  9871.                         example:
  9872.  
  9873.  
  9874.  
  9875.                         add word [bx], word[si]
  9876.  
  9877.  
  9878.  
  9879.         in wrong segment - a variable or label is being defined in a 
  9880.  
  9881.                         segment different than the segment of the 
  9882.  
  9883.                         'public' statement.  Remember that 'public' 
  9884.  
  9885.  
  9886.  
  9887.  
  9888.  
  9889.  
  9890.  
  9891.  
  9892.  
  9893.  
  9894.  
  9895.  
  9896.  
  9897.  
  9898.  
  9899.  
  9900.  
  9901.         Messages                                            Page 70
  9902.  
  9903.  
  9904.  
  9905.  
  9906.  
  9907.                         statements must be in the correct segment, 
  9908.  
  9909.                         following 'dseg' or 'cseg' as appropriate.
  9910.  
  9911.  
  9912.  
  9913.         invalid BYTE constant - a byte constant was needed, but something 
  9914.  
  9915.                         else was found.
  9916.  
  9917.  
  9918.  
  9919.         invalid constant - the instruction needed a constant and 
  9920.  
  9921.                         something else was found.
  9922.  
  9923.  
  9924.  
  9925.         invalid DD constant - the value of a 'DD' must be a constant 
  9926.  
  9927.                         expression.
  9928.  
  9929.  
  9930.  
  9931.         invalid DW constant - the value of a 'DW' must be a constant 
  9932.  
  9933.                         expression or a variable name.  In the latter 
  9934.  
  9935.                         case, offset is assumed.  The statement:
  9936.  
  9937.  
  9938.  
  9939.                         dw   offset  zip
  9940.  
  9941.  
  9942.  
  9943.                         is illegal since offset is already implied.  Just 
  9944.  
  9945.                         use:
  9946.  
  9947.  
  9948.  
  9949.                         dw   zip
  9950.  
  9951.  
  9952.  
  9953.         invalid offset  - an offset of the expression cannot be taken.
  9954.  
  9955.  
  9956.  
  9957.         line too long   - the maximum input line to PCCA is 110 
  9958.  
  9959.                         characters.
  9960.  
  9961.  
  9962.  
  9963.         mismatched types - the types of the two operands must agree.
  9964.  
  9965.  
  9966.  
  9967.                         example:
  9968.  
  9969.  
  9970.  
  9971.                         db      chr
  9972.  
  9973.                         add     ax,bl           ;illegal
  9974.  
  9975.                         add     chr,ax          ;illegal
  9976.  
  9977.                         add     word chr,ax     ;legal
  9978.  
  9979.  
  9980.  
  9981.  
  9982.  
  9983.         misplaced reserved word - a reserved word was found in an 
  9984.  
  9985.                         expression.
  9986.  
  9987.  
  9988.  
  9989.         missing :       - the '?' operator was missing the colon part.
  9990.  
  9991.  
  9992.  
  9993.         missing )       - mismatched parenthesis.
  9994.  
  9995.  
  9996.  
  9997.         missing ]       - mismatched braces in an address expression.
  9998.  
  9999.  
  10000.  
  10001.         missing ':'     - labels to instructions must be followed by a 
  10002.  
  10003.                         colon.  This message also prints when a mnemonic 
  10004.  
  10005.                         is misspelled.  The assembler thinks that the bad 
  10006.  
  10007.                         mnemonic is a label without a colon.
  10008.  
  10009.  
  10010.  
  10011.         missing EQU name - an equate statement lacks a name.
  10012.  
  10013.  
  10014.  
  10015.         missing type    - the memory reference needs a type.  In the case 
  10016.  
  10017.  
  10018.  
  10019.  
  10020.  
  10021.  
  10022.  
  10023.  
  10024.  
  10025.  
  10026.  
  10027.  
  10028.  
  10029.  
  10030.  
  10031.  
  10032.  
  10033.         Messages                                            Page 71
  10034.  
  10035.  
  10036.  
  10037.  
  10038.  
  10039.                         of 'public's defined elsewhere, the type can be 
  10040.  
  10041.                         supplied by ':byte' or ':word' on the public 
  10042.  
  10043.                         statement.  In the case of anonymous references, 
  10044.  
  10045.                         the 'byte' or 'word' keyword must be used.
  10046.  
  10047.  
  10048.  
  10049.                         example:
  10050.  
  10051.  
  10052.  
  10053.                         public  a:byte
  10054.  
  10055.                         inc     a               ; illegal
  10056.  
  10057.                         inc     byte a          ; legal
  10058.  
  10059.                         inc     es:[bx]         ; illegal
  10060.  
  10061.                         inc     es:word[bx]     ; legal
  10062.  
  10063.  
  10064.  
  10065.         need constant   - something other than a constant expression 
  10066.  
  10067.                         followed a 'ret'.
  10068.  
  10069.  
  10070.  
  10071.         need label      - a jump relative was made to something other 
  10072.  
  10073.                         than a label.  'jmp's may be indirect but 'jz's 
  10074.  
  10075.                         etc. can only jump to a label.
  10076.  
  10077.  
  10078.  
  10079.         nested include  - an included file may not include another.
  10080.  
  10081.  
  10082.  
  10083.         not a label     - only names can be public.
  10084.  
  10085.  
  10086.  
  10087.         RB must have label - a 'RB' statement must have a label.
  10088.  
  10089.  
  10090.  
  10091.         RB must be in DS - 'RB's must follow a DSEG directive as they can 
  10092.  
  10093.                         only be in the data segment.  'DB's can be in the 
  10094.  
  10095.                         code segment.
  10096.  
  10097.  
  10098.  
  10099.         RW must be in DS - as above.
  10100.  
  10101.  
  10102.  
  10103.         too many arguments - the instruction had more operands than 
  10104.  
  10105.                         allowed or the last operand contains an illegal 
  10106.  
  10107.                         op-code.
  10108.  
  10109.  
  10110.  
  10111.         undefined variable <name> - the name is referred to but not 
  10112.  
  10113.                         defined or listed as public.
  10114.  
  10115.  
  10116.  
  10117.         unknown mnemonic - the mnemonic is illegal.
  10118.  
  10119.  
  10120.  
  10121.  
  10122.  
  10123.  
  10124.  
  10125.         A.3. PCCL Messages
  10126.  
  10127.  
  10128.  
  10129.  
  10130.  
  10131.         A.3.1. Banner and Termination Messages
  10132.  
  10133.  
  10134.  
  10135.         PCCL Linker PCC and PCCA   V1.2b  Copyright Mark DeSmet 1988
  10136.  
  10137.         end of PCCL        9% utilization
  10138.  
  10139.  
  10140.  
  10141.  
  10142.  
  10143.         A.3.2. Warnings from PCCL
  10144.  
  10145.  
  10146.  
  10147.         undefined PUBLIC - <name> - the name is referenced, but not 
  10148.  
  10149.  
  10150.  
  10151.  
  10152.  
  10153.  
  10154.  
  10155.  
  10156.  
  10157.  
  10158.  
  10159.  
  10160.  
  10161.  
  10162.  
  10163.  
  10164.  
  10165.         Messages                                            Page 72
  10166.  
  10167.  
  10168.  
  10169.  
  10170.  
  10171.                         defined in any module.  PCCL will complete and 
  10172.  
  10173.                         the resulting .EXE module may execute as long as 
  10174.  
  10175.                         the undefined PUBLICs are not referenced.  If 
  10176.  
  10177.                         they are referenced, then the result is 
  10178.  
  10179.                         undefined.
  10180.  
  10181.  
  10182.  
  10183.  
  10184.  
  10185.         A.3.3. Fatal Errors from PCCL 
  10186.  
  10187.  
  10188.  
  10189.         PCCL prints the message, prints 'PCCL abandoned' and quits.
  10190.  
  10191.  
  10192.  
  10193.         bad argument    - an argument is illegal.
  10194.  
  10195.  
  10196.  
  10197.         bad object file<name> - the object or library file contains an 
  10198.  
  10199.                         illegal record.
  10200.  
  10201.  
  10202.  
  10203.         bad stack option - the 'S' option should be followed by one to 
  10204.  
  10205.                         four hex digits.
  10206.  
  10207.  
  10208.  
  10209.         cannot close <file> - I/O error occurred.
  10210.  
  10211.  
  10212.  
  10213.         cannot create <file> - I/O error or disk out of room.  On MS-DOS 
  10214.  
  10215.                         2.0 and later, make sure that the CONFIG.SYS file 
  10216.  
  10217.                         contains a FILES=20 command.
  10218.  
  10219.  
  10220.  
  10221.         cannot open <file> - the object file could not be found.  On MS-
  10222.  
  10223.                         DOS 2.0 and later, make sure that the CONFIG.SYS 
  10224.  
  10225.                         file contains a FILES=20 command.
  10226.  
  10227.  
  10228.  
  10229.         cannot read <file> - I/O error occurred.
  10230.  
  10231.  
  10232.  
  10233.         cannot seek <file> - I/O error occurred.
  10234.  
  10235.  
  10236.  
  10237.         cannot write <file> - I/O error or disk out of room.
  10238.  
  10239.  
  10240.  
  10241.         different segments for - <name> - the public is declared in 
  10242.  
  10243.                         different segments in different modules.  
  10244.  
  10245.                         Probably both as a function and as a variable.
  10246.  
  10247.  
  10248.  
  10249.         illegal overlay number - in the overlay options -Vnn and -Mnn, 
  10250.  
  10251.                         the value nn must be between 1 and 39 in 
  10252.  
  10253.                         ascending, consecutive order.
  10254.  
  10255.  
  10256.  
  10257.         multiply defined <name> - the same public appears in two modules.
  10258.  
  10259.  
  10260.  
  10261.         over 100 arguments - PCCL only allows 100 arguments, including 
  10262.  
  10263.                         arguments in -F files. 
  10264.  
  10265.  
  10266.  
  10267.         over 64K code   - a segment has over 64K of code. See the 
  10268.  
  10269.                         description of PCCL overlay support.
  10270.  
  10271.  
  10272.  
  10273.         over 64K data   - the resultant program has over 64K of data. 
  10274.  
  10275.                         This is not supported.  You will have to move 
  10276.  
  10277.                         some data to locals or use overlays.
  10278.  
  10279.  
  10280.  
  10281.  
  10282.  
  10283.  
  10284.  
  10285.  
  10286.  
  10287.  
  10288.  
  10289.  
  10290.  
  10291.  
  10292.  
  10293.  
  10294.  
  10295.  
  10296.  
  10297.         Messages                                            Page 73
  10298.  
  10299.  
  10300.  
  10301.  
  10302.  
  10303.         over 300 modules - only 300 modules can be linked together.  The 
  10304.  
  10305.                         supplied library only contains about 60 modules.
  10306.  
  10307.  
  10308.  
  10309.         too many filenames - there are only 2000 bytes reserved for all 
  10310.  
  10311.                         filenames.
  10312.  
  10313.  
  10314.  
  10315.         too many labels in <name> - a module in the named file had over 
  10316.  
  10317.                         1000 labels.
  10318.  
  10319.  
  10320.  
  10321.         too many total PUBLICS in <name> - symbol table has overflowed.  
  10322.  
  10323.                         The named file was being read when the overflow 
  10324.  
  10325.                         occurred.
  10326.  
  10327.  
  10328.  
  10329.  
  10330.  
  10331.  
  10332.  
  10333.  
  10334.  
  10335.  
  10336.  
  10337.  
  10338.  
  10339.  
  10340.  
  10341.  
  10342.  
  10343.  
  10344.  
  10345.  
  10346.  
  10347.  
  10348.  
  10349.  
  10350.  
  10351.  
  10352.  
  10353.  
  10354.  
  10355.  
  10356.  
  10357.  
  10358.  
  10359.  
  10360.  
  10361.  
  10362.  
  10363.  
  10364.  
  10365.  
  10366.  
  10367.  
  10368.  
  10369.  
  10370.  
  10371.  
  10372.  
  10373.  
  10374.  
  10375.  
  10376.  
  10377.  
  10378.  
  10379.  
  10380.  
  10381.  
  10382.  
  10383.  
  10384.  
  10385.  
  10386.  
  10387.  
  10388.  
  10389.  
  10390.  
  10391.  
  10392.  
  10393.  
  10394.  
  10395.  
  10396.  
  10397.  
  10398.  
  10399.  
  10400.  
  10401.  
  10402.  
  10403.  
  10404.  
  10405.  
  10406.  
  10407.  
  10408.  
  10409.  
  10410.  
  10411.  
  10412.  
  10413.  
  10414.  
  10415.  
  10416.  
  10417.  
  10418.  
  10419.  
  10420.  
  10421.  
  10422.  
  10423.  
  10424.  
  10425.  
  10426.  
  10427.  
  10428.  
  10429.         Order Form                                          Page 74
  10430.  
  10431.  
  10432.  
  10433.  
  10434.  
  10435.         B. Order Form
  10436.  
  10437.  
  10438.  
  10439.         Remit to: C Ware Corporation
  10440.  
  10441.                   P.O. Box 428
  10442.  
  10443.                   Paso Robles, CA 94447
  10444.  
  10445.  
  10446.  
  10447.         PCC version 1.2c
  10448.  
  10449.  
  10450.  
  10451.         You can also order by phone using your P.O.#, Mastercard or VISA.  
  10452.  
  10453.         (805) 239-4620, 9:00 a.m. - 4:00 p.m., PST ONLY.
  10454.  
  10455.  
  10456.  
  10457.         ____ PCC Registration .................... @ $ 30.00 ea  $ ______
  10458.  
  10459.              (includes registration software -OR- 
  10460.  
  10461.               latest version of PCC)
  10462.  
  10463.  
  10464.  
  10465.         ____ UPGRADE to the newest version .......  @ $ 5.00 ea  $ ______
  10466.  
  10467.              (includes latest version of the program diskette,
  10468.  
  10469.               with documentation on the disk.)
  10470.  
  10471.  
  10472.  
  10473.         Orders are normally shipped by USPS at no additional charge.
  10474.  
  10475.  
  10476.  
  10477.         For UPS shipment, please add $3.00            $  3.00 ea  $ _____
  10478.  
  10479.  
  10480.  
  10481.                                                        Subtotal    ______
  10482.  
  10483.  
  10484.  
  10485.                                                   Less Discount    ______
  10486.  
  10487.  
  10488.  
  10489.                                                            Total $ ______
  10490.  
  10491.  
  10492.  
  10493.  
  10494.  
  10495.  
  10496.  
  10497.         Payment by:  [ ] Check  [ ] MC  [ ] Visa  [ ] PO # ______________
  10498.  
  10499.  
  10500.  
  10501.         Name: ___________________________________________________________
  10502.  
  10503.  
  10504.  
  10505.         Company: ________________________________________________________
  10506.  
  10507.  
  10508.  
  10509.         Address: ________________________________________________________
  10510.  
  10511.  
  10512.  
  10513.                : ________________________________________________________
  10514.  
  10515.  
  10516.  
  10517.                : ________________________________________________________
  10518.  
  10519.  
  10520.  
  10521.         Day Phone: _______________________ Eve: _________________________
  10522.  
  10523.  
  10524.  
  10525.          Card #: _______________________________ Exp. Date: _____________
  10526.  
  10527.  
  10528.  
  10529.         Signature of cardholder: ________________________________________
  10530.  
  10531.  
  10532.  
  10533.  
  10534.  
  10535.  
  10536.  
  10537.  
  10538.  
  10539.  
  10540.  
  10541.  
  10542.  
  10543.  
  10544.  
  10545.  
  10546.  
  10547.  
  10548.  
  10549.  
  10550.  
  10551.  
  10552.  
  10553.  
  10554.  
  10555.  
  10556.  
  10557.  
  10558.  
  10559.  
  10560.  
  10561.         User Comments                                       Page 75
  10562.  
  10563.  
  10564.  
  10565.  
  10566.  
  10567.         C. User Comments
  10568.  
  10569.  
  10570.  
  10571.         I acquired PCC from
  10572.  
  10573.                 [ ] - Friend                    [ ] - Software product
  10574.  
  10575.                 [ ] - Computer Club             [ ] - Computer Store
  10576.  
  10577.                 [ ] - Data Base Service         [ ] - Electronic BBS
  10578.  
  10579.                 [ ] - Other - Please Specify ____________________________
  10580.  
  10581.  
  10582.  
  10583.         We would also appreciate any input you would care to give 
  10584.  
  10585.         concerning PCC.  If you have any ideas or comments that would 
  10586.  
  10587.         make PCC a better program, then please let us know.
  10588.  
  10589.  
  10590.  
  10591.         We value your comments!
  10592.  
  10593.  
  10594.  
  10595.         Comments and/or suggestions:
  10596.  
  10597.         ________________________________________________________________
  10598.  
  10599.  
  10600.  
  10601.         ________________________________________________________________
  10602.  
  10603.  
  10604.  
  10605.         ________________________________________________________________
  10606.  
  10607.  
  10608.  
  10609.         ________________________________________________________________
  10610.  
  10611.  
  10612.  
  10613.         ________________________________________________________________
  10614.  
  10615.  
  10616.  
  10617.         ________________________________________________________________
  10618.  
  10619.  
  10620.  
  10621.         ________________________________________________________________
  10622.  
  10623.  
  10624.  
  10625.         ________________________________________________________________
  10626.  
  10627.  
  10628.  
  10629.         ________________________________________________________________
  10630.  
  10631.  
  10632.  
  10633.         ________________________________________________________________
  10634.  
  10635.  
  10636.  
  10637.         ________________________________________________________________
  10638.  
  10639.  
  10640.  
  10641.         ________________________________________________________________
  10642.  
  10643.  
  10644.  
  10645.         ________________________________________________________________
  10646.  
  10647.  
  10648.  
  10649.  
  10650.  
  10651.  
  10652.  
  10653.  
  10654.  
  10655.  
  10656.  
  10657.  
  10658.  
  10659.  
  10660.  
  10661.  
  10662.  
  10663.  
  10664.  
  10665.  
  10666.  
  10667.  
  10668.  
  10669.  
  10670.  
  10671.  
  10672.  
  10673.  
  10674.  
  10675.  
  10676.  
  10677.  
  10678.  
  10679.  
  10680.  
  10681.  
  10682.  
  10683.  
  10684.  
  10685.  
  10686.  
  10687.  
  10688.  
  10689.  
  10690.  
  10691.  
  10692.  
  10693.         User Comments                                       Page 76
  10694.  
  10695.  
  10696.  
  10697.  
  10698.  
  10699.          index
  10700.  
  10701.  
  10702.  
  10703.         A
  10704.  
  10705.         abs(), 34
  10706.  
  10707.         An Introduction To PCC, 8
  10708.  
  10709.         atof(), 35
  10710.  
  10711.         atoi(), 34
  10712.  
  10713.         atol(), 35
  10714.  
  10715.  
  10716.  
  10717.         B
  10718.  
  10719.         Banner and Termination Messages, 60, 67, 71
  10720.  
  10721.         Basic System, 10
  10722.  
  10723.  
  10724.  
  10725.         C
  10726.  
  10727.         Calling Conventions, 29
  10728.  
  10729.         ceil(), 36
  10730.  
  10731.         chain(), 36
  10732.  
  10733.         close(), 37
  10734.  
  10735.         Completion Codes, 11
  10736.  
  10737.         Corporate
  10738.  
  10739.            Business, Government and Commercial Use, 5
  10740.  
  10741.         creat(), 37
  10742.  
  10743.  
  10744.  
  10745.         D
  10746.  
  10747.         Data Types, 15
  10748.  
  10749.         dates(), 37
  10750.  
  10751.         DISCLAIMER, 3
  10752.  
  10753.         Disk Input/Output Routines, 32
  10754.  
  10755.         doint(), 37
  10756.  
  10757.  
  10758.  
  10759.         E
  10760.  
  10761.         Errors from PCCA, 68
  10762.  
  10763.         Example, 21
  10764.  
  10765.         Examples, 14, 24
  10766.  
  10767.         exec(), 38
  10768.  
  10769.         exit(), 39
  10770.  
  10771.         exp(), 39
  10772.  
  10773.         Extensions, 16
  10774.  
  10775.         Externs, 18
  10776.  
  10777.  
  10778.  
  10779.         F
  10780.  
  10781.         fabs(), 40
  10782.  
  10783.         Fatal Errors From PCCA, 68
  10784.  
  10785.         Fatal Errors from PCCL, 72
  10786.  
  10787.         fclose(), 40
  10788.  
  10789.         fgetc(), 40
  10790.  
  10791.         fgets(), 40
  10792.  
  10793.         floor(), 41
  10794.  
  10795.         fopen(), 41
  10796.  
  10797.         FOREIGN RESHIPMENT LIABILITY, 3
  10798.  
  10799.         Forward References, 18
  10800.  
  10801.         fputc(), 41
  10802.  
  10803.         fputs(), 42
  10804.  
  10805.         frand(), 42
  10806.  
  10807.         fscanf(), 42
  10808.  
  10809.  
  10810.  
  10811.  
  10812.  
  10813.  
  10814.  
  10815.  
  10816.  
  10817.  
  10818.  
  10819.  
  10820.  
  10821.  
  10822.  
  10823.  
  10824.  
  10825.         User Comments                                       Page 77
  10826.  
  10827.  
  10828.  
  10829.  
  10830.  
  10831.  
  10832.  
  10833.         G
  10834.  
  10835.         General, 4
  10836.  
  10837.         getc(), 42
  10838.  
  10839.         getchar(), 43
  10840.  
  10841.         gets(), 43
  10842.  
  10843.         Getting Started, 9
  10844.  
  10845.         getw(), 44
  10846.  
  10847.  
  10848.  
  10849.         I
  10850.  
  10851.         IBM-PC Screen and Keyboard Interface, 34
  10852.  
  10853.         in(), 44
  10854.  
  10855.         index(), 44
  10856.  
  10857.         Introduction, 13, 21, 23, 28
  10858.  
  10859.         Invocation, 21, 23
  10860.  
  10861.  
  10862.  
  10863.         L
  10864.  
  10865.         Libraries, 27
  10866.  
  10867.         LIBRARY CONVENTIONS, 31
  10868.  
  10869.         License, 2
  10870.  
  10871.         LIMITATIONS OF REMEDIES, 3
  10872.  
  10873.         LIMITED WARRANTY                                                                , 3
  10874.  
  10875.         lmove(), 45
  10876.  
  10877.         log(), 44
  10878.  
  10879.         longjmp(), 45
  10880.  
  10881.  
  10882.  
  10883.         M
  10884.  
  10885.         Macros, 20
  10886.  
  10887.         Math Routines, 33
  10888.  
  10889.         Messages, 60
  10890.  
  10891.         Messages Produced by PCCA, 67
  10892.  
  10893.  
  10894.  
  10895.         N
  10896.  
  10897.         Names, 28
  10898.  
  10899.  
  10900.  
  10901.         O
  10902.  
  10903.         open(), 46
  10904.  
  10905.         Order Form, 74
  10906.  
  10907.         ORDERING INFORMATION, 4
  10908.  
  10909.         os(), 46
  10910.  
  10911.         out(), 46
  10912.  
  10913.         Overlays, 25
  10914.  
  10915.  
  10916.  
  10917.         P
  10918.  
  10919.         PCC -- The Personal C Compiler, 13
  10920.  
  10921.         PCC Compiler Messages, 60
  10922.  
  10923.         PCC Errors, 62
  10924.  
  10925.         PCC Fatal Errors, 60
  10926.  
  10927.         PCC Files, 9
  10928.  
  10929.         PCC Warnings, 66
  10930.  
  10931.         PCCA Assembler Messages, 67
  10932.  
  10933.         PCCA Errors ( from PCC Execution ), 67
  10934.  
  10935.         PCCL Messages, 71
  10936.  
  10937.         peek(), 46
  10938.  
  10939.         poke(), 47
  10940.  
  10941.  
  10942.  
  10943.  
  10944.  
  10945.  
  10946.  
  10947.  
  10948.  
  10949.  
  10950.  
  10951.  
  10952.  
  10953.  
  10954.  
  10955.  
  10956.  
  10957.         User Comments                                       Page 78
  10958.  
  10959.  
  10960.  
  10961.  
  10962.  
  10963.         pow(), 47
  10964.  
  10965.         Preface, 7
  10966.  
  10967.         Preprocessor directives, 15
  10968.  
  10969.         Program Initialization, 28
  10970.  
  10971.         putc(), 47
  10972.  
  10973.         putchar(), 47
  10974.  
  10975.         puts(), 48
  10976.  
  10977.         putw(), 48
  10978.  
  10979.  
  10980.  
  10981.         Q
  10982.  
  10983.         qsort(), 48
  10984.  
  10985.  
  10986.  
  10987.         R
  10988.  
  10989.         RAM DISK, 11
  10990.  
  10991.         rand(), 49
  10992.  
  10993.         rename(), 49
  10994.  
  10995.         rindex(), 49
  10996.  
  10997.  
  10998.  
  10999.         S
  11000.  
  11001.         scanf(), 50
  11002.  
  11003.         scr_aputs(), 52
  11004.  
  11005.         scr_ci(), 52
  11006.  
  11007.         scr_clr(), 52
  11008.  
  11009.         scr_clrl(), 52
  11010.  
  11011.         scr_cls(), 53
  11012.  
  11013.         scr_co(), 52
  11014.  
  11015.         scr_csts(), 53
  11016.  
  11017.         scr_cursoff(), 53
  11018.  
  11019.         scr_curson(), 53
  11020.  
  11021.         scr_rowcol(), 53
  11022.  
  11023.         scr_scdn(), 54
  11024.  
  11025.         scr_scrdn(), 54
  11026.  
  11027.         scr_scrup(), 54
  11028.  
  11029.         scr_scup(), 54
  11030.  
  11031.         scr_setmode(), 54
  11032.  
  11033.         scr_setup(), 55
  11034.  
  11035.         scr_sinp(), 55
  11036.  
  11037.         setjmp(), 56
  11038.  
  11039.         Setting Up DOS 2.xx
  11040.  
  11041.            3.xx, ..., 10
  11042.  
  11043.         Space Considerations, 25
  11044.  
  11045.         sqrt(), 56
  11046.  
  11047.         srand(), 56
  11048.  
  11049.         sscanf(), 57
  11050.  
  11051.         Standard Library Functions, 34
  11052.  
  11053.         strcat(), 57
  11054.  
  11055.         strcmp(), 57
  11056.  
  11057.         strcpy(), 57
  11058.  
  11059.         Strings, 20
  11060.  
  11061.         strlen(), 58
  11062.  
  11063.         strncat(), 58
  11064.  
  11065.         strncmp(), 58
  11066.  
  11067.         strncpy(), 59
  11068.  
  11069.         Support Policy, 2
  11070.  
  11071.  
  11072.  
  11073.  
  11074.  
  11075.  
  11076.  
  11077.  
  11078.  
  11079.  
  11080.  
  11081.  
  11082.  
  11083.  
  11084.  
  11085.  
  11086.  
  11087.  
  11088.  
  11089.         User Comments                                       Page 79
  11090.  
  11091.  
  11092.  
  11093.  
  11094.  
  11095.         T
  11096.  
  11097.         The C Language, 15
  11098.  
  11099.         The Legal Stuff, 1
  11100.  
  11101.         The PCCA 8088 Assembler, 21
  11102.  
  11103.         The PCCL Object File Linker, 23
  11104.  
  11105.         The PCCS.S Standard Library, 28
  11106.  
  11107.         times(), 59
  11108.  
  11109.         TRADEMARKS, 4
  11110.  
  11111.  
  11112.  
  11113.         U
  11114.  
  11115.         ungetc(), 59
  11116.  
  11117.         unlink(), 59
  11118.  
  11119.         Use by Educational Institutions, 5
  11120.  
  11121.         User Comments, 75
  11122.  
  11123.  
  11124.  
  11125.         W
  11126.  
  11127.         Warnings from PCCL, 71
  11128.  
  11129.  
  11130.  
  11131.         U
  11132.  
  11133.         Using Text
  11134.  
  11135.            Book, Magazine or Download source code, 8
  11136.  
  11137.  
  11138.  
  11139.  
  11140.  
  11141.  
  11142.  
  11143.  
  11144.  
  11145.  
  11146.  
  11147.  
  11148.  
  11149.  
  11150.  
  11151.  
  11152.  
  11153.  
  11154.  
  11155.  
  11156.  
  11157.  
  11158.  
  11159.  
  11160.  
  11161.  
  11162.  
  11163.  
  11164.  
  11165.  
  11166.  
  11167.  
  11168.  
  11169.  
  11170.  
  11171.  
  11172.  
  11173.  
  11174.  
  11175.  
  11176.  
  11177.  
  11178.  
  11179.  
  11180.  
  11181.  
  11182.  
  11183.  
  11184.  
  11185.  
  11186.  
  11187.  
  11188.  
  11189.  
  11190.  
  11191.  
  11192.  
  11193.  
  11194.  
  11195.  
  11196.  
  11197.  
  11198.  
  11199.  
  11200.  
  11201.  
  11202.  
  11203.  
  11204.  
  11205.  
  11206.  
  11207.  
  11208.  
  11209.  
  11210.  
  11211.  
  11212.  
  11213.  
  11214.  
  11215.  
  11216.  
  11217.  
  11218.  
  11219.  
  11220.  
  11221.