예제 #1
0
    def update_info(self):
        ''' update values on screen '''
        self.ax_info.set_text(str(processor.r[0]))
        self.bx_info.set_text(str(processor.r[1]))
        self.cs_info.set_text(str(processor.cs))
        self.ds_info.set_text(str(processor.ds))
        self.c_info.set_text(str(processor.c))
        self.ic_info.set_text(str(processor.ic))
        self.c_info.set_text(str(processor.c))
        self.chst0_info.set_text(str(processor.chst[0]))
        self.chst1_info.set_text(str(processor.chst[1]))
        self.chst2_info.set_text(str(processor.chst[2]))
        self.pi_info.set_text(str(processor.pi))
        self.si_info.set_text(str(processor.si))
        self.ti_info.set_text(str(processor.ti))
        self.ioi_info.set_text(str(processor.ioi))
        self.time_info.set_text(str(processor.time))
        self.mode_info.set_text(str(processor.mode))
        self.ptr_info.set_text(str(processor.ptr))

        # updating virtual memory 
        self.update_virtual_memory()
        # updating output
        self.output_buffer.set_text(output_device.output)

        # updating commands
        string = ""
        for i in range(5):
            string += str( user_memory.fetch(to_hex(to_int(processor.ic) + i))) + '\n'
        self.commands_buffer.set_text(string)
예제 #2
0
 def WS(self, XY):
     ''' Value of XY in shared memory is sent to ax '''
     user_memory.write(
         self.get_ax(),
         to_hex(configs.SH_MEMEORY_STARTING_BLOCK * configs.BLOCK_SIZE +
                to_int(str(XY)[0]) * configs.BLOCK_SIZE +
                to_int(str(XY)[1])))
예제 #3
0
 def update_real(self, widget):
     addr = self.real_address.get_text()
     # some regexp validation should be here 
     
     i = 0
     for widget in self.realtable:
         widget.set_text(str( user_memory.fetch( to_hex(to_int(addr) + i) )))
         i += 1
예제 #4
0
    def next(self, widget):
        self.save_state()
        self.vm.iterate()
        processor.ic = to_hex(to_int(processor.ic)  + 1)
        self.update_info()

        if processor.si == 3:
            self.show_popup()
예제 #5
0
 def execute(self, widget):
     while True:
         self.vm.iterate()
         processor.ic = to_hex(to_int(processor.ic)  + 1)
         self.update_info()
           
         if processor.si == 3:
             self.show_popup()
             break
예제 #6
0
 def update_virtual_memory(self):
     wg_num = 0
     for widget in [self.wm0, self.wm1, self.wm2, self.wm3, self.wm4, self.wm5, self.wm6, self.wm7, 
         self.wm8, self.wm9, self.wma, self.wmb, self.wmc, self.wmd, self.wme, self.wmf]:
         strin = ""
         for i in range(BLOCK_SIZE):
             strin += str( self.vm.read(to_hex(wg_num * BLOCK_SIZE + i)[2:4]) ) + " "
         widget.set_text(strin)
         wg_num += 1
예제 #7
0
    def __init__(self, opts={}):
        opts['name'] = 'vm_' + str(kernel_data.PID)
        opts['priority'] = configs.LOADER_PRIORITY
        Process.__init__(self, opts)
        self.cs_length = opts['cs_length']
        self.ds_length = opts['ds_length']
        self.addresses = opts['addresses']

        # state
        self.ic = None
        self.num = self.ds_length + 1  # skip DATA SEGMENT

        # prepare DS
        for i in range(1, self.ds_length):
            data = user_memory.fetch(self.addresses[i])
            if data[0:2] != "DW":
                processor.pi = 2
                kernel.create_resource(InterruptEvent, self, {'process': self})
            else:
                user_memory.write(to_hex(to_int(data[2:4])), self.addresses[i])
예제 #8
0
    def __init__(self, opts = {}):
        opts['name'] = 'vm_' + str(kernel_data.PID)
        opts['priority'] = configs.LOADER_PRIORITY
        Process.__init__(self, opts)
        self.cs_length = opts['cs_length']
        self.ds_length = opts['ds_length']
        self.addresses = opts['addresses']
        
        # state 
        self.ic = None
        self.num = self.ds_length + 1 # skip DATA SEGMENT

        # prepare DS 
        for i in range(1, self.ds_length):
            data = user_memory.fetch(self.addresses[i])
            if data[0:2] != "DW":
                processor.pi = 2
                kernel.create_resource(InterruptEvent, self, {'process' : self })
            else:
                user_memory.write(to_hex(to_int(data[2:4])), self.addresses[i])
예제 #9
0
 def SUB(self):
     '''ax = ax - bx'''
     answer = to_int(self.get_ax()) - to_int(self.get_bx())
     if (answer < 0):
       self.set_c(2)
     self.set_ax(to_hex(answer))
예제 #10
0
 def ADD(self):
     '''ax = ax + bx'''
     self.set_ax( to_hex( to_int(self.get_ax()) + to_int(self.get_bx())))
예제 #11
0
 def LS(self, XY):
     ''' Value of ax is sent to shared memory '''                                                                          
     value = user_memory.fetch(to_hex(configs.SH_MEMEORY_STARTING_BLOCK * configs.BLOCK_SIZE + to_int(XY[0]) * configs.BLOCK_SIZE + to_int(XY[1])))
     self.set_ax(value)
예제 #12
0
 def WS(self, XY):
     ''' Value of XY in shared memory is sent to ax '''
     user_memory.write(self.get_ax(), to_hex(configs.SH_MEMEORY_STARTING_BLOCK * configs.BLOCK_SIZE + to_int(str(XY)[0]) * configs.BLOCK_SIZE + to_int(str(XY)[1]))) 
예제 #13
0
 def BXOR(self):
     '''bx = ax ^ bx '''
     self.set_bx(to_hex(to_int(self.get_ax()) ^ to_int(self.get_bx())))
예제 #14
0
 def SUB(self):
     '''ax = ax - bx'''
     answer = to_int(self.get_ax()) - to_int(self.get_bx())
     if (answer < 0):
         self.set_c(2)
     self.set_ax(to_hex(answer))
예제 #15
0
 def LS(self, XY):
     ''' Value of ax is sent to shared memory '''
     value = user_memory.fetch(
         to_hex(configs.SH_MEMEORY_STARTING_BLOCK * configs.BLOCK_SIZE +
                to_int(XY[0]) * configs.BLOCK_SIZE + to_int(XY[1])))
     self.set_ax(value)
예제 #16
0
 def ADD(self):
     '''ax = ax + bx'''
     self.set_ax(to_hex(to_int(self.get_ax()) + to_int(self.get_bx())))
예제 #17
0
 def BXOR(self):
     '''bx = ax ^ bx '''
     self.set_bx( to_hex ( to_int(self.get_ax()) ^ to_int(self.get_bx()) ))
예제 #18
0
 def update_page_table(self):
     i = 0
     for widget in self.pgtable:
         widget.set_text(str( user_memory.fetch(to_hex(to_int(processor.ptr) + i)) ))
         i += 1