mirror of
https://github.com/cc65/cc65.git
synced 2024-12-28 06:30:16 +00:00
Merge pull request #2099 from bbbradsmith/split2092-sim65-fix
sim65 fix platform-dependent issues
This commit is contained in:
commit
7b40515506
@ -36,6 +36,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <limits.h>
|
||||||
|
|
||||||
/* common */
|
/* common */
|
||||||
#include "abend.h"
|
#include "abend.h"
|
||||||
@ -63,6 +64,12 @@ const char* ProgramFile;
|
|||||||
/* exit simulator after MaxCycles Cycles */
|
/* exit simulator after MaxCycles Cycles */
|
||||||
unsigned long MaxCycles;
|
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' */
|
/* Header signature 'sim65' */
|
||||||
static const unsigned char HeaderSignature[] = {
|
static const unsigned char HeaderSignature[] = {
|
||||||
0x73, 0x69, 0x6D, 0x36, 0x35
|
0x73, 0x69, 0x6D, 0x36, 0x35
|
||||||
@ -72,7 +79,6 @@ static const unsigned char HeaderSignature[] = {
|
|||||||
static const unsigned char HeaderVersion = 2;
|
static const unsigned char HeaderVersion = 2;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Code */
|
/* Code */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
@ -140,6 +146,10 @@ static void OptQuitXIns (const char* Opt attribute ((unused)),
|
|||||||
/* quit after MaxCycles cycles */
|
/* quit after MaxCycles cycles */
|
||||||
{
|
{
|
||||||
MaxCycles = strtoul(Arg, NULL, 0);
|
MaxCycles = strtoul(Arg, NULL, 0);
|
||||||
|
/* Guard against overflow. */
|
||||||
|
if (MaxCycles >= MAXCYCLES_LIMIT) {
|
||||||
|
Error("'-x parameter out of range. Max: %lu",MAXCYCLES_LIMIT);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned char ReadProgramFile (void)
|
static unsigned char ReadProgramFile (void)
|
||||||
@ -184,6 +194,7 @@ static unsigned char ReadProgramFile (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Get load address */
|
/* Get load address */
|
||||||
|
Val2 = 0; /* suppress uninitialized variable warning */
|
||||||
if (((Val = fgetc(F)) == EOF) ||
|
if (((Val = fgetc(F)) == EOF) ||
|
||||||
((Val2 = fgetc(F)) == EOF)) {
|
((Val2 = fgetc(F)) == EOF)) {
|
||||||
Error ("'%s': Header missing load address", ProgramFile);
|
Error ("'%s': Header missing load address", ProgramFile);
|
||||||
|
@ -242,7 +242,15 @@ static void PVClose (CPURegs* Regs)
|
|||||||
|
|
||||||
Print (stderr, 2, "PVClose ($%04X)\n", FD);
|
Print (stderr, 2, "PVClose ($%04X)\n", FD);
|
||||||
|
|
||||||
RetVal = close (FD);
|
if (FD != 0xFFFF) {
|
||||||
|
RetVal = close (FD);
|
||||||
|
} else {
|
||||||
|
/* test/val/constexpr.c "abuses" close, expecting close(-1) to return -1.
|
||||||
|
** This behaviour is not the same on all target platforms.
|
||||||
|
** MSVC's close treats it as a fatal error instead and terminates.
|
||||||
|
*/
|
||||||
|
RetVal = 0xFFFF;
|
||||||
|
}
|
||||||
|
|
||||||
SetAX (Regs, RetVal);
|
SetAX (Regs, RetVal);
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,8 @@ ifdef QUIET
|
|||||||
NULLERR = 2>$(NULLDEV)
|
NULLERR = 2>$(NULLDEV)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
SIM65FLAGS = -x 5000000000
|
# sim65 can support 64-bit cycle counts on some platforms, but not all. This must fit in 32-bit.
|
||||||
|
SIM65FLAGS = -x 4000000000
|
||||||
|
|
||||||
CA65 := $(if $(wildcard ../../../bin/ca65*),..$S..$S..$Sbin$Sca65,ca65)
|
CA65 := $(if $(wildcard ../../../bin/ca65*),..$S..$S..$Sbin$Sca65,ca65)
|
||||||
LD65 := $(if $(wildcard ../../../bin/ld65*),..$S..$S..$Sbin$Sld65,ld65)
|
LD65 := $(if $(wildcard ../../../bin/ld65*),..$S..$S..$Sbin$Sld65,ld65)
|
||||||
|
@ -22,7 +22,8 @@ ifdef QUIET
|
|||||||
NULLERR = 2>$(NULLDEV)
|
NULLERR = 2>$(NULLDEV)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
SIM65FLAGS = -x 5000000000 -c
|
# sim65 can support 64-bit cycle counts on some platforms, but not all. This must fit in 32-bit.
|
||||||
|
SIM65FLAGS = -x 4000000000 -c
|
||||||
|
|
||||||
CC65 := $(if $(wildcard ../../bin/cc65*),..$S..$Sbin$Scc65,cc65)
|
CC65 := $(if $(wildcard ../../bin/cc65*),..$S..$Sbin$Scc65,cc65)
|
||||||
CA65 := $(if $(wildcard ../../bin/ca65*),..$S..$Sbin$Sca65,ca65)
|
CA65 := $(if $(wildcard ../../bin/ca65*),..$S..$Sbin$Sca65,ca65)
|
||||||
|
@ -24,7 +24,8 @@ ifdef QUIET
|
|||||||
NULLERR = 2>$(NULLDEV)
|
NULLERR = 2>$(NULLDEV)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
SIM65FLAGS = -x 5000000000 -c
|
# sim65 can support 64-bit cycle counts on some platforms, but not all. This must fit in 32-bit.
|
||||||
|
SIM65FLAGS = -x 4000000000 -c
|
||||||
|
|
||||||
CC65 := $(if $(wildcard ../../bin/cc65*),..$S..$Sbin$Scc65,cc65)
|
CC65 := $(if $(wildcard ../../bin/cc65*),..$S..$Sbin$Scc65,cc65)
|
||||||
CA65 := $(if $(wildcard ../../bin/ca65*),..$S..$Sbin$Sca65,ca65)
|
CA65 := $(if $(wildcard ../../bin/ca65*),..$S..$Sbin$Sca65,ca65)
|
||||||
|
Loading…
Reference in New Issue
Block a user