Enabling CPU trace and hex edit
This commit is contained in:
+1
-1
@@ -96,7 +96,7 @@ static void busWrite(
|
||||
address &= ~((uint32_t) TYPE_SIZES[type] - 1);
|
||||
|
||||
/* Process by address range */
|
||||
switch (address >> 24 ^ 7) {
|
||||
switch (address >> 24 & 7) {
|
||||
case 0 : return; /* VIP */
|
||||
case 1 : return; /* VSU */
|
||||
case 2 : return; /* Miscellaneous hardware */
|
||||
|
||||
+22
-18
@@ -756,15 +756,15 @@ static void cpuAND(VB *emu, VB_INSTRUCTION *inst) {
|
||||
/* And Bit String Upward */
|
||||
#define cpuANDBSU(emu, inst) cpuBitString(emu, inst)
|
||||
|
||||
/* And Not Bit String Upward */
|
||||
#define cpuANDNBSU(emu, inst) cpuBitString(emu, inst)
|
||||
|
||||
/* And Immediate */
|
||||
static void cpuANDI(VB *emu, VB_INSTRUCTION *inst) {
|
||||
emu->cpu.program[inst->bits[0] >> 5 & 0x1F] = cpuBitwise(emu,
|
||||
emu->cpu.program[inst->bits[0] & 0x1F] & inst->bits[1]);
|
||||
}
|
||||
|
||||
/* And Not Bit String Upward */
|
||||
#define cpuANDNBSU(emu, inst) cpuBitString(emu, inst)
|
||||
|
||||
/* Conditional Branch */
|
||||
static void cpuBCOND(VB *emu, VB_INSTRUCTION *inst) {
|
||||
int32_t disp; /* Target address displacement */
|
||||
@@ -1124,15 +1124,15 @@ static void cpuOR(VB *emu, VB_INSTRUCTION *inst) {
|
||||
/* Or Bit String Upward */
|
||||
#define cpuORBSU(emu, inst) cpuBitString(emu, inst)
|
||||
|
||||
/* Or Not Bit String Upward */
|
||||
#define cpuORNBSU(emu, inst) cpuBitString(emu, inst)
|
||||
|
||||
/* Or Immediate */
|
||||
static void cpuORI(VB *emu, VB_INSTRUCTION *inst) {
|
||||
emu->cpu.program[inst->bits[0] >> 5 & 0x1F] = cpuBitwise(emu,
|
||||
emu->cpu.program[inst->bits[0] & 0x1F] | inst->bits[1]);
|
||||
}
|
||||
|
||||
/* Or Not Bit String Upward */
|
||||
#define cpuORNBSU(emu, inst) cpuBitString(emu, inst)
|
||||
|
||||
/* Output Byte */
|
||||
#define cpuOUT_B(emu, inst) cpuStore(emu, inst, VB_U8, 4)
|
||||
|
||||
@@ -1334,15 +1334,15 @@ static void cpuXOR(VB *emu, VB_INSTRUCTION *inst) {
|
||||
/* Exclusive Or Bit String Upward */
|
||||
#define cpuXORBSU(emu, inst) cpuBitString(emu, inst)
|
||||
|
||||
/* Exclusive Or Not Bit String Upward */
|
||||
#define cpuXORNBSU(emu, inst) cpuBitString(emu, inst)
|
||||
|
||||
/* Exclusive Or Immediate */
|
||||
static void cpuXORI(VB *emu, VB_INSTRUCTION *inst) {
|
||||
emu->cpu.program[inst->bits[0] >> 5 & 0x1F] = cpuBitwise(emu,
|
||||
emu->cpu.program[inst->bits[0] & 0x1F] ^ inst->bits[1]);
|
||||
}
|
||||
|
||||
/* Exclusive Or Not Bit String Upward */
|
||||
#define cpuXORNBSU(emu, inst) cpuBitString(emu, inst)
|
||||
|
||||
|
||||
|
||||
/***************************** Module Functions ******************************/
|
||||
@@ -1505,14 +1505,14 @@ static int cpuExecute(VB *emu) {
|
||||
|
||||
/* Enter an exception state */
|
||||
static int cpuException(VB *emu) {
|
||||
uint16_t causeCode = emu->cpu.causeCode;
|
||||
|
||||
/* Fatal exception */
|
||||
if (emu->cpu.psw.np) {
|
||||
|
||||
/* Write the cause code for debugging */
|
||||
if (emu->cpu.busWait == 0) {
|
||||
if (cpuWrite(emu, 0x00000000, VB_S32,
|
||||
0xFFFF0000 | emu->cpu.causeCode))
|
||||
if (cpuWrite(emu, 0x00000000, VB_S32, 0xFFFF0000 | causeCode))
|
||||
return 1;
|
||||
|
||||
/* Update state */
|
||||
@@ -1562,7 +1562,7 @@ static int cpuException(VB *emu) {
|
||||
|
||||
/* Duplexed exception */
|
||||
if (emu->cpu.psw.ep) {
|
||||
emu->cpu.ecr.fecc = emu->cpu.causeCode;
|
||||
emu->cpu.ecr.fecc = causeCode;
|
||||
emu->cpu.fepsw = vbGetSystemRegister(emu, VB_PSW);
|
||||
emu->cpu.fepc = emu->cpu.pc;
|
||||
emu->cpu.fepcFrom = emu->cpu.pcFrom;
|
||||
@@ -1573,17 +1573,19 @@ static int cpuException(VB *emu) {
|
||||
|
||||
/* Exception or interrupt */
|
||||
else {
|
||||
emu->cpu.ecr.eicc = emu->cpu.causeCode;
|
||||
emu->cpu.ecr.eicc = causeCode;
|
||||
emu->cpu.eipsw = vbGetSystemRegister(emu, VB_PSW);
|
||||
emu->cpu.eipc = emu->cpu.pc;
|
||||
emu->cpu.eipcFrom = emu->cpu.pcFrom;
|
||||
emu->cpu.eipcTo = emu->cpu.pcTo;
|
||||
emu->cpu.psw.ep = 1;
|
||||
emu->cpu.pc = (emu->cpu.causeCode & 0x0040) != 0 ?
|
||||
0xFFFFFF60 : ((uint32_t) 0xFFFF0000 | emu->cpu.causeCode);
|
||||
emu->cpu.pc = (causeCode & 0x0040) != 0 ?
|
||||
0xFFFFFF60 : ((uint32_t) 0xFFFF0000 | causeCode);
|
||||
}
|
||||
|
||||
/* Interrupt */
|
||||
if (emu->cpu.causeCode < 0xFF00)
|
||||
emu->cpu.psw.i = emu->cpu.psw.i == 15 ? 15 : emu->cpu.psw.i + 1;
|
||||
if (causeCode < 0xFF00)
|
||||
emu->cpu.psw.i += emu->cpu.psw.i == 15 ? 0 : 1;
|
||||
|
||||
/* Update state */
|
||||
emu->cpu.causeCode = 0;
|
||||
@@ -1593,7 +1595,9 @@ static int cpuException(VB *emu) {
|
||||
emu->cpu.pcFrom = emu->cpu.pc;
|
||||
emu->cpu.pcTo = emu->cpu.pc;
|
||||
/* emu->cpu.clocks = ? */
|
||||
return 0;
|
||||
|
||||
/* Call the breakpoint handler if available */
|
||||
return emu->onException != NULL && emu->onException(emu, causeCode);
|
||||
}
|
||||
|
||||
/* Perform instruction fetch operations */
|
||||
|
||||
@@ -16,7 +16,9 @@ static const uint8_t TYPE_SIZES[] = { 1, 1, 2, 2, 4 };
|
||||
/********************************** Macros ***********************************/
|
||||
|
||||
/* Sign-extend a value of some number of bits to 32 bits */
|
||||
#define SignExtend(v,b) ((v) | (((v) & ((1<<(b)) - 1)) ? ~(int32_t)0<<(b) : 0))
|
||||
#define SignExtend(v,b) \
|
||||
((v) | (((v) & (1 << ((b) - 1))) ? (uint32_t) 0xFFFFFFFF << (b) : 0))
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -220,7 +222,9 @@ void vbReset(VB *emu) {
|
||||
emu->cpu.pcTo = 0xFFFFFFF0;
|
||||
|
||||
/* Other CPU state */
|
||||
emu->cpu.state = CPU_FETCH;
|
||||
emu->cpu.busWait = 0;
|
||||
emu->cpu.state = CPU_FETCH;
|
||||
emu->cpu.substring = 0;
|
||||
for (x = 0; x < 5; x++)
|
||||
emu->cpu.irq[x] = 0;
|
||||
|
||||
@@ -277,6 +281,6 @@ uint32_t vbSetSystemRegister(VB *emu, int id, uint32_t value) {
|
||||
|
||||
/* Write a data unit to the bus */
|
||||
void vbWrite(VB *emu, uint32_t address, int type, int32_t value, int debug) {
|
||||
if (type < 0 || type >= (int32_t) sizeof TYPE_SIZES)
|
||||
if (type >= 0 && type < (int32_t) sizeof TYPE_SIZES)
|
||||
busWrite(emu, address, type, value, debug);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user