Beispiel #1
0
 def execute(self,
             registers: Registers,
             coprocessor: COProcessor,
             program_counter,
             memory: Memory,
             *args,
             **kwargs):
     local_registers = coprocessor.registers
     fs_register = local_registers.get_register(self.fs_number)
     ft_register = local_registers.get_register(self.ft_number)
     
     fs = Bin2Float.convert(Int2Bits.convert(fs_register.to_signed_int()))
     ft = Bin2Float.convert(Int2Bits.convert(ft_register.to_signed_int()))
     
     fd = fs * ft
     fd = Float2Int.convert(fd)
     local_registers.set_register_value(self.fd_number, fd)
     return registers, program_counter + 4, memory, local_registers
    def execute(self, registers: Registers, coprocessor: COProcessor,
                program_counter, memory: Memory, *args, **kwargs):
        local_registers = registers
        local_co_registers = coprocessor.registers
        new_pc = program_counter
        new_memory = memory

        v0_register = local_registers.get_register(self.v0)
        v0_value = v0_register.get_data()

        a0_register = local_registers.get_register(self.a0)

        f12_register = local_co_registers.get_register(self.f12)
        f13_register = local_co_registers.get_register(self.f13)

        if v0_value == 1:
            print(a0_register.get_data(), end='')
        elif v0_value == 2:
            print(f12_register.to_single_precision(), end='')
        elif v0_value == 3:
            f13_b = Int2Bits.convert(f13_register.get_data())
            f12_b = Int2Bits.convert(f12_register.get_data())
            f = f13_b + f12_b
            print(Bin2Float.convert(f, True), end='')
        elif v0_value == 4:
            a0_address = a0_register.get_data()
            string = self.__read_string(a0_address,
                                        memory=memory,
                                        pc=program_counter,
                                        logger=kwargs['logger'])
            print(string, end='')

        elif v0_value == 5:
            read = int(input())
            local_registers.set_register_value(self.v0, read)
        elif v0_value == 6:
            read = float(input())
            read_bit = Float2Int.convert(read)
            local_co_registers.set_register_value(self.f0, read_bit)
        elif v0_value == 7:
            read = float(input())
            read_bit = Float2Bin.convert(read, True)
            read_bit_high = Bin2Int.convert(read_bit[0:32])
            read_bit_low = Bin2Int.convert(read_bit[32:64])

            local_co_registers.set_register_value(self.f1, read_bit_high)
            local_co_registers.set_register_value(self.f0, read_bit_low)

        elif v0_value == 10:
            return local_registers, -1, new_memory, local_co_registers
        elif v0_value == 11:
            print(Bin2Chr.convert(Int2Bits.convert(a0_register.get_data())),
                  end='')

        return local_registers, new_pc + 4, new_memory, local_co_registers
    def execute(self, registers: Registers, coprocessor: COProcessor,
                program_counter, memory: Memory, *args, **kwargs):
        local_registers = coprocessor.registers
        fs_register = local_registers.get_register(self.fs_number)
        fs1_register = local_registers.get_register(self.fs_number + 1)
        fs = Int2Bits.convert(fs1_register.to_signed_int()) + Int2Bits.convert(
            fs_register.to_signed_int())

        fs = Bin2Float.convert(fs, True)
        fs_bits = Float2Bin.convert(fs)
        fs = Bin2Int.convert(fs_bits)
        local_registers.set_register_value(self.fd_number, fs)
        return registers, program_counter + 4, memory, local_registers
    def execute(self, registers, coprocessor: COProcessor, program_counter,
                memory: Memory, *args, **kwargs):
        local_registers = coprocessor.registers
        fs_register = local_registers.get_register(self.fs_number)
        fs1_register = local_registers.get_register(self.fs_number + 1)

        ft_register = local_registers.get_register(self.ft_number)
        ft1_register = local_registers.get_register(self.ft_number + 1)

        fs = Bin2Float.convert(
            Int2Bits.convert(fs1_register.to_signed_int()) +
            Int2Bits.convert(fs_register.to_signed_int()), True)
        ft = Bin2Float.convert(
            Int2Bits.convert(ft1_register.to_signed_int()) +
            Int2Bits.convert(ft_register.to_signed_int()), True)
        rd = fs + ft

        fd_bin = Float2Bin.convert(rd, doubled=True)
        fd_bin_higher = Bin2Int.convert(fd_bin[0:32])
        fd_bin_lower = Bin2Int.convert(fd_bin[32:64])

        local_registers.set_register_value(self.fd_number + 1, fd_bin_higher)
        local_registers.set_register_value(self.fd_number, fd_bin_lower)
        return registers, program_counter + 4, memory, local_registers