Example #1
0
    def test_length():
        res = bitmap.zero
        res = bitmap.push(res, (0, 1))
        res = bitmap.push(res, (38, 7))
        x = pbinary.new(ber.Length,source=ptypes.prov.string(bitmap.data(res)))
        print(x.l)
        print(x.int())

        res = bitmap.zero
        res = bitmap.push(res, (0x81,8))
        res = bitmap.push(res, (0xc9,8))
        x = pbinary.new(ber.Length,source=ptypes.prov.string(bitmap.data(res)))
        print(x.l)
        print(x.int())
Example #2
0
    def test_tag():
        res = bitmap.new(0x1e, 5)

        res = bitmap.zero
        res = bitmap.push(res, (0x1f, 5))
        res = bitmap.push(res, (0x1, 1))
        res = bitmap.push(res, (0x10, 7))
        res = bitmap.push(res, (0x1, 0))
        res = bitmap.push(res, (0x0, 7))
        x = pbinary.new(ber.Tag, source=ptypes.prov.string(bitmap.data(res)))
        print x.l
        print x['TagLong'][0]
        print x.int()
        print int(x['TagLong'])
Example #3
0
 def data_padding_reversed():
     res = bitmap.new(0x123, 12)
     data = bitmap.data(res, reversed=1)
     if tohex(data) == '3012':
         raise Success
Example #4
0
 def data_padding():
     res = bitmap.new(0x123, 12)
     data = bitmap.data(res, reversed=0)
     if tohex(data) == '1230':
         raise Success
Example #5
0
                x *= -1
            else:
                x &= mask

        result.append(x)

    return special, tuple(result)


def decode(string, *args, **kwds):
    return consume(iter(string), *args, **kwds)


if True:
    a = bitmap.new(0x0b058547, 32)
    b = bitmap.data(a)

    print bitmap.string(a)
    j, (instr_index, ) = decode(b)
    print hex(instr_index << 2)

    #RAM:8C161580 0B 05 85 47                             j       loc_9FC7A134     # [note] simulator branches to 8c16151c
    #AC 82 00 00
    #ROM:9FC7A138 14 40 FF D0                             bnez    $v0, loc_9FC7A07C
    #RAM:8C161560 14 40 FF D0                             bnez    $v0, loc_9FC7A0BC  # 8c1614a4 #8c161564

if True:
    a = bitmap.new(0x1440ffd0, 32)
    b = bitmap.data(a)

    addr, (bne, (rs, rt, offset)) = 0x8c161560, decode(b, (5, 5, -16))
Example #6
0
 def data_padding_reversed():
     res = bitmap.new(0x123, 12)
     data = bitmap.data(res, reversed=1)
     if data.encode('hex') == '3012':
         raise Success
Example #7
0
 def data_padding():
     res = bitmap.new(0x123, 12)
     data = bitmap.data(res, reversed=0)
     if data.encode('hex') == '1230':
         raise Success
Example #8
0
 def data_padding_reversed():
     res = bitmap.new(0x123, 12)
     data = bitmap.data(res, reversed=1)
     if data.encode('hex') == '3012':
         raise Success
Example #9
0
 def data_padding():
     res = bitmap.new(0x123, 12)
     data = bitmap.data(res, reversed=0)
     if data.encode('hex') == '1230':
         raise Success
Example #10
0
            if x & sf:
                x = x & mask
                x *= -1
            else:
                x &= mask

        result.append(x)

    return special,tuple(result)

def decode(string, *args, **kwds):
    return consume( iter(string), *args, **kwds )

if True:
    a = bitmap.new(0x0b058547, 32)
    b = bitmap.data(a)

    print bitmap.string(a)
    j,(instr_index,) = decode(b)
    print hex(instr_index<<2)

    #RAM:8C161580 0B 05 85 47                             j       loc_9FC7A134     # [note] simulator branches to 8c16151c
    #AC 82 00 00
    #ROM:9FC7A138 14 40 FF D0                             bnez    $v0, loc_9FC7A07C
    #RAM:8C161560 14 40 FF D0                             bnez    $v0, loc_9FC7A0BC  # 8c1614a4 #8c161564

if True:
    a = bitmap.new(0x1440ffd0, 32)
    b = bitmap.data(a)

    addr,(bne,(rs,rt,offset)) = 0x8c161560, decode(b, (5,5,-16))