* Definitions for the emulator architecture *
\***************************************************************************/
-void ARMul_EmulateInit(void) ;
-ARMul_State *ARMul_NewState(void) ;
-void ARMul_Reset(ARMul_State *state) ;
-ARMword ARMul_DoCycle(ARMul_State *state) ;
-unsigned ARMul_DoCoPro(ARMul_State *state) ;
-ARMword ARMul_DoProg(ARMul_State *state) ;
-ARMword ARMul_DoInstr(ARMul_State *state) ;
-void ARMul_Abort(ARMul_State *state, ARMword address) ;
-
-unsigned ARMul_MultTable[32] = {1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,
- 10,10,11,11,12,12,13,13,14,14,15,15,16,16,16} ;
-ARMword ARMul_ImmedTable[4096] ; /* immediate DP LHS values */
-char ARMul_BitList[256] ; /* number of bits in a byte table */
+void ARMul_EmulateInit (void);
+ARMul_State *ARMul_NewState (void);
+void ARMul_Reset (ARMul_State * state);
+ARMword ARMul_DoCycle (ARMul_State * state);
+unsigned ARMul_DoCoPro (ARMul_State * state);
+ARMword ARMul_DoProg (ARMul_State * state);
+ARMword ARMul_DoInstr (ARMul_State * state);
+void ARMul_Abort (ARMul_State * state, ARMword address);
+
+unsigned ARMul_MultTable[32] =
+ { 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9,
+ 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 16
+};
+ARMword ARMul_ImmedTable[4096]; /* immediate DP LHS values */
+char ARMul_BitList[256]; /* number of bits in a byte table */
/***************************************************************************\
* Call this routine once to set up the emulator's tables. *
\***************************************************************************/
-void ARMul_EmulateInit(void)
-{unsigned long i, j ;
+void
+ARMul_EmulateInit (void)
+{
+ unsigned long i, j;
- for (i = 0 ; i < 4096 ; i++) { /* the values of 12 bit dp rhs's */
- ARMul_ImmedTable[i] = ROTATER(i & 0xffL,(i >> 7L) & 0x1eL) ;
+ for (i = 0; i < 4096; i++)
+ { /* the values of 12 bit dp rhs's */
+ ARMul_ImmedTable[i] = ROTATER (i & 0xffL, (i >> 7L) & 0x1eL);
}
- for (i = 0 ; i < 256 ; ARMul_BitList[i++] = 0 ) ; /* how many bits in LSM */
- for (j = 1 ; j < 256 ; j <<= 1)
- for (i = 0 ; i < 256 ; i++)
- if ((i & j) > 0 )
- ARMul_BitList[i]++ ;
+ for (i = 0; i < 256; ARMul_BitList[i++] = 0); /* how many bits in LSM */
+ for (j = 1; j < 256; j <<= 1)
+ for (i = 0; i < 256; i++)
+ if ((i & j) > 0)
+ ARMul_BitList[i]++;
+
+ for (i = 0; i < 256; i++)
+ ARMul_BitList[i] *= 4; /* you always need 4 times these values */
- for (i = 0 ; i < 256 ; i++)
- ARMul_BitList[i] *= 4 ; /* you always need 4 times these values */
-
}
/***************************************************************************\
* Returns a new instantiation of the ARMulator's state *
\***************************************************************************/
-ARMul_State *ARMul_NewState(void)
-{ARMul_State *state ;
- unsigned i, j ;
-
- state = (ARMul_State *)malloc(sizeof(ARMul_State)) ;
- memset (state, 0, sizeof (ARMul_State));
-
- state->Emulate = RUN ;
- for (i = 0 ; i < 16 ; i++) {
- state->Reg[i] = 0 ;
- for (j = 0 ; j < 7 ; j++)
- state->RegBank[j][i] = 0 ;
+ARMul_State *
+ARMul_NewState (void)
+{
+ ARMul_State *state;
+ unsigned i, j;
+
+ state = (ARMul_State *) malloc (sizeof (ARMul_State));
+ memset (state, 0, sizeof (ARMul_State));
+
+ state->Emulate = RUN;
+ for (i = 0; i < 16; i++)
+ {
+ state->Reg[i] = 0;
+ for (j = 0; j < 7; j++)
+ state->RegBank[j][i] = 0;
}
- for (i = 0 ; i < 7 ; i++)
- state->Spsr[i] = 0 ;
- state->Mode = 0 ;
-
- state->CallDebug = FALSE ;
- state->Debug = FALSE ;
- state->VectorCatch = 0 ;
- state->Aborted = FALSE ;
- state->Reseted = FALSE ;
- state->Inted = 3 ;
- state->LastInted = 3 ;
-
- state->MemDataPtr = NULL ;
- state->MemInPtr = NULL ;
- state->MemOutPtr = NULL ;
- state->MemSparePtr = NULL ;
- state->MemSize = 0 ;
-
- state->OSptr = NULL ;
- state->CommandLine = NULL ;
-
- state->EventSet = 0 ;
- state->Now = 0 ;
- state->EventPtr = (struct EventNode **)malloc((unsigned)EVENTLISTSIZE *
- sizeof(struct EventNode *)) ;
- for (i = 0 ; i < EVENTLISTSIZE ; i++)
- *(state->EventPtr + i) = NULL ;
+ for (i = 0; i < 7; i++)
+ state->Spsr[i] = 0;
+
+ state->Mode = USER26MODE;
+
+ state->CallDebug = FALSE;
+ state->Debug = FALSE;
+ state->VectorCatch = 0;
+ state->Aborted = FALSE;
+ state->Reseted = FALSE;
+ state->Inted = 3;
+ state->LastInted = 3;
+
+ state->MemDataPtr = NULL;
+ state->MemInPtr = NULL;
+ state->MemOutPtr = NULL;
+ state->MemSparePtr = NULL;
+ state->MemSize = 0;
+
+ state->OSptr = NULL;
+ state->CommandLine = NULL;
+
+ state->EventSet = 0;
+ state->Now = 0;
+ state->EventPtr = (struct EventNode **) malloc ((unsigned) EVENTLISTSIZE *
+ sizeof (struct EventNode
+ *));
+ for (i = 0; i < EVENTLISTSIZE; i++)
+ *(state->EventPtr + i) = NULL;
#ifdef ARM61
- state->prog32Sig = LOW ;
- state->data32Sig = LOW ;
+ state->prog32Sig = LOW;
+ state->data32Sig = LOW;
#else
- state->prog32Sig = HIGH ;
- state->data32Sig = HIGH ;
+ state->prog32Sig = HIGH;
+ state->data32Sig = HIGH;
#endif
- state->lateabtSig = LOW ;
- state->bigendSig = LOW ;
+ state->lateabtSig = LOW;
+ state->bigendSig = LOW;
- ARMul_Reset(state) ;
- return(state) ;
- }
+ ARMul_Reset (state);
+ return (state);
+}
/***************************************************************************\
* Call this routine to set ARMulator to model a certain processor *
\***************************************************************************/
-
-void ARMul_SelectProcessor(ARMul_State *state, unsigned processor) {
- if (processor & ARM_Fix26_Prop) {
- state->prog32Sig = LOW;
- state->data32Sig = LOW;
- }else{
- state->prog32Sig = HIGH;
- state->data32Sig = HIGH;
- }
-
+
+void
+ARMul_SelectProcessor (ARMul_State * state, unsigned processor)
+{
+ if (processor & ARM_Fix26_Prop)
+ {
+ state->prog32Sig = LOW;
+ state->data32Sig = LOW;
+ }
+ else
+ {
+ state->prog32Sig = HIGH;
+ state->data32Sig = HIGH;
+ }
+
state->lateabtSig = LOW;
}
* Call this routine to set up the initial machine state (or perform a RESET *
\***************************************************************************/
-void ARMul_Reset(ARMul_State *state)
-{state->NextInstr = 0 ;
- if (state->prog32Sig) {
- state->Reg[15] = 0 ;
- state->Cpsr = INTBITS | SVC32MODE ;
+void
+ARMul_Reset (ARMul_State * state)
+{
+ state->NextInstr = 0;
+
+ if (state->prog32Sig)
+ {
+ state->Reg[15] = 0;
+ state->Cpsr = INTBITS | SVC32MODE;
+ state->Mode = SVC32MODE;
}
- else {
- state->Reg[15] = R15INTBITS | SVC26MODE ;
- state->Cpsr = INTBITS | SVC26MODE ;
+ else
+ {
+ state->Reg[15] = R15INTBITS | SVC26MODE;
+ state->Cpsr = INTBITS | SVC26MODE;
+ state->Mode = SVC26MODE;
}
- ARMul_CPSRAltered(state) ;
- state->Bank = SVCBANK ;
- FLUSHPIPE ;
-
- state->EndCondition = 0 ;
- state->ErrorCode = 0 ;
-
- state->Exception = FALSE ;
- state->NresetSig = HIGH ;
- state->NfiqSig = HIGH ;
- state->NirqSig = HIGH ;
- state->NtransSig = (state->Mode & 3)?HIGH:LOW ;
- state->abortSig = LOW ;
- state->AbortAddr = 1 ;
-
- state->NumInstrs = 0 ;
- state->NumNcycles = 0 ;
- state->NumScycles = 0 ;
- state->NumIcycles = 0 ;
- state->NumCcycles = 0 ;
- state->NumFcycles = 0 ;
-#ifdef ASIM
- (void)ARMul_MemoryInit() ;
- ARMul_OSInit(state) ;
-#endif
+
+ ARMul_CPSRAltered (state);
+ state->Bank = SVCBANK;
+
+ FLUSHPIPE;
+
+ state->EndCondition = 0;
+ state->ErrorCode = 0;
+
+ state->Exception = FALSE;
+ state->NresetSig = HIGH;
+ state->NfiqSig = HIGH;
+ state->NirqSig = HIGH;
+ state->NtransSig = (state->Mode & 3) ? HIGH : LOW;
+ state->abortSig = LOW;
+ state->AbortAddr = 1;
+
+ state->NumInstrs = 0;
+ state->NumNcycles = 0;
+ state->NumScycles = 0;
+ state->NumIcycles = 0;
+ state->NumCcycles = 0;
+ state->NumFcycles = 0;
+#ifdef ASIM
+ (void) ARMul_MemoryInit ();
+ ARMul_OSInit (state);
+#endif
}
* address of the last instruction that is executed. *
\***************************************************************************/
-ARMword ARMul_DoProg(ARMul_State *state)
-{ARMword pc = 0 ;
-
- state->Emulate = RUN ;
- while (state->Emulate != STOP) {
- state->Emulate = RUN ;
- if (state->prog32Sig && ARMul_MODE32BIT)
- pc = ARMul_Emulate32(state) ;
- else
- pc = ARMul_Emulate26(state) ;
+ARMword
+ARMul_DoProg (ARMul_State * state)
+{
+ ARMword pc = 0;
+
+ state->Emulate = RUN;
+ while (state->Emulate != STOP)
+ {
+ state->Emulate = RUN;
+ if (state->prog32Sig && ARMul_MODE32BIT)
+ pc = ARMul_Emulate32 (state);
+ else
+ pc = ARMul_Emulate26 (state);
}
- return(pc) ;
- }
+ return (pc);
+}
/***************************************************************************\
* Emulate the execution of one instruction. Start the correct emulator *
* address of the instruction that is executed. *
\***************************************************************************/
-ARMword ARMul_DoInstr(ARMul_State *state)
-{ARMword pc = 0 ;
+ARMword
+ARMul_DoInstr (ARMul_State * state)
+{
+ ARMword pc = 0;
- state->Emulate = ONCE ;
- if (state->prog32Sig && ARMul_MODE32BIT)
- pc = ARMul_Emulate32(state) ;
- else
- pc = ARMul_Emulate26(state) ;
+ state->Emulate = ONCE;
+ if (state->prog32Sig && ARMul_MODE32BIT)
+ pc = ARMul_Emulate32 (state);
+ else
+ pc = ARMul_Emulate26 (state);
- return(pc) ;
- }
+ return (pc);
+}
/***************************************************************************\
* This routine causes an Abort to occur, including selecting the correct *
* appropriate vector's memory address (0,4,8 ....) *
\***************************************************************************/
-void ARMul_Abort(ARMul_State *state, ARMword vector)
-{ARMword temp ;
+void
+ARMul_Abort (ARMul_State * state, ARMword vector)
+{
+ ARMword temp;
- state->Aborted = FALSE ;
+ state->Aborted = FALSE;
- if (ARMul_OSException(state,vector,ARMul_GetPC(state)))
- return ;
+ if (ARMul_OSException (state, vector, ARMul_GetPC (state)))
+ return;
- if (state->prog32Sig)
+ if (state->prog32Sig)
if (ARMul_MODE26BIT)
- temp = R15PC ;
+ temp = R15PC;
else
- temp = state->Reg[15] ;
- else
- temp = R15PC | ECC | ER15INT | EMODE ;
-
- switch (vector) {
- case ARMul_ResetV : /* RESET */
- state->Spsr[SVCBANK] = CPSR ;
- SETABORT(INTBITS,state->prog32Sig?SVC32MODE:SVC26MODE) ;
- ARMul_CPSRAltered(state) ;
- state->Reg[14] = temp ;
- break ;
- case ARMul_UndefinedInstrV : /* Undefined Instruction */
- state->Spsr[state->prog32Sig?UNDEFBANK:SVCBANK] = CPSR ;
- SETABORT(IBIT,state->prog32Sig?UNDEF32MODE:SVC26MODE) ;
- ARMul_CPSRAltered(state) ;
- state->Reg[14] = temp - 4 ;
- break ;
- case ARMul_SWIV : /* Software Interrupt */
- state->Spsr[SVCBANK] = CPSR ;
- SETABORT(IBIT,state->prog32Sig?SVC32MODE:SVC26MODE) ;
- ARMul_CPSRAltered(state) ;
- state->Reg[14] = temp - 4 ;
- break ;
- case ARMul_PrefetchAbortV : /* Prefetch Abort */
- state->AbortAddr = 1 ;
- state->Spsr[state->prog32Sig?ABORTBANK:SVCBANK] = CPSR ;
- SETABORT(IBIT,state->prog32Sig?ABORT32MODE:SVC26MODE) ;
- ARMul_CPSRAltered(state) ;
- state->Reg[14] = temp - 4 ;
- break ;
- case ARMul_DataAbortV : /* Data Abort */
- state->Spsr[state->prog32Sig?ABORTBANK:SVCBANK] = CPSR ;
- SETABORT(IBIT,state->prog32Sig?ABORT32MODE:SVC26MODE) ;
- ARMul_CPSRAltered(state) ;
- state->Reg[14] = temp - 4 ; /* the PC must have been incremented */
- break ;
- case ARMul_AddrExceptnV : /* Address Exception */
- state->Spsr[SVCBANK] = CPSR ;
- SETABORT(IBIT,SVC26MODE) ;
- ARMul_CPSRAltered(state) ;
- state->Reg[14] = temp - 4 ;
- break ;
- case ARMul_IRQV : /* IRQ */
- state->Spsr[IRQBANK] = CPSR ;
- SETABORT(IBIT,state->prog32Sig?IRQ32MODE:IRQ26MODE) ;
- ARMul_CPSRAltered(state) ;
- state->Reg[14] = temp - 4 ;
- break ;
- case ARMul_FIQV : /* FIQ */
- state->Spsr[FIQBANK] = CPSR ;
- SETABORT(INTBITS,state->prog32Sig?FIQ32MODE:FIQ26MODE) ;
- ARMul_CPSRAltered(state) ;
- state->Reg[14] = temp - 4 ;
- break ;
+ temp = state->Reg[15];
+ else
+ temp = R15PC | ECC | ER15INT | EMODE;
+
+ switch (vector)
+ {
+ case ARMul_ResetV: /* RESET */
+ state->Spsr[SVCBANK] = CPSR;
+ SETABORT (INTBITS, state->prog32Sig ? SVC32MODE : SVC26MODE);
+ ARMul_CPSRAltered (state);
+ state->Reg[14] = temp;
+ break;
+ case ARMul_UndefinedInstrV: /* Undefined Instruction */
+ state->Spsr[state->prog32Sig ? UNDEFBANK : SVCBANK] = CPSR;
+ SETABORT (IBIT, state->prog32Sig ? UNDEF32MODE : SVC26MODE);
+ ARMul_CPSRAltered (state);
+ state->Reg[14] = temp - 4;
+ break;
+ case ARMul_SWIV: /* Software Interrupt */
+ state->Spsr[SVCBANK] = CPSR;
+ SETABORT (IBIT, state->prog32Sig ? SVC32MODE : SVC26MODE);
+ ARMul_CPSRAltered (state);
+ state->Reg[14] = temp - 4;
+ break;
+ case ARMul_PrefetchAbortV: /* Prefetch Abort */
+ state->AbortAddr = 1;
+ state->Spsr[state->prog32Sig ? ABORTBANK : SVCBANK] = CPSR;
+ SETABORT (IBIT, state->prog32Sig ? ABORT32MODE : SVC26MODE);
+ ARMul_CPSRAltered (state);
+ state->Reg[14] = temp - 4;
+ break;
+ case ARMul_DataAbortV: /* Data Abort */
+ state->Spsr[state->prog32Sig ? ABORTBANK : SVCBANK] = CPSR;
+ SETABORT (IBIT, state->prog32Sig ? ABORT32MODE : SVC26MODE);
+ ARMul_CPSRAltered (state);
+ state->Reg[14] = temp - 4; /* the PC must have been incremented */
+ break;
+ case ARMul_AddrExceptnV: /* Address Exception */
+ state->Spsr[SVCBANK] = CPSR;
+ SETABORT (IBIT, SVC26MODE);
+ ARMul_CPSRAltered (state);
+ state->Reg[14] = temp - 4;
+ break;
+ case ARMul_IRQV: /* IRQ */
+ state->Spsr[IRQBANK] = CPSR;
+ SETABORT (IBIT, state->prog32Sig ? IRQ32MODE : IRQ26MODE);
+ ARMul_CPSRAltered (state);
+ state->Reg[14] = temp - 4;
+ break;
+ case ARMul_FIQV: /* FIQ */
+ state->Spsr[FIQBANK] = CPSR;
+ SETABORT (INTBITS, state->prog32Sig ? FIQ32MODE : FIQ26MODE);
+ ARMul_CPSRAltered (state);
+ state->Reg[14] = temp - 4;
+ break;
}
- if (ARMul_MODE32BIT)
- ARMul_SetR15(state,vector) ;
- else
- ARMul_SetR15(state,R15CCINTMODE | vector) ;
+ if (ARMul_MODE32BIT)
+ ARMul_SetR15 (state, vector);
+ else
+ ARMul_SetR15 (state, R15CCINTMODE | vector);
}
ARMword ARMul_SwitchMode (ARMul_State * state, ARMword oldmode,
ARMword newmode);
-static ARMword ModeToBank (ARMul_State * state, ARMword mode);
+static ARMword ModeToBank (ARMword mode);
unsigned ARMul_NthReg (ARMword instr, unsigned number);
{
mode &= MODEBITS;
if (mode != state->Mode)
- return (state->RegBank[ModeToBank (state, (ARMword) mode)][reg]);
+ return (state->RegBank[ModeToBank ((ARMword) mode)][reg]);
else
return (state->Reg[reg]);
}
{
mode &= MODEBITS;
if (mode != state->Mode)
- state->RegBank[ModeToBank (state, (ARMword) mode)][reg] = value;
+ state->RegBank[ModeToBank ((ARMword) mode)][reg] = value;
else
state->Reg[reg] = value;
}
ARMword
ARMul_GetSPSR (ARMul_State * state, ARMword mode)
{
- ARMword bank = ModeToBank (state, mode & MODEBITS);
- if (bank == USERBANK || bank == DUMMYBANK)
- return (CPSR);
- else
- return (state->Spsr[bank]);
+ ARMword bank = ModeToBank (mode & MODEBITS);
+
+ if (! BANK_CAN_ACCESS_SPSR (bank))
+ return CPSR;
+
+ return state->Spsr[bank];
}
/***************************************************************************\
void
ARMul_SetSPSR (ARMul_State * state, ARMword mode, ARMword value)
{
- ARMword bank = ModeToBank (state, mode & MODEBITS);
- if (bank != USERBANK && bank != DUMMYBANK)
+ ARMword bank = ModeToBank (mode & MODEBITS);
+
+ if (BANK_CAN_ACCESS_SPSR (bank))
state->Spsr[bank] = value;
}
void
ARMul_FixSPSR (ARMul_State * state, ARMword instr, ARMword rhs)
{
- if (state->Bank != USERBANK && state->Bank != DUMMYBANK)
+ if (BANK_CAN_ACCESS_SPSR (state->Bank))
{
if (BITS (16, 19) == 9)
SETPSR (state->Spsr[state->Bank], rhs);
if (state->prog32Sig == LOW)
state->Cpsr &= (CCBITS | INTBITS | R15MODEBITS);
+
oldmode = state->Mode;
+
if (state->Mode != (state->Cpsr & MODEBITS))
{
state->Mode =
ARMul_SwitchMode (state, state->Mode, state->Cpsr & MODEBITS);
+
state->NtransSig = (state->Mode & 3) ? HIGH : LOW;
}
else
state->Reg[15] = ECC | ER15INT | EMODE | R15PC;
}
-
}
/***************************************************************************\
ARMul_SwitchMode (ARMul_State * state, ARMword oldmode, ARMword newmode)
{
unsigned i;
-
- oldmode = ModeToBank (state, oldmode);
- state->Bank = ModeToBank (state, newmode);
- if (oldmode != state->Bank)
+ ARMword oldbank;
+ ARMword newbank;
+
+ oldbank = ModeToBank (oldmode);
+ newbank = state->Bank = ModeToBank (newmode);
+
+ if (oldbank != newbank)
{ /* really need to do it */
- switch (oldmode)
+ switch (oldbank)
{ /* save away the old registers */
+ case SYSTEMBANK:
+ /* The System mode uses the USER bank. */
+ oldbank = USERBANK;
+ /* Fall through. */
case USERBANK:
case IRQBANK:
case SVCBANK:
case ABORTBANK:
case UNDEFBANK:
- if (state->Bank == FIQBANK)
+ if (newbank == FIQBANK)
for (i = 8; i < 13; i++)
state->RegBank[USERBANK][i] = state->Reg[i];
- state->RegBank[oldmode][13] = state->Reg[13];
- state->RegBank[oldmode][14] = state->Reg[14];
+ state->RegBank[oldbank][13] = state->Reg[13];
+ state->RegBank[oldbank][14] = state->Reg[14];
break;
case FIQBANK:
for (i = 8; i < 15; i++)
for (i = 8; i < 15; i++)
state->RegBank[DUMMYBANK][i] = 0;
break;
-
+ default:
+ abort ();
}
- switch (state->Bank)
+
+ switch (newbank)
{ /* restore the new registers */
+ case SYSTEMBANK:
+ newbank = USERBANK;
+ /* Fall through. */
case USERBANK:
case IRQBANK:
case SVCBANK:
case ABORTBANK:
case UNDEFBANK:
- if (oldmode == FIQBANK)
+ if (oldbank == FIQBANK)
for (i = 8; i < 13; i++)
state->Reg[i] = state->RegBank[USERBANK][i];
- state->Reg[13] = state->RegBank[state->Bank][13];
- state->Reg[14] = state->RegBank[state->Bank][14];
+ state->Reg[13] = state->RegBank[newbank][13];
+ state->Reg[14] = state->RegBank[newbank][14];
break;
case FIQBANK:
for (i = 8; i < 15; i++)
for (i = 8; i < 15; i++)
state->Reg[i] = 0;
break;
+ default:
+ abort ();
} /* switch */
} /* if */
- return (newmode);
+
+ return newmode;
}
/***************************************************************************\
\***************************************************************************/
static ARMword
-ModeToBank (ARMul_State * state ATTRIBUTE_UNUSED, ARMword mode)
+ModeToBank (ARMword mode)
{
- static ARMword bankofmode[] = { USERBANK, FIQBANK, IRQBANK, SVCBANK,
+ static ARMword bankofmode[] =
+ {
+ USERBANK, FIQBANK, IRQBANK, SVCBANK,
DUMMYBANK, DUMMYBANK, DUMMYBANK, DUMMYBANK,
DUMMYBANK, DUMMYBANK, DUMMYBANK, DUMMYBANK,
DUMMYBANK, DUMMYBANK, DUMMYBANK, DUMMYBANK,
- USERBANK, FIQBANK, IRQBANK, SVCBANK,
+ USERBANK, FIQBANK, IRQBANK, SVCBANK,
DUMMYBANK, DUMMYBANK, DUMMYBANK, ABORTBANK,
- DUMMYBANK, DUMMYBANK, DUMMYBANK, UNDEFBANK
+ DUMMYBANK, DUMMYBANK, DUMMYBANK, UNDEFBANK,
+ DUMMYBANK, DUMMYBANK, DUMMYBANK, SYSTEMBANK
};
- if (mode > UNDEF32MODE)
- return (DUMMYBANK);
- else
- return (bankofmode[mode]);
+ if (mode >= (sizeof (bankofmode) / sizeof (bankofmode[0])))
+ return DUMMYBANK;
+
+ return bankofmode[mode];
}
/***************************************************************************\
unsigned cpab;
cpab = (state->MCR[CPNum]) (state, ARMul_FIRST, instr, source);
+
while (cpab == ARMul_BUSY)
{
ARMul_Icycles (state, 1, 0);
+
if (IntPending (state))
{
cpab = (state->MCR[CPNum]) (state, ARMul_INTERRUPT, instr, 0);
else
cpab = (state->MCR[CPNum]) (state, ARMul_BUSY, instr, source);
}
+
if (cpab == ARMul_CANT)
ARMul_Abort (state, ARMul_UndefinedInstrV);
else