Example #1
0
    def set_bitmap_unsigned():
        x = bitmap.new(0xf000000000000000, 64)
        #x = bitmap.set(x, 60, count=4)
        print(bitmap.string(x))

        y, res = bitmap.shift(x, 4)
        print(res, bitmap.string(y))

        x = bitmap.new(0, 0)
        x = bitmap.push(x, (0x1, 4))
        x = bitmap.push(x, (0x2, 4))
        x = bitmap.push(x, (0x3, 4))
        x = bitmap.push(x, (0x4, 4))
        print(x, bitmap.string(x))

        x = bitmap.new(0, 0)
        x = bitmap.insert(x, (0x1, 4))
        x = bitmap.insert(x, (0x2, 4))
        x = bitmap.insert(x, (0x3, 4))
        x = bitmap.insert(x, (0x4, 4))
        print(x, bitmap.string(x))

        x = bitmap.consumer(b'\x12\x34')
        print(x.consume(4))
        print(x.consume(4))
        print(x.consume(4))
        print(x.consume(4))

        x = bitmap.new(0, 4)
        for i in range(6):
            print(x)
            x = bitmap.add(x, 3)

        for i in range(6):
            print(x)
            x = bitmap.sub(x, 6)

        x = bitmap.new(4, 4)
        print(bitmap.string(bitmap.ror(bitmap.ror(bitmap.ror(x)))))
Example #2
0
    def set_bitmap_unsigned():
        x = bitmap.new(0xf000000000000000,64)
        #x = bitmap.set(x, 60, count=4)
        print bitmap.string(x)

        y,res = bitmap.shift(x, 4)
        print res,bitmap.string(y)

        x = bitmap.new(0,0)
        x = bitmap.push(x, (0x1,4) )
        x = bitmap.push(x, (0x2,4) )
        x = bitmap.push(x, (0x3,4) )
        x = bitmap.push(x, (0x4,4) )
        print x,bitmap.string(x)

        x = bitmap.new(0,0)
        x = bitmap.insert(x, (0x1,4) )
        x = bitmap.insert(x, (0x2,4) )
        x = bitmap.insert(x, (0x3,4) )
        x = bitmap.insert(x, (0x4,4) )
        print x,bitmap.string(x)

        x = bitmap.consumer('\x12\x34')
        print x.consume(4)
        print x.consume(4)
        print x.consume(4)
        print x.consume(4)

        x = bitmap.new(0, 4)
        for i in six.moves.range(6):
            print x
            x = bitmap.add(x, 3)

        for i in six.moves.range(6):
            print x
            x = bitmap.sub(x, 6)

        x = bitmap.new(4,4)
        print bitmap.string(bitmap.ror(bitmap.ror(bitmap.ror(x))))
Example #3
0
 def signed_sub_negative_wrap():
     x = (133, -8)
     res = bitmap.sub(x, 10)
     if res == (123, -8) and bitmap.value(res) == 123:
         raise Success
Example #4
0
 def signed_sub_negative_nowrap():
     x = (156, -8)
     res = bitmap.sub(x, 10)
     if res == (146, -8) and bitmap.value(res) == -110:
         raise Success
Example #5
0
 def signed_sub_positive_nowrap():
     x = (10, -8)
     res = bitmap.sub(x, 5)
     if res == (5, -8) and bitmap.value(res) == 5:
         raise Success
Example #6
0
 def signed_sub_positive_wrap():
     x = (5, -8)
     res = bitmap.sub(x, 10)
     if res == (251, -8) and bitmap.value(res) == -5:
         raise Success
Example #7
0
 def signed_sub_negative_wrap():
     x = (133,-8)
     res = bitmap.sub(x, 10)
     if res == (123,-8) and bitmap.value(res) == 123:
         raise Success
Example #8
0
 def signed_sub_negative_nowrap():
     x = (156,-8)
     res = bitmap.sub(x, 10)
     if res == (146,-8) and bitmap.value(res) == -110:
         raise Success
Example #9
0
 def signed_sub_positive_nowrap():
     x = (10, -8)
     res = bitmap.sub(x, 5)
     if res == (5, -8) and bitmap.value(res) == 5:
         raise Success
Example #10
0
 def signed_sub_positive_wrap():
     x = (5, -8)
     res = bitmap.sub(x, 10)
     if res == (251, -8) and bitmap.value(res) == -5:
         raise Success