VSU performance tweak, add immediate notation setting
This commit is contained in:
+14
-6
@@ -253,18 +253,24 @@ static void dasmOpDisp26(char*dest, VBU_DasmConfig*config, VBU_DasmLine*line) {
|
||||
}
|
||||
|
||||
/* Format a 5-bit sign-extended immediate operand */
|
||||
static void dasmOpImm5S(char *dest, VBU_DasmLine *line) {
|
||||
static void dasmOpImm5S(char *dest, VBU_DasmConfig*config, VBU_DasmLine *line){
|
||||
if (config->immediateNotation == VBU_NUMBER)
|
||||
*dest++ = '#';
|
||||
sprintf(dest, "%d", SignExtend(line->code[0], 5));
|
||||
}
|
||||
|
||||
/* Format a 5-bit zero-filled immediate operand */
|
||||
static void dasmOpImm5U(char *dest, VBU_DasmLine *line) {
|
||||
static void dasmOpImm5U(char *dest, VBU_DasmConfig*config, VBU_DasmLine *line){
|
||||
if (config->immediateNotation == VBU_NUMBER)
|
||||
*dest++ = '#';
|
||||
sprintf(dest, "%d", line->code[0] & 31);
|
||||
}
|
||||
|
||||
/* Format a 16-bit sign-extended immediate operand */
|
||||
static void dasmOpImm16S(char*dest, VBU_DasmConfig*config, VBU_DasmLine*line) {
|
||||
int32_t imm = (int16_t) ((int16_t) line->code[3] << 8 | line->code[2]);
|
||||
int32_t imm = (int16_t) ((int16_t) line->code[3] << 8 | line->code[2]);
|
||||
if (config->immediateNotation == VBU_NUMBER)
|
||||
*dest++ = '#';
|
||||
if (imm >= -256 && imm <= 256) {
|
||||
sprintf(dest, "%d", imm);
|
||||
return;
|
||||
@@ -279,6 +285,8 @@ static void dasmOpImm16S(char*dest, VBU_DasmConfig*config, VBU_DasmLine*line) {
|
||||
/* Format a 16-bit zero-filled immediate operand */
|
||||
static void dasmOpImm16U(char*dest, VBU_DasmConfig*config, VBU_DasmLine*line) {
|
||||
uint16_t imm = (uint16_t) line->code[3] << 8 | line->code[2];
|
||||
if (config->immediateNotation == VBU_NUMBER)
|
||||
*dest++ = '#';
|
||||
dasmToHex(dest, config, 4, imm);
|
||||
}
|
||||
|
||||
@@ -454,8 +462,8 @@ static void dasmOperand(char *dest, VBU_DasmConfig *config,
|
||||
case DASM_BCOND : dasmOpBCOND (dest, config, line); break;
|
||||
case DASM_DISP9 : dasmOpDisp9 (dest, config, line); break;
|
||||
case DASM_DISP26: dasmOpDisp26(dest, config, line); break;
|
||||
case DASM_IMM5S : dasmOpImm5S (dest, line); break;
|
||||
case DASM_IMM5U : dasmOpImm5U (dest, line); break;
|
||||
case DASM_IMM5S : dasmOpImm5S (dest, config, line); break;
|
||||
case DASM_IMM5U : dasmOpImm5U (dest, config, line); break;
|
||||
case DASM_IMM16S: dasmOpImm16S(dest, config, line); break;
|
||||
case DASM_IMM16U: dasmOpImm16U(dest, config, line); break;
|
||||
case DASM_JMP : dasmOpJMP (dest, config, line); break;
|
||||
@@ -680,7 +688,7 @@ static VBU_DasmLine* dasmDisassemble(VB *sim, uint32_t address,
|
||||
if (dasmLine(sim, &addr, pc, config, &lines, &size, &offset, x))
|
||||
goto catch;
|
||||
}
|
||||
return lines;
|
||||
return VBU_REALLOC(lines, offset);
|
||||
|
||||
/* Exception handler */
|
||||
catch:
|
||||
|
||||
Reference in New Issue
Block a user