Example #1
0
def make_F3(cond, c, invert=False, v=False):
  # v = True -> PC to be stored in register R15
  assert 0 <= cond < 0x111, repr(cond)
  assert 0 <= c < 0x10, repr(c)
  assert bool(invert) == invert, repr(invert)
  assert bool(v) == v, repr(v)
  return bint(
    (0b11 << 30) + # set p, q
    (v << 28) +
    (invert << 27) +
    (cond << 24) +
    c
    )
Example #2
0
def make_F0(u, op, a, b, c):
  assert bool(u) == u, repr(u)
  assert ops['Mov'] <= op <= ops['Div'], repr(op)
  assert 0 <= a < 0x10, repr(a)
  assert 0 <= b < 0x10, repr(b)
  assert 0 <= c < 0x10, repr(c)
  return bint(
    (u << 29) +
    (a << 24) +
    (b << 20) +
    (op << 16) +
    c
    )
Example #3
0
def make_F2(u, v, a, b, offset):
  assert bool(u) == u, repr(u)
  assert bool(v) == v, repr(v)
  assert 0 <= a < 0x10, repr(a)
  assert 0 <= b < 0x10, repr(b)
  assert 0 <= abs(offset) < 2**20, repr(offset)
  return bint(
    (1 << 31) + 
    (u << 29) +
    (v << 28) +
    (a << 24) +
    (b << 20) +
    signed(offset, 20)
    )
Example #4
0
def make_F1(u, v, op, a, b, K):
  assert bool(u) == u, repr(u)
  assert bool(v) == v, repr(v)
  assert ops['Mov'] <= op <= ops['Div'], repr(op)
  assert 0 <= a < 0x10, repr(a)
  assert 0 <= b < 0x10, repr(b)
  assert 0 <= abs(K) < 2**16, repr(K)
  return bint(
    (1 << 30) + # set q
    (u << 29) +
    (v << 28) +
    (a << 24) +
    (b << 20) +
    (op << 16) +
    signed(K)
    )
Example #5
0
def dis(n):
  '''
  Take an integer and return a human-readable string description of the
  assembly instruction.
  '''
  IR = bint(n)[32:0]
  p, q = IR[31], IR[30]
  if not p:
    if not q:
      return dis_F0(IR)
    return dis_F1(IR)
  if not q:
    return dis_F2(IR)
  if not IR[29]:
    return dis_F3(IR)
  return dis_F3imm(IR)