Fix mod
This commit is contained in:
32
README.md
32
README.md
@ -1,33 +1,13 @@
|
|||||||
# The many faces of EForth
|
# EForth
|
||||||
|
|
||||||
EForth is a delightfully minimalist approach to Forth originated by Bill Muench and Dr. C. H. Ting.
|
EForth is a delightfully minimalist approach to Forth originated by Bill Muench and Dr. C. H. Ting.
|
||||||
|
|
||||||
In its original form metacompilation is avoided.
|
For more information visit:
|
||||||
|
|
||||||
|
[https://eforth.appspot.com/](https://eforth.appspot.com/)
|
||||||
|
|
||||||
## Directories
|
## Directories
|
||||||
|
|
||||||
* reference/ - EForth Reference Material
|
* ueforth/ - µEforth - EForth refactored to allow source boostraping.
|
||||||
* circleforth/ - A minimalist Forth modeled after toy Lisps.
|
* circleforth/ - A minimalist Forth modeled after toy Lisps.
|
||||||
* ueforth/ - micro EForth - EForth refactored to allow source boostraping.
|
* reference/ - EForth Reference Material
|
||||||
|
|
||||||
## EForth Quirks
|
|
||||||
|
|
||||||
EForth uses `FOR..NEXT` in favor of `DO..LOOP`:
|
|
||||||
[FOR/NEXT](https://github.com/TG9541/stm8ef/wiki/eForth-FOR-..-NEXT).
|
|
||||||
|
|
||||||
This construct has the odd property that it iterates one "extra" time for zero.
|
|
||||||
|
|
||||||
```
|
|
||||||
: FOO 10 FOR R@ . NEXT ; FOO
|
|
||||||
10 9 8 7 6 5 4 3 2 1 0 ok
|
|
||||||
```
|
|
||||||
|
|
||||||
To permit a more ordinary loop the `AFT` word is used in the sequence `FOR..AFT..THEN..NEXT`.
|
|
||||||
|
|
||||||
```
|
|
||||||
: FOO 10 FOR ( 1st time only ) AFT R@ . THEN NEXT ; FOO
|
|
||||||
9 8 7 6 5 4 3 2 1 0 ok
|
|
||||||
```
|
|
||||||
|
|
||||||
The even more enigmatic `FOR..WHILE..NEXT..ELSE..THEN` is used in place of `DO..LEAVE..LOOP`.
|
|
||||||
It allows a while condition to early out of a counted loop.
|
|
||||||
|
|||||||
@ -16,16 +16,14 @@ typedef uintptr_t ucell_t;
|
|||||||
#ifndef SSMOD_FUNC
|
#ifndef SSMOD_FUNC
|
||||||
# if __SIZEOF_POINTER__ == 8
|
# if __SIZEOF_POINTER__ == 8
|
||||||
typedef __int128_t dcell_t;
|
typedef __int128_t dcell_t;
|
||||||
typedef __uint128_t udcell_t;
|
|
||||||
# elif __SIZEOF_POINTER__ == 4 || defined(_M_IX86)
|
# elif __SIZEOF_POINTER__ == 4 || defined(_M_IX86)
|
||||||
typedef int64_t dcell_t;
|
typedef int64_t dcell_t;
|
||||||
typedef uint64_t udcell_t;
|
|
||||||
# else
|
# else
|
||||||
# error "unsupported cell size"
|
# error "unsupported cell size"
|
||||||
# endif
|
# endif
|
||||||
# define SSMOD_FUNC dcell_t d = (dcell_t) *sp * (dcell_t) sp[-1]; \
|
# define SSMOD_FUNC dcell_t d = (dcell_t) *sp * (dcell_t) sp[-1]; \
|
||||||
--sp; *sp = (cell_t) (((udcell_t) d) % tos); \
|
--sp; cell_t a = (cell_t) (d < 0 ? ~(~d / tos) : d / tos); \
|
||||||
tos = (cell_t) (d < 0 ? ~(~d / tos) : d / tos)
|
*sp = (cell_t) (d - ((dcell_t) a) * tos); tos = a
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define OPCODE_LIST \
|
#define OPCODE_LIST \
|
||||||
|
|||||||
Reference in New Issue
Block a user