home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / sys / hp48 / 7291 < prev    next >
Encoding:
Text File  |  1993-01-23  |  4.7 KB  |  168 lines

  1. Newsgroups: comp.sys.hp48
  2. Path: sparky!uunet!gatech!destroyer!news.iastate.edu!cfrandal
  3. From: cfrandal@iastate.edu (Charles F Randall)
  4. Subject: Re: C compiler for HP48
  5. Message-ID: <C1BB9x.C15@news.iastate.edu>
  6. Sender: news@news.iastate.edu (USENET News System)
  7. Organization: Iowa State University, Ames, IA
  8. References: <C15xss.1H6@nvcc.uucp> <C19FEw.8Ep@panix.com>
  9. Date: Sat, 23 Jan 1993 15:05:57 GMT
  10. Lines: 156
  11.  
  12. In <C15xss.1H6@nvcc.uucp> robdoss@harrier (Robert C. Doss) writes:
  13. >    It never dawned on me before, but it seems possible that there
  14. >should be a way to write a C compiler for the HP48.  Are there any C
  15. >compilers out there for the HP48 ?  If not are there any programmers up to
  16. >writing a C compiler for the HP48 ?
  17.  
  18. I've attached a post about an ANSI-C to PostScript "compiler" that I
  19. found in comp.compilers. I'd think that this could be modified (I'm
  20. not making any statements about how easy this'd be.) to pump out RPL
  21. instead of ps. If you're interested, you could contact the author.
  22. [he says that the distribution only contains .exe's]
  23. Anyone care to comment?
  24.  
  25. FYI,
  26. Randy
  27.  
  28. Charles F. Randall IV |    _               | "Are you kidding? I study
  29. Aerospace Engineering |  == \---------..,  |  from crisis to crisis!"
  30. Iowa State University |  ==___-----_____>  |       -anonymous student
  31. cfrandal@iastate.edu  | _____b________d___ | <== ascii space shuttle
  32.  
  33.     o /
  34. -------- X--- Cut here -----------------------------------------
  35.     O \
  36.  
  37. Newsgroups: comp.windows.news,comp.lang.postscript,comp.compilers
  38. Subject: PDB -- ANSI-C to PostScript compiler
  39. Date: 21 Jan 93 12:52:14 GMT
  40. Sender: compilers-sender@iecc.cambridge.ma.us
  41. Reply-To: arthur@turing.ac.uk (Arthur van Hoff)
  42. Organization: The Turing Institute Ltd., Glasgow, Scotland
  43.  
  44. Hi PostScript Hackers,
  45.  
  46. PdB version 2.1 (ANSI-C to PostScript compiler) is now available via
  47. anonymous ftp from:
  48.  
  49.      turing.com (192.133.90.28) in pub/pdb2.1-demo.tar.Z
  50.      ftp.uu.net (192.48.96.9) in graphics/NeWS/pdb2.1-demo.tar.Z
  51.  
  52. There is no more need to write PostScript! Start using PdB right now!  PdB
  53. is an optimizing compiler to compile ANSI-C (like) code into Adobe
  54. compatible PostScript. It includes executables, examples and many useful
  55. header files. Note that it is not dependend on NeWS.
  56.  
  57. The release of version 2.1 includes:
  58.  
  59. - - Binaries for Sun SPARC station and IBM RS6000.
  60. - - Include files for Abobe PostScript level I.
  61. - - Include files for NeWS upto version 3.1.
  62. - - Include files for TNT upto version 3.1.
  63. - - Support for CPS OpenWindows upto version 3.1.
  64. - - Support NeWS classing in a C++ manner.
  65. - - Plenty of examples of all the above functions.
  66. - - NeWS/OpenWindows test suite.
  67. - - PostScript reference manual.
  68. - - UNIX manual pages.
  69.  
  70. Below are some examples of PdB code together with the PostScript
  71. produced by the compiler.
  72.  
  73. Have fun,
  74.  
  75.     Arthur van Hoff
  76.     pdb@turing.com
  77.  
  78. ################################
  79. Code to draw a star shape in PdB
  80. ################################
  81.  
  82. #include <graphics.h>
  83.  
  84. void starpath(int ang)
  85. {
  86.         int i;
  87.  
  88.         newpath();
  89.         moveto(100,100);
  90.         for (i = 1 ; i <= (int)(360 / ang) ; i++) {
  91.                 rotate(180 + ang);
  92.                 rlineto(100,0);
  93.         }
  94.         setgray(0);
  95.         stroke();
  96. }
  97.  
  98. ########################
  99. Verbatim Compiler output
  100. ########################
  101.  
  102. /starpath {
  103.   % int --
  104.   newpath 100 100 moveto 1 360 2 index div cvi exch sub 1 add 0 max {
  105.     dup 180 add rotate 100 0 rlineto
  106.   } repeat
  107.   pop 0 setgray stroke
  108. } def
  109.  
  110. ###########################
  111. Code for bubble-sort in PdB
  112. ###########################
  113.  
  114. #include <postscript.h>
  115.  
  116. /******************************************************
  117.  * Bubble sort (page 66)
  118.  * From: Algorithms + Data Structures = Programs
  119.  *       Nicklaus Wirth
  120.  */
  121.  
  122. void bubblesort(int *a)
  123. {
  124.         int i, j;
  125.  
  126.         for (i = length(a)-1 ; i > 1 ; i--)
  127.                 for (j = 0 ; j < i ; j++)
  128.                         if (a[j] > a[j+1]) {
  129.                                 int x = a[j+1];
  130.                                 a[j+1] = a[j];
  131.                                 a[j] = x;
  132.                         }
  133. }
  134.  
  135. ########################
  136. Verbatim Compiler output
  137. ########################
  138.  
  139. /bubblesort {
  140.   % int * --
  141.   dup length 1 sub -1 2 {
  142.     0 1 3 -1 roll 1 sub {
  143.       2 copy get 2 index 2 index 1 add get gt {
  144.         2 copy 1 add get 2 index 2 index 1 add 4 index 4 index get put
  145.         2 index 3 1 roll put
  146.       } {pop} ifelse
  147.     } for
  148.   } for
  149.   pop
  150. } def
  151.  
  152. - --
  153. Arthur van Hoff
  154. The Turing Institute Limited
  155. 36 North Hanover Street,
  156. G1 2AD Glasgow, Scotland
  157.  
  158. Tel: +44 41 552 8858 or +44 41 552 6400  Fax: +44 41 552 2985
  159. Email: arthur@turing.com
  160. - --
  161. Send compilers articles to compilers@iecc.cambridge.ma.us or
  162. {ima | spdcc | world}!iecc!compilers.  Meta-mail to compilers-request.
  163.  
  164. ------- End of Forwarded Message
  165.  
  166.  
  167.  
  168.