Exemple #1
0
	def vectors(self, hi, base=0x0):
		for a in range(0, hi):
			x = const.w32(self.p, base + a * 4)
			if a in m68kvecs:
				x.lcmt(m68kvecs[a])
			if a > 0:
				self.disass(self.p.m.w32(base + a * 4))
Exemple #2
0
def caseW(a):
	x = p.m.b32(a)
	assert (x >> 16) == 0x2100
	l = x & 0xffff
	y = p.m.b16(a + 4)
	assert y == 0x1402
	y = p.m.b32(a + 6)
	z = p.m.b16(y - 2)
	assert z == 0x1e28
	z = cpu.disass(y - 2)
	print("CASE", "l=%d" % l, "y=%x" % y)
	q = dict()
	for i in range (0,l):
		const.w16(p, y + 2 * i)
		t = y + 2 * l + 4 * i
		idx = p.m.b16(y + 2 * i)
		res = p.m.b32(t)
		# XXX: should be .PTR
		x = const.w32(p, t)
		x.lcmt(" case %04x" % idx)
		z.flow("cond", "%d" % i, res)
		cpu.disass(res)
		q[idx]= res
	return q
Exemple #3
0
def caseW(a):
    x = p.m.b32(a)
    assert (x >> 16) == 0x2100
    l = x & 0xffff
    y = p.m.b16(a + 4)
    assert y == 0x1402
    y = p.m.b32(a + 6)
    z = p.m.b16(y - 2)
    assert z == 0x1e28
    z = cpu.disass(y - 2)
    print("CASE", "l=%d" % l, "y=%x" % y)
    q = dict()
    for i in range(0, l):
        const.w16(p, y + 2 * i)
        t = y + 2 * l + 4 * i
        idx = p.m.b16(y + 2 * i)
        res = p.m.b32(t)
        # XXX: should be .PTR
        x = const.w32(p, t)
        x.lcmt(" case %04x" % idx)
        z.flow("cond", "%d" % i, res)
        cpu.disass(res)
        q[idx] = res
    return q
Exemple #4
0
	def do_thumb(self, adr, ins):

		p = self.p	
		iw = p.m.b16(adr)
		# XXX: below needed ?
		ins.oper = list()
		try:
			c = self.thumb_root.find(p, adr, p.m.l16)
		except:
			ins.mne = "???"
			ins.hi = ins.lo + 2
			return
		print("IW %08x %04x" % (adr, iw), c)

		if iw == 0:
			ins.mne = "???"
			ins.hi = ins.lo + 2
			return

		ins.mne = c.spec[0]

		na = adr + (c.width >> 3)

		for i in c.spec[1].split(","):
			if i == "simm11":
				da = self.thumb_field(p, c, adr, i)
				da = da << 1
				if da & 0x0800:
					da -= 4096
				da = da + 4 + adr
				ins.oper.append((da, "0x%08x" % da))
				ins.flow("cond", "T", da)
			elif i == "[SP+imm8l*4]":
				da = self.thumb_field(p, c, adr, "imm8l")
				da = da << 2
				ins.oper.append(("[SP,#0x%x]" % da))
			elif i == "[PC+imm8l*4]":
				da = self.thumb_field(p, c, adr, "imm8l")
				da = da << 2
				da += (adr & ~3) + 4
				ins.oper.append((da, "0x%08x" % da))
				const.w32(p,da)
			elif i == "[Rn+Rm]":
				rn = self.thumb_field(p, c, adr, "Rn")
				rm = self.thumb_field(p, c, adr, "Rm")
				ins.oper.append("[R%d,R%d]" % (rn, rm))
			elif i == "[Rn+imm5]":
				da = self.thumb_field(p, c, adr, "imm5")
				rn = self.thumb_field(p, c, adr, "Rn")
				ins.oper.append("[R%d,#0x%x]" % (rn, da))
			elif i == "[Rn+imm5w*2]":
				da = self.thumb_field(p, c, adr, "imm5w")
				rn = self.thumb_field(p, c, adr, "Rn")
				ins.oper.append("[R%d,#0x%x]" % (rn, da << 1))
			elif i == "[Rn+imm5l*4]":
				da = self.thumb_field(p, c, adr, "imm5l")
				rn = self.thumb_field(p, c, adr, "Rn")
				ins.oper.append("[R%d,#0x%x]" % (rn, da << 2))
			elif i == "Rd" or i == "Rm" or i == "Rn":
				da = self.thumb_field(p, c, adr, i)
				ins.oper.append("R%d" % da)
			elif i == "RdH":
				r = self.thumb_field(p, c, adr, "Rd")
				if self.thumb_field(p, c, adr, "H"):
					r += 8
				ins.oper.append("R%d" % r)
			elif i == "Rmh":
				r = self.thumb_field(p, c, adr, "Rm")
				if self.thumb_field(p, c, adr, "h"):
					r += 8
				ins.oper.append("R%d" % r)
				ins.flow("cond", "T", None)
			elif i == "imm7l" or i == "imm8l":
				da = self.thumb_field(p, c, adr, i)
				ins.oper.append("#0x%x" % (da << 2))
			elif i == "imm8" or i == "imm5" or i == "imm3":
				da = self.thumb_field(p, c, adr, i)
				ins.oper.append("#0x%x" % da)
			elif i == "simm8":
				da = self.thumb_field(p, c, adr, i)
				if da & 0x80:
					da -= 256
				da = da << 1
				da += adr + 4
				ins.oper.append((da, "0x%08x" % da))
			elif i == "cond":
				cc = self.thumb_field(p, c, adr, i)
				da = ins.oper[-1][0]
				if ins.mne == "B":
					ins.flow("cond", cond_code[cc], da)
					if cc != 14:
						ins.flow("cond", cond_code[cc ^ 1], adr + 2)
				ins.mne += cond_code[cc]
			elif i == "bl_tgt":
				da = self.thumb_field(p, c, adr, "off11_a")
				da = da << 12
				if da & 0x400000:
					da |= 0xff800000
				da += (adr & ~3) + 4
				db = self.thumb_field(p, c, adr, "off11_b")
				da += db << 1
				da = da & 0xffffffff
				ins.oper.append((da, "0x%08x" % da))
				if ins.mne == "BL":
					ins.flow("call", "T", da)
			elif i == "regs":
				l = list()
				r = self.thumb_field(p, c, adr, i)
				for i in range(0,8):
					if r & (1 << i):
						l.append("R%d" % i)
				r = self.thumb_field(p, c, adr, "R")
				if r:
					l.append("LR")
				ins.oper.append("{" + ",".join(l) + "}")
			elif i == "SP":
				ins.oper.append(i)
			else:
				try:
					arg = self.thumb_field(p,c, adr, i)
				except:
					arg = None
				ins.oper.append(i)
				print(">>>", i, arg)
				ins.flow("ret", "T", None)

		ins.hi = na
		print("==", ins, ins.mne, ins.oper)
Exemple #5
0
def txtptr(a):
	x = const.w32(p, a)
	w = const.txt(p, p.m.b32(a))
	w.fold = True
	x.lcmt('"' + w.txt + '"')
Exemple #6
0
				if y & (1 << b):
					s += "#"
				else:
					s += "."
			x.lcmt(s)
	

	for a in range(0x4606, 0x6700,66):
		chargen(a)
else:
	x.fold = True
	x.render = "[...]"

###############
for a in range(0x3e90, 0x3ea0, 4):
	const.w32(p, a)
	cpu.disass(p.m.b32(a))

###############
def caseW(a):
	x = p.m.b32(a)
	assert (x >> 16) == 0x2100
	l = x & 0xffff
	y = p.m.b16(a + 4)
	assert y == 0x1402
	y = p.m.b32(a + 6)
	z = p.m.b16(y - 2)
	assert z == 0x1e28
	z = cpu.disass(y - 2)
	print("CASE", "l=%d" % l, "y=%x" % y)
	q = dict()
Exemple #7
0
def txtptr(a):
    x = const.w32(p, a)
    w = const.txt(p, p.m.b32(a))
    w.fold = True
    x.lcmt('"' + w.txt + '"')
Exemple #8
0
            for b in range(15, -1, -1):
                if y & (1 << b):
                    s += "#"
                else:
                    s += "."
            x.lcmt(s)

    for a in range(0x4606, 0x6700, 66):
        chargen(a)
else:
    x.fold = True
    x.render = "[...]"

###############
for a in range(0x3e90, 0x3ea0, 4):
    const.w32(p, a)
    cpu.disass(p.m.b32(a))


###############
def caseW(a):
    x = p.m.b32(a)
    assert (x >> 16) == 0x2100
    l = x & 0xffff
    y = p.m.b16(a + 4)
    assert y == 0x1402
    y = p.m.b32(a + 6)
    z = p.m.b16(y - 2)
    assert z == 0x1e28
    z = cpu.disass(y - 2)
    print("CASE", "l=%d" % l, "y=%x" % y)