Esempio n. 1
0
 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))
Esempio n. 2
0
 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)
Esempio n. 3
0
 def clearblock(self, addr, size):
     raise MemoryProtectionError('Unsupported operation by I/O map.')
Esempio n. 4
0
 def writeblock(self, addr, block):
     raise MemoryProtectionError('Unsupported operation by I/O map.')
Esempio n. 5
0
 def fetch(self):
     if not self.__execute:
         raise MemoryProtectionError(
             'Attempted to execute code from protected memory space!')
     return ord(self.mem.read(1))
Esempio n. 6
0
 def mem_write(self, addr, byte):
     raise MemoryProtectionError('Unable to write to memory address.')
Esempio n. 7
0
 def mem_read(self, addr):
     try:
         return ord(self.mem[addr])
     except IndexError:
         raise MemoryProtectionError('Unable to read from memory address.')