sim65: cycles does not increment 1 at a time, so some small overhead is needed in range check
This commit is contained in:
@@ -64,6 +64,12 @@ const char* ProgramFile;
|
||||
/* exit simulator after MaxCycles Cycles */
|
||||
unsigned long MaxCycles;
|
||||
|
||||
/* maximum number of cycles that can be tested,
|
||||
** requires overhead for longest possible instruction,
|
||||
** which should be 7, using 16 for safety.
|
||||
*/
|
||||
#define MAXCYCLES_LIMIT (ULONG_MAX-16)
|
||||
|
||||
/* Header signature 'sim65' */
|
||||
static const unsigned char HeaderSignature[] = {
|
||||
0x73, 0x69, 0x6D, 0x36, 0x35
|
||||
@@ -73,7 +79,6 @@ static const unsigned char HeaderSignature[] = {
|
||||
static const unsigned char HeaderVersion = 2;
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Code */
|
||||
/*****************************************************************************/
|
||||
@@ -142,8 +147,8 @@ static void OptQuitXIns (const char* Opt attribute ((unused)),
|
||||
{
|
||||
MaxCycles = strtoul(Arg, NULL, 0);
|
||||
/* Guard against overflow. */
|
||||
if (MaxCycles == ULONG_MAX && errno == ERANGE) {
|
||||
Error("'-x parameter out of range. Max: %lu",ULONG_MAX);
|
||||
if (MaxCycles >= MAXCYCLES_LIMIT) {
|
||||
Error("'-x parameter out of range. Max: %lu",MAXCYCLES_LIMIT);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user