def assy_COP(self): return ([ assy.Arg_verbatim("%d" % self['cop']), assy.Arg_verbatim("%d" % self['opc1']), self.assy_Rt(), assy.Arg_verbatim("CR%d" % self['crn']), assy.Arg_verbatim("CR%d" % self['crm']), assy.Arg_verbatim("{%d}" % self['opc2']), ])
def assy_Pzy(self): d = self.lang.m[self.hi] self.hi += 1 return [ assy.Arg_dst(self.lang.m, d), assy.Arg_verbatim("Y"), ]
def assy_Indy(self): d = self.lang.m[self.hi] self.hi += 1 return [ assy.Arg_dst(self.lang.m, d, pfx="(", sfx=")"), assy.Arg_verbatim("Y"), ]
def assy_Absy(self): d = self.lang.m.lu16(self.hi) self.hi += 2 return [ assy.Arg_dst(self.lang.m, d), assy.Arg_verbatim("Y"), ]
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 flow_post_arg(pj, ins): z = post_arg.get(ins.dstadr) if z == None: return ins.flow_out.pop(-1) if len(z) <= 1: a = data.Pstruct(pj, ins.hi, ">h", "%d", ".INFIX").hi ins.add_flow(pj, ">", True, a) return l = [] for i in z[1:]: if i[1:] == "A6rel": r = pj.m.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 = pj.m.bu16(ins.hi) if r & 0x8000: r |= 0xffff0000 ins.hi += 2 l.append("0x%08x" % r) elif i == "drel": r = ins.hi + pj.m.bs16(ins.hi) ins.hi += 2 ins.lcmt += " @0x%x\n" % r y = data_double(pj, r) l.append("%g" % y.data[0]) elif i == "brel": r = ins.hi + pj.m.bs16(ins.hi) ins.hi += 2 ins.lcmt += " @0x%x\n" % r y = data_bcd(pj, r); l.append("%x" % y.data[0]) elif i == "lrel": r = ins.hi + pj.m.bs16(ins.hi) ins.hi += 2 ins.lcmt += " @0x%x\n" % r y = data.Pstruct(pj, r, ">L", "%d", ".LONG") l.append("%d" % y.data[0]) elif i == "frel": r = ins.hi + pj.m.bs16(ins.hi) ins.hi += 2 ins.lcmt += " @0x%x\n" % r y = data_float(pj, r) l.append("%g" % y.val) elif i == "bcd": r = pj.m.bu16(ins.hi) y = data.Pstruct(pj, ins.hi, ">H", "%x", ".BCD") l.append("%04x" % r) ins.hi += 2 else: l.append(i) ins.oper.append(assy.Arg_verbatim(pj, "(" + ",".join(l) + ")")) ins.add_flow(pj, True, True, ins.hi)
def assy_cpsr(self): t = "CPSR_" if self['msk'] & 8: t += "f" if self['msk'] & 4: t += "s" if self['msk'] & 2: t += "x" if self['msk'] & 1: t += "c" return assy.Arg_verbatim(t)
def assy_dst(self, cde=True): a = self['adr'] if a & 0x200: a -= 0x400 if self['c']: a += self.lo dd = (a + (1 << 16)) & 0x7fff if not self['d']: if cde: self.dstadr = dd return assy.Arg_dst(self.lang.m, dd) try: d = self.lang.m[dd] y = data.Data(self.lang.m, dd, dd + 1) y.rendered = ".REF\t0x%04x" % d if cde: self.dstadr = d return [assy.Arg_dst(self.lang.m, d), assy.Arg_verbatim("[Via 0x%04x]" % dd)] except mem.MemError: pass if cde: self.dstadr = dd return [assy.Arg_dst(self.lang.m, dd), assy.Arg_verbatim("I")]
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_chn(self): ''' ... ''' chain = { 0x00: "M.MAR", 0x01: "M.DREG_FULL", 0x02: "M.DREG_VAL_PAR", 0x03: "TV.WDR", 0x04: "V.UIR", 0x05: "T.UIR", 0x06: "F.MAR", 0x07: "F.MDREG", 0x08: "F.UIR", 0x09: "S.TYPVAL", 0x0a: "S.UIR", 0x0b: "S.DECODER", 0x0c: "S.MISC", 0x0d: "I.DUMMY", }.get(self['chn'], "%02x" % self['chn']) return assy.Arg_verbatim("{" + chain + ":%02x}" % self['fsm'])
def assy_fsm(self): ''' ... ''' return assy.Arg_verbatim("{%02x}" % self['fsm'])
def assy_vec(self): ''' ... ''' return assy.Arg_verbatim("[0x%x]" % self['vec'])
def assy_Rs(self): typ = self['typ'] rs = self['rs'] return assy.Arg_verbatim("%s,%s" % (["lsl", "lsr", "asr", "ror"][typ], REG[rs]))
def assy_w(self): if (self['w']): return assy.Arg_verbatim("!")
def assy_vrn(self): return assy.Arg_verbatim("[%s]" % REG[self['rn']])
def assy_imm5(self): return assy.Arg_verbatim("#0x%x" % self['imm5'])