From 1d4b77fd90e01ef05e90b8136c928b3db1ff6dbd Mon Sep 17 00:00:00 2001 From: Koichi Nakamura Date: Mon, 11 Jan 2021 02:06:11 +0900 Subject: [PATCH] Add shift operations --- bootstrap.fs | 9 ++++++++- planck.xxd | 10 +++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/bootstrap.fs b/bootstrap.fs index 1652ab9..efe108e 100644 --- a/bootstrap.fs +++ b/bootstrap.fs @@ -458,6 +458,9 @@ alias-builtin and & alias-builtin or | alias-builtin xor ^ alias-builtin u< u +alias-builtin lshift ( +alias-builtin rshift ) +alias-builtin arshift % alias-builtin runtime-info_ V \ Rename existing FORTH words @@ -658,6 +661,10 @@ allot-cell : &find! [ ' L , , ] ; \ ( c-addr -- nt ) Throw exception at error \ ( a b c -- (a<=c & c -rot <= and ; +\ arithmetic shift +: 2* 1 lshift ; +: 2/ 1 arshift ; + \ === Conditional Branch === \ if then \ if else then @@ -2465,7 +2472,7 @@ need-defined (read) ' ['] compile [compile] literal + - * /mod / mod negate not and or xor invert within max min abs < > <= >= = <> 0< 0> 0<= 0>= 0= 0<> 1+ 1- - u< u> u<= u>= + u< u> u<= u>= lshift rshift 2* 2/ true false diff --git a/planck.xxd b/planck.xxd index e7b85e9..891f5d4 100644 --- a/planck.xxd +++ b/planck.xxd @@ -80,11 +80,11 @@ 000001f8: 6283 0408 0000 0000 000001fc: f081 0408 013d 0000 =: equal 00000204: 7083 0408 0000 0000 -00000208: fc81 0408 017b 0000 {: shl +00000208: fc81 0408 0128 0000 (: shl 00000210: 7e83 0408 0000 0000 -00000214: 0882 0408 017d 0000 }: shr +00000214: 0882 0408 0129 0000 ): shr 0000021c: 8683 0408 0000 0000 -00000220: 1482 0408 0129 0000 ): sar +00000220: 1482 0408 0125 0000 %: sar 00000228: 8e83 0408 0000 0000 0000022c: 2082 0408 0176 0000 v: argv 00000234: 9683 0408 0000 0000 @@ -174,9 +174,9 @@ 00000370: 585b 39c3 0f94 c00f (equal) popl %eax; popl %ebx; cmpl %eax,%ebx 00000378: b6c0 50ad ff20 0000 setl %al; movzbl %al, %eax; pushl %eax; next; -0000037e: 5958 d3e0 50ad ff20 (shl) popl %ecx; popl %eax; shll %cl,%eax next; +0000037e: 5958 d3e0 50ad ff20 (shl) popl %ecx; popl %eax; shll %cl,%eax;next; -00000386: 5958 d3e8 50ad ff20 (shr) popl %ecx; popl %eax; shrl %cl,%eax next; +00000386: 5958 d3e8 50ad ff20 (shr) popl %ecx; popl %eax; shrl %cl,%eax;next; 0000038e: 5958 d3f8 50ad ff20 (sar) popl %ecx; popl %eax; sarl %cl,%eax; next;