Example #1
0
def test_decoder_007():
  c = b'\x81\xc3\xe0\x08'
  i = cpu.disassemble(c)
  assert i.mnemonic == 'jmpl'
  assert str(i.operands[0]) == '(o7+0x8)'
  assert i.operands[1].ref == 'g0'
  assert str(i) == 'retl'
Example #2
0
def test_decoder_005():
  c = b'\xb0\x10\x00\x01'
  i = cpu.disassemble(c)
  assert i.mnemonic == 'or'
  assert i.operands[0].ref == 'g0'
  assert i.operands[1].ref == 'g1'
  assert i.operands[2].ref == 'i0'
  assert str(i) == 'mov     %g1, %i0'
Example #3
0
def test_decoder_003():
  c = b'\x82\x00\x60\x42'
  i = cpu.disassemble(c)
  assert i.mnemonic == 'add'
  assert i.operands[0].ref == 'g1'
  assert i.operands[1] == 0x42
  assert i.operands[2].ref == 'g1'
  assert str(i) == 'inc     66, %g1'
Example #4
0
def test_decoder_000():
  c = b'\x9d\xe3\xbf\x98'
  i = cpu.disassemble(c)
  assert i.mnemonic == 'save'
  assert i.operands[0].ref == 'sp'
  assert i.operands[1] == -104
  assert i.operands[2].ref == 'sp'
  assert str(i) == 'save    %sp, -104, %sp'
Example #5
0
def test_decoder_004():
  c = b'\xc2\x27\xbf\xfc'
  i = cpu.disassemble(c)
  assert i.mnemonic == 'st'
  assert i.operands[0].ref == 'g1'
  assert i.operands[1].size == 32
  assert i.operands[1].base.ref == 'fp'
  assert i.operands[1].disp == -4
  assert str(i) == 'st      %g1, [%fp+-4]'
Example #6
0
def test_decoder_009():
    class Symbol(object):
        def __init__(self, s):
            self.s = s

        def __str__(self):
            return self.s

    c = b'\x03\x00\x00\x00'
    i = cpu.disassemble(c)
    i.operands[0] = cpu.slc(cpu.lab(Symbol('foo'), size=32), 10, 22)
    assert str(i) == 'sethi   %hi(foo), %g1'
Example #7
0
 def from_bin(self, in_str, section):
     ''' binary input, in assembly format '''
     self.section = section
     self.offset = in_str.offset
     self.bytelen = 4
     try:
         instr = cpu_v8.disassemble(in_str[in_str.offset:in_str.offset + 4])
     except IOError:
         instr = None
     if instr is None:
         instr = NoneASM()
     self.amoco = instr
     return self
Example #8
0
def test_decoder_008():
  c = b'\x01\x00\x00\x00'
  i = cpu.disassemble(c)
  assert i.mnemonic == 'nop'
  assert str(i) == 'nop     '
Example #9
0
def test_decoder_006():
  c = b'\x81\xe8\x00\x00'
  i = cpu.disassemble(c)
  assert i.mnemonic == 'restore'
  assert str(i) == 'restore'