def flow_switch(asp, ins): if ins.dstadr != 0x2f38: return ins.flow_out.pop(0) ins += code.Flow(cond="?") asp.set_label(ins.hi, "break_%04x" % ins.lo) y = data.Const(asp, ins.lo - 2, ins.lo) ncase = asp.bu16(ins.lo - 2) y.typ = ".NCASE" y.fmt = "%d" % ncase cs = switches.get(ins.lo) if cs is None: cs = {} a = ins.lo - 2 for i in range(ncase): a -= 2 ct = cs.get(i) if ct is None: ct = "_%d" % i w = data.Const(asp, a, a + 2) z = asp.bs16(a) w.typ = ".CASE" w.fmt = "0x%x, %d" % (i, z) w.fmt += ", 0x%04x" % (ins.hi + z) ins += code.Jump(cond="0x%x" % i, to=ins.hi + z) if z < 0: asp.set_label(ins.hi + z, ".case_%04x_%s" % (ins.lo, ct))
def flow_post_arg(asp, ins): z = post_arg.get(ins.dstadr) if z is None: return ins.flow_out.pop(-1) if len(z) <= 1: a = data.Pstruct(asp, ins.hi, ">h", "%d", ".INFIX").hi ins += code.Jump(to=a) return l = [] for i in z[1:]: if i[1:] == "A6rel": r = asp.bs16(ins.hi) ins.hi += 2 if r < 0: l.append("(A6-0x%x)" % -r) else: l.append("(A6+0x%x)" % r) elif i[1:] == "abs": r = asp.bu16(ins.hi) if r & 0x8000: r |= 0xffff0000 ins.hi += 2 l.append("0x%08x" % r) elif i == "drel": r = ins.hi + asp.bs16(ins.hi) ins.hi += 2 ins.lcmt += " @0x%x\n" % r y = data_double(asp, r) l.append("%g" % y.data[0]) elif i == "brel": r = ins.hi + asp.bs16(ins.hi) ins.hi += 2 ins.lcmt += " @0x%x\n" % r y = data_bcd(asp, r) l.append("%x" % y.data[0]) elif i == "lrel": r = ins.hi + asp.bs16(ins.hi) ins.hi += 2 ins.lcmt += " @0x%x\n" % r if not asp.occupied(r): data.Pstruct(asp, r, ">L", "%d", ".LONG") l.append("%d" % asp.bu32(r)) elif i == "frel": r = ins.hi + asp.bs16(ins.hi) ins.hi += 2 ins.lcmt += " @0x%x\n" % r y = data_float(asp, r) l.append("%g" % y.val) elif i == "bcd": r = asp.bu16(ins.hi) # y = data.Pstruct(asp, ins.hi, ">H", "%x", ".BCD") l.append("%04x" % r) ins.hi += 2 else: l.append(i) ins.oper.append(assy.Arg_verbatim("(" + ",".join(l) + ")")) ins += code.Flow()
def fc_arg(asp, ins, arg): ins.flow_out.pop(-1) for c in arg: b = asp[ins.hi] ins.hi += 1 if c == "T": try: y = wgstring(asp, b) ins.oper.append(assy.Arg_verbatim(y.txt)) except mem.MemError: ins.oper.append(assy.Arg_verbatim("T@0x%x" % b)) elif c == "F": ins.oper.append(assy.Arg_verbatim("FP@0x%x" % b)) try: x = asp[b] y = data.Const(asp, b, b + 4) y.typ = ".FP" except mem.MemError: pass elif c == "P": ins.oper.append(assy.Arg_verbatim("P@0x%x" % b)) else: assert False, "BAD fc_arg spec: " + c ins += code.Flow()
def assy_vect(self): if self.lang.trap_returns.get(self['vect']): self += code.Flow() return "#%d" % self['vect']
def assy_C(self): return cond = self['cond'] self.mne += CC[cond] if self['cond'] != 14: self += code.Flow(cond="?")
def args_done(self): if 'cond' in self.lim[-1].flds: cond = self['cond'] self.mne += CC[cond] if self['cond'] != 14: self += code.Flow(cond="?")