diff --git a/common/base_tests.fs b/common/base_tests.fs index c8a3f09..c414990 100644 --- a/common/base_tests.fs +++ b/common/base_tests.fs @@ -129,3 +129,12 @@ e: test-?dup 0 ?dup 0 =assert depth 0 =assert ;e + +e: test-lshift + $1234 4 lshift $12340 =assert +;e + +e: test-rshift + $1234 4 rshift $123 =assert + -1 cell 8 * 1- rshift 1 =assert +;e diff --git a/common/opcodes.h b/common/opcodes.h index 011ebfc..bfa55ca 100644 --- a/common/opcodes.h +++ b/common/opcodes.h @@ -82,7 +82,7 @@ typedef struct { tos = (ucell_t) w / (ucell_t) tos) \ X("*/MOD", SSMOD, SSMOD_FUNC) \ Y(LSHIFT, tos = (*sp-- << tos)) \ - Y(RSHIFT, tos = (*sp-- >> tos)) \ + Y(RSHIFT, tos = (((ucell_t) *sp--) >> tos)) \ Y(AND, tos &= *sp--) \ Y(OR, tos |= *sp--) \ Y(XOR, tos ^= *sp--) \