/** * @brief Reads in target specific instructions from the given file * and generates generic instruction for the simulator. * @param[in] instream File containing the instructions in binary format. */ void readInstructions(FILE* instream) { uint32_t instruction_size = gen_simulator->getFileHeader()->instruction_size; sparc_instruction** instructions = gen_simulator->getInstructions(); sparc_instruction* instructions_array; uint32_t opcode; uint32_t i, j; int value; /* all binary instructions have 4 bytes */ if (instruction_size % 4) { gen_simulator->cleanUp(); simerror("Invalid instruction size: has to be a multiple of 4!"); } else { instruction_size = instruction_size / 4; } /* allocate memory for instructions */ *instructions = malloc(sizeof(sparc_instruction)*(instruction_size)); instructions_array = *instructions; if (!instructions_array) { gen_simulator->cleanUp(); simerror("Could not allocate memory for instructions!"); } /* set number of allocated instructions */ number_instructions = instruction_size; /* read in instructions */ for (i = 0; i < instruction_size; i++) { /* clear current opcode */ opcode = 0; /* read in opcode from current filestream */ for (j = 0; j < 4; j++) { if ((value = fgetc(instream)) == EOF) { gen_simulator->cleanUp(); simerror("Could not read from file!"); } opcode <<= 8; opcode |= (uint32_t) ((value) & 0xff); } /* save instruction number */ instructions_array[i].instr_no = i; /* convert opcode to instruction data structure */ saveInstruction(opcode, &(instructions_array[i])); } }
BrewDayScrollWidget::BrewDayScrollWidget(QWidget* parent) : QWidget(parent), doc(new QWebView()) { setupUi(this); setObjectName("BrewDayScrollWidget"); recObs = 0; connect( listWidget, SIGNAL(currentRowChanged(int)), this, SLOT(showInstruction(int)) ); // connect( plainTextEdit, SIGNAL(textChanged()), this, SLOT(saveInstruction()) ); connect(btTextEdit,SIGNAL(textModified()), this, SLOT(saveInstruction())); connect( pushButton_insert, SIGNAL(clicked()), this, SLOT(insertInstruction()) ); connect( pushButton_remove, SIGNAL(clicked()), this, SLOT(removeSelectedInstruction()) ); connect( pushButton_up, SIGNAL(clicked()), this, SLOT(pushInstructionUp()) ); connect( pushButton_down, SIGNAL(clicked()), this, SLOT(pushInstructionDown()) ); connect( pushButton_generateInstructions, SIGNAL(clicked()), this, SLOT(generateInstructions()) ); }