Exemplo n.º 1
0
Arquivo: tests.py Projeto: da-raf/z80
    def step_instruction(self):
        trace = ""
        ins, args = False, []
        pc = self.registers.PC

        if self._interrupted and self.registers.IFF:
            self.registers.IFF = False
            self._interrupted = False
            if self.registers.IM == 1:
                print "!!! Interrupt  !!!"
                ins, args = self.instructions << 0xCD
                ins, args = self.instructions << 0x38
                ins, args = self.instructions << 0x00
                self.registers.IFF = False
        else:
            while not ins:
                try:
                    ins, args = self.instructions << self._memory[
                        self.registers.PC]
                except:
                    raise Exception("Can't decode instruction.")
                self.registers.PC = util.inc16(self.registers.PC)
            trace += "{0:X} : {1}\n ".format(pc, ins.assembler(args))

        rd = ins.get_read_list(args)
        data = [0] * len(rd)
        for n, i in enumerate(rd):
            if i < 0x10000:
                data[n] = self._memory[i]
            else:
                address = i & 0xFF
                #data[n] = self._iomap.address[address].read(address)
                data[n] = self.registers.A
                print "Read IO ",
                raise Exception("Skip.")
        wrt = ins.execute(data, args)
        for i in wrt:

            if i[0] > 0x10000:
                address = i[0] & 0xFF
                #iomap.address[address].write.emit(address, i[1])
                #self._iomap.address[address].write(address, i[1])
                #print (chr(i[1]))
                print "Write IO ",
                raise Exception("Skip.")
            else:
                try:
                    self._memory[i[0]] = i[1]
                except:
                    print i
                    print trace
                    raise
        return ins.tstates, trace
Exemplo n.º 2
0
    def step_instruction(self):
        trace = ""
        ins, args = False, []
        pc = self.registers.PC
        
        if self._interrupted and self.registers.IFF:
            self.registers.IFF = False
            self._interrupted = False
            if self.registers.IM == 1:
                print "!!! Interrupt  !!!"
                ins, args = self.instructions << 0xCD
                ins, args = self.instructions << 0x38
                ins, args = self.instructions << 0x00
                self.registers.IFF = False
        else:        
            while not ins:
                try:
                    ins, args = self.instructions << self._memory[self.registers.PC]
                except:
                    raise Exception("Can't decode instruction.")
                self.registers.PC = util.inc16(self.registers.PC)
            trace +=  "{0:X} : {1}\n ".format(pc, ins.assembler(args))
        
        rd =  ins.get_read_list(args)
        data = [0] * len(rd)
        for n, i in enumerate(rd):
            if i < 0x10000:
                data[n] = self._memory[i]
            else:
                address = i & 0xFF
                #data[n] = self._iomap.address[address].read(address)
                data[n] = self.registers.A 
                print "Read IO ",
                raise Exception("Skip.")
        wrt = ins.execute(data, args)
        for i in wrt:

            if i[0] > 0x10000:
                address = i[0] & 0xFF
                #iomap.address[address].write.emit(address, i[1])
                #self._iomap.address[address].write(address, i[1])
                #print (chr(i[1]))
                print "Write IO ",
                raise Exception("Skip.")
            else:
                try:
                    self._memory[i[0]] = i[1]
                except:
                    print i
                    print trace
                    raise
        return  ins.tstates,  trace
Exemplo n.º 3
0
    def step_instruction(self):
        ins, args = False, []
        pc = self.registers.PC

        if self._interrupted and self.registers.IFF:
            self.registers.IFF = False
            self._interrupted = False
            if self.registers.IM == 1:
                print("!!! Interrupt  !!!")
                ins, args = self.instructions << 0xCD
                ins, args = self.instructions << 0x38
                ins, args = self.instructions << 0x00
                self.registers.IFF = False
        else:
            while not ins:
                ins, args = self.instructions << self._memory[
                    self.registers.PC]
                self.registers.PC = util.inc16(self.registers.PC)
            #print( "{0:X} : {1} ".format(pc, ins.assembler(args)))

        rd = ins.get_read_list(args)
        data = [0] * len(rd)
        for n, i in enumerate(rd):
            if i < 0x10000:
                data[n] = self._memory[i]
            else:
                address = i & 0xFF
                data[n] = self._iomap.address[address].read(address)
        wrt = ins.execute(data, args)
        for i in wrt:

            if i[0] > 0x10000:
                address = i[0] & 0xFF
                #iomap.address[address].write.emit(address, i[1])
                self._iomap.address[address].write(address, i[1])
                #print (chr(i[1]))
            else:
                self._memory[i[0]] = i[1]

        return ins, args
Exemplo n.º 4
0
    def step_instruction(self):
        ins, args = False, []
        pc = self.registers.PC
        
        if self._interrupted and self.registers.IFF:
            self.registers.IFF = False
            self._interrupted = False
            if self.registers.IM == 1:
                print "!!! Interrupt  !!!"
                ins, args = self.instructions << 0xCD
                ins, args = self.instructions << 0x38
                ins, args = self.instructions << 0x00
                self.registers.IFF = False
        else:        
            while not ins:
                ins, args = self.instructions << self._memory[self.registers.PC]
                self.registers.PC = util.inc16(self.registers.PC)
            #print( "{0:X} : {1} ".format(pc, ins.assembler(args)))
        
        rd =  ins.get_read_list(args)
        data = [0] * len(rd)
        for n, i in enumerate(rd):
            if i < 0x10000:
                data[n] = self._memory[i]
            else:
                address = i & 0xFF
                data[n] = self._iomap.address[address].read(address)
        wrt = ins.execute(data, args)
        for i in wrt:

            if i[0] > 0x10000:
                address = i[0] & 0xFF
                #iomap.address[address].write.emit(address, i[1])
                self._iomap.address[address].write(address, i[1])
                #print (chr(i[1]))
            else:
                self._memory[i[0]] = i[1]
        
        return ins, args