Binary manipulation in Forth #74
-
Are there any words to logically shift binary similar to C's >> & << in Forth? If not would they be difficult to create? Presumably assembler would have these commands. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
For single-cell integers there are For double-cell integers there are |
Beta Was this translation helpful? Give feedback.
For single-cell integers there are
lshift
, for shift left,rshift
, for shift right (i.e unsigned shift right), andarshift
, for arithmetic shift right (i.e. signed shift right).For double-cell integers there are
2lshift
, for shift left, and2rshift
, for shift right (i.e. unsigned shift right). There is also2arshift
, but I found a significant bug when I was testing it this morning, so it will need more work.