Search the web
Sign In
New User? Sign Up
euroforth · EuroForth conference list
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Hear how Yahoo! Groups has changed the lives of others. Take me there.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Question   Message List  
Reply | Forward Message #73 of 153 |
Re: [EuroFORTH] Question

> So given the following definition with a name and a body but no stack
> comment, how would I replace the question marks with the correct interface
> components. I do not quite understand what 'TYPE+' does.
> : TYPE+ ( ? -- ? ) 0 DO DUP C@ EMIT 1+ LOOP ;

TYPE+ requires 2 arguments on top of stack:
- first a count on top of stack, as second argument to DO ( limit start -- ),
- then an address, each time in the loop first DUPlicated to C@ a byte and EMIT
it, then incremented for the next time in the loop
Then the stack comment could be ( addr u -- addr1 ), or more clearly:

: TYPE+ ( addr u -- addr+u ) 0 DO DUP C@ EMIT 1+ LOOP ;

A more elegant, more compact, and more efficient equivalent definition:

: TYPE+ ( addr u -- addr+u ) 2DUP TYPE + ;

Have fun,
CL



Fri Oct 19, 2001 10:31 am

cl@...
Send Email Send Email

Forward
Message #73 of 153 |
Expand Messages Author Sort by Date

I am just learning FORTH and I have a qustion. I know that in Forth, the name of a definition indicates what it does, the definition body of the definition...
Randy Tsen
malaysianpri...
Offline Send Email
Oct 17, 2001
11:07 pm

Dear Randy Tsen: The EuroForth discussion group is about announces and questions related to the annual EuroForth conference (such as call for papers,...
Michael L.Gassanenko
m_l_g3
Offline Send Email
Oct 18, 2001
4:57 am

... TYPE+ requires 2 arguments on top of stack: - first a count on top of stack, as second argument to DO ( limit start -- ), - then an address, each time in...
Christophe Lavarenne
cl@...
Send Email
Oct 19, 2001
10:31 am
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help