1 /*
2   Arith
3 */
4 
5 #include "arith.h"
6 
7 #include "jump.h"
8 #include "var.h"
9 
10 
logical_shift(word param1,word param2)11 void logical_shift(word param1, word param2)
12 {
13   signed_word bits_to_shift = (signed_word) param2;
14   if(bits_to_shift < 0)
15     store((word) (param1 >> (-bits_to_shift)));
16   else
17     store((word) (param1 << bits_to_shift));
18 }
19 
arithmetic_shift(word param1,word param2)20 void arithmetic_shift(word param1, word param2)
21 {
22   signed_word bits_to_shift = (signed_word) param2;
23   if(bits_to_shift < 0)
24     if(((signed_word) param1) < 0)
25       store((word) (~((signed_word) (~param1) >> (-bits_to_shift))));
26     else
27       store((word) ((signed_word) param1 >> (-bits_to_shift)));
28   else
29     store((word) (param1 << bits_to_shift));
30 }
31