Example #1
0
 def bpl(self):
     if not self._flag.n:
         self._pc.value = self._pc.value + s8(self._data)
         return True
     return False
Example #2
0
 def bvs(self):
     if self._flag.v:
         self._pc.value = self._pc.value + s8(self._data)
         return True
     return False
Example #3
0
 def pre_fill(self, read_data=True):
     opcode = self._bus.read(self._pc.value)
     ins = self._ins[opcode]
     mode = ins.addr_mode()
     cross_boundry = False
     if mode == AddrMode.Implied:
         self._addr = -1
         self._data = -1
     elif mode == AddrMode.Absolute:
         lo = self.fetch(1)
         hi = self.fetch(2)
         self._addr = u16((hi << 8) + lo)
         if read_data:
             self._data = self._bus.read(self._addr)
     elif mode == AddrMode.Accumulator:
         self._addr = -1
         self._data = self._a.value
     elif mode == AddrMode.Immediate:
         self._addr = -1
         self._data = self.fetch(1)
     elif mode == AddrMode.ZeroPage:
         self._addr = self.fetch(1)
         if read_data:
             self._data = self._bus.read(self._addr)
     elif mode == AddrMode.Relative:
         self._addr = -1
         self._data = self.fetch(1)
         prev_ = self._next_addr
         next_ = self._next_addr + s8(self._data)
         if (prev_ & 0xff00) != (next_ & 0xff00):
             cross_boundry = True
     elif mode == AddrMode.IndexedIndirectY:
         addr = self.fetch(1)
         lo = self._bus.read(addr)
         hi = self._bus.read((addr + 1) % 256)
         self._addr = u16((hi << 8) + lo + self._y.value)
         if read_data:
             self._data = self._bus.read(self._addr)
         cross_boundry = (lo + self._y.value) > 0xff
     elif mode == AddrMode.ZeroIndexedIndirectX:
         index = u8(self.fetch(1) + self._x.value)
         self._addr = u16(self._bus.read(index) + ((self._bus.read((index + 1) & 0xff)) << 8))
         if read_data:
             self._data = self._bus.read(self._addr)
     elif mode == AddrMode.AbslouteIndirect:
         addr = self.fetch(1) + (self.fetch(2) << 8)
         if (addr & 0xff) == 0xff:
             self._addr = self._bus.read(addr) + (self._bus.read(addr & 0xff00) << 8)
         else: 
             self._addr = self._bus.read(addr) + (self._bus.read(addr + 1) << 8)
         self._data = -1
     elif mode == AddrMode.AbslouteIndexedY:
         self._addr = u16(self._y.value + self.fetch(1) + (self.fetch(2) << 8))
         if read_data:
             self._data = self._bus.read(self._addr)
         cross_boundry = (self._y.value + self.fetch(1) > 0xff)
     elif mode == AddrMode.ZeroIndexedX:
         self._addr = u8(self._x.value + self.fetch(1))
         if read_data:
             self._data = self._bus.read(self._addr)
     elif mode == AddrMode.ZeroIndexedY:
         self._addr = u8(self._y.value + self.fetch(1))
         if read_data:
             self._data = self._bus.read(self._addr)
     elif mode == AddrMode.AbslouteIndexedX:
         self._addr = u16(self._x.value + self.fetch(1) + (self.fetch(2) << 8))
         if read_data:
             self._data = self._bus.read(self._addr)
         cross_boundry = (self._x.value + self.fetch(1) > 0xff)
     else:
         assert False, 'Need to impl, {}'.format(mode)
     return cross_boundry