Article View: comp.lang.forth.mac
Article #30Re: Pocket Forth
From: Jim Lynch
Date: Tue, 15 Dec 1992 03:27
Date: Tue, 15 Dec 1992 03:27
44 lines
1486 bytes
1486 bytes
Here's a pre-83 PICK for Pocket Forth,,, ROLL, -ROLL and PACK might be
forthcoming someday...
--- cut here
: code create -8 allot ;
hex
code pick ( works! )
3D3C , 0002 , ( MOVE #$02,-(PS) )
4EAB , ' * , ( JSR times-base(BP) )
301E , ( MOVE (PS)+,D0 )
41F6 , 0000 , ( LEA 0(PS,D0.W),A )
3D20 , ( MOVE -(A0),-(PS) )
4E75 , ( RTS )
decimal
: (-loop) ( amount to subtract from index -> flag for until. )
r> r> ( ret addr )
r> ( index )
4 pick -
dup r > 0= ( terminate do...-loop now? ) dup
if swap drop ( drop new index )
r> drop ( drop limit )
rot rot >r >r ( put ret addr back )
else swap >r ( put index back )
rot rot >r >r ( put ret addr back )
then
swap drop ( get rid of amount )
;
: -loop [ ' (-loop) literal ] compile [compile] until ; immediate
--- cut here
Oh yeah, here's a bonus: -loop!
Try this:
: CountBackwards 0 4 do r . 1 -loop ; CountBackwards
One more thing: 1 pick = dup, 2 pick = over...
Enjoy.
Technical Details
Message-ID:
<1992Dec15.032759.23843@netcom.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!darwin.sura.net!spool.mu.edu!umn.edu!csus.edu!netcom.com!jimlynchReferences:
<sorry?no?email-141292131847@meded6.med.upenn.edu>Show Full Headers
Complete Article Headers
Newsgroups: comp.lang.forth.mac Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!darwin.sura.net!spool.mu.edu!umn.edu!csus.edu!netcom.com!jimlynch From: jimlynch@netcom.com (Jim Lynch) Subject: Re: Pocket Forth Message-ID: <1992Dec15.032759.23843@netcom.com> Organization: Netcom - Online Communication Services (408 241-9760 guest) References: <sorry?no?email-141292131847@meded6.med.upenn.edu> Date: Tue, 15 Dec 1992 03:27:59 GMT Lines: 45