Пример #1
0
 def on_actionDebug_File_hex_triggered(self):
     self.debug.setText('')
     text = self.scintilla.text()
     result, line, e, process = asm(text)
     if line == -1:
         i = 0
         while i < len(result):
             self.debug.append(
                 hex(int((i + 32) / 32 - 4)) + ' : ' +
                 hex(int(result[i:i + 32], 2)).replace(
                     '0x', '').upper().zfill(8) + '\n')
             i = i + 32
         self.debug_label.setText('Debug Console (hex)')
         self.output.append(
             'Output : Successfully generated debug(hex) file.\n')
     else:
         if (re.search('Line', str(e))):
             if (process == 1):
                 self.output.append('(During First Scan)' + str(e) + '\n')
             if (process == 2):
                 self.output.append('(During Second Scan)' + str(e) + '\n')
         else:
             if (process == 1):
                 self.output.append(
                     '(During First Scan:Unexpected ERROR!)\n' +
                     'Line %d :' % line + str(e) + '\n')
             if (process == 2):
                 self.output.append(
                     '(During Second Scan:Unexpected ERROR!)\n' +
                     'Line %d :' % line + str(e) + '\n')
Пример #2
0
 def on_actionGenerate_bin_triggered(self):
     fname, _ = QFileDialog.getSaveFileName(
         self,
         'Save bin file',
         filter="bin Files (*.bin);;Text Files (*.txt);;All Files (*.*)")
     if not fname:
         return
     text = self.scintilla.text()
     result, line, e, process = asm(text)
     if line == -1:
         with open(fname, 'wb') as f:
             f.write(
                 int(result, 2).to_bytes(int(len(result) / 8),
                                         byteorder='big'))
         self.output.append('Output : Successfully generated bin file.\n')
     else:
         if (re.search('Line', str(e))):
             if (process == 1):
                 self.output.append('(During First Scan)' + str(e) + '\n')
             if (process == 2):
                 self.output.append('(During Second Scan)' + str(e) + '\n')
         else:
             if (process == 1):
                 self.output.append(
                     '(During First Scan:Unexpected ERROR!)' +
                     'Line %d :' % line + str(e) + '\n')
             if (process == 2):
                 self.output.append(
                     '(During Second Scan:Unexpected ERROR!)' +
                     'Line %d :' % line + str(e) + '\n')
Пример #3
0
 def on_actionGenerate_coe_triggered(self):
     fname, _ = QFileDialog.getSaveFileName(
         self,
         'Save bin file',
         filter="coe Files (*.coe);;Text Files (*.txt);;All Files (*.*)")
     if not fname:
         return
     text = self.scintilla.text()
     result, line, e, process = asm(text)
     if line == -1:
         with open(fname, 'w+') as f:
             f.write(
                 'memory_initialization_radix=16;\nmemory_initialization_vector=\n'
             )
             i = 0
             while i < len(result) - 32:
                 temp = hex(int(result[i:i + 32], 2))[2:].upper()
                 while len(temp) < 8:
                     temp = '0' + temp
                 f.write(temp)
                 f.write(',')
                 i = i + 32
                 if (i % (32 * 4) == 0):
                     f.write('\n')
             temp = hex(int(result[len(result) - 32:len(result)],
                            2))[2:].upper()
             while len(temp) < 8:
                 temp = '0' + temp
             f.write(temp)
             f.write(';')
         self.output.append('Output : Successfully generated coe file.\n')
     else:
         if (re.search('Line', str(e))):
             if (process == 1):
                 self.output.append('(During First Scan)' + str(e) + '\n')
             if (process == 2):
                 self.output.append('(During Second Scan)' + str(e) + '\n')
         else:
             if (process == 1):
                 self.output.append(
                     '(During First Scan:Unexpected ERROR!\n)' +
                     'Line %d :' % line + str(e) + '\n')
             if (process == 2):
                 self.output.append(
                     '(During Second Scan:Unexpected ERROR!\n)' +
                     'Line %d :' % line + str(e) + '\n')