def read(self, addr=None): if not self.__read: raise MemoryProtectionError( 'Attempted to read from protected memory space: %s' % addr) if addr is not None: self.__check_addr(addr) return ord(self.mem[addr]) return ord(self.mem.read(1))
def write(self, addr, byte=None): if not self.__write: raise MemoryProtectionError( 'Attempted to write to protected memory space: %s' % addr) if byte is not None: self.__check_addr(addr) if isinstance(byte, int): byte = chr(byte) self.mem[addr] = byte else: if isinstance(addr, int): addr = chr(addr) self.mem.write(addr)
def clearblock(self, addr, size): raise MemoryProtectionError('Unsupported operation by I/O map.')
def writeblock(self, addr, block): raise MemoryProtectionError('Unsupported operation by I/O map.')
def fetch(self): if not self.__execute: raise MemoryProtectionError( 'Attempted to execute code from protected memory space!') return ord(self.mem.read(1))
def mem_write(self, addr, byte): raise MemoryProtectionError('Unable to write to memory address.')
def mem_read(self, addr): try: return ord(self.mem[addr]) except IndexError: raise MemoryProtectionError('Unable to read from memory address.')