From c1da0d2561b27741a6feb73336b0712f5ddc7e97 Mon Sep 17 00:00:00 2001 From: dos-reis Date: Thu, 22 Jul 2010 00:33:05 +0000 Subject: * algebra/data.spad.pamphlet (Byte) [~]: Tidy. (SystemNonNegativeInteger) [~]: Likewise. * interp/g-util.boot: Better expansion of byte operations. --- src/interp/g-opt.boot | 2 +- src/interp/g-util.boot | 32 ++++++++++++++++++++++++++------ 2 files changed, 27 insertions(+), 7 deletions(-) (limited to 'src/interp') diff --git a/src/interp/g-opt.boot b/src/interp/g-opt.boot index 4d598b05..b9705f6b 100644 --- a/src/interp/g-opt.boot +++ b/src/interp/g-opt.boot @@ -473,7 +473,7 @@ $VMsideEffectFreeOperators == MINUSP GREATERP ZEROP ODDP FLOAT_-RADIX FLOAT FLOAT_-SIGN FLOAT_-DIGITS CGREATERP GGREATERP CHAR BOOLE GET BVEC_-GREATER %false %true %and %or %not %peq %ieq %ilt %ile %igt %ige %head %tail %integer? - %beq %blt %ble %bgt %bge %bitand %bitior %bitnot + %beq %blt %ble %bgt %bge %bitand %bitior %bitnot %bcompl %imul %iadd %isub %igcd %ilcm %ipow %imin %imax %ieven? %iodd? %iinc %feq %flt %fle %fgt %fge %fmul %fadd %fsub %fexp %fmin %fmax %float? %fpow %fdiv %fneg %i2f %fminval %fmaxval %fbase %fprec %ftrunc diff --git a/src/interp/g-util.boot b/src/interp/g-util.boot index df6628f9..012a9ccc 100644 --- a/src/interp/g-util.boot +++ b/src/interp/g-util.boot @@ -230,6 +230,20 @@ expandPeq ['%peq,x,y] == expandBefore? ['%before?,x,y] == ['GGREATERP,expandToVMForm y,expandToVMForm x] +-- Byte operations +expandBle ['%ble,x,y] == + expandToVMForm ['%not,['%blt,y,x]] + +expandBgt ['%bgt,x,y] == + expandToVMForm ['%blt,y,x] + +expandBge ['%bge,x,y] == + expandToVMForm ['%not,['%blt,x,y]] + +expandBcompl ['%bcompl,x] == + integer? x => 255 - x + ['_+,256,['LOGNOT,expandToVMForm x]] + -- Integer operations expandIneg ['%ineg,x] == x := expandToVMForm x @@ -237,12 +251,16 @@ expandIneg ['%ineg,x] == ['_-,x] expandIlt ['%ilt,x,y] == - integer? x and x = 0 => ['PLUSP,expandToVMForm y] - integer? y and y = 0 => ['MINUSP,expandToVMForm x] + integer? x and x = 0 => + integer? y => y > 0 + ['PLUSP,expandToVMForm y] + integer? y and y = 0 => + integer? x => x < 0 + ['MINUSP,expandToVMForm x] ['_<,expandToVMForm x,expandToVMForm y] expandIgt ['%igt,x,y] == - expandFlt ['%ilt,y,x] + expandIlt ['%ilt,y,x] expandBitand ['%bitand,x,y] == ['BOOLE,'BOOLE_-AND,expandToVMForm x,expandToVMForm y] @@ -331,9 +349,6 @@ for x in [ -- byte operations ['%beq, :'byteEqual], ['%blt, :'byteLessThan], - ['%ble, :'byteLessEqual], - ['%bgt, :'byteGreaterThan], - ['%bge, :'byteGreaterEqual], -- unary integer operations. ['%iabs, :'ABS], @@ -417,6 +432,11 @@ for x in [ ['%loop, :function expandLoop], ['%return, :function expandReturn], + ['%ble, :function expandBle], + ['%bgt, :function expandBgt], + ['%bge, :function expandBge], + ['%bcompl, :function expandBcompl], + ['%igt, :function expandIgt], ['%ilt, :function expandIlt], ['%ineg, :function expandIneg], -- cgit v1.2.3