From 9a58f8a55d29e4edda7d9352b292be42642b50eb Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Thu, 2 Mar 2023 20:48:00 -0500 Subject: [PATCH] word, division compliance --- core.fth | 19 ++- corewords.cpp | 4 +- test/core.fr | 395 +++++++++++++++++++++++++------------------------- 3 files changed, 212 insertions(+), 206 deletions(-) diff --git a/core.fth b/core.fth index e3ec5d0..40ad2b0 100644 --- a/core.fth +++ b/core.fth @@ -120,8 +120,8 @@ : /mod 2dup % -rot / ; : */ >r m* r> _/ ; -: */mod >r m* 2dup r@ _% r> _/ ; : sm/rem >r 2dup r@ _% -rot r> _/ ; +: */mod >r m* r> sm/rem ; : fm/mod 2dup dup >r ^ >r sm/rem swap dup if r> 0< if r> + swap 1- else swap r> drop then else swap 2r> 2drop then ; @@ -141,11 +141,12 @@ : key begin _input @ dup 0 <= while drop _in repeat dup 1- _input ! _input cell+ 80 chars + swap - c@ ; -: word here -1 cells over ! dup cell+ rot begin key 2dup <> while - 2 pick c! swap char+ swap repeat - 2drop over - over +! ; -: count dup cell+ swap @ ; -: char bl word cell+ c@ ; +: word here dup >r char+ >r + begin key 2dup <> while + r> tuck c! char+ >r repeat + 2drop r> r> tuck - 1- over c! ; +: count dup char+ swap c@ ; +: char bl word char+ c@ ; : [char] char postpone literal ; imm : ( begin [char] ) key <> while repeat ; imm @@ -167,7 +168,11 @@ : ." postpone s" state @ if ['] type , else type then ; imm : .( [char] ) word count type ; imm -: create align here bl word count nip cell+ allot align +: create align here + 1 cells 1 chars - allot + bl word count nip + 1 chars allot + tuck over ! swap allot align ['] _lit , here 3 cells + , ['] exit dup , , dup @ 31 & over _latest @ - 6 << or over ! _latest ! ; : _does> _latest @ dup @ 31 & + cell+ aligned 2 cells + diff --git a/corewords.cpp b/corewords.cpp index ff09bcc..4de9413 100644 --- a/corewords.cpp +++ b/corewords.cpp @@ -102,14 +102,14 @@ execute: cell = state.pop(); dcell = state.pop(); dcell <<= sizeof(Cell) * 8; - dcell |= state.pop(); + dcell |= static_cast(state.pop()); state.push(dcell / cell); break; case 10: // mod ( d n -- n ) cell = state.pop(); dcell = state.pop(); dcell <<= sizeof(Cell) * 8; - dcell |= state.pop(); + dcell |= static_cast(state.pop()); state.push(dcell % cell); break; case 11: // peek diff --git a/test/core.fr b/test/core.fr index 229ca29..10386c4 100644 --- a/test/core.fr +++ b/test/core.fr @@ -342,75 +342,76 @@ T{ MID-UINT+1 1 RSHIFT MID-UINT+1 OR 2 * -> MID-UINT+1 }T \ T{ 1S 2 UM* -> 1S 1 LSHIFT 1 }T \ T{ MAX-UINT MAX-UINT UM* -> 1 1 INVERT }T -\ \ ------------------------------------------------------------------------ -\ TESTING DIVIDE: FM/MOD SM/REM UM/MOD */ */MOD / /MOD MOD -\ -\ T{ 0 S>D 1 FM/MOD -> 0 0 }T -\ T{ 1 S>D 1 FM/MOD -> 0 1 }T -\ T{ 2 S>D 1 FM/MOD -> 0 2 }T -\ T{ -1 S>D 1 FM/MOD -> 0 -1 }T -\ T{ -2 S>D 1 FM/MOD -> 0 -2 }T -\ T{ 0 S>D -1 FM/MOD -> 0 0 }T -\ T{ 1 S>D -1 FM/MOD -> 0 -1 }T -\ T{ 2 S>D -1 FM/MOD -> 0 -2 }T -\ T{ -1 S>D -1 FM/MOD -> 0 1 }T -\ T{ -2 S>D -1 FM/MOD -> 0 2 }T -\ T{ 2 S>D 2 FM/MOD -> 0 1 }T -\ T{ -1 S>D -1 FM/MOD -> 0 1 }T -\ T{ -2 S>D -2 FM/MOD -> 0 1 }T -\ T{ 7 S>D 3 FM/MOD -> 1 2 }T -\ T{ 7 S>D -3 FM/MOD -> -2 -3 }T -\ T{ -7 S>D 3 FM/MOD -> 2 -3 }T -\ T{ -7 S>D -3 FM/MOD -> -1 2 }T -\ T{ MAX-INT S>D 1 FM/MOD -> 0 MAX-INT }T -\ T{ MIN-INT S>D 1 FM/MOD -> 0 MIN-INT }T -\ T{ MAX-INT S>D MAX-INT FM/MOD -> 0 1 }T -\ T{ MIN-INT S>D MIN-INT FM/MOD -> 0 1 }T -\ T{ 1S 1 4 FM/MOD -> 3 MAX-INT }T -\ T{ 1 MIN-INT M* 1 FM/MOD -> 0 MIN-INT }T -\ T{ 1 MIN-INT M* MIN-INT FM/MOD -> 0 1 }T -\ T{ 2 MIN-INT M* 2 FM/MOD -> 0 MIN-INT }T -\ T{ 2 MIN-INT M* MIN-INT FM/MOD -> 0 2 }T -\ T{ 1 MAX-INT M* 1 FM/MOD -> 0 MAX-INT }T -\ T{ 1 MAX-INT M* MAX-INT FM/MOD -> 0 1 }T -\ T{ 2 MAX-INT M* 2 FM/MOD -> 0 MAX-INT }T -\ T{ 2 MAX-INT M* MAX-INT FM/MOD -> 0 2 }T -\ T{ MIN-INT MIN-INT M* MIN-INT FM/MOD -> 0 MIN-INT }T -\ T{ MIN-INT MAX-INT M* MIN-INT FM/MOD -> 0 MAX-INT }T -\ T{ MIN-INT MAX-INT M* MAX-INT FM/MOD -> 0 MIN-INT }T -\ T{ MAX-INT MAX-INT M* MAX-INT FM/MOD -> 0 MAX-INT }T -\ -\ T{ 0 S>D 1 SM/REM -> 0 0 }T -\ T{ 1 S>D 1 SM/REM -> 0 1 }T -\ T{ 2 S>D 1 SM/REM -> 0 2 }T -\ T{ -1 S>D 1 SM/REM -> 0 -1 }T -\ T{ -2 S>D 1 SM/REM -> 0 -2 }T -\ T{ 0 S>D -1 SM/REM -> 0 0 }T -\ T{ 1 S>D -1 SM/REM -> 0 -1 }T -\ T{ 2 S>D -1 SM/REM -> 0 -2 }T -\ T{ -1 S>D -1 SM/REM -> 0 1 }T -\ T{ -2 S>D -1 SM/REM -> 0 2 }T -\ T{ 2 S>D 2 SM/REM -> 0 1 }T -\ T{ -1 S>D -1 SM/REM -> 0 1 }T -\ T{ -2 S>D -2 SM/REM -> 0 1 }T -\ T{ 7 S>D 3 SM/REM -> 1 2 }T -\ T{ 7 S>D -3 SM/REM -> 1 -2 }T -\ T{ -7 S>D 3 SM/REM -> -1 -2 }T -\ T{ -7 S>D -3 SM/REM -> -1 2 }T -\ T{ MAX-INT S>D 1 SM/REM -> 0 MAX-INT }T -\ T{ MIN-INT S>D 1 SM/REM -> 0 MIN-INT }T -\ T{ MAX-INT S>D MAX-INT SM/REM -> 0 1 }T -\ T{ MIN-INT S>D MIN-INT SM/REM -> 0 1 }T -\ T{ 1S 1 4 SM/REM -> 3 MAX-INT }T -\ T{ 2 MIN-INT M* 2 SM/REM -> 0 MIN-INT }T -\ T{ 2 MIN-INT M* MIN-INT SM/REM -> 0 2 }T -\ T{ 2 MAX-INT M* 2 SM/REM -> 0 MAX-INT }T -\ T{ 2 MAX-INT M* MAX-INT SM/REM -> 0 2 }T -\ T{ MIN-INT MIN-INT M* MIN-INT SM/REM -> 0 MIN-INT }T -\ T{ MIN-INT MAX-INT M* MIN-INT SM/REM -> 0 MAX-INT }T -\ T{ MIN-INT MAX-INT M* MAX-INT SM/REM -> 0 MIN-INT }T -\ T{ MAX-INT MAX-INT M* MAX-INT SM/REM -> 0 MAX-INT }T -\ +\ ------------------------------------------------------------------------ +." TESTING DIVIDE: FM/MOD SM/REM UM/MOD */ */MOD / /MOD MOD" CR + +T{ 0 S>D 1 FM/MOD -> 0 0 }T +T{ 1 S>D 1 FM/MOD -> 0 1 }T +T{ 2 S>D 1 FM/MOD -> 0 2 }T +T{ -1 S>D 1 FM/MOD -> 0 -1 }T +T{ -2 S>D 1 FM/MOD -> 0 -2 }T +T{ 0 S>D -1 FM/MOD -> 0 0 }T +T{ 1 S>D -1 FM/MOD -> 0 -1 }T +T{ 2 S>D -1 FM/MOD -> 0 -2 }T +T{ -1 S>D -1 FM/MOD -> 0 1 }T +T{ -2 S>D -1 FM/MOD -> 0 2 }T +T{ 2 S>D 2 FM/MOD -> 0 1 }T +T{ -1 S>D -1 FM/MOD -> 0 1 }T +T{ -2 S>D -2 FM/MOD -> 0 1 }T +T{ 7 S>D 3 FM/MOD -> 1 2 }T +T{ 7 S>D -3 FM/MOD -> -2 -3 }T +T{ -7 S>D 3 FM/MOD -> 2 -3 }T +T{ -7 S>D -3 FM/MOD -> -1 2 }T +T{ MAX-INT S>D 1 FM/MOD -> 0 MAX-INT }T +T{ MIN-INT S>D 1 FM/MOD -> 0 MIN-INT }T +T{ MAX-INT S>D MAX-INT FM/MOD -> 0 1 }T +T{ MIN-INT S>D MIN-INT FM/MOD -> 0 1 }T +T{ 1S 1 4 FM/MOD -> 3 MAX-INT }T +T{ 1 MIN-INT M* 1 FM/MOD -> 0 MIN-INT }T +T{ 1 MIN-INT M* MIN-INT FM/MOD -> 0 1 }T +T{ 2 MIN-INT M* 2 FM/MOD -> 0 MIN-INT }T +T{ 2 MIN-INT M* MIN-INT FM/MOD -> 0 2 }T +T{ 1 MAX-INT M* 1 FM/MOD -> 0 MAX-INT }T +T{ 1 MAX-INT M* MAX-INT FM/MOD -> 0 1 }T +T{ 2 MAX-INT M* 2 FM/MOD -> 0 MAX-INT }T +T{ 2 MAX-INT M* MAX-INT FM/MOD -> 0 2 }T +T{ MIN-INT MIN-INT M* MIN-INT FM/MOD -> 0 MIN-INT }T +T{ MIN-INT MAX-INT M* MIN-INT FM/MOD -> 0 MAX-INT }T +T{ MIN-INT MAX-INT M* MAX-INT FM/MOD -> 0 MIN-INT }T +T{ MAX-INT MAX-INT M* MAX-INT FM/MOD -> 0 MAX-INT }T + +T{ 0 S>D 1 SM/REM -> 0 0 }T +T{ 1 S>D 1 SM/REM -> 0 1 }T +T{ 2 S>D 1 SM/REM -> 0 2 }T +T{ -1 S>D 1 SM/REM -> 0 -1 }T +T{ -2 S>D 1 SM/REM -> 0 -2 }T +T{ 0 S>D -1 SM/REM -> 0 0 }T +T{ 1 S>D -1 SM/REM -> 0 -1 }T +T{ 2 S>D -1 SM/REM -> 0 -2 }T +T{ -1 S>D -1 SM/REM -> 0 1 }T +T{ -2 S>D -1 SM/REM -> 0 2 }T +T{ 2 S>D 2 SM/REM -> 0 1 }T +T{ -1 S>D -1 SM/REM -> 0 1 }T +T{ -2 S>D -2 SM/REM -> 0 1 }T +T{ 7 S>D 3 SM/REM -> 1 2 }T +T{ 7 S>D -3 SM/REM -> 1 -2 }T +T{ -7 S>D 3 SM/REM -> -1 -2 }T +T{ -7 S>D -3 SM/REM -> -1 2 }T +T{ MAX-INT S>D 1 SM/REM -> 0 MAX-INT }T +T{ MIN-INT S>D 1 SM/REM -> 0 MIN-INT }T +T{ MAX-INT S>D MAX-INT SM/REM -> 0 1 }T +T{ MIN-INT S>D MIN-INT SM/REM -> 0 1 }T +T{ 1S 1 4 SM/REM -> 3 MAX-INT }T +T{ 2 MIN-INT M* 2 SM/REM -> 0 MIN-INT }T +T{ 2 MIN-INT M* MIN-INT SM/REM -> 0 2 }T +T{ 2 MAX-INT M* 2 SM/REM -> 0 MAX-INT }T +T{ 2 MAX-INT M* MAX-INT SM/REM -> 0 2 }T +T{ MIN-INT MIN-INT M* MIN-INT SM/REM -> 0 MIN-INT }T +T{ MIN-INT MAX-INT M* MIN-INT SM/REM -> 0 MAX-INT }T +T{ MIN-INT MAX-INT M* MAX-INT SM/REM -> 0 MIN-INT }T +T{ MAX-INT MAX-INT M* MAX-INT SM/REM -> 0 MAX-INT }T + + \ T{ 0 0 1 UM/MOD -> 0 0 }T \ T{ 1 0 1 UM/MOD -> 0 1 }T \ T{ 1 0 2 UM/MOD -> 1 0 }T @@ -418,133 +419,133 @@ T{ MID-UINT+1 1 RSHIFT MID-UINT+1 OR 2 * -> MID-UINT+1 }T \ T{ MAX-UINT 2 UM* 2 UM/MOD -> 0 MAX-UINT }T \ T{ MAX-UINT 2 UM* MAX-UINT UM/MOD -> 0 2 }T \ T{ MAX-UINT MAX-UINT UM* MAX-UINT UM/MOD -> 0 MAX-UINT }T -\ -\ : IFFLOORED -\ [ -3 2 / -2 = INVERT ] LITERAL IF POSTPONE \ THEN ; -\ -\ : IFSYM -\ [ -3 2 / -1 = INVERT ] LITERAL IF POSTPONE \ THEN ; -\ -\ \ THE SYSTEM MIGHT DO EITHER FLOORED OR SYMMETRIC DIVISION. -\ \ SINCE WE HAVE ALREADY TESTED M*, FM/MOD, AND SM/REM WE CAN USE THEM IN TEST -\ -\ IFFLOORED : T/MOD >R S>D R> FM/MOD ; -\ IFFLOORED : T/ T/MOD SWAP DROP ; -\ IFFLOORED : TMOD T/MOD DROP ; -\ IFFLOORED : T*/MOD >R M* R> FM/MOD ; -\ IFFLOORED : T*/ T*/MOD SWAP DROP ; -\ IFSYM : T/MOD >R S>D R> SM/REM ; -\ IFSYM : T/ T/MOD SWAP DROP ; -\ IFSYM : TMOD T/MOD DROP ; -\ IFSYM : T*/MOD >R M* R> SM/REM ; -\ IFSYM : T*/ T*/MOD SWAP DROP ; -\ -\ T{ 0 1 /MOD -> 0 1 T/MOD }T -\ T{ 1 1 /MOD -> 1 1 T/MOD }T -\ T{ 2 1 /MOD -> 2 1 T/MOD }T -\ T{ -1 1 /MOD -> -1 1 T/MOD }T -\ T{ -2 1 /MOD -> -2 1 T/MOD }T -\ T{ 0 -1 /MOD -> 0 -1 T/MOD }T -\ T{ 1 -1 /MOD -> 1 -1 T/MOD }T -\ T{ 2 -1 /MOD -> 2 -1 T/MOD }T -\ T{ -1 -1 /MOD -> -1 -1 T/MOD }T -\ T{ -2 -1 /MOD -> -2 -1 T/MOD }T -\ T{ 2 2 /MOD -> 2 2 T/MOD }T -\ T{ -1 -1 /MOD -> -1 -1 T/MOD }T -\ T{ -2 -2 /MOD -> -2 -2 T/MOD }T -\ T{ 7 3 /MOD -> 7 3 T/MOD }T -\ T{ 7 -3 /MOD -> 7 -3 T/MOD }T -\ T{ -7 3 /MOD -> -7 3 T/MOD }T -\ T{ -7 -3 /MOD -> -7 -3 T/MOD }T -\ T{ MAX-INT 1 /MOD -> MAX-INT 1 T/MOD }T -\ T{ MIN-INT 1 /MOD -> MIN-INT 1 T/MOD }T -\ T{ MAX-INT MAX-INT /MOD -> MAX-INT MAX-INT T/MOD }T -\ T{ MIN-INT MIN-INT /MOD -> MIN-INT MIN-INT T/MOD }T -\ -\ T{ 0 1 / -> 0 1 T/ }T -\ T{ 1 1 / -> 1 1 T/ }T -\ T{ 2 1 / -> 2 1 T/ }T -\ T{ -1 1 / -> -1 1 T/ }T -\ T{ -2 1 / -> -2 1 T/ }T -\ T{ 0 -1 / -> 0 -1 T/ }T -\ T{ 1 -1 / -> 1 -1 T/ }T -\ T{ 2 -1 / -> 2 -1 T/ }T -\ T{ -1 -1 / -> -1 -1 T/ }T -\ T{ -2 -1 / -> -2 -1 T/ }T -\ T{ 2 2 / -> 2 2 T/ }T -\ T{ -1 -1 / -> -1 -1 T/ }T -\ T{ -2 -2 / -> -2 -2 T/ }T -\ T{ 7 3 / -> 7 3 T/ }T -\ T{ 7 -3 / -> 7 -3 T/ }T -\ T{ -7 3 / -> -7 3 T/ }T -\ T{ -7 -3 / -> -7 -3 T/ }T -\ T{ MAX-INT 1 / -> MAX-INT 1 T/ }T -\ T{ MIN-INT 1 / -> MIN-INT 1 T/ }T -\ T{ MAX-INT MAX-INT / -> MAX-INT MAX-INT T/ }T -\ T{ MIN-INT MIN-INT / -> MIN-INT MIN-INT T/ }T -\ -\ T{ 0 1 MOD -> 0 1 TMOD }T -\ T{ 1 1 MOD -> 1 1 TMOD }T -\ T{ 2 1 MOD -> 2 1 TMOD }T -\ T{ -1 1 MOD -> -1 1 TMOD }T -\ T{ -2 1 MOD -> -2 1 TMOD }T -\ T{ 0 -1 MOD -> 0 -1 TMOD }T -\ T{ 1 -1 MOD -> 1 -1 TMOD }T -\ T{ 2 -1 MOD -> 2 -1 TMOD }T -\ T{ -1 -1 MOD -> -1 -1 TMOD }T -\ T{ -2 -1 MOD -> -2 -1 TMOD }T -\ T{ 2 2 MOD -> 2 2 TMOD }T -\ T{ -1 -1 MOD -> -1 -1 TMOD }T -\ T{ -2 -2 MOD -> -2 -2 TMOD }T -\ T{ 7 3 MOD -> 7 3 TMOD }T -\ T{ 7 -3 MOD -> 7 -3 TMOD }T -\ T{ -7 3 MOD -> -7 3 TMOD }T -\ T{ -7 -3 MOD -> -7 -3 TMOD }T -\ T{ MAX-INT 1 MOD -> MAX-INT 1 TMOD }T -\ T{ MIN-INT 1 MOD -> MIN-INT 1 TMOD }T -\ T{ MAX-INT MAX-INT MOD -> MAX-INT MAX-INT TMOD }T -\ T{ MIN-INT MIN-INT MOD -> MIN-INT MIN-INT TMOD }T -\ -\ T{ 0 2 1 */ -> 0 2 1 T*/ }T -\ T{ 1 2 1 */ -> 1 2 1 T*/ }T -\ T{ 2 2 1 */ -> 2 2 1 T*/ }T -\ T{ -1 2 1 */ -> -1 2 1 T*/ }T -\ T{ -2 2 1 */ -> -2 2 1 T*/ }T -\ T{ 0 2 -1 */ -> 0 2 -1 T*/ }T -\ T{ 1 2 -1 */ -> 1 2 -1 T*/ }T -\ T{ 2 2 -1 */ -> 2 2 -1 T*/ }T -\ T{ -1 2 -1 */ -> -1 2 -1 T*/ }T -\ T{ -2 2 -1 */ -> -2 2 -1 T*/ }T -\ T{ 2 2 2 */ -> 2 2 2 T*/ }T -\ T{ -1 2 -1 */ -> -1 2 -1 T*/ }T -\ T{ -2 2 -2 */ -> -2 2 -2 T*/ }T -\ T{ 7 2 3 */ -> 7 2 3 T*/ }T -\ T{ 7 2 -3 */ -> 7 2 -3 T*/ }T -\ T{ -7 2 3 */ -> -7 2 3 T*/ }T -\ T{ -7 2 -3 */ -> -7 2 -3 T*/ }T -\ T{ MAX-INT 2 MAX-INT */ -> MAX-INT 2 MAX-INT T*/ }T -\ T{ MIN-INT 2 MIN-INT */ -> MIN-INT 2 MIN-INT T*/ }T -\ -\ T{ 0 2 1 */MOD -> 0 2 1 T*/MOD }T -\ T{ 1 2 1 */MOD -> 1 2 1 T*/MOD }T -\ T{ 2 2 1 */MOD -> 2 2 1 T*/MOD }T -\ T{ -1 2 1 */MOD -> -1 2 1 T*/MOD }T -\ T{ -2 2 1 */MOD -> -2 2 1 T*/MOD }T -\ T{ 0 2 -1 */MOD -> 0 2 -1 T*/MOD }T -\ T{ 1 2 -1 */MOD -> 1 2 -1 T*/MOD }T -\ T{ 2 2 -1 */MOD -> 2 2 -1 T*/MOD }T -\ T{ -1 2 -1 */MOD -> -1 2 -1 T*/MOD }T -\ T{ -2 2 -1 */MOD -> -2 2 -1 T*/MOD }T -\ T{ 2 2 2 */MOD -> 2 2 2 T*/MOD }T -\ T{ -1 2 -1 */MOD -> -1 2 -1 T*/MOD }T -\ T{ -2 2 -2 */MOD -> -2 2 -2 T*/MOD }T -\ T{ 7 2 3 */MOD -> 7 2 3 T*/MOD }T -\ T{ 7 2 -3 */MOD -> 7 2 -3 T*/MOD }T -\ T{ -7 2 3 */MOD -> -7 2 3 T*/MOD }T -\ T{ -7 2 -3 */MOD -> -7 2 -3 T*/MOD }T -\ T{ MAX-INT 2 MAX-INT */MOD -> MAX-INT 2 MAX-INT T*/MOD }T -\ T{ MIN-INT 2 MIN-INT */MOD -> MIN-INT 2 MIN-INT T*/MOD }T -\ + +: IFFLOORED + [ -3 2 / -2 = INVERT ] LITERAL IF POSTPONE \ THEN ; + +: IFSYM + [ -3 2 / -1 = INVERT ] LITERAL IF POSTPONE \ THEN ; + +\ THE SYSTEM MIGHT DO EITHER FLOORED OR SYMMETRIC DIVISION. +\ SINCE WE HAVE ALREADY TESTED M*, FM/MOD, AND SM/REM WE CAN USE THEM IN TEST + +IFFLOORED : T/MOD >R S>D R> FM/MOD ; +IFFLOORED : T/ T/MOD SWAP DROP ; +IFFLOORED : TMOD T/MOD DROP ; +IFFLOORED : T*/MOD >R M* R> FM/MOD ; +IFFLOORED : T*/ T*/MOD SWAP DROP ; +IFSYM : T/MOD >R S>D R> SM/REM ; +IFSYM : T/ T/MOD SWAP DROP ; +IFSYM : TMOD T/MOD DROP ; +IFSYM : T*/MOD >R M* R> SM/REM ; +IFSYM : T*/ T*/MOD SWAP DROP ; + +T{ 0 1 /MOD -> 0 1 T/MOD }T +T{ 1 1 /MOD -> 1 1 T/MOD }T +T{ 2 1 /MOD -> 2 1 T/MOD }T +T{ -1 1 /MOD -> -1 1 T/MOD }T +T{ -2 1 /MOD -> -2 1 T/MOD }T +T{ 0 -1 /MOD -> 0 -1 T/MOD }T +T{ 1 -1 /MOD -> 1 -1 T/MOD }T +T{ 2 -1 /MOD -> 2 -1 T/MOD }T +T{ -1 -1 /MOD -> -1 -1 T/MOD }T +T{ -2 -1 /MOD -> -2 -1 T/MOD }T +T{ 2 2 /MOD -> 2 2 T/MOD }T +T{ -1 -1 /MOD -> -1 -1 T/MOD }T +T{ -2 -2 /MOD -> -2 -2 T/MOD }T +T{ 7 3 /MOD -> 7 3 T/MOD }T +T{ 7 -3 /MOD -> 7 -3 T/MOD }T +T{ -7 3 /MOD -> -7 3 T/MOD }T +T{ -7 -3 /MOD -> -7 -3 T/MOD }T +T{ MAX-INT 1 /MOD -> MAX-INT 1 T/MOD }T +T{ MIN-INT 1 /MOD -> MIN-INT 1 T/MOD }T +T{ MAX-INT MAX-INT /MOD -> MAX-INT MAX-INT T/MOD }T +T{ MIN-INT MIN-INT /MOD -> MIN-INT MIN-INT T/MOD }T + +T{ 0 1 / -> 0 1 T/ }T +T{ 1 1 / -> 1 1 T/ }T +T{ 2 1 / -> 2 1 T/ }T +T{ -1 1 / -> -1 1 T/ }T +T{ -2 1 / -> -2 1 T/ }T +T{ 0 -1 / -> 0 -1 T/ }T +T{ 1 -1 / -> 1 -1 T/ }T +T{ 2 -1 / -> 2 -1 T/ }T +T{ -1 -1 / -> -1 -1 T/ }T +T{ -2 -1 / -> -2 -1 T/ }T +T{ 2 2 / -> 2 2 T/ }T +T{ -1 -1 / -> -1 -1 T/ }T +T{ -2 -2 / -> -2 -2 T/ }T +T{ 7 3 / -> 7 3 T/ }T +T{ 7 -3 / -> 7 -3 T/ }T +T{ -7 3 / -> -7 3 T/ }T +T{ -7 -3 / -> -7 -3 T/ }T +T{ MAX-INT 1 / -> MAX-INT 1 T/ }T +T{ MIN-INT 1 / -> MIN-INT 1 T/ }T +T{ MAX-INT MAX-INT / -> MAX-INT MAX-INT T/ }T +T{ MIN-INT MIN-INT / -> MIN-INT MIN-INT T/ }T + +T{ 0 1 MOD -> 0 1 TMOD }T +T{ 1 1 MOD -> 1 1 TMOD }T +T{ 2 1 MOD -> 2 1 TMOD }T +T{ -1 1 MOD -> -1 1 TMOD }T +T{ -2 1 MOD -> -2 1 TMOD }T +T{ 0 -1 MOD -> 0 -1 TMOD }T +T{ 1 -1 MOD -> 1 -1 TMOD }T +T{ 2 -1 MOD -> 2 -1 TMOD }T +T{ -1 -1 MOD -> -1 -1 TMOD }T +T{ -2 -1 MOD -> -2 -1 TMOD }T +T{ 2 2 MOD -> 2 2 TMOD }T +T{ -1 -1 MOD -> -1 -1 TMOD }T +T{ -2 -2 MOD -> -2 -2 TMOD }T +T{ 7 3 MOD -> 7 3 TMOD }T +T{ 7 -3 MOD -> 7 -3 TMOD }T +T{ -7 3 MOD -> -7 3 TMOD }T +T{ -7 -3 MOD -> -7 -3 TMOD }T +T{ MAX-INT 1 MOD -> MAX-INT 1 TMOD }T +T{ MIN-INT 1 MOD -> MIN-INT 1 TMOD }T +T{ MAX-INT MAX-INT MOD -> MAX-INT MAX-INT TMOD }T +T{ MIN-INT MIN-INT MOD -> MIN-INT MIN-INT TMOD }T + +T{ 0 2 1 */ -> 0 2 1 T*/ }T +T{ 1 2 1 */ -> 1 2 1 T*/ }T +T{ 2 2 1 */ -> 2 2 1 T*/ }T +T{ -1 2 1 */ -> -1 2 1 T*/ }T +T{ -2 2 1 */ -> -2 2 1 T*/ }T +T{ 0 2 -1 */ -> 0 2 -1 T*/ }T +T{ 1 2 -1 */ -> 1 2 -1 T*/ }T +T{ 2 2 -1 */ -> 2 2 -1 T*/ }T +T{ -1 2 -1 */ -> -1 2 -1 T*/ }T +T{ -2 2 -1 */ -> -2 2 -1 T*/ }T +T{ 2 2 2 */ -> 2 2 2 T*/ }T +T{ -1 2 -1 */ -> -1 2 -1 T*/ }T +T{ -2 2 -2 */ -> -2 2 -2 T*/ }T +T{ 7 2 3 */ -> 7 2 3 T*/ }T +T{ 7 2 -3 */ -> 7 2 -3 T*/ }T +T{ -7 2 3 */ -> -7 2 3 T*/ }T +T{ -7 2 -3 */ -> -7 2 -3 T*/ }T +T{ MAX-INT 2 MAX-INT */ -> MAX-INT 2 MAX-INT T*/ }T +T{ MIN-INT 2 MIN-INT */ -> MIN-INT 2 MIN-INT T*/ }T + +T{ 0 2 1 */MOD -> 0 2 1 T*/MOD }T +T{ 1 2 1 */MOD -> 1 2 1 T*/MOD }T +T{ 2 2 1 */MOD -> 2 2 1 T*/MOD }T +T{ -1 2 1 */MOD -> -1 2 1 T*/MOD }T +T{ -2 2 1 */MOD -> -2 2 1 T*/MOD }T +T{ 0 2 -1 */MOD -> 0 2 -1 T*/MOD }T +T{ 1 2 -1 */MOD -> 1 2 -1 T*/MOD }T +T{ 2 2 -1 */MOD -> 2 2 -1 T*/MOD }T +T{ -1 2 -1 */MOD -> -1 2 -1 T*/MOD }T +T{ -2 2 -1 */MOD -> -2 2 -1 T*/MOD }T +T{ 2 2 2 */MOD -> 2 2 2 T*/MOD }T +T{ -1 2 -1 */MOD -> -1 2 -1 T*/MOD }T +T{ -2 2 -2 */MOD -> -2 2 -2 T*/MOD }T +T{ 7 2 3 */MOD -> 7 2 3 T*/MOD }T +T{ 7 2 -3 */MOD -> 7 2 -3 T*/MOD }T +T{ -7 2 3 */MOD -> -7 2 3 T*/MOD }T +T{ -7 2 -3 */MOD -> -7 2 -3 T*/MOD }T +T{ MAX-INT 2 MAX-INT */MOD -> MAX-INT 2 MAX-INT T*/MOD }T +T{ MIN-INT 2 MIN-INT */MOD -> MIN-INT 2 MIN-INT T*/MOD }T + \ ------------------------------------------------------------------------ ." TESTING HERE , @ ! CELL+ CELLS C, C@ C! CHARS 2@ 2! ALIGN ALIGNED +! ALLOT" CR @@ -651,7 +652,7 @@ HERE 3 C, CHAR G C, CHAR T C, CHAR 2 C, CONSTANT GT2STRING \ ( HOW TO SEARCH FOR NON-EXISTENT WORD? ) T{ : GT3 GT2 LITERAL ; -> }T T{ GT3 -> ' GT1 }T -\ T{ GT1STRING COUNT -> GT1STRING CHAR+ 3 }T +T{ GT1STRING COUNT -> GT1STRING CHAR+ 3 }T T{ : GT4 POSTPONE GT1 ; IMMEDIATE -> }T T{ : GT5 GT4 ; -> }T