Exemple #1
0
    def nextBytes(self, size=1, pack=True):
      pc = self.registers.pc

      byte = self.memory[pc:pc + size]
      self.registers.incrementPC(size)
      if pack is True:
          return utils.pack_bytes(byte)
      return byte
Exemple #2
0
    def load(self, code, name=None):
        if name is not None:
            self.name = name

        get_bytes = lambda x: [code.pop(0) for i in range(x)]

        # Check file header
        self.check_header(get_bytes(3))

        data_size = pack_bytes(get_bytes(2))
        for i in range(0, data_size):
            self.memory.append(code.pop(0))

        self.program_memory.extend(code)
        self.last_op_index = len(self.program_memory) - 1
Exemple #3
0
 def mov_reg_mem(self):
     a = self.program_scanner.nextRegister()
     b = self.program_scanner.nextMemory()
     print(b)
     b = self.memory[b:b + Registers.sizeOf(a)]
     self.registers.set(a, pack_bytes(b))
Exemple #4
0
 def read_int(self):
     a = pack_bytes(unpack_bytes(int(input("")), 2, 2))
     self.registers.set('ax', a)