home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!haven.umd.edu!darwin.sura.net!zaphod.mps.ohio-state.edu!ub!dsinc!netnews.upenn.edu!microlab15.med.upenn.edu!user
- From: sorry no email address (Peters, Randolph)
- Newsgroups: comp.lang.forth
- Subject: Pocket Forth bug fix
- Message-ID: <sorry?no?email?address-141292094737@microlab15.med.upenn.edu>
- Date: 14 Dec 92 15:00:02 GMT
- Sender: news@netnews.upenn.edu
- Followup-To: comp.lang.forth
- Organization: Hospital of the University of Pennsylvania
- Lines: 37
- Nntp-Posting-Host: microlab15.med.upenn.edu
-
- I came up with my own answer to a question I posted on the net a few weeks
- ago. Basically, for users of Pocket forth, there is a problem with the
- word interpret (which interprets the contents of the text input buffer).
- Specifically, you can fill the text input buffer, but you can't reset the
- input stream easily because there is no user variable to mark current
- position in the input stream. I have come up with a simple fix:
-
- : 0>is ( -- ) ( resets the input stream to the text input buffer )
- tib ( -- buffer.addr )
- a>r ( single -- r: -- double )
- 2r> ( -- double.length.buffer.addr r: -- )
- ,$ 285E ( compile inline code for MOVEA.L [A6]+, A4 )
- ; macro ( in pocket forth, the top of the parameter stack )
- ( is in A6 and the absolute position of the text )
- ( input buffer in memory is in A4 )
-
- ( example of usage of the above )
- : query tib 80 32 fill ( empty the tib)
- 0>is ( reset the input stream pointer)
- tib 80 expect interpret ." hello" ;
-
- This only solves one problem; now text can be transferred to the input
- buffer
- and correctly interpreted. Afterwards, however, control does not return to
- the
- word in which 'interpret' is contained. "hello" would never appear on the
- display. This is because interpret empties out the return stack and the
- parameter stack ( arrgh! ). Is this standard (for this question, I mean F83
- or MMSFORTH standard) behavior for this word? And is there any way to patch
- this behavior?
-
- Comments and insight appreciated.
-
- Randolph Peters
- Suite C, 3rd Floor Silverstein
- Hospital of the University of Pennsylvania
- 34th and Spruce Streets, Phila PA 19104
-