Implement disassembler
This commit is contained in:
+97
@@ -0,0 +1,97 @@
|
||||
#ifndef VBU_H_
|
||||
#define VBU_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef VBUAPI
|
||||
#define VBUAPI extern
|
||||
#endif
|
||||
|
||||
/* Header includes */
|
||||
#include <vb.h>
|
||||
|
||||
|
||||
|
||||
/********************************* Constants *********************************/
|
||||
|
||||
/* Disassembler options */
|
||||
#define VBU_0X 0
|
||||
#define VBU_ABSOLUTE 0
|
||||
#define VBU_C 1
|
||||
#define VBU_DEST_FIRST 1
|
||||
#define VBU_DEST_LAST 0
|
||||
#define VBU_DOLLAR 1
|
||||
#define VBU_E 0
|
||||
#define VBU_H 2
|
||||
#define VBU_INSIDE 1
|
||||
#define VBU_JOINED 0
|
||||
#define VBU_L 0
|
||||
#define VBU_LOWER 1
|
||||
#define VBU_NAMES 1
|
||||
#define VBU_NUMBERS 0
|
||||
#define VBU_OUTSIDE 0
|
||||
#define VBU_RELATIVE 1
|
||||
#define VBU_SPLIT 1
|
||||
#define VBU_UPPER 0
|
||||
#define VBU_Z 1
|
||||
|
||||
|
||||
|
||||
/*********************************** Types ***********************************/
|
||||
|
||||
/* Disassembler text options */
|
||||
typedef struct { /* Defaults listed first */
|
||||
uint8_t bcondNotation; /* JOINED, SPLIT */
|
||||
uint8_t branchNotation; /* ABSOLUTE, RELATIVE */
|
||||
uint8_t conditionCase; /* LOWER, UPPER */
|
||||
uint8_t conditionCL; /* L, C */
|
||||
uint8_t conditionEZ; /* Z, E */
|
||||
uint8_t conditionNotation; /* NAMES, NUMBERS */
|
||||
uint8_t hexCase; /* UPPER, LOWER */
|
||||
uint8_t hexNotation; /* 0X, H, DOLLAR */
|
||||
uint8_t memoryNotation; /* OUTSIDE, INSIDE */
|
||||
uint8_t mnemonicCase; /* UPPER, LOWER */
|
||||
uint8_t operandOrder; /* DEST_LAST, DEST_FIRST */
|
||||
uint8_t programCase; /* LOWER, UPPER */
|
||||
uint8_t programNotation; /* NAMES, NUMBERS */
|
||||
uint8_t setfNotation; /* SPLIT, JOINED */
|
||||
uint8_t systemCase; /* LOWER, UPPER */
|
||||
uint8_t systemNotation; /* NAMES, NUMBERS */
|
||||
} VBU_DasmConfig;
|
||||
|
||||
/* Disassembler output line */
|
||||
typedef struct {
|
||||
|
||||
/* Parsed */
|
||||
uint32_t address; /* Memory address */
|
||||
uint16_t code[4]; /* Instruction bytes */
|
||||
uint8_t codeLength; /* Number of items in code */
|
||||
uint8_t isPC; /* Set if PC is on this line */
|
||||
|
||||
/* Display text */
|
||||
struct {
|
||||
char *address; /* Memory address */
|
||||
char *code[4]; /* Instruction bytes */
|
||||
char *mnemonic; /* Instruction mnemonic */
|
||||
char *operands[3]; /* Instruction operands */
|
||||
uint8_t operandsLength; /* Number of items in operands */
|
||||
} text;
|
||||
|
||||
} VBU_DasmLine;
|
||||
|
||||
|
||||
|
||||
/******************************* API Commands ********************************/
|
||||
|
||||
VBUAPI VBU_DasmConfig* vbuDasmInit (VBU_DasmConfig *config);
|
||||
VBUAPI VBU_DasmLine* vbuDisassemble(VB *sim, uint32_t address, VBU_DasmConfig *config, unsigned length, int line);
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* VBU_H_ */
|
||||
Reference in New Issue
Block a user