MOD and /MOD with Pygmy Forth 
Author Message
 MOD and /MOD with Pygmy Forth

I'm just starting to learn Forth, using "Starting Forth" and Frank
Sergeant's Pygmy Forth 1.5 for DOS.

At p. 40 of "Starting Forth", the MOD and /MOD operators are mentioned.
They don't seem to work for me with Pygmy, but the "Starting Forth
Notes" part of the documentation, which lists differences between
"Starting Forth" and Pygmy, doesn't mention this.

I'd appreciate help. (Or, in the alternative, suggestions regarding a
different Forth for DOS. I'd prefer something free and already
compiled -- I'd prefer not to have to compile it myself.)

--

Ottawa, Canada
Francais / English / Esperanto
Maintainer, Esperanto FAQ: http://www.*-*-*.com/



Fri, 12 Apr 2002 03:00:00 GMT  
 MOD and /MOD with Pygmy Forth

Quote:

>I'm just starting to learn Forth, using "Starting Forth" and Frank
>Sergeant's Pygmy Forth 1.5 for DOS.
>At p. 40 of "Starting Forth", the MOD and /MOD operators are mentioned.
>They don't seem to work for me with Pygmy, but the "Starting Forth
>Notes" part of the documentation, which lists differences between
>"Starting Forth" and Pygmy, doesn't mention this.

Pygmy provides UMOD which works fine for unsigned numbers with a few
exceptions.  (It's possible to get some division exceptions when you
use the wrong divisor.)

Pygmy gives the following code for /

CODE / ( n div -- quo )
  AX POP, CWD, BX AX IDIV, AX BX MOV, NXT, END-CODE

I have the idea that the following might give you MOD

CODE MOD ( n div -- rem )
  AX POP, CWD, BX AX IDIV, CX BX MOV, NXT, END-CODE

but it might not do quite what you want, check it enough to find
out.

You're likely to want other arithmetic ops that are missing in Pygmy.
I found I didn't really need them, I could usually get by just fine
with what Pygmy provides, but if you're trying out code that needs
them it's easier to use the commands the code needs while you're
figuring it out than rewrite it from scratch without fully understanding
it.  So here are a few others:

COMPILER
: >R COMPILE PUSH ;
: R> COMPILE POP ;

FORTH
: S>D DUP 0< ;
CODE SM/REM
   DX POP, AX POP, BX IDIV, ( signed div)
   DX PUSH, ( rem) AX BX MOV, ( quo)
   NXT, END-CODE
: /MOD >R S>D R> SM/REM ;
: MOD /MOD DROP ;

As before you should test these to find out whether they do what you want.
If they don't please let me know.



Sat, 13 Apr 2002 03:00:00 GMT  
 MOD and /MOD with Pygmy Forth


Quote:
> I'm just starting to learn Forth, using "Starting Forth" and Frank
> Sergeant's Pygmy Forth 1.5 for DOS.

> At p. 40 of "Starting Forth", the MOD and /MOD operators are mentioned.
> They don't seem to work for me with Pygmy, but the "Starting Forth
> Notes" part of the documentation, which lists differences between
> "Starting Forth" and Pygmy, doesn't mention this.

> I'd appreciate help. (Or, in the alternative, suggestions regarding a
> different Forth for DOS. I'd prefer something free and already
> compiled -- I'd prefer not to have to compile it myself.)

You could try F83 for DOS (there are versions of it for other processors too)
which you will probably get from www.forth.org. Someone has also done some
useful notes for using thebook with ANS Forth but I forget who.

--

Forth based HIDECS Consultancy .... <www.amleth.demon.co.uk>
Tel: +44 (0)7971-620145
Going Forth Safely



Sat, 13 Apr 2002 03:00:00 GMT  
 MOD and /MOD with Pygmy Forth


Quote:

> >I'm just starting to learn Forth, using "Starting Forth" and Frank
> >Sergeant's Pygmy Forth 1.5 for DOS.

> >At p. 40 of "Starting Forth", the MOD and /MOD operators are mentioned.
> >They don't seem to work for me with Pygmy, but the "Starting Forth
> >Notes" part of the documentation, which lists differences between
> >"Starting Forth" and Pygmy, doesn't mention this.

> Pygmy provides UMOD which works fine for unsigned numbers with a few
> exceptions.  (It's possible to get some division exceptions when you
> use the wrong divisor.)

> Pygmy gives the following code for /

> CODE / ( n div -- quo )
>   AX POP, CWD, BX AX IDIV, AX BX MOV, NXT, END-CODE

> I have the idea that the following might give you MOD

> CODE MOD ( n div -- rem )
>   AX POP, CWD, BX AX IDIV, CX BX MOV, NXT, END-CODE

    Change "CX BX MOV" to "DX BX MOV" and it should work.

--

-GJC



Sat, 13 Apr 2002 03:00:00 GMT  
 MOD and /MOD with Pygmy Forth
On Mon, 25 Oct 1999 22:44:59 -0400,

Quote:
>I'd appreciate help. (Or, in the alternative, suggestions regarding a
>different Forth for DOS. I'd prefer something free and already
>compiled -- I'd prefer not to have to compile it myself.)

An alternative: FIG-Forth
o small size easy to comprehend
o pure Forth without applications obscuring the concepts
o tracks Starting Forth very well
o public domain
You can download vintage FIG-Forth from my Forth page that has source
code and user guide. A companion file has the Forth pre-built.

--

WasteLand  http://www.dhc.net/~tzegub
|_|_|_|_  
  | | | |  http://www.dhc.net/~tzegub/fop.htm



Sat, 13 Apr 2002 03:00:00 GMT  
 MOD and /MOD with Pygmy Forth

Quote:



> > I'm just starting to learn Forth, using "Starting Forth" and Frank
> > Sergeant's Pygmy Forth 1.5 for DOS.

> > At p. 40 of "Starting Forth", the MOD and /MOD operators are mentioned.
> > They don't seem to work for me with Pygmy, but the "Starting Forth
> > Notes" part of the documentation, which lists differences between
> > "Starting Forth" and Pygmy, doesn't mention this.

> > I'd appreciate help. (Or, in the alternative, suggestions regarding a
> > different Forth for DOS. I'd prefer something free and already
> > compiled -- I'd prefer not to have to compile it myself.)

> You could try F83 for DOS (there are versions of it for other processors too)
> which you will probably get from www.forth.org. Someone has also done some
> useful notes for using thebook with ANS Forth but I forget who.

> --

> Forth based HIDECS Consultancy .... <www.amleth.demon.co.uk>
> Tel: +44 (0)7971-620145
> Going Forth Safely

I'd recommend F-PC for DOS. Free, pretty debugged, good user interface,
has TCOM for making small compiled apps, what else do you want,
egg in your beer?

--
Julian V. Noble

"Elegance is for tailors!"    -- Ludwig Boltzmann



Mon, 15 Apr 2002 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. SM/REM FM/MOD and UM/MOD on a 32bit cell ix86 Forth

2. Utils.Mod, ET.Mod

3. Mod-2 or Mod-3 for Mac

4. Mod-2 and Mod-3 compiler

5. Mod-2 and Mod-3 compiler for the IBM PC and compatibles

6. search algorithm for a math mod function (5 mod[2]=1)

7. awk's mod operator % question (application: log base2 non-integer result)

8. MOD Library ?

9. Something Better then MOD?

10. How to play Mod with RB?

11. xml.smalltalk.org, mod.smalltalk.org and camp.smalltalk.org DNS problems resolved

12. xml.smalltalk.org and mod.smalltalk.org

 

 
Powered by phpBB® Forum Software