int Exec6502(M6502 *R,int RunCycles) { register pair J,K; register byte I; /* Execute requested number of cycles */ while(RunCycles>0) { #ifdef DEBUG /* Turn tracing on when reached trap address */ if(R->PC.W==R->Trap) R->Trace=1; /* Call single-step debugger, exit if requested */ if(R->Trace) if(!Debug6502(R)) return(RunCycles); #endif I=Op6502(R->PC.W++); RunCycles-=Cycles[I]; switch(I) { #include "Codes.h" } } /* Return number of cycles left (<=0) */ return(RunCycles); }
word Run6502(M6502 *R) { register pair J,K; register byte I; for(;;) { #ifdef S60 Opt6502(R); #else /* !S60 */ #ifdef DEBUG /* Turn tracing on when reached trap address */ if(R->PC.W==R->Trap) R->Trace=1; /* Call single-step debugger, exit if requested */ if(R->Trace) if(!Debug6502(R)) return(R->PC.W); #endif I=Op6502(R->PC.W++); R->ICount-=Cycles[I]; switch(I) { #include "Codes.h" } #endif /* !S60 */ /* If cycle counter expired... */ if(R->ICount<=0) { /* If we have come after CLI, get INT_? from IRequest */ /* Otherwise, get it from the loop handler */ if(R->AfterCLI) { I=R->IRequest; /* Get pending interrupt */ R->ICount+=R->IBackup-1; /* Restore the ICount */ R->AfterCLI=0; /* Done with AfterCLI state */ } else { I=Loop6502(R); /* Call the periodic handler */ R->ICount+=R->IPeriod; /* Reset the cycle counter */ if(!I) I=R->IRequest; /* Realize pending interrupt */ } if(I==INT_QUIT) return(R->PC.W); /* Exit if INT_QUIT */ if(I) Int6502(R,I); /* Interrupt if needed */ } } /* Execution stopped */ return(R->PC.W); }
/*************************************************************/ #if 0 /* -NS- */ word Exec6502(M6502 *R) { register pair J,K; register byte I; I=Op6502(R->PC.W++); R->ICount-=Cycles[I]; switch(I) { #include "Codes.h" } /* We are done */ return(R->PC.W); }