mirror of
https://github.com/mgcaret/of816.git
synced 2024-12-27 04:29:32 +00:00
85 lines
1.7 KiB
Forth
85 lines
1.7 KiB
Forth
testing 7.3.2.2 Bitwise logical operators
|
|
|
|
( WE TRUST 1S, INVERT, AND BITSSET?; WE WILL CONFIRM RSHIFT LATER )
|
|
1S 1 RSHIFT INVERT CONSTANT MSB
|
|
T{ MSB BITSSET? -> 0 0 }T
|
|
|
|
T{ 1 0 LSHIFT -> 1 }T
|
|
T{ 1 1 LSHIFT -> 2 }T
|
|
T{ 1 2 LSHIFT -> 4 }T
|
|
T{ 1 F LSHIFT -> 8000 }T \ BIGGEST GUARANTEED SHIFT
|
|
T{ 1S 1 LSHIFT 1 XOR -> 1S }T
|
|
T{ MSB 1 LSHIFT -> 0 }T
|
|
|
|
T{ 1 0 RSHIFT -> 1 }T
|
|
T{ 1 1 RSHIFT -> 0 }T
|
|
T{ 2 1 RSHIFT -> 1 }T
|
|
T{ 4 2 RSHIFT -> 1 }T
|
|
T{ 8000 F RSHIFT -> 1 }T \ BIGGEST
|
|
T{ MSB 1 RSHIFT MSB AND -> 0 }T \ RSHIFT ZERO FILLS MSBS
|
|
T{ MSB 1 RSHIFT 2* -> MSB }T
|
|
|
|
t{ 1 1 >>a -> 0 }t
|
|
t{ 0 1 >>a -> 0 }t
|
|
t{ 0 invert 1 >> 1 >>a 0< -> false }t
|
|
t{ -1 1 >>a -> -1 }t
|
|
t{ -1 2 >>a -> -1 }t
|
|
t{ -1 4 >>a -> -1 }t
|
|
t{ -2 1 >>a -> -1 }t
|
|
t{ -4 1 >>a -> -2 }t
|
|
|
|
\ << >> are synonyms for lshift and rshift, do abbreviated test
|
|
T{ 1 0 << -> 1 }T
|
|
T{ 1 1 << -> 2 }T
|
|
T{ 1 2 << -> 4 }T
|
|
|
|
T{ 1 0 >> -> 1 }T
|
|
T{ 1 1 >> -> 0 }T
|
|
T{ 2 1 >> -> 1 }T
|
|
T{ 4 2 >> -> 1 }T
|
|
|
|
T{ 0S 2*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