CPU corrections
This commit is contained in:
parent
573f72e46f
commit
89feaaa3e9
|
@ -520,7 +520,7 @@
|
|||
line : line,
|
||||
lines : lines,
|
||||
target : address,
|
||||
seekToPC: seekToPC,
|
||||
seekToPC: !!seekToPC,
|
||||
size : (end - start + 1) * 4
|
||||
});
|
||||
}
|
||||
|
|
|
@ -366,9 +366,9 @@
|
|||
let bits = this.bits(inst);
|
||||
let reg2 = this.PROREGNAMES[bits >> 21 & 31];
|
||||
let reg1 = this.PROREGNAMES[bits >> 16 & 31];
|
||||
let subop = this.signExtend(bits & 0xFFFF, 16);
|
||||
let subop = bits >> 10 & 63;
|
||||
inst.mnemonic = this.FLOATENDO[subop];
|
||||
if (inst.mnemonic = null)
|
||||
if (inst.mnemonic == null)
|
||||
return;
|
||||
switch (subop) {
|
||||
case 0b001000: // XB
|
||||
|
|
|
@ -149,6 +149,7 @@ globalThis.MemoryWindow = class MemoryWindow extends Toolkit.Window {
|
|||
command: "Write",
|
||||
sim : this.debug.sim,
|
||||
dbgwnd : "Memory",
|
||||
debug : true,
|
||||
address: this.selected,
|
||||
type : 0,
|
||||
value : value
|
||||
|
|
|
@ -483,7 +483,7 @@
|
|||
setRegister(value) {
|
||||
this.debug.core.postMessage({
|
||||
command: "SetRegister",
|
||||
debug : "CPU",
|
||||
dbgwnd : "CPU",
|
||||
id : this.id,
|
||||
sim : this.debug.sim,
|
||||
type : this.system ? this.id == -1 ? "pc" : "system" : "program",
|
||||
|
|
38
core/cpu.c
38
core/cpu.c
|
@ -657,7 +657,7 @@ static uint32_t cpuSetSystemRegister(VB *emu,int id,uint32_t value,int debug) {
|
|||
static int cpuShiftRight(VB *emu, int32_t value, int bits, int arithmetic) {
|
||||
if (bits != 0) {
|
||||
emu->cpu.psw.cy = (value >> (bits - 1)) & 1;
|
||||
value = value >> bits & (int32_t) 0xFFFFFFFF << bits;
|
||||
value = value >> bits & (((uint32_t) 1 << (32 - bits)) - 1);
|
||||
if (arithmetic)
|
||||
value = SignExtend(value, 32 - bits);
|
||||
} else emu->cpu.psw.cy = 0;
|
||||
|
@ -1064,7 +1064,7 @@ static void cpuMPYHW(VB *emu, VB_INSTRUCTION *inst) {
|
|||
|
||||
/* Multiply */
|
||||
static void cpuMUL(VB *emu, VB_INSTRUCTION *inst) {
|
||||
int32_t *reg2 = &emu->cpu.program[inst->bits[0] >> 5 & 0xFF];
|
||||
int32_t *reg2 = &emu->cpu.program[inst->bits[0] >> 5 & 0x1F];
|
||||
int64_t result = (int64_t) *reg2 *
|
||||
emu->cpu.program[inst->bits[0] & 0x1F];
|
||||
emu->cpu.program[30] = result >> 32;
|
||||
|
@ -1095,7 +1095,7 @@ static void cpuMULF_S(VB *emu, VB_INSTRUCTION *inst) {
|
|||
|
||||
/* Multiply Unsigned */
|
||||
static void cpuMULU(VB *emu, VB_INSTRUCTION *inst) {
|
||||
uint32_t *reg2 = (uint32_t *) &emu->cpu.program[inst->bits[0]>>5&0xFF];
|
||||
uint32_t *reg2 = (uint32_t *) &emu->cpu.program[inst->bits[0]>>5&0x1F];
|
||||
uint64_t result = (uint64_t) *reg2 *
|
||||
(uint32_t) emu->cpu.program[inst->bits[0] & 0x1F];
|
||||
emu->cpu.program[30] = result >> 32;
|
||||
|
@ -1182,11 +1182,12 @@ static void cpuRETI(VB *emu, VB_INSTRUCTION *inst) {
|
|||
/* Reverse Bits in Word */
|
||||
static void cpuREV(VB *emu, VB_INSTRUCTION *inst) {
|
||||
int32_t value = emu->cpu.program[inst->bits[0] & 0x1F];
|
||||
value = (value >> 8 & 0x00FF00FF) | (value << 8 & (int32_t) 0xFF00FF00);
|
||||
value = (value >> 4 & 0x0F0F0F0F) | (value << 4 & (int32_t) 0xF0F0F0F0);
|
||||
value = (value >> 2 & 0x33333333) | (value << 2 & (int32_t) 0xCCCCCCCC);
|
||||
value = (value >> 16 & 0x0000FFFF) | (value << 16 & (int32_t) 0xFFFF0000);
|
||||
value = (value >> 8 & 0x00FF00FF) | (value << 8 & (int32_t) 0xFF00FF00);
|
||||
value = (value >> 4 & 0x0F0F0F0F) | (value << 4 & (int32_t) 0xF0F0F0F0);
|
||||
value = (value >> 2 & 0x33333333) | (value << 2 & (int32_t) 0xCCCCCCCC);
|
||||
emu->cpu.program[inst->bits[0] >> 5 & 0x1F] =
|
||||
(value >> 1 & 0x55555555) | (value << 1 & (int32_t) 0xAAAAAAAA);
|
||||
(value >> 1 & 0x55555555) | (value << 1 & (int32_t) 0xAAAAAAAA);
|
||||
emu->cpu.clocks = 22;
|
||||
}
|
||||
|
||||
|
@ -1311,9 +1312,9 @@ static void cpuTRAP(VB *emu, VB_INSTRUCTION *inst) {
|
|||
static void cpuXB(VB *emu, VB_INSTRUCTION *inst) {
|
||||
int32_t *reg2 = &emu->cpu.program[inst->bits[0] >> 5 & 0x1F];
|
||||
*reg2 =
|
||||
(*reg2 >> 8 & (int32_t) 0x00FF0000) |
|
||||
(*reg2 << 8 & (int32_t) 0xFF000000) |
|
||||
(*reg2 & (int32_t) 0x0000FFFF)
|
||||
(*reg2 >> 8 & (int32_t) 0x000000FF) |
|
||||
(*reg2 << 8 & (int32_t) 0x0000FF00) |
|
||||
(*reg2 & (int32_t) 0xFFFF0000)
|
||||
;
|
||||
emu->cpu.clocks = 6;
|
||||
}
|
||||
|
@ -1378,8 +1379,18 @@ static int cpuCheckIRQs(VB *emu) {
|
|||
|
||||
/* Perform instruction execute operations */
|
||||
static int cpuExecute(VB *emu) {
|
||||
int broke = 0; /* Application break occurred */
|
||||
VB_INSTRUCTION *inst = &emu->cpu.inst; /* Shorthand reference */
|
||||
int broke; /* Application break occurred */
|
||||
VB_INSTRUCTION *inst; /* Shorthand reference */
|
||||
|
||||
/* Check for address trap */
|
||||
if (emu->cpu.psw.ae && emu->cpu.adtre == emu->cpu.pc) {
|
||||
emu->cpu.causeCode = 0xFFC0;
|
||||
emu->cpu.state = CPU_EXCEPTION;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Working variables */
|
||||
inst = &emu->cpu.inst;
|
||||
|
||||
/* Check for application break */
|
||||
if (emu->onExecute != NULL && emu->onExecute(emu, inst))
|
||||
|
@ -1389,6 +1400,7 @@ static int cpuExecute(VB *emu) {
|
|||
emu->cpu.causeCode = 0;
|
||||
|
||||
/* Processing by ID */
|
||||
broke = 0;
|
||||
switch (inst->id) {
|
||||
case CPU_ADD_IMM: cpuADD_IMM(emu, inst); break;
|
||||
case CPU_ADD_REG: cpuADD_REG(emu, inst); break;
|
||||
|
@ -1651,7 +1663,7 @@ static int cpuFetch(VB *emu) {
|
|||
}
|
||||
|
||||
/* Update state */
|
||||
emu->cpu.fetch = -1;
|
||||
emu->cpu.fetch = 0;
|
||||
emu->cpu.state = CPU_EXECUTE;
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue