Merge branch 'master' into StaticConst

This commit is contained in:
acqn
2020-08-27 06:27:23 +08:00
committed by GitHub
45 changed files with 872 additions and 200 deletions

View File

@@ -170,6 +170,8 @@
/* No support for dynamically loadable drivers */ /* No support for dynamically loadable drivers */
#define DYN_DRV 0 #define DYN_DRV 0
#define JOY_DATA 0x4400 /* hw register to read the pad bits from */
/* Masks for joy_read */ /* Masks for joy_read */
#define JOY_UP_MASK 0x01 #define JOY_UP_MASK 0x01
#define JOY_DOWN_MASK 0x02 #define JOY_DOWN_MASK 0x02

View File

@@ -157,6 +157,11 @@ void Assignment (ExprDesc* Expr)
Error ("Assignment to const"); Error ("Assignment to const");
} }
/* Check for assignment to incomplete type */
if (IsIncompleteESUType (ltype)) {
Error ("Assignment to incomplete type '%s'", GetFullTypeName (ltype));
}
/* Skip the '=' token */ /* Skip the '=' token */
NextToken (); NextToken ();

View File

@@ -112,6 +112,7 @@ void CL_MoveRefs (CodeLabel* OldLabel, CodeLabel* NewLabel)
CodeEntry* E = CL_GetRef (OldLabel, Count); CodeEntry* E = CL_GetRef (OldLabel, Count);
/* Change the reference to the new label */ /* Change the reference to the new label */
CHECK (E->JumpTo != NULL);
CHECK (E->JumpTo == OldLabel); CHECK (E->JumpTo == OldLabel);
CL_AddRef (NewLabel, E); CL_AddRef (NewLabel, E);

View File

@@ -140,19 +140,10 @@ static void Parse (void)
comma = 0; comma = 0;
while (1) { while (1) {
Declaration Decl; Declaration Decl;
/* Read the next declaration */ /* Read the next declaration */
ParseDecl (&Spec, &Decl, DM_NEED_IDENT); ParseDecl (&Spec, &Decl, DM_NEED_IDENT);
if (Decl.Ident[0] == '\0') {
NextToken ();
break;
}
if ((Decl.StorageClass & SC_FICTITIOUS) == SC_FICTITIOUS) {
/* Failed parsing */
goto SkipOneDecl;
}
/* Check if we must reserve storage for the variable. We do this, /* Check if we must reserve storage for the variable. We do this,
** **
@@ -163,8 +154,9 @@ static void Parse (void)
** **
** This means that "extern int i;" will not get storage allocated. ** This means that "extern int i;" will not get storage allocated.
*/ */
if ((Decl.StorageClass & SC_FUNC) != SC_FUNC && if ((Decl.StorageClass & SC_FUNC) != SC_FUNC &&
(Decl.StorageClass & SC_TYPEMASK) != SC_TYPEDEF) { (Decl.StorageClass & SC_TYPEMASK) != SC_TYPEDEF &&
(Decl.StorageClass & SC_FICTITIOUS) != SC_FICTITIOUS) {
if ((Spec.Flags & DS_DEF_STORAGE) != 0 || if ((Spec.Flags & DS_DEF_STORAGE) != 0 ||
(Decl.StorageClass & (SC_EXTERN|SC_STATIC)) == SC_STATIC || (Decl.StorageClass & (SC_EXTERN|SC_STATIC)) == SC_STATIC ||
((Decl.StorageClass & SC_EXTERN) != 0 && ((Decl.StorageClass & SC_EXTERN) != 0 &&
@@ -296,7 +288,6 @@ static void Parse (void)
} }
SkipOneDecl:
/* Check for end of declaration list */ /* Check for end of declaration list */
if (CurTok.Tok == TOK_COMMA) { if (CurTok.Tok == TOK_COMMA) {
NextToken (); NextToken ();
@@ -452,10 +443,6 @@ void Compile (const char* FileName)
} }
Sym = GetSymType (GetElementType (Entry->Type)); Sym = GetSymType (GetElementType (Entry->Type));
if (Size == 0 && Sym != 0 && SymIsDef (Sym)) {
/* Array of 0-size elements */
Warning ("Array '%s[]' has 0-sized elements", Entry->Name);
}
} }
/* For non-ESU types, Size != 0 */ /* For non-ESU types, Size != 0 */

View File

@@ -687,7 +687,10 @@ const Type* GetUnderlyingType (const Type* Type)
Internal ("Enum tag type error in GetUnderlyingTypeCode"); Internal ("Enum tag type error in GetUnderlyingTypeCode");
} }
return ((SymEntry*)Type->A.P)->V.E.Type; /* If incomplete enum type is used, just return its raw type */
if (((SymEntry*)Type->A.P)->V.E.Type != 0) {
return ((SymEntry*)Type->A.P)->V.E.Type;
}
} }
return Type; return Type;
@@ -1247,9 +1250,14 @@ Type* IntPromotion (Type* T)
** to unsigned int. ** to unsigned int.
*/ */
return IsSignUnsigned (T) ? type_uint : type_int; return IsSignUnsigned (T) ? type_uint : type_int;
} else { } else if (!IsIncompleteESUType (T)) {
/* Otherwise, the type is not smaller than int, so leave it alone. */ /* The type is a complete type not smaller than int, so leave it alone. */
return T; return T;
} else {
/* Otherwise, this is an incomplete enum, and there is expceted to be an error already.
** Assume int to avoid further errors.
*/
return type_int;
} }
} }

View File

@@ -457,6 +457,37 @@ static unsigned ParseOneStorageClass (void)
static void CheckArrayElementType (Type* DataType)
/* Check if data type consists of arrays of incomplete element types */
{
Type* T = DataType;
while (T->C != T_END) {
if (IsTypeArray (T)) {
++T;
if (IsIncompleteESUType (T)) {
/* We cannot have an array of incomplete elements */
Error ("Array of incomplete element type '%s'", GetFullTypeName (T));
} else if (SizeOf (T) == 0) {
/* If the array is multi-dimensional, try to get the true
** element type.
*/
if (IsTypeArray (T)) {
continue;
}
/* We could support certain 0-size element types as an extension */
if (!IsTypeVoid (T) || IS_Get (&Standard) != STD_CC65) {
Error ("Array of 0-size element type '%s'", GetFullTypeName (T));
}
}
} else {
++T;
}
}
}
static void ParseStorageClass (DeclSpec* D, unsigned DefStorage) static void ParseStorageClass (DeclSpec* D, unsigned DefStorage)
/* Parse a storage class */ /* Parse a storage class */
{ {
@@ -908,8 +939,15 @@ static SymEntry* ParseUnionDecl (const char* Name)
} }
} }
/* Check for incomplete type */
if (IsIncompleteESUType (Decl.Type)) {
Error ("Field '%s' has incomplete type '%s'",
Decl.Ident,
GetFullTypeName (Decl.Type));
}
/* Handle sizes */ /* Handle sizes */
FieldSize = CheckedSizeOf (Decl.Type); FieldSize = SizeOf (Decl.Type);
if (FieldSize > UnionSize) { if (FieldSize > UnionSize) {
UnionSize = FieldSize; UnionSize = FieldSize;
} }
@@ -946,16 +984,16 @@ NextMember: if (CurTok.Tok != TOK_COMMA) {
FieldTab = GetSymTab (); FieldTab = GetSymTab ();
LeaveStructLevel (); LeaveStructLevel ();
/* Empty union is not supported now */
if (UnionSize == 0) {
Error ("Empty union type '%s' is not supported", Name);
}
/* Return a fictitious symbol if errors occurred during parsing */ /* Return a fictitious symbol if errors occurred during parsing */
if (PrevErrorCount != ErrorCount) { if (PrevErrorCount != ErrorCount) {
Flags |= SC_FICTITIOUS; Flags |= SC_FICTITIOUS;
} }
/* Empty union is not supported now */
if (UnionSize == 0) {
Error ("Empty union type '%s' is not supported", Name);
}
/* Make a real entry from the forward decl and return it */ /* Make a real entry from the forward decl and return it */
return AddStructSym (Name, SC_UNION | SC_DEF | Flags, UnionSize, FieldTab); return AddStructSym (Name, SC_UNION | SC_DEF | Flags, UnionSize, FieldTab);
} }
@@ -1092,6 +1130,13 @@ static SymEntry* ParseStructDecl (const char* Name)
} }
} }
/* Check for incomplete type */
if (IsIncompleteESUType (Decl.Type)) {
Error ("Field '%s' has incomplete type '%s'",
Decl.Ident,
GetFullTypeName (Decl.Type));
}
/* Add a field entry to the table */ /* Add a field entry to the table */
if (FieldWidth > 0) { if (FieldWidth > 0) {
/* Full bytes have already been added to the StructSize, /* Full bytes have already been added to the StructSize,
@@ -1116,7 +1161,7 @@ static SymEntry* ParseStructDecl (const char* Name)
AddLocalSym (Decl.Ident, Decl.Type, SC_STRUCTFIELD, StructSize); AddLocalSym (Decl.Ident, Decl.Type, SC_STRUCTFIELD, StructSize);
} }
if (!FlexibleMember) { if (!FlexibleMember) {
StructSize += CheckedSizeOf (Decl.Type); StructSize += SizeOf (Decl.Type);
} }
} }
@@ -1143,16 +1188,16 @@ NextMember: if (CurTok.Tok != TOK_COMMA) {
FieldTab = GetSymTab (); FieldTab = GetSymTab ();
LeaveStructLevel (); LeaveStructLevel ();
/* Empty struct is not supported now */
if (StructSize == 0) {
Error ("Empty struct type '%s' is not supported", Name);
}
/* Return a fictitious symbol if errors occurred during parsing */ /* Return a fictitious symbol if errors occurred during parsing */
if (PrevErrorCount != ErrorCount) { if (PrevErrorCount != ErrorCount) {
Flags |= SC_FICTITIOUS; Flags |= SC_FICTITIOUS;
} }
/* Empty struct is not supported now */
if (StructSize == 0) {
Error ("Empty struct type '%s' is not supported", Name);
}
/* Make a real entry from the forward decl and return it */ /* Make a real entry from the forward decl and return it */
return AddStructSym (Name, SC_STRUCT | SC_DEF | Flags, StructSize, FieldTab); return AddStructSym (Name, SC_STRUCT | SC_DEF | Flags, StructSize, FieldTab);
} }
@@ -1904,6 +1949,9 @@ void ParseDecl (const DeclSpec* Spec, Declaration* D, declmode_t Mode)
/* Do several fixes on qualifiers */ /* Do several fixes on qualifiers */
FixQualifiers (D->Type); FixQualifiers (D->Type);
/* Check if the data type consists of any arrays of forbidden types */
CheckArrayElementType (D->Type);
/* If we have a function, add a special storage class */ /* If we have a function, add a special storage class */
if (IsTypeFunc (D->Type)) { if (IsTypeFunc (D->Type)) {
D->StorageClass |= SC_FUNC; D->StorageClass |= SC_FUNC;
@@ -1975,10 +2023,15 @@ void ParseDecl (const DeclSpec* Spec, Declaration* D, declmode_t Mode)
Error ("Invalid size in declaration (0x%06X)", Size); Error ("Invalid size in declaration (0x%06X)", Size);
} }
} }
}
if (PrevErrorCount != ErrorCount) { if (PrevErrorCount != ErrorCount) {
/* Don't give storage if the declaration is not parsed correctly */ /* Make the declaration fictitious if is is not parsed correctly */
D->StorageClass |= SC_DECL | SC_FICTITIOUS; D->StorageClass |= SC_DECL | SC_FICTITIOUS;
if (Mode == DM_NEED_IDENT && D->Ident[0] == '\0') {
/* Use a fictitious name for the identifier if it is missing */
AnonName (D->Ident, "global");
} }
} }
} }
@@ -2223,7 +2276,7 @@ static unsigned ParseArrayInit (Type* T, int* Braces, int AllowFlexibleMembers)
/* Get the array data */ /* Get the array data */
Type* ElementType = GetElementType (T); Type* ElementType = GetElementType (T);
unsigned ElementSize = CheckedSizeOf (ElementType); unsigned ElementSize = SizeOf (ElementType);
long ElementCount = GetElementCount (T); long ElementCount = GetElementCount (T);
/* Special handling for a character array initialized by a literal */ /* Special handling for a character array initialized by a literal */

View File

@@ -1862,8 +1862,8 @@ static void UnaryOp (ExprDesc* Expr)
/* Value is not constant */ /* Value is not constant */
LoadExpr (CF_NONE, Expr); LoadExpr (CF_NONE, Expr);
/* Get the type of the expression */ /* Adjust the type of the value */
Flags = TypeOf (Expr->Type); Flags = g_typeadjust (TypeOf (Expr->Type), TypeOf (type_int) | CF_CONST);
/* Handle the operation */ /* Handle the operation */
switch (Tok) { switch (Tok) {
@@ -1876,6 +1876,9 @@ static void UnaryOp (ExprDesc* Expr)
/* The result is an rvalue in the primary */ /* The result is an rvalue in the primary */
ED_FinalizeRValLoad (Expr); ED_FinalizeRValLoad (Expr);
} }
/* Adjust the type of the expression */
Expr->Type = IntPromotion (Expr->Type);
} }

View File

@@ -142,6 +142,10 @@ void LoadExpr (unsigned Flags, struct ExprDesc* Expr)
BitFieldFullWidthFlags |= CF_UNSIGNED; BitFieldFullWidthFlags |= CF_UNSIGNED;
} }
} else if ((Flags & CF_TYPEMASK) == 0) { } else if ((Flags & CF_TYPEMASK) == 0) {
/* If Expr is an incomplete ESY type, bail out */
if (IsIncompleteESUType (Expr->Type)) {
return;
}
Flags |= TypeOf (Expr->Type); Flags |= TypeOf (Expr->Type);
} }

View File

@@ -173,7 +173,11 @@ static void ParseRegisterDecl (Declaration* Decl, int Reg)
/* Cannot allocate a variable of zero size */ /* Cannot allocate a variable of zero size */
if (Size == 0) { if (Size == 0) {
Error ("Variable '%s' has unknown size", Decl->Ident); if (IsTypeArray (Decl->Type)) {
Error ("Array '%s' has unknown size", Decl->Ident);
} else {
Error ("Variable '%s' has unknown size", Decl->Ident);
}
} }
} }
@@ -360,7 +364,11 @@ static void ParseAutoDecl (Declaration* Decl)
/* Cannot allocate a variable of zero size */ /* Cannot allocate a variable of zero size */
if (Size == 0) { if (Size == 0) {
Error ("Variable '%s' has unknown size", Decl->Ident); if (IsTypeArray (Decl->Type)) {
Error ("Array '%s' has unknown size", Decl->Ident);
} else {
Error ("Variable '%s' has unknown size", Decl->Ident);
}
} }
} }
@@ -414,7 +422,11 @@ static void ParseStaticDecl (Declaration* Decl)
/* Cannot allocate a variable of zero size */ /* Cannot allocate a variable of zero size */
if (Size == 0) { if (Size == 0) {
Error ("Variable '%s' has unknown size", Decl->Ident); if (IsTypeArray (Decl->Type)) {
Error ("Array '%s' has unknown size", Decl->Ident);
} else {
Error ("Variable '%s' has unknown size", Decl->Ident);
}
} }
} }

View File

@@ -8,23 +8,22 @@ ifdef CMD_EXE
EXE = .exe EXE = .exe
MKDIR = mkdir $(subst /,\,$1) MKDIR = mkdir $(subst /,\,$1)
RMDIR = -rmdir /s /q $(subst /,\,$1) RMDIR = -rmdir /s /q $(subst /,\,$1)
DEL = del /f $(subst /,\,$1)
else else
EXE = EXE =
MKDIR = mkdir -p $1 MKDIR = mkdir -p $1
RMDIR = $(RM) -r $1 RMDIR = $(RM) -r $1
DEL = $(RM) $1
endif endif
ifdef QUIET ifdef QUIET
.SILENT: .SILENT:
endif endif
CL65 := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65) CA65 := $(if $(wildcard ../../bin/ca65*),../../bin/ca65,ca65)
LD65 := $(if $(wildcard ../../bin/ld65*),../../bin/ld65,ld65)
WORKDIR = ../../testwrk/asm WORKDIR = ../../testwrk/asm
DIFF = $(WORKDIR)/isequal$(EXE) ISEQUAL = $(WORKDIR)/isequal$(EXE)
CC = gcc CC = gcc
CFLAGS = -O2 CFLAGS = -O2
@@ -44,29 +43,28 @@ all: $(OPCODE_BINS) $(CPUDETECT_BINS)
$(WORKDIR): $(WORKDIR):
$(call MKDIR,$(WORKDIR)) $(call MKDIR,$(WORKDIR))
$(DIFF): ../isequal.c | $(WORKDIR) $(ISEQUAL): ../isequal.c | $(WORKDIR)
$(CC) $(CFLAGS) -o $@ $< $(CC) $(CFLAGS) -o $@ $<
define OPCODE_template define OPCODE_template
$(WORKDIR)/$1-opcodes.bin: $1-opcodes.s $(DIFF) $(WORKDIR)/$1-opcodes.bin: $1-opcodes.s $(ISEQUAL)
$(if $(QUIET),echo asm/$1-opcodes.bin) $(if $(QUIET),echo asm/$1-opcodes.bin)
$(CL65) --cpu $1 -t none -l $(WORKDIR)/$1-opcodes.lst -o $$@ $$< $(CA65) --cpu $1 -t none -l $(WORKDIR)/$1-opcodes.lst -o $(WORKDIR)/$1-opcodes.o $$<
$(DIFF) $$@ $1-opcodes.ref $(LD65) -t none -o $$@ $(WORKDIR)/$1-opcodes.o none.lib
$(ISEQUAL) $$@ $1-opcodes.ref
endef # OPCODE_template endef # OPCODE_template
$(foreach cpu,$(OPCODE_CPUS),$(eval $(call OPCODE_template,$(cpu)))) $(foreach cpu,$(OPCODE_CPUS),$(eval $(call OPCODE_template,$(cpu))))
# cpudetect.o is written by multiple rules
.NOTPARALLEL:
define CPUDETECT_template define CPUDETECT_template
$(WORKDIR)/$1-cpudetect.bin: cpudetect.s $(DIFF) $(WORKDIR)/$1-cpudetect.bin: cpudetect.s $(ISEQUAL)
$(if $(QUIET),echo asm/$1-cpudetect.bin) $(if $(QUIET),echo asm/$1-cpudetect.bin)
$(CL65) --cpu $1 -t none -l $(WORKDIR)/$1-cpudetect.lst -o $$@ $$< $(CA65) --cpu $1 -t none -l $(WORKDIR)/$1-cpudetect.lst -o $(WORKDIR)/$1-cpudetect.o $$<
$(DIFF) $$@ $1-cpudetect.ref $(LD65) -t none -o $$@ $(WORKDIR)/$1-cpudetect.o none.lib
$(ISEQUAL) $$@ $1-cpudetect.ref
endef # CPUDETECT_template endef # CPUDETECT_template
@@ -74,4 +72,3 @@ $(foreach cpu,$(CPUDETECT_CPUS),$(eval $(call CPUDETECT_template,$(cpu))))
clean: clean:
@$(call RMDIR,$(WORKDIR)) @$(call RMDIR,$(WORKDIR))
@$(call DEL,$(OPCODE_REFS:.ref=.o) cpudetect.o)

View File

@@ -8,12 +8,10 @@ ifdef CMD_EXE
EXE = .exe EXE = .exe
MKDIR = mkdir $(subst /,\,$1) MKDIR = mkdir $(subst /,\,$1)
RMDIR = -rmdir /s /q $(subst /,\,$1) RMDIR = -rmdir /s /q $(subst /,\,$1)
DEL = del /f $(subst /,\,$1)
else else
EXE = EXE =
MKDIR = mkdir -p $1 MKDIR = mkdir -p $1
RMDIR = $(RM) -r $1 RMDIR = $(RM) -r $1
DEL = $(RM) $1
endif endif
ifdef QUIET ifdef QUIET
@@ -25,7 +23,7 @@ DA65 := $(if $(wildcard ../../bin/da65*),../../bin/da65,da65)
WORKDIR = ../../testwrk/dasm WORKDIR = ../../testwrk/dasm
DIFF = $(WORKDIR)/isequal$(EXE) ISEQUAL = $(WORKDIR)/isequal$(EXE)
CC = gcc CC = gcc
CFLAGS = -O2 CFLAGS = -O2
@@ -44,7 +42,7 @@ all: $(BINS)
$(WORKDIR): $(WORKDIR):
$(call MKDIR,$(WORKDIR)) $(call MKDIR,$(WORKDIR))
$(DIFF): ../isequal.c | $(WORKDIR) $(ISEQUAL): ../isequal.c | $(WORKDIR)
$(CC) $(CFLAGS) -o $@ $< $(CC) $(CFLAGS) -o $@ $<
define DISASS_template define DISASS_template
@@ -55,10 +53,10 @@ $(WORKDIR)/$1-disass.bin: $1-disass.s | $(WORKDIR)
$(WORKDIR)/$1-reass.s: $(WORKDIR)/$1-disass.bin $(WORKDIR)/$1-reass.s: $(WORKDIR)/$1-disass.bin
$(DA65) --cpu $1 $(START) -o $$@ $$< $(DA65) --cpu $1 $(START) -o $$@ $$<
$(WORKDIR)/$1-reass.bin: $(WORKDIR)/$1-reass.s $(DIFF) $(WORKDIR)/$1-reass.bin: $(WORKDIR)/$1-reass.s $(ISEQUAL)
$(if $(QUIET),echo dasm/$1-reass.bin) $(if $(QUIET),echo dasm/$1-reass.bin)
$(CL65) --cpu $1 -t none $(START) -o $$@ $$< $(CL65) --cpu $1 -t none $(START) -o $$@ $$<
$(DIFF) $$@ $(WORKDIR)/$1-disass.bin $(ISEQUAL) $$@ $(WORKDIR)/$1-disass.bin
endef # DISASS_template endef # DISASS_template
@@ -66,4 +64,3 @@ $(foreach cpu,$(CPUS),$(eval $(call DISASS_template,$(cpu))))
clean: clean:
@$(call RMDIR,$(WORKDIR)) @$(call RMDIR,$(WORKDIR))
@$(call DEL,$(SOURCES:.s=.o))

View File

@@ -23,23 +23,23 @@ ifdef QUIET
NULLERR = 2>$(NULLDEV) NULLERR = 2>$(NULLDEV)
endif endif
CL65 := $(if $(wildcard ../../bin/cl65*),..$S..$Sbin$Scl65,cl65) CC65 := $(if $(wildcard ../../bin/cc65*),..$S..$Sbin$Scc65,cc65)
WORKDIR = ../../testwrk/err WORKDIR = ../../testwrk/err
.PHONY: all clean .PHONY: all clean
SOURCES := $(wildcard *.c) SOURCES := $(wildcard *.c)
TESTS = $(patsubst %.c,$(WORKDIR)/%.prg,$(SOURCES)) TESTS = $(patsubst %.c,$(WORKDIR)/%.s,$(SOURCES))
all: $(TESTS) all: $(TESTS)
$(WORKDIR): $(WORKDIR):
$(call MKDIR,$(WORKDIR)) $(call MKDIR,$(WORKDIR))
$(WORKDIR)/%.prg: %.c | $(WORKDIR) $(WORKDIR)/%.s: %.c | $(WORKDIR)
$(if $(QUIET),echo err/$*.s) $(if $(QUIET),echo err/$*.s)
$(NOT) $(CL65) -o $@ $< $(NULLERR) $(NOT) $(CC65) -o $@ $< $(NULLERR)
clean: clean:
@$(call RMDIR,$(WORKDIR)) @$(call RMDIR,$(WORKDIR))

View File

@@ -0,0 +1,52 @@
/*
Copyright 2020 The cc65 Authors
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
/*
Test of indirect goto with label merge ICE.
https://github.com/cc65/cc65/issues/1211
This should compile and should be moved to tests/val/ when the bug is fixed.
*/
#include <stdio.h>
/* When operating correctly, f(0) = 31 and f(1) = 41. */
int f (int x)
{
static const void *const labels[] = {&&L0, &&L1};
goto *labels[x];
L0: if (labels[0] != labels[1]) return 31;
else return 13;
L1: return 41;
}
static unsigned char failures = 0;
int main (void)
{
if (f (0) != 31) failures++;
if (failures == 0) {
printf ("PASS\n");
} else {
printf ("FAIL\n");
}
return failures;
}

View File

@@ -0,0 +1,51 @@
/*
Copyright 2020 The cc65 Authors
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
/*
Test of indirect goto with label merge ICE.
https://github.com/cc65/cc65/issues/1211
This should compile and should be moved to tests/val/ when the bug is fixed.
*/
#include <stdio.h>
/* When operating correctly, this returns 0. */
int f (void)
{
static const void *const x[2] = {&&L0, &&L1};
goto *x[0];
L0:
L1: return 0;
}
static unsigned char failures = 0;
int main (void)
{
if (f () != 0) failures++;
if (failures == 0) {
printf ("PASS\n");
} else {
printf ("FAIL\n");
}
return failures;
}

View File

@@ -11,7 +11,6 @@ ifdef CMD_EXE
NULLDEV = nul: NULLDEV = nul:
MKDIR = mkdir $(subst /,\,$1) MKDIR = mkdir $(subst /,\,$1)
RMDIR = -rmdir /s /q $(subst /,\,$1) RMDIR = -rmdir /s /q $(subst /,\,$1)
DEL = del /f $(subst /,\,$1)
else else
S = / S = /
NOT = ! NOT = !
@@ -19,7 +18,6 @@ else
NULLDEV = /dev/null NULLDEV = /dev/null
MKDIR = mkdir -p $1 MKDIR = mkdir -p $1
RMDIR = $(RM) -r $1 RMDIR = $(RM) -r $1
DEL = $(RM) $1
endif endif
ifdef QUIET ifdef QUIET
@@ -30,14 +28,16 @@ endif
SIM65FLAGS = -x 200000000 SIM65FLAGS = -x 200000000
CL65 := $(if $(wildcard ../../bin/cl65*),..$S..$Sbin$Scl65,cl65) CC65 := $(if $(wildcard ../../bin/cc65*),..$S..$Sbin$Scc65,cc65)
CA65 := $(if $(wildcard ../../bin/ca65*),..$S..$Sbin$Sca65,ca65)
LD65 := $(if $(wildcard ../../bin/ld65*),..$S..$Sbin$Sld65,ld65)
SIM65 := $(if $(wildcard ../../bin/sim65*),..$S..$Sbin$Ssim65,sim65) SIM65 := $(if $(wildcard ../../bin/sim65*),..$S..$Sbin$Ssim65,sim65)
WORKDIR = ..$S..$Stestwrk$Smisc WORKDIR = ..$S..$Stestwrk$Smisc
OPTIONS = g O Os Osi Osir Osr Oi Oir Or OPTIONS = g O Os Osi Osir Osr Oi Oir Or
DIFF = $(WORKDIR)$Sisequal$(EXE) ISEQUAL = $(WORKDIR)$Sisequal$(EXE)
CC = gcc CC = gcc
CFLAGS = -O2 CFLAGS = -O2
@@ -50,15 +50,10 @@ TESTS += $(foreach option,$(OPTIONS),$(SOURCES:%.c=$(WORKDIR)/%.$(option).65c02.
all: $(TESTS) all: $(TESTS)
# The same input file is processed with different cl65 args,
# but cl65 uses the input file name to make the temp file name,
# and they stomp each other.
.NOTPARALLEL:
$(WORKDIR): $(WORKDIR):
$(call MKDIR,$(WORKDIR)) $(call MKDIR,$(WORKDIR))
$(DIFF): ../isequal.c | $(WORKDIR) $(ISEQUAL): ../isequal.c | $(WORKDIR)
$(CC) $(CFLAGS) -o $@ $< $(CC) $(CFLAGS) -o $@ $<
define PRG_template define PRG_template
@@ -67,44 +62,65 @@ define PRG_template
$(WORKDIR)/bug760.$1.$2.prg: bug760.c | $(WORKDIR) $(WORKDIR)/bug760.$1.$2.prg: bug760.c | $(WORKDIR)
@echo "FIXME: " $$@ "currently does not compile." @echo "FIXME: " $$@ "currently does not compile."
$(if $(QUIET),echo misc/bug760.$1.$2.prg) $(if $(QUIET),echo misc/bug760.$1.$2.prg)
$(NOT) $(CL65) -t sim$2 -$1 -o $$@ $$< $(NULLERR) $(NOT) $(CC65) -t sim$2 -$1 -o $$@ $$< $(NULLERR)
# should compile, but gives an error
$(WORKDIR)/bug1209-ind-goto-rev.$1.$2.prg: bug1209-ind-goto-rev.c | $(WORKDIR)
@echo "FIXME: " $$@ "currently does not compile."
$(if $(QUIET),echo misc/bug1209-ind-goto-rev.$1.$2.prg)
$(CC65) -t sim$2 -$1 -o $$(@:.prg=.s) $$< $(NULLERR)
$(CA65) -t sim$2 -o $$(@:.prg=.o) $$(@:.prg=.s) $(NULLERR)
$(NOT) $(LD65) -t sim$2 -o $$@ $$(@:.prg=.o) sim$2.lib $(NULLERR)
# should compile, but gives an error
$(WORKDIR)/bug1209-ind-goto-rev-2.$1.$2.prg: bug1209-ind-goto-rev-2.c | $(WORKDIR)
@echo "FIXME: " $$@ "currently does not compile."
$(if $(QUIET),echo misc/bug1209-ind-goto-rev-2.$1.$2.prg)
$(CC65) -t sim$2 -$1 -o $$(@:.prg=.s) $$< $(NULLERR)
$(CA65) -t sim$2 -o $$(@:.prg=.o) $$(@:.prg=.s) $(NULLERR)
$(NOT) $(LD65) -t sim$2 -o $$@ $$(@:.prg=.o) sim$2.lib $(NULLERR)
# should compile, but gives an error
$(WORKDIR)/bug1209-ind-goto-rev-3.$1.$2.prg: bug1209-ind-goto-rev-3.c | $(WORKDIR)
@echo "FIXME: " $$@ "currently does not compile."
$(if $(QUIET),echo misc/bug1209-ind-goto-rev-3.$1.$2.prg)
$(CC65) -t sim$2 -$1 -o $$(@:.prg=.s) $$< $(NULLERR)
$(CA65) -t sim$2 -o $$(@:.prg=.o) $$(@:.prg=.s) $(NULLERR)
$(NOT) $(LD65) -t sim$2 -o $$@ $$(@:.prg=.o) sim$2.lib $(NULLERR)
# should compile, but gives an error # should compile, but gives an error
$(WORKDIR)/pptest2.$1.$2.prg: pptest2.c | $(WORKDIR) $(WORKDIR)/pptest2.$1.$2.prg: pptest2.c | $(WORKDIR)
@echo "FIXME: " $$@ "currently does not compile." @echo "FIXME: " $$@ "currently does not compile."
$(if $(QUIET),echo misc/pptest2.$1.$2.prg) $(if $(QUIET),echo misc/pptest2.$1.$2.prg)
$(NOT) $(CL65) -t sim$2 -$1 -o $$@ $$< $(NULLERR) $(NOT) $(CC65) -t sim$2 -$1 -o $$@ $$< $(NULLERR)
# this should fail to compile, because there are errors in the code
# instead, the compiler crashes
$(WORKDIR)/bug1113.$1.$2.prg: bug1113.c | $(WORKDIR)
@echo "FIXME: " $$@ "compiler crashes but should give an error."
$(if $(QUIET),echo misc/bug1113.$1.$2.prg)
$(NOT) $(CL65) -t sim$2 -$1 -o $$@ $$< $(NULLERR)
# should compile, but then hangs in an endless loop # should compile, but then hangs in an endless loop
$(WORKDIR)/endless.$1.$2.prg: endless.c | $(WORKDIR) $(WORKDIR)/endless.$1.$2.prg: endless.c | $(WORKDIR)
$(if $(QUIET),echo misc/endless.$1.$2.prg) $(if $(QUIET),echo misc/endless.$1.$2.prg)
$(CL65) -t sim$2 -$1 -o $$@ $$< $(NULLERR) $(CC65) -t sim$2 -$1 -o $$(@:.prg=.s) $$< $(NULLERR)
$(CA65) -t sim$2 -o $$(@:.prg=.o) $$(@:.prg=.s) $(NULLERR)
$(LD65) -t sim$2 -o $$@ $$(@:.prg=.o) sim$2.lib $(NULLERR)
$(NOT) $(SIM65) $(SIM65FLAGS) $$@ $(NULLOUT) $(NULLERR) $(NOT) $(SIM65) $(SIM65FLAGS) $$@ $(NULLOUT) $(NULLERR)
# these need reference data that can't be generated by a host-compiled program, # these need reference data that can't be generated by a host-compiled program,
# in a useful way # in a useful way
$(WORKDIR)/limits.$1.$2.prg: limits.c $(DIFF) | $(WORKDIR) $(WORKDIR)/limits.$1.$2.prg: limits.c $(ISEQUAL) | $(WORKDIR)
$(if $(QUIET),echo misc/limits.$1.$2.prg) $(if $(QUIET),echo misc/limits.$1.$2.prg)
$(CL65) -t sim$2 -$1 -o $$@ $$< $(NULLERR) $(CC65) -t sim$2 -$1 -o $$(@:.prg=.s) $$< $(NULLERR)
$(CA65) -t sim$2 -o $$(@:.prg=.o) $$(@:.prg=.s) $(NULLERR)
$(LD65) -t sim$2 -o $$@ $$(@:.prg=.o) sim$2.lib $(NULLERR)
$(SIM65) $(SIM65FLAGS) $$@ > $(WORKDIR)/limits.$1.$2.out $(SIM65) $(SIM65FLAGS) $$@ > $(WORKDIR)/limits.$1.$2.out
$(DIFF) $(WORKDIR)/limits.$1.$2.out limits.ref $(ISEQUAL) $(WORKDIR)/limits.$1.$2.out limits.ref
$(WORKDIR)/goto.$1.$2.prg: goto.c $(DIFF) | $(WORKDIR) $(WORKDIR)/goto.$1.$2.prg: goto.c $(ISEQUAL) | $(WORKDIR)
$(if $(QUIET),echo misc/goto.$1.$2.prg) $(if $(QUIET),echo misc/goto.$1.$2.prg)
$(CL65) -t sim$2 -$1 -o $$@ $$< 2>$(WORKDIR)/goto.$1.$2.out $(CC65) -t sim$2 -$1 -o $$@ $$< 2>$(WORKDIR)/goto.$1.$2.out
$(DIFF) $(WORKDIR)/goto.$1.$2.out goto.ref $(ISEQUAL) $(WORKDIR)/goto.$1.$2.out goto.ref
# the rest are tests that fail currently for one reason or another # the rest are tests that fail currently for one reason or another
$(WORKDIR)/sitest.$1.$2.prg: sitest.c | $(WORKDIR) $(WORKDIR)/sitest.$1.$2.prg: sitest.c | $(WORKDIR)
@echo "FIXME: " $$@ "currently does not compile." @echo "FIXME: " $$@ "currently does not compile."
$(NOT) $(CL65) -t sim$2 -$1 -o $$@ $$< $(NULLERR) $(NOT) $(CC65) -t sim$2 -$1 -o $$@ $$< $(NULLERR)
# $(SIM65) $(SIM65FLAGS) $$@ $(NULLOUT) # $(SIM65) $(SIM65FLAGS) $$@ $(NULLOUT)
endef # PRG_template endef # PRG_template
@@ -114,4 +130,3 @@ $(foreach option,$(OPTIONS),$(eval $(call PRG_template,$(option),65c02)))
clean: clean:
@$(call RMDIR,$(WORKDIR)) @$(call RMDIR,$(WORKDIR))
@$(call DEL,$(SOURCES:.c=.o))

View File

@@ -0,0 +1,54 @@
/*
Copyright 2020 The cc65 Authors
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
/*
Test of indirect goto without dynamic labels and order label def, label ref, goto.
https://github.com/cc65/cc65/issues/1209
This should compile and should be moved to tests/val/ when the bug is fixed.
*/
#include <stdio.h>
#include <stdlib.h>
/* When operating correctly, this returns 0. */
static unsigned char y = 0;
int f (void) {
L: if (y) return 0;
{
static const void *const x[1] = {&&L};
y = 1;
goto *x[0];
}
}
static unsigned char failures = 0;
int main (void)
{
if (f () != 0) failures++;
if (failures == 0) {
printf ("PASS\n");
} else {
printf ("FAIL\n");
}
return failures;
}

View File

@@ -0,0 +1,52 @@
/*
Copyright 2020 The cc65 Authors
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
/*
Test of indirect goto without dynamic labels and order label ref, label def, goto.
https://github.com/cc65/cc65/issues/1209
This should compile and should be moved to tests/val/ when the bug is fixed.
*/
#include <stdio.h>
#include <stdlib.h>
/* When operating correctly, this returns 0. */
static unsigned char y = 0;
int f (void) {
static const void *const x[1] = {&&L};
L: if (y) return 0;
y = 1;
goto *x[0];
}
static unsigned char failures = 0;
int main (void)
{
if (f () != 0) failures++;
if (failures == 0) {
printf ("PASS\n");
} else {
printf ("FAIL\n");
}
return failures;
}

View File

@@ -19,7 +19,7 @@
*/ */
/* /*
Tests of indirect goto with the label before the goto. Test of indirect goto with dynamic labels and order label def, label ref, goto.
https://github.com/cc65/cc65/issues/1209 https://github.com/cc65/cc65/issues/1209
This should compile and should be moved to tests/val/ when the bug is fixed. This should compile and should be moved to tests/val/ when the bug is fixed.
*/ */
@@ -32,7 +32,7 @@ int f (void)
{ {
static void *x[1]; static void *x[1];
/* Define the label before referencing it with indirect label syntax. */ /* Define the label before referencing it with indirect label syntax. */
L: if (x[0] != 0) return 0; L: if (x[0] != 0) return 0;
x[0] = &&L; x[0] = &&L;
goto *x[0]; goto *x[0];
} }
@@ -46,7 +46,7 @@ int main (void)
if (failures == 0) { if (failures == 0) {
printf ("PASS\n"); printf ("PASS\n");
} else { } else {
printf ("FAIL: %d failures\n", failures); printf ("FAIL\n");
} }
return failures; return failures;

View File

@@ -11,14 +11,12 @@ ifdef CMD_EXE
NULLDEV = nul: NULLDEV = nul:
MKDIR = mkdir $(subst /,\,$1) MKDIR = mkdir $(subst /,\,$1)
RMDIR = -rmdir /s /q $(subst /,\,$1) RMDIR = -rmdir /s /q $(subst /,\,$1)
DEL = del /f $(subst /,\,$1)
else else
S = / S = /
EXE = EXE =
NULLDEV = /dev/null NULLDEV = /dev/null
MKDIR = mkdir -p $1 MKDIR = mkdir -p $1
RMDIR = $(RM) -r $1 RMDIR = $(RM) -r $1
DEL = $(RM) $1
endif endif
ifdef QUIET ifdef QUIET
@@ -28,14 +26,16 @@ endif
SIM65FLAGS = -x 200000000 SIM65FLAGS = -x 200000000
CL65 := $(if $(wildcard ../../bin/cl65*),..$S..$Sbin$Scl65,cl65) CC65 := $(if $(wildcard ../../bin/cc65*),..$S..$Sbin$Scc65,cc65)
CA65 := $(if $(wildcard ../../bin/ca65*),..$S..$Sbin$Sca65,ca65)
LD65 := $(if $(wildcard ../../bin/ld65*),..$S..$Sbin$Sld65,ld65)
SIM65 := $(if $(wildcard ../../bin/sim65*),..$S..$Sbin$Ssim65,sim65) SIM65 := $(if $(wildcard ../../bin/sim65*),..$S..$Sbin$Ssim65,sim65)
WORKDIR = ..$S..$Stestwrk$Sref WORKDIR = ..$S..$Stestwrk$Sref
OPTIONS = g O Os Osi Osir Osr Oi Oir Or OPTIONS = g O Os Osi Osir Osr Oi Oir Or
DIFF = $(WORKDIR)$Sisequal$(EXE) ISEQUAL = $(WORKDIR)$Sisequal$(EXE)
CC = gcc CC = gcc
CFLAGS = -O2 -Wall -W -Wextra -funsigned-char -fwrapv -fno-strict-overflow CFLAGS = -O2 -Wall -W -Wextra -funsigned-char -fwrapv -fno-strict-overflow
@@ -57,7 +57,7 @@ $(WORKDIR)/%.ref: %.c | $(WORKDIR)
$(CC) $(CFLAGS) -o $(WORKDIR)/$*.host $< $(NULLERR) $(CC) $(CFLAGS) -o $(WORKDIR)/$*.host $< $(NULLERR)
$(WORKDIR)$S$*.host > $@ $(WORKDIR)$S$*.host > $@
$(DIFF): ../isequal.c | $(WORKDIR) $(ISEQUAL): ../isequal.c | $(WORKDIR)
$(CC) $(CFLAGS) -o $@ $< $(CC) $(CFLAGS) -o $@ $<
# "yaccdbg.c" includes "yacc.c". # "yaccdbg.c" includes "yacc.c".
@@ -68,11 +68,13 @@ $(WORKDIR)/yaccdbg.%.prg: yacc.c
define PRG_template define PRG_template
$(WORKDIR)/%.$1.$2.prg: %.c $(WORKDIR)/%.ref $(DIFF) $(WORKDIR)/%.$1.$2.prg: %.c $(WORKDIR)/%.ref $(ISEQUAL)
$(if $(QUIET),echo ref/$$*.$1.$2.prg) $(if $(QUIET),echo ref/$$*.$1.$2.prg)
$(CL65) -t sim$2 $$(CC65FLAGS) -$1 -o $$@ $$< $(NULLERR) $(CC65) -t sim$2 $$(CC65FLAGS) -$1 -o $$(@:.prg=.s) $$< $(NULLERR)
$(CA65) -t sim$2 -o $$(@:.prg=.o) $$(@:.prg=.s) $(NULLERR)
$(LD65) -t sim$2 -o $$@ $$(@:.prg=.o) sim$2.lib $(NULLERR)
$(SIM65) $(SIM65FLAGS) $$@ > $(WORKDIR)/$$*.$1.$2.out $(SIM65) $(SIM65FLAGS) $$@ > $(WORKDIR)/$$*.$1.$2.out
$(DIFF) $(WORKDIR)/$$*.$1.$2.out $(WORKDIR)/$$*.ref $(ISEQUAL) $(WORKDIR)/$$*.$1.$2.out $(WORKDIR)/$$*.ref
endef # PRG_template endef # PRG_template
@@ -81,4 +83,3 @@ $(foreach option,$(OPTIONS),$(eval $(call PRG_template,$(option),65c02)))
clean: clean:
@$(call RMDIR,$(WORKDIR)) @$(call RMDIR,$(WORKDIR))
@$(call DEL,$(SOURCES:.c=.o))

View File

@@ -10,14 +10,12 @@ ifdef CMD_EXE
NULLDEV = nul: NULLDEV = nul:
MKDIR = mkdir $(subst /,\,$1) MKDIR = mkdir $(subst /,\,$1)
RMDIR = -rmdir /s /q $(subst /,\,$1) RMDIR = -rmdir /s /q $(subst /,\,$1)
DEL = del /f $(subst /,\,$1)
else else
S = / S = /
NOT = ! NOT = !
NULLDEV = /dev/null NULLDEV = /dev/null
MKDIR = mkdir -p $1 MKDIR = mkdir -p $1
RMDIR = $(RM) -r $1 RMDIR = $(RM) -r $1
DEL = $(RM) $1
endif endif
ifdef QUIET ifdef QUIET
@@ -28,7 +26,9 @@ endif
SIM65FLAGS = -x 200000000 SIM65FLAGS = -x 200000000
CL65 := $(if $(wildcard ../../bin/cl65*),..$S..$Sbin$Scl65,cl65) CC65 := $(if $(wildcard ../../bin/cc65*),..$S..$Sbin$Scc65,cc65)
CA65 := $(if $(wildcard ../../bin/ca65*),..$S..$Sbin$Sca65,ca65)
LD65 := $(if $(wildcard ../../bin/ld65*),..$S..$Sbin$Sld65,ld65)
SIM65 := $(if $(wildcard ../../bin/sim65*),..$S..$Sbin$Ssim65,sim65) SIM65 := $(if $(wildcard ../../bin/sim65*),..$S..$Sbin$Ssim65,sim65)
WORKDIR = ../../testwrk/val WORKDIR = ../../testwrk/val
@@ -50,7 +50,9 @@ define PRG_template
$(WORKDIR)/%.$1.$2.prg: %.c | $(WORKDIR) $(WORKDIR)/%.$1.$2.prg: %.c | $(WORKDIR)
$(if $(QUIET),echo val/$$*.$1.$2.prg) $(if $(QUIET),echo val/$$*.$1.$2.prg)
$(CL65) -t sim$2 $$(CC65FLAGS) -$1 -o $$@ $$< $(NULLERR) $(CC65) -t sim$2 $$(CC65FLAGS) -$1 -o $$(@:.prg=.s) $$< $(NULLERR)
$(CA65) -t sim$2 -o $$(@:.prg=.o) $$(@:.prg=.s) $(NULLERR)
$(LD65) -t sim$2 -o $$@ $$(@:.prg=.o) sim$2.lib $(NULLERR)
$(NOT) $(SIM65) $(SIM65FLAGS) $$@ $(NULLOUT) $(NOT) $(SIM65) $(SIM65FLAGS) $$@ $(NULLOUT)
endef # PRG_template endef # PRG_template
@@ -60,4 +62,3 @@ $(foreach option,$(OPTIONS),$(eval $(call PRG_template,$(option),65c02)))
clean: clean:
@$(call RMDIR,$(WORKDIR)) @$(call RMDIR,$(WORKDIR))
@$(call DEL,$(SOURCES:.c=.o))

View File

@@ -9,13 +9,11 @@ ifdef CMD_EXE
NULLDEV = nul: NULLDEV = nul:
MKDIR = mkdir $(subst /,\,$1) MKDIR = mkdir $(subst /,\,$1)
RMDIR = -rmdir /s /q $(subst /,\,$1) RMDIR = -rmdir /s /q $(subst /,\,$1)
DEL = del /f $(subst /,\,$1)
else else
S = / S = /
NULLDEV = /dev/null NULLDEV = /dev/null
MKDIR = mkdir -p $1 MKDIR = mkdir -p $1
RMDIR = $(RM) -r $1 RMDIR = $(RM) -r $1
DEL = $(RM) $1
endif endif
ifdef QUIET ifdef QUIET
@@ -26,7 +24,9 @@ endif
SIM65FLAGS = -x 5000000000 SIM65FLAGS = -x 5000000000
CL65 := $(if $(wildcard ../../bin/cl65*),..$S..$Sbin$Scl65,cl65) CC65 := $(if $(wildcard ../../bin/cc65*),..$S..$Sbin$Scc65,cc65)
CA65 := $(if $(wildcard ../../bin/ca65*),..$S..$Sbin$Sca65,ca65)
LD65 := $(if $(wildcard ../../bin/ld65*),..$S..$Sbin$Sld65,ld65)
SIM65 := $(if $(wildcard ../../bin/sim65*),..$S..$Sbin$Ssim65,sim65) SIM65 := $(if $(wildcard ../../bin/sim65*),..$S..$Sbin$Ssim65,sim65)
WORKDIR = ../../testwrk/val WORKDIR = ../../testwrk/val
@@ -41,11 +41,6 @@ TESTS += $(foreach option,$(OPTIONS),$(SOURCES:%.c=$(WORKDIR)/%.$(option).65c02.
all: $(TESTS) all: $(TESTS)
# The same input file is processed with different cl65 args,
# but cl65 uses the input file name to make the temp file name,
# and they stomp each other.
.NOTPARALLEL:
$(WORKDIR): $(WORKDIR):
$(call MKDIR,$(WORKDIR)) $(call MKDIR,$(WORKDIR))
@@ -53,7 +48,9 @@ define PRG_template
$(WORKDIR)/%.$1.$2.prg: %.c | $(WORKDIR) $(WORKDIR)/%.$1.$2.prg: %.c | $(WORKDIR)
$(if $(QUIET),echo val/$$*.$1.$2.prg) $(if $(QUIET),echo val/$$*.$1.$2.prg)
$(CL65) -t sim$2 $$(CC65FLAGS) -$1 -o $$@ $$< $(NULLERR) $(CC65) -t sim$2 $$(CC65FLAGS) -$1 -o $$(@:.prg=.s) $$< $(NULLERR)
$(CA65) -t sim$2 -o $$(@:.prg=.o) $$(@:.prg=.s) $(NULLERR)
$(LD65) -t sim$2 -o $$@ $$(@:.prg=.o) sim$2.lib $(NULLERR)
$(SIM65) $(SIM65FLAGS) $$@ $(NULLOUT) $(SIM65) $(SIM65FLAGS) $$@ $(NULLOUT)
endef # PRG_template endef # PRG_template
@@ -63,4 +60,3 @@ $(foreach option,$(OPTIONS),$(eval $(call PRG_template,$(option),65c02)))
clean: clean:
@$(call RMDIR,$(WORKDIR)) @$(call RMDIR,$(WORKDIR))
@$(call DEL,$(SOURCES:.c=.o))

25
test/val/bug1201.c Normal file
View File

@@ -0,0 +1,25 @@
/* bug #1201 - The unary operators +, - and ~ should do integer promote on the result types. */
char a;
short b;
int c;
long d;
enum E {
Z
} e;
struct S {
int a : 1;
} f;
_Static_assert(sizeof(+a) == sizeof(int), "Result type should be int");
_Static_assert(sizeof(+b) == sizeof(int), "Result type should be int");
_Static_assert(sizeof(+c) == sizeof(int), "Result type should be int");
_Static_assert(sizeof(+d) == sizeof(long), "Result type should be long");
_Static_assert(sizeof(+e) == sizeof(int), "Result type should be int");
_Static_assert(sizeof(+f.a) == sizeof(int), "Result type should be int");
int main(void)
{
return 0;
}

View File

@@ -0,0 +1,37 @@
# Just the usual way to find out if we're
# using cmd.exe to execute make rules.
ifneq ($(shell echo),)
CMD_EXE = 1
endif
ifdef CMD_EXE
NULLDEV = nul:
DEL = -del /f
RMDIR = rmdir /s /q
else
NULLDEV = /dev/null
DEL = $(RM)
RMDIR = $(RM) -r
endif
ifdef CC65_HOME
AS = $(CC65_HOME)/bin/ca65
CC = $(CC65_HOME)/bin/cc65
CL = $(CC65_HOME)/bin/cl65
LD = $(CC65_HOME)/bin/ld65
else
AS := $(if $(wildcard ../../../bin/ca65*),../../../bin/ca65,ca65)
CC := $(if $(wildcard ../../../bin/cc65*),../../../bin/cc65,cc65)
CL := $(if $(wildcard ../../../bin/cl65*),../../../bin/cl65,cl65)
LD := $(if $(wildcard ../../../bin/ld65*),../../../bin/ld65,ld65)
endif
all: paramcount.o
paramcount.o: paramcount.s
$(AS) -o paramcount.o -l paramcount.lst paramcount.s
clean:
$(RM) paramcount.o
$(RM) paramcount.lst

58
testcode/disasm/Makefile Normal file
View File

@@ -0,0 +1,58 @@
# Sample makefile using a preprocessor against info files
# and the --sync-lines option
# Just the usual way to find out if we're
# using cmd.exe to execute make rules.
ifneq ($(shell echo),)
CMD_EXE = 1
endif
ifdef CMD_EXE
NULLDEV = nul:
DEL = -del /f
RMDIR = rmdir /s /q
else
NULLDEV = /dev/null
DEL = $(RM)
RMDIR = $(RM) -r
endif
ifdef CC65_HOME
AS = $(CC65_HOME)/bin/ca65
CC = $(CC65_HOME)/bin/cc65
CL = $(CC65_HOME)/bin/cl65
LD = $(CC65_HOME)/bin/ld65
DA = $(CC65_HOME)/bin/da65
else
AS := $(if $(wildcard ../../../bin/ca65*),../../../bin/ca65,ca65)
CC := $(if $(wildcard ../../../bin/cc65*),../../../bin/cc65,cc65)
CL := $(if $(wildcard ../../../bin/cl65*),../../../bin/cl65,cl65)
LD := $(if $(wildcard ../../../bin/ld65*),../../../bin/ld65,ld65)
DA := $(if $(wildcard ../../../bin/da65*),../../../bin/da65,da65)
endif
CPP = env LANG=C cpp
CPPFLAGS = # -DTEST_ERROR
ASMS = fixed.s bank0.s bank1.s
DAIS = fixed.dai bank0.dai bank1.dai
.SUFFIXES: .da .dai .s
.PHONY: all clean maintainer-clean
.SECONDARY: $(DAIS)
.da.dai:
$(CPP) -o $@ $(CPPFLAGS) $<
.dai.s:
$(DA) --sync-lines -o $@ -i $< image.bin
all: $(ASMS)
clean:
$(RM) $(ASMS)
maintainer-clean: clean
$(RM) $(DAIS)
$(DAIS): fixed.da

View File

@@ -1,28 +0,0 @@
# Sample makefile using a preprocessor against info files
# and the --sync-lines option
CPP = env LANG=C cpp
CPPFLAGS = # -DTEST_ERROR
ASMS = fixed.s bank0.s bank1.s
DAIS = fixed.dai bank0.dai bank1.dai
.SUFFIXES: .da .dai .s
.PHONY: all clean maintainer-clean
.SECONDARY: $(DAIS)
.da.dai:
$(CPP) -o $@ $(CPPFLAGS) $<
.dai.s:
da65 --sync-lines -o $@ -i $< image.bin
all: $(ASMS)
clean:
rm -f $(ASMS)
maintainer-clean: clean
rm -f $(DAIS)
$(DAIS): fixed.da

52
testcode/grc/Makefile Normal file
View File

@@ -0,0 +1,52 @@
# Just the usual way to find out if we're
# using cmd.exe to execute make rules.
ifneq ($(shell echo),)
CMD_EXE = 1
endif
ifdef CMD_EXE
NULLDEV = nul:
DEL = -del /f
RMDIR = rmdir /s /q
else
NULLDEV = /dev/null
DEL = $(RM)
RMDIR = $(RM) -r
endif
ifdef CC65_HOME
AS = $(CC65_HOME)/bin/ca65
CC = $(CC65_HOME)/bin/cc65
CL = $(CC65_HOME)/bin/cl65
LD = $(CC65_HOME)/bin/ld65
GRC = $(CC65_HOME)/bin/grc65
else
AS := $(if $(wildcard ../../../bin/ca65*),../../../bin/ca65,ca65)
CC := $(if $(wildcard ../../../bin/cc65*),../../../bin/cc65,cc65)
CL := $(if $(wildcard ../../../bin/cl65*),../../../bin/cl65,cl65)
LD := $(if $(wildcard ../../../bin/ld65*),../../../bin/ld65,ld65)
GRC := $(if $(wildcard ../../../bin/grc65*),../../../bin/grc65,grc65)
endif
all: test.s vlir.cvt
test.s: test.grc
$(GRC) -s test.s test.grc
vlir.cvt: vlir.grc vlir0.s vlir1.s vlir2.s
# using seperate calls here for demonstration purposes:
$(GRC) -t geos-cbm -s vlir.s vlir.grc
$(AS) -t geos-cbm vlir.s
$(AS) -t geos-cbm vlir0.s
$(AS) -t geos-cbm vlir1.s
$(AS) -t geos-cbm vlir2.s
$(LD) -t geos-cbm -o vlir.cvt vlir.o vlir0.o vlir1.o vlir2.o geos-cbm.lib
# you can also do the above in one command:
# $(CL) -t geos-cbm -o vlir.cvt vlir.grc vlir0.s vlir1.s vlir2.s
clean:
$(RM) test.s test.h
$(RM) vlir.s vlir.cvt vlir.c vlir.h
$(RM) *.o

View File

@@ -5,10 +5,10 @@
; include some GEOS defines ; include some GEOS defines
.include "../../libsrc/geos/inc/const.inc" .include "../../libsrc/geos-common/const.inc"
.include "../../libsrc/geos/inc/jumptab.inc" .include "../../libsrc/geos-cbm/jumptab.inc"
.include "../../libsrc/geos/inc/geossym.inc" .include "../../libsrc/geos-cbm/geossym.inc"
.include "../../libsrc/geos/inc/geosmac.inc" .include "../../libsrc/geos-common/geosmac.inc"
; import load addresses for all VLIR chains ; import load addresses for all VLIR chains
; these labels are defined upon linking with ld65 ; these labels are defined upon linking with ld65

View File

@@ -5,10 +5,10 @@
; include some GEOS defines ; include some GEOS defines
.include "../../libsrc/geos/inc/const.inc" .include "../../libsrc/geos-common/const.inc"
.include "../../libsrc/geos/inc/jumptab.inc" .include "../../libsrc/geos-cbm/jumptab.inc"
.include "../../libsrc/geos/inc/geossym.inc" .include "../../libsrc/geos-cbm/geossym.inc"
.include "../../libsrc/geos/inc/geosmac.inc" .include "../../libsrc/geos-common/geosmac.inc"
; export names of functions that will be used in the main program ; export names of functions that will be used in the main program

View File

@@ -5,10 +5,10 @@
; similar to vlir1.s except the fact that this is chain #2 ; similar to vlir1.s except the fact that this is chain #2
.include "../../libsrc/geos/inc/const.inc" .include "../../libsrc/geos-common/const.inc"
.include "../../libsrc/geos/inc/jumptab.inc" .include "../../libsrc/geos-cbm/jumptab.inc"
.include "../../libsrc/geos/inc/geossym.inc" .include "../../libsrc/geos-cbm/geossym.inc"
.include "../../libsrc/geos/inc/geosmac.inc" .include "../../libsrc/geos-common/geosmac.inc"
.export OVERLAY2_Function1 .export OVERLAY2_Function1
.export OVERLAY2_Function2 .export OVERLAY2_Function2

View File

@@ -1,4 +1,30 @@
CL ?= cl65 # Just the usual way to find out if we're
# using cmd.exe to execute make rules.
ifneq ($(shell echo),)
CMD_EXE = 1
endif
ifdef CMD_EXE
NULLDEV = nul:
DEL = -del /f
RMDIR = rmdir /s /q
else
NULLDEV = /dev/null
DEL = $(RM)
RMDIR = $(RM) -r
endif
ifdef CC65_HOME
AS = $(CC65_HOME)/bin/ca65
CC = $(CC65_HOME)/bin/cc65
CL = $(CC65_HOME)/bin/cl65
LD = $(CC65_HOME)/bin/ld65
else
AS := $(if $(wildcard ../../../bin/ca65*),../../../bin/ca65,ca65)
CC := $(if $(wildcard ../../../bin/cc65*),../../../bin/cc65,cc65)
CL := $(if $(wildcard ../../../bin/cl65*),../../../bin/cl65,cl65)
LD := $(if $(wildcard ../../../bin/ld65*),../../../bin/ld65,ld65)
endif
all: c64-scpu-test.prg c128-scpu-test.prg c64dtv-test.prg \ all: c64-scpu-test.prg c128-scpu-test.prg c64dtv-test.prg \
c64-c128-test.prg c128-test.prg chameleon-test.prg \ c64-c128-test.prg c128-test.prg chameleon-test.prg \
@@ -27,3 +53,6 @@ c65-test.prg: c65-test.c
turbomaster-test.prg: turbomaster-test.c turbomaster-test.prg: turbomaster-test.c
$(CL) -t c64 turbomaster-test.c -o turbomaster-test.prg $(CL) -t c64 turbomaster-test.c -o turbomaster-test.prg
clean:
$(RM) *.prg

View File

@@ -1,9 +1,37 @@
# For this one see https://applecommander.github.io/ # For this one see https://applecommander.github.io/
AC ?= ac.jar AC ?= ac.jar
CL ?= cl65 # Just the usual way to find out if we're
# using cmd.exe to execute make rules.
ifneq ($(shell echo),)
CMD_EXE = 1
endif
all: hgr.dsk dhgr.dsk ifdef CMD_EXE
NULLDEV = nul:
DEL = -del /f
RMDIR = rmdir /s /q
else
NULLDEV = /dev/null
DEL = $(RM)
RMDIR = $(RM) -r
endif
ifdef CC65_HOME
AS = $(CC65_HOME)/bin/ca65
CC = $(CC65_HOME)/bin/cc65
CL = $(CC65_HOME)/bin/cl65
LD = $(CC65_HOME)/bin/ld65
else
AS := $(if $(wildcard ../../../bin/ca65*),../../../bin/ca65,ca65)
CC := $(if $(wildcard ../../../bin/cc65*),../../../bin/cc65,cc65)
CL := $(if $(wildcard ../../../bin/cl65*),../../../bin/cl65,cl65)
LD := $(if $(wildcard ../../../bin/ld65*),../../../bin/ld65,ld65)
endif
all: hgrshow hgrtest dhgrshow
disk: hgr.dsk dhgr.dsk
hgr.dsk: hgrshow hgrtest hgr.dsk: hgrshow hgrtest
cp prodos.dsk $@ cp prodos.dsk $@
@@ -35,3 +63,9 @@ dhgr.dsk: dhgrshow
dhgrshow: dhgrshow.c dhgrshow: dhgrshow.c
$(CL) -Oirs -t apple2enh --start-addr 0x4000 -m dhgrshow.map $^ $(CL) -Oirs -t apple2enh --start-addr 0x4000 -m dhgrshow.map $^
clean:
$(RM) hgr.dsk dhgr.dsk
$(RM) hgrshow hgrshow.map
$(RM) hgrtest hgrtest.map
$(RM) dhgrshow dhgrshow.map

View File

@@ -0,0 +1,61 @@
# Just the usual way to find out if we're
# using cmd.exe to execute make rules.
ifneq ($(shell echo),)
CMD_EXE = 1
endif
ifdef CMD_EXE
NULLDEV = nul:
DEL = -del /f
RMDIR = rmdir /s /q
else
NULLDEV = /dev/null
DEL = $(RM)
RMDIR = $(RM) -r
endif
ifdef CC65_HOME
AS = $(CC65_HOME)/bin/ca65
CC = $(CC65_HOME)/bin/cc65
CL = $(CC65_HOME)/bin/cl65
LD = $(CC65_HOME)/bin/ld65
else
AS := $(if $(wildcard ../../../bin/ca65*),../../../bin/ca65,ca65)
CC := $(if $(wildcard ../../../bin/cc65*),../../../bin/cc65,cc65)
CL := $(if $(wildcard ../../../bin/cl65*),../../../bin/cl65,cl65)
LD := $(if $(wildcard ../../../bin/ld65*),../../../bin/ld65,ld65)
endif
all: charmapping.xex defdev.xex displaylist.xex mem.xex multi.xex ostype.xex \
scrcode.com sys.xex
charmapping.xex: charmapping.c
$(CL) -t atari -o charmapping.xex charmapping.c
defdev.xex: defdev.c
$(CL) -t atari -o defdev.xex defdev.c
displaylist.xex: displaylist.c
$(CL) -t atari -o displaylist.xex displaylist.c
mem.xex: mem.c ../getsp.s
$(CL) -t atari -o mem.xex mem.c ../getsp.s
multi.xex: multi-xex.s multi-xex.cfg
$(CL) -t atari -C multi-xex.cfg multi-xex.s -o multi.xex
ostype.xex: ostype.c
$(CL) -t atari -o ostype.xex ostype.c
scrcode.com: scrcode.s
# ca65 -t atari -o scrcode.o scrcode.s
# ld65 -C atari-asm.cfg -o scrcode.com scrcode.o
$(CL) -t atari -C atari-asm.cfg -o scrcode.com scrcode.s
sys.xex: sys.c
$(CL) -t atari -o sys.xex sys.c
clean:
$(RM) charmapping.xex
$(RM) defdev.xex
$(RM) displaylist.xex
$(RM) mem.xex
$(RM) multi.xex
$(RM) ostype.xex
$(RM) scrcode.o
$(RM) scrcode.com
$(RM) sys.xex

Binary file not shown.

View File

@@ -43,15 +43,20 @@ key: lda CH
dispdata: scrcode "fooBa", 'r', $66, 3+4 dispdata: scrcode "fooBa", 'r', $66, 3+4
disp_len = * - dispdata disp_len = * - dispdata
.export __AUTOSTART__: absolute = 1
.segment "AUTOSTRT" .segment "AUTOSTRT"
.word $02E0 .word $02E0
.word $02E1 .word $02E1
.word __CODE_LOAD__+1 .word __CODE_LOAD__+1
.export __EXEHDR__: absolute = 1
.segment "EXEHDR" .segment "EXEHDR"
.word $FFFF .word $FFFF
.segment "MAINHDR"
.word __CODE_LOAD__ .word __CODE_LOAD__
.word __BSS_LOAD__ - 1 .word __BSS_LOAD__ - 1

View File

@@ -10,6 +10,8 @@
#include <6502.h> #include <6502.h>
#include <conio.h> #include <conio.h>
#define IOCB (OS.iocb[0])
static struct regs regs; static struct regs regs;
static struct __iocb *iocb = &IOCB; /* use IOCB #0 */ static struct __iocb *iocb = &IOCB; /* use IOCB #0 */

View File

@@ -0,0 +1,36 @@
# Just the usual way to find out if we're
# using cmd.exe to execute make rules.
ifneq ($(shell echo),)
CMD_EXE = 1
endif
ifdef CMD_EXE
NULLDEV = nul:
DEL = -del /f
RMDIR = rmdir /s /q
else
NULLDEV = /dev/null
DEL = $(RM)
RMDIR = $(RM) -r
endif
ifdef CC65_HOME
AS = $(CC65_HOME)/bin/ca65
CC = $(CC65_HOME)/bin/cc65
CL = $(CC65_HOME)/bin/cl65
LD = $(CC65_HOME)/bin/ld65
else
AS := $(if $(wildcard ../../../bin/ca65*),../../../bin/ca65,ca65)
CC := $(if $(wildcard ../../../bin/cc65*),../../../bin/cc65,cc65)
CL := $(if $(wildcard ../../../bin/cl65*),../../../bin/cl65,cl65)
LD := $(if $(wildcard ../../../bin/ld65*),../../../bin/ld65,ld65)
endif
all: hello
hello: hello.c
$(CL) -t atari5200 -o hello hello.c
clean:
$(RM) hello

View File

@@ -19,9 +19,13 @@
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
#include <dirent.h> #include <dirent.h>
#include <cbm.h>
#include <conio.h> #include <conio.h>
#if defined(__CBM__)
#include <cbm.h>
#elif defined(__APPLE2__)
#include <apple2.h>
#endif
int main(void) int main(void)
{ {
@@ -51,9 +55,13 @@ int main(void)
printf("contents of \"%s\":\n", name); printf("contents of \"%s\":\n", name);
while ((E = readdir (D)) != 0) { while ((E = readdir (D)) != 0) {
printf ("dirent.d_name[] : \"%s\"\n", E->d_name); printf ("dirent.d_name[] : \"%s\"\n", E->d_name);
#if !defined(__ATARI__)
printf ("dirent.d_blocks : %10u\n", E->d_blocks); printf ("dirent.d_blocks : %10u\n", E->d_blocks);
#endif
printf ("dirent.d_type : %10d\n", E->d_type); printf ("dirent.d_type : %10d\n", E->d_type);
#if !defined(__APPLE2__) && !defined(__ATARI__)
printf ("telldir() : %10lu\n", telldir (D)); printf ("telldir() : %10lu\n", telldir (D));
#endif
printf ("---\n"); printf ("---\n");
if (!go) { if (!go) {
switch (cgetc ()) { switch (cgetc ()) {
@@ -63,14 +71,16 @@ int main(void)
case 'q': case 'q':
goto done; goto done;
#if !defined(__APPLE2__) && !defined(__ATARI__)
case 'r': case 'r':
seekdir (D, E->d_off); seekdir (D, E->d_off);
break; break;
#endif
#if !defined(__ATARI__)
case 's': case 's':
rewinddir (D); rewinddir (D);
break; break;
#endif
} }
} }

View File

@@ -1,14 +1,42 @@
# Just the usual way to find out if we're
# using cmd.exe to execute make rules.
ifneq ($(shell echo),)
CMD_EXE = 1
endif
ifdef CMD_EXE
NULLDEV = nul:
DEL = -del /f
RMDIR = rmdir /s /q
else
NULLDEV = /dev/null
DEL = $(RM)
RMDIR = $(RM) -r
endif
ifdef CC65_HOME
AS = $(CC65_HOME)/bin/ca65
CC = $(CC65_HOME)/bin/cc65
CL = $(CC65_HOME)/bin/cl65
LD = $(CC65_HOME)/bin/ld65
else
AS := $(if $(wildcard ../../../bin/ca65*),../../../bin/ca65,ca65)
CC := $(if $(wildcard ../../../bin/cc65*),../../../bin/cc65,cc65)
CL := $(if $(wildcard ../../../bin/cl65*),../../../bin/cl65,cl65)
LD := $(if $(wildcard ../../../bin/ld65*),../../../bin/ld65,ld65)
endif
all: audiotest.bin lcdtest.bin ctest.bin all: audiotest.bin lcdtest.bin ctest.bin
audiotest.bin: audiotest.s audiotest.bin: audiotest.s
../../../bin/cl65 -l audiotest.lst -t gamate -o audiotest.bin audiotest.s $(CL) -l audiotest.lst -t gamate -o audiotest.bin audiotest.s
lcdtest.bin: lcdtest.s lcdtest.bin: lcdtest.s
../../../bin/cl65 -l lcdtest.lst -t gamate -o lcdtest.bin lcdtest.s $(CL) -l lcdtest.lst -t gamate -o lcdtest.bin lcdtest.s
ctest.bin: ctest.c ctest.bin: ctest.c
../../../bin/cl65 -l ctest.lst -t gamate -o ctest.bin ctest.c $(CL) -l ctest.lst -t gamate -o ctest.bin ctest.c
nachtm.bin: nachtm.c nachtm.bin: nachtm.c
../../../bin/cl65 -Os -l nachtm.lst -t gamate -o nachtm.bin nachtm.c $(CL) -Os -l nachtm.lst -t gamate -o nachtm.bin nachtm.c
gamate-fixcart nachtm.bin gamate-fixcart nachtm.bin
test1: lcdtest.bin test1: lcdtest.bin
@@ -21,5 +49,6 @@ testn: nachtm.bin
cd ~/Desktop/mame/winmess/ && wine mess.exe gamate -window -skip_gameinfo -cart ~/Desktop/cc65/github/cc65/testcode/lib/gamate/nachtm.bin cd ~/Desktop/mame/winmess/ && wine mess.exe gamate -window -skip_gameinfo -cart ~/Desktop/cc65/github/cc65/testcode/lib/gamate/nachtm.bin
clean: clean:
rm -f lcdtest.o audiotest.o ctest.o $(RM) lcdtest.o audiotest.o ctest.o
rm -f lcdtest.bin audiotest.bin ctest.bin nachtm.bin $(RM) lcdtest.bin audiotest.bin ctest.bin nachtm.bin
$(RM) audiotest.lst lcdtest.lst ctest.lst

View File

@@ -25,19 +25,19 @@ int main(int argc, char *argv[])
gotoxy(0,2);cprintf("%04x %02x %02x %02x", n, x, y, *((unsigned char*)JOY_DATA)); gotoxy(0,2);cprintf("%04x %02x %02x %02x", n, x, y, *((unsigned char*)JOY_DATA));
switch((*((unsigned char*)JOY_DATA))) { switch((*((unsigned char*)JOY_DATA))) {
case 0xff ^ JOY_DATA_UP: case 0xff ^ JOY_UP_MASK:
++y; if (y == 0xc8) y = 0; ++y; if (y == 0xc8) y = 0;
break; break;
case 0xff ^ JOY_DATA_DOWN: case 0xff ^ JOY_DOWN_MASK:
--y; if (y == 0xff) y = 0xc7; --y; if (y == 0xff) y = 0xc7;
break; break;
case 0xff ^ JOY_DATA_LEFT: case 0xff ^ JOY_LEFT_MASK:
++x; ++x;
break; break;
case 0xff ^ JOY_DATA_RIGHT: case 0xff ^ JOY_RIGHT_MASK:
--x; --x;
break; break;
case 0xff ^ JOY_DATA_FIRE_A: case 0xff ^ JOY_BTN_A_MASK:
break; break;
} }

View File

@@ -214,10 +214,10 @@ int main (void)
/* Show info at start */ /* Show info at start */
ShowInfo (); ShowInfo ();
#if !defined(__APPLE2__)
/* Remember the time */ /* Remember the time */
T = clock (); T = clock ();
#endif
/* Do the tests */ /* Do the tests */
Test1 (); Test1 ();
Test2 (); Test2 ();
@@ -226,10 +226,11 @@ int main (void)
Test5 (); Test5 ();
Test6 (); Test6 ();
#if !defined(__APPLE2__)
/* Calculate the time and print it */ /* Calculate the time and print it */
T = clock () - T; T = clock () - T;
printf ("Time needed: %lu ticks\n", T); printf ("Time needed: %lu ticks\n", T);
#endif
/* Done */ /* Done */
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }

View File

@@ -190,7 +190,7 @@ int main (void)
#endif #endif
/* Set dark-on-light colors. Clear the screen. */ /* Set dark-on-light colors. Clear the screen. */
#ifdef __CBM__ #if defined(__CBM__) && !defined(__VIC20__)
(void) bordercolor (COLOR_GRAY2); (void) bordercolor (COLOR_GRAY2);
(void) bgcolor (COLOR_WHITE); (void) bgcolor (COLOR_WHITE);
(void) textcolor (COLOR_GRAY1); (void) textcolor (COLOR_GRAY1);

View File

@@ -1,3 +1,32 @@
# Just the usual way to find out if we're
# using cmd.exe to execute make rules.
ifneq ($(shell echo),)
CMD_EXE = 1
endif
ifdef CMD_EXE
NULLDEV = nul:
DEL = -del /f
RMDIR = rmdir /s /q
else
NULLDEV = /dev/null
DEL = $(RM)
RMDIR = $(RM) -r
endif
ifdef CC65_HOME
AS = $(CC65_HOME)/bin/ca65
CC = $(CC65_HOME)/bin/cc65
CL = $(CC65_HOME)/bin/cl65
LD = $(CC65_HOME)/bin/ld65
else
AS := $(if $(wildcard ../../../bin/ca65*),../../../bin/ca65,ca65)
CC := $(if $(wildcard ../../../bin/cc65*),../../../bin/cc65,cc65)
CL := $(if $(wildcard ../../../bin/cl65*),../../../bin/cl65,cl65)
LD := $(if $(wildcard ../../../bin/ld65*),../../../bin/ld65,ld65)
endif
.PHONY: all clean test .PHONY: all clean test
# Size of cartridge to generate. # Size of cartridge to generate.

View File

@@ -14,9 +14,7 @@
/* Define USE_STDIO, when you want to use the stdio functions. /* Define USE_STDIO, when you want to use the stdio functions.
** Do not define it, when you want to use the conio functions. ** Do not define it, when you want to use the conio functions.
*/ */
/*
#define USE_STDIO #define USE_STDIO
*/
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
@@ -35,22 +33,23 @@
#define ARRAYSIZE(a) (sizeof (a) / sizeof (a)[0]) #define ARRAYSIZE(a) (sizeof (a) / sizeof (a)[0])
typedef enum {
INT,
CHAR
} TYPE;
typedef union {
int nvalue;
const char *svalue;
} VALUE;
static const struct { static const struct {
const char *input, *format; const char *input, *format;
int rvalue; int rvalue;
enum TYPE { TYPE type1;
INT, VALUE v1;
CHAR TYPE type2;
} type1; VALUE v2;
union {
int nvalue;
const char *svalue;
} v1;
enum TYPE type2;
union {
int nvalue;
const char *svalue;
} v2;
} test_data[] = { } test_data[] = {
/* Input sequences for character specifiers must be less than 80 characters /* Input sequences for character specifiers must be less than 80 characters
** long. These format strings are allowwed a maximum of two assignment ** long. These format strings are allowwed a maximum of two assignment

View File

@@ -84,19 +84,21 @@ int main (void)
/* Show info at start */ /* Show info at start */
ShowInfo (); ShowInfo ();
#if !defined(__APPLE2__)
/* Remember the time */ /* Remember the time */
T = clock (); T = clock ();
#endif
/* Do the tests */ /* Do the tests */
FillArray (); FillArray ();
ShowInfo (); ShowInfo ();
FreeArray (); FreeArray ();
ShowInfo (); ShowInfo ();
#if !defined(__APPLE2__)
/* Calculate the time and print it */ /* Calculate the time and print it */
T = clock () - T; T = clock () - T;
printf ("Time needed: %lu ticks\n", T); printf ("Time needed: %lu ticks\n", T);
#endif
/* Done */ /* Done */
return EXIT_SUCCESS; return EXIT_SUCCESS;