Ejemplo n.º 1
0
    def filled(self, params, ctx):
        reads = set()
        writes = set()
        values = dict()
        loads = []

        for x in self.reads:
            if x.startswith("#"):
                assert(len(x) == 2)
                value = params[x[1]]
                operand = placeholders.get(x[1], value)
                # XXX: solution here: just add operand.getDependencies()
                if hasattr(operand, 'target'):
                    reads.add('mem')
                    reads |= splitRegister('HL')  # TODO: XXX: bad
                else:
                    reads |= splitRegister(operand.name)
            else:
                reads |= splitRegister(x)

        for x in self.writes:
            if x.startswith("#"):
                assert(len(x) == 2)
                value = params[x[1]]
                operand = placeholders.get(x[1], value)
                if hasattr(operand, 'target'):
                    name = '['+operand.target.name+']'
                    writes.add('mem')
                    reads |= splitRegister('HL')  # TODO: XXX: bad
                else:
                    name = operand.name
                    writes |= splitRegister(name)
                if x in self.values:
                    e = parse(self.values[x])
                    values[name] = e.optimizedWithContext(ctx)
                    loads.append((name, values[name]))
            else:
                writes |= splitRegister(x)
                if x in self.values:
                    e = parse(self.values[x])
                    values[x] = e.optimizedWithContext(ctx)
                    loads.append((x, values[x]))

        #values = dict() # TODO: XXX:
        #loads = []

        return reads, writes, values, loads
Ejemplo n.º 2
0
    def filled(self, params, ctx):
        reads = set()
        writes = set()
        values = dict()
        loads = []

        for x in self.reads:
            if x.startswith("#"):
                assert (len(x) == 2)
                value = params[x[1]]
                operand = placeholders.get(x[1], value)
                # XXX: solution here: just add operand.getDependencies()
                if hasattr(operand, 'target'):
                    reads.add('mem')
                    reads |= splitRegister('HL')  # TODO: XXX: bad
                else:
                    reads |= splitRegister(operand.name)
            else:
                reads |= splitRegister(x)

        for x in self.writes:
            if x.startswith("#"):
                assert (len(x) == 2)
                value = params[x[1]]
                operand = placeholders.get(x[1], value)
                if hasattr(operand, 'target'):
                    name = '[' + operand.target.name + ']'
                    writes.add('mem')
                    reads |= splitRegister('HL')  # TODO: XXX: bad
                else:
                    name = operand.name
                    writes |= splitRegister(name)
                if x in self.values:
                    e = parse(self.values[x])
                    values[name] = e.optimizedWithContext(ctx)
                    loads.append((name, values[name]))
            else:
                writes |= splitRegister(x)
                if x in self.values:
                    e = parse(self.values[x])
                    values[x] = e.optimizedWithContext(ctx)
                    loads.append((x, values[x]))

        #values = dict() # TODO: XXX:
        #loads = []

        return reads, writes, values, loads
Ejemplo n.º 3
0
def make_context(params, argument, next_addr):
    ctx = Context()
    if next_addr.bank() > 0:
        ctx.setValue('ROMBANK', Constant(next_addr.bank()))
    ctx.setValue('v8', Constant(argument))
    ctx.setValue('FF00_v8', Constant(0xFF00 + argument))
    ctx.setValue('v16', Constant(argument))
    offset = argument
    if offset & 0x80:  # convert to signed offset
        offset -= 0x100
    ctx.setValue('v8_rel', Constant(next_addr.offset(offset).virtual()))
    for p in params:
        value = placeholders.get(p, params[p])
        ctx.setValue('#'+p, value)
    return ctx
Ejemplo n.º 4
0
def make_context(params, argument, next_addr):
    ctx = Context()
    if next_addr.bank() > 0:
        ctx.setValue('ROMBANK', Constant(next_addr.bank()))
    ctx.setValue('v8', Constant(argument))
    ctx.setValue('FF00_v8', Constant(0xFF00 + argument))
    ctx.setValue('v16', Constant(argument))
    offset = argument
    if offset & 0x80:  # convert to signed offset
        offset -= 0x100
    ctx.setValue('v8_rel', Constant(next_addr.offset(offset).virtual()))
    for p in params:
        value = placeholders.get(p, params[p])
        ctx.setValue('#' + p, value)
    return ctx