home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / arch / 8922 < prev    next >
Encoding:
Internet Message Format  |  1992-08-16  |  2.4 KB

  1. Path: sparky!uunet!sun-barr!rutgers!cbmvax!jesup
  2. From: jesup@cbmvax.commodore.com (Randell Jesup)
  3. Newsgroups: comp.arch
  4. Subject: Re: Threaded Code
  5. Message-ID: <34301@cbmvax.commodore.com>
  6. Date: 16 Aug 92 21:20:42 GMT
  7. References: <55535@mentor.cc.purdue.edu> <13910@goanna.cs.rmit.oz.au> <GLEW.92Aug7185506@pdx007.intel.com> <1992Aug10.141731.10007@email.tuwien.ac.at> <martin.713808550@bert>
  8. Reply-To: jesup@cbmvax.commodore.com (Randell Jesup)
  9. Organization: Commodore, West Chester, PA
  10. Lines: 37
  11.  
  12. martin@math.rwth-aachen.de (  Martin Schoenert) writes:
  13. >Subroutine threading (sub.c):
  14. >    For each instruction there is a (C) function which implements this
  15. >    instruction.  The instructions are encoded with the addresses of
  16. >    those functions.  Each function returns after it has done its work,
  17. >    and there is a central dispatcher in 'main', which looks as follows
  18. >    'while (1) (**pc++)();'
  19.  
  20.     This is not what I would call "subroutine threading".  Subroutine
  21. threading (at least from my perspective of having written a subroutine-
  22. threaded forth) means that you do not have an array of function addresses,
  23. you have an array of "jsr <address>".  On top of that, the code that
  24. generates the instructions can inline when appropriate (a big win in forth
  25. on modern processors, since many simple operations are smaller than an
  26. instruction or even an address).
  27.  
  28.     I'm not sure what I'd call your method.  It's big problem is that
  29. it requires an explicit "interpret" instruction to call an instruction
  30. written from instructions instead of as a pre-existing C routine.  If I had
  31. to name it I would call it an "explicit-threaded interpreter", since the
  32. thing that compiles the code must know to generate "interpret" instructions
  33. to execute words that need interpretation, while all standard methods of
  34. threading do not need to know.
  35.  
  36.     The various forms of threading have been heavily explored in Forth
  37. literature and implementations over the years.  If you're really interested
  38. in efficient interpretation, I advise reading some of the Forth literature
  39. (FORML proceedings, Rochester forth proceedings, even old Byte and Dr. Dobbs
  40. issues, etc).
  41.  
  42. -- 
  43. "Rev on the redline, you're on your own; seems like a lifetime, but soon it's
  44.  gone..."  Foreigner
  45. -
  46. Randell Jesup, Jack-of-quite-a-few-trades, Commodore Engineering.
  47. {uunet|rutgers}!cbmvax!jesup, jesup@cbmvax.cbm.commodore.com  BIX: rjesup  
  48. Disclaimer: Nothing I say is anything other than my personal opinion.
  49.