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:
|
||||
|
||||
@@ -47,6 +47,7 @@ VBUAPI VBU_DasmConfig* vbuDasmInit(VBU_DasmConfig *config) {
|
||||
config->conditionNotation = VBU_NAMES;
|
||||
config->hexCase = VBU_UPPER;
|
||||
config->hexNotation = VBU_0X;
|
||||
config->immediateNotation = VBU_NONE;
|
||||
config->memoryNotation = VBU_OUTSIDE;
|
||||
config->mnemonicCase = VBU_UPPER;
|
||||
config->operandOrder = VBU_DEST_LAST;
|
||||
|
||||
@@ -29,6 +29,8 @@ extern "C" {
|
||||
#define VBU_L 0
|
||||
#define VBU_LOWER 1
|
||||
#define VBU_NAMES 1
|
||||
#define VBU_NONE 0
|
||||
#define VBU_NUMBER 1
|
||||
#define VBU_NUMBERS 0
|
||||
#define VBU_OUTSIDE 0
|
||||
#define VBU_SPLIT 1
|
||||
@@ -48,6 +50,7 @@ typedef struct { /* Defaults listed first */
|
||||
uint8_t conditionNotation; /* NAMES, NUMBERS */
|
||||
uint8_t hexCase; /* UPPER, LOWER */
|
||||
uint8_t hexNotation; /* 0X, H, DOLLAR */
|
||||
uint8_t immediateNotation; /* NONE, NUMBER */
|
||||
uint8_t memoryNotation; /* OUTSIDE, INSIDE */
|
||||
uint8_t mnemonicCase; /* UPPER, LOWER */
|
||||
uint8_t operandOrder; /* DEST_LAST, DEST_FIRST */
|
||||
|
||||
Reference in New Issue
Block a user