67 lines
1.9 KiB
C
67 lines
1.9 KiB
C
#ifndef VBUAPI
|
|
#define VBUAPI
|
|
#endif
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <vbu.h>
|
|
|
|
/* Memory management */
|
|
#ifndef VBU_REALLOC
|
|
#include <stdlib.h>
|
|
#define VBU_REALLOC realloc
|
|
#else
|
|
extern void* VBU_REALLOC(void *, size_t);
|
|
#endif
|
|
|
|
|
|
|
|
/***************************** Library Functions *****************************/
|
|
|
|
/* Sign-extend an integer of variable width */
|
|
static int32_t SignExtend(int32_t value, int32_t bits) {
|
|
#ifndef VB_SIGNED_PROPAGATE
|
|
value &= ~((uint32_t) 0xFFFFFFFF << bits);
|
|
bits = (int32_t) 1 << (bits - (int32_t) 1);
|
|
return (value ^ bits) - bits;
|
|
#else
|
|
return value << (32 - bits) >> (32 - bits);
|
|
#endif
|
|
}
|
|
|
|
|
|
|
|
/******************************** Sub-Modules ********************************/
|
|
|
|
#include "disassembler.c"
|
|
|
|
|
|
|
|
/******************************* API Commands ********************************/
|
|
|
|
/* Initialize disassembler options with default settings */
|
|
VBUAPI VBU_DasmConfig* vbuDasmInit(VBU_DasmConfig *config) {
|
|
config->bcondNotation = VBU_JOINED;
|
|
config->conditionCase = VBU_LOWER;
|
|
config->conditionCL = VBU_L;
|
|
config->conditionEZ = VBU_Z;
|
|
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;
|
|
config->programCase = VBU_LOWER;
|
|
config->programNotation = VBU_NAMES;
|
|
config->setfNotation = VBU_SPLIT;
|
|
config->systemCase = VBU_LOWER;
|
|
config->systemNotation = VBU_NAMES;
|
|
return config;
|
|
}
|
|
|
|
/* Disassemble from a simulation */
|
|
VBUAPI VBU_DasmLine* vbuDisassemble(VB *sim, uint32_t address,
|
|
VBU_DasmConfig *config, unsigned length, int line) {
|
|
return dasmDisassemble(sim, address, config, length, line);
|
|
}
|