From 613ee94f445463c76135c5cb9ebffad6b9027cae Mon Sep 17 00:00:00 2001 From: Jeff Tranter Date: Sun, 30 Apr 2023 18:40:09 -0400 Subject: [PATCH 01/98] Source listing in bootstrap.s is incorrect. The OSI C1P alternative boot file format works, but the code in the source listing does not match the ASCII-coded hex translation (which is actually used). This is confusing to anyone trying to maintain the code. Also, the source code does not assemble when ASM is defined. With these changes the source file should correctly match what is used at run time. --- libsrc/osic1p/bootstrap.s | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/libsrc/osic1p/bootstrap.s b/libsrc/osic1p/bootstrap.s index e88e257fd..292f98914 100644 --- a/libsrc/osic1p/bootstrap.s +++ b/libsrc/osic1p/bootstrap.s @@ -34,7 +34,7 @@ ram_top := __MAIN_START__ + __MAIN_SIZE__ .ifdef ASM - .include "osic1p.inc" + .include "screen-c1p-24x24.s" .macpack generic load := $08 ; private variables @@ -45,20 +45,22 @@ GETCHAR := $FFBF ; gets one character from ACIA FIRSTVISC = $85 ; Offset of first visible character in video RAM LINEDIST = $20 ; Offset in video RAM between two lines - ldy #<$0000 + ldy #<$00 lda #load_addr sta load stx load+1 - ldx #(load_size) + 1 - stx count+1 ; save size with each byte incremented separately + lda #load_size + eor #$FF + sta count+1 -L1: dec count +L1: inc count bnz L2 - dec count+1 + inc count+1 bze L3 L2: jsr GETCHAR ; (doesn't change .Y) sta (load),y @@ -70,7 +72,7 @@ L2: jsr GETCHAR ; (doesn't change .Y) lsr a and #8 - 1 ora #$10 ; eight arrow characters - sta SCRNBASE + FIRSTVISC + 2 * LINEDIST + 11 + sta C1P_SCR_BASE + FIRSTVISC + 2 * LINEDIST + 11 iny bnz L1 From 4d97e30b557172d32435c83b1cb41f8eb5106042 Mon Sep 17 00:00:00 2001 From: Jeff Tranter Date: Sun, 30 Apr 2023 18:40:09 -0400 Subject: [PATCH 02/98] Source listing in bootstrap.s is incorrect. The OSI C1P alternative boot file format works, but the code in the source listing does not match the ASCII-coded hex translation (which is actually used). This is confusing to anyone trying to maintain the code. Also, the source code did not assemble when ASM is defined. Also removed use of branch macros and an unnecessary "<" operator. With these changes the source file should correctly match what is used at run time. --- libsrc/osic1p/bootstrap.s | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/libsrc/osic1p/bootstrap.s b/libsrc/osic1p/bootstrap.s index e88e257fd..52ce31f84 100644 --- a/libsrc/osic1p/bootstrap.s +++ b/libsrc/osic1p/bootstrap.s @@ -34,7 +34,7 @@ ram_top := __MAIN_START__ + __MAIN_SIZE__ .ifdef ASM - .include "osic1p.inc" + .include "screen-c1p-24x24.s" .macpack generic load := $08 ; private variables @@ -45,21 +45,23 @@ GETCHAR := $FFBF ; gets one character from ACIA FIRSTVISC = $85 ; Offset of first visible character in video RAM LINEDIST = $20 ; Offset in video RAM between two lines - ldy #<$0000 + ldy #$00 lda #load_addr sta load stx load+1 - ldx #(load_size) + 1 - stx count+1 ; save size with each byte incremented separately + lda #load_size + eor #$FF + sta count+1 -L1: dec count - bnz L2 - dec count+1 - bze L3 +L1: inc count + bne L2 + inc count+1 + beq L3 L2: jsr GETCHAR ; (doesn't change .Y) sta (load),y @@ -70,12 +72,12 @@ L2: jsr GETCHAR ; (doesn't change .Y) lsr a and #8 - 1 ora #$10 ; eight arrow characters - sta SCRNBASE + FIRSTVISC + 2 * LINEDIST + 11 + sta C1P_SCR_BASE + FIRSTVISC + 2 * LINEDIST + 11 iny - bnz L1 + bne L1 inc load+1 - bnz L1 ; branch always + bne L1 ; branch always L3: jmp load_addr From bf5b37a3b2b0a286e3cc14d1435f0ddbaa6cee4d Mon Sep 17 00:00:00 2001 From: bbbradsmith Date: Tue, 2 May 2023 21:27:02 -0400 Subject: [PATCH 03/98] Error check for internal overflow of numerical constant See bug #2026 --- src/cc65/scanner.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/cc65/scanner.c b/src/cc65/scanner.c index 36fd1301b..055c02450 100644 --- a/src/cc65/scanner.c +++ b/src/cc65/scanner.c @@ -522,6 +522,7 @@ static void NumericConst (void) char C; unsigned DigitVal; unsigned long IVal; /* Value */ + int Overflow; /* Get the pp-number first, then parse on it */ CopyPPNumber (&Src); @@ -575,6 +576,7 @@ static void NumericConst (void) /* Since we now know the correct base, convert the input into a number */ SB_SetIndex (&Src, Index); IVal = 0; + Overflow = 0; while ((C = SB_Peek (&Src)) != '\0' && (Base <= 10 ? IsDigit (C) : IsXDigit (C))) { DigitVal = HexVal (C); if (DigitVal >= Base) { @@ -582,9 +584,17 @@ static void NumericConst (void) SB_Clear (&Src); break; } - IVal = (IVal * Base) + DigitVal; + if ((((unsigned long)(IVal * Base)) / Base) != IVal) + Overflow = 1; + IVal = IVal * Base; + if (((unsigned long)(IVal + DigitVal)) < IVal) + Overflow = 1; + IVal += DigitVal; SB_Skip (&Src); } + if (Overflow) + Error ("Numerical constant \"%s\" too large for internal 32-bit representation", + SB_GetConstBuf (&Src)); /* Distinguish between integer and floating point constants */ if (!IsFloat) { From 409235aee65ce5fd807a50b32a2a4ba664aaab70 Mon Sep 17 00:00:00 2001 From: bbbradsmith Date: Tue, 2 May 2023 22:27:28 -0400 Subject: [PATCH 04/98] Optional warning for implicit constant conversion overflow --- doc/cc65.sgml | 2 ++ src/cc65/error.c | 2 ++ src/cc65/error.h | 1 + src/cc65/typeconv.c | 5 +++++ 4 files changed, 10 insertions(+) diff --git a/doc/cc65.sgml b/doc/cc65.sgml index 683249bda..5a094571a 100644 --- a/doc/cc65.sgml +++ b/doc/cc65.sgml @@ -754,6 +754,8 @@ Here is a description of all the command line options: Warn about unused function parameters. Warn about unused variables. + + Warn if numerical constant conversion implies overflow. (Disabled by default.) The full list of available warning names can be retrieved by using the diff --git a/src/cc65/error.c b/src/cc65/error.c index 3f36d9e97..6ac3e594b 100644 --- a/src/cc65/error.c +++ b/src/cc65/error.c @@ -79,6 +79,7 @@ IntStack WarnUnusedLabel = INTSTACK(1); /* - unused labels */ IntStack WarnUnusedParam = INTSTACK(1); /* - unused parameters */ IntStack WarnUnusedVar = INTSTACK(1); /* - unused variables */ IntStack WarnUnusedFunc = INTSTACK(1); /* - unused functions */ +IntStack WarnConstOverflow = INTSTACK(0); /* - overflow conversion of numerical constants */ /* Map the name of a warning to the intstack that holds its state */ typedef struct WarnMapEntry WarnMapEntry; @@ -102,6 +103,7 @@ static WarnMapEntry WarnMap[] = { { &WarnUnusedLabel, "unused-label" }, { &WarnUnusedParam, "unused-param" }, { &WarnUnusedVar, "unused-var" }, + { &WarnConstOverflow, "const-overflow" }, }; Collection DiagnosticStrBufs; diff --git a/src/cc65/error.h b/src/cc65/error.h index 7fcb03467..83be8c782 100644 --- a/src/cc65/error.h +++ b/src/cc65/error.h @@ -76,6 +76,7 @@ extern IntStack WarnUnusedLabel; /* - unused labels */ extern IntStack WarnUnusedParam; /* - unused parameters */ extern IntStack WarnUnusedVar; /* - unused variables */ extern IntStack WarnUnusedFunc; /* - unused functions */ +extern IntStack WarnConstOverflow; /* - overflow conversion of numerical constants */ /* Forward */ struct StrBuf; diff --git a/src/cc65/typeconv.c b/src/cc65/typeconv.c index f77ec3951..49dfcc597 100644 --- a/src/cc65/typeconv.c +++ b/src/cc65/typeconv.c @@ -128,6 +128,7 @@ static void DoConversion (ExprDesc* Expr, const Type* NewType) ** internally already represented by a long. */ if (NewBits <= OldBits) { + unsigned long OldVal = Expr->IVal; /* Cut the value to the new size */ Expr->IVal &= (0xFFFFFFFFUL >> (32 - NewBits)); @@ -139,6 +140,10 @@ static void DoConversion (ExprDesc* Expr, const Type* NewType) Expr->IVal |= shl_l (~0UL, NewBits); } } + + if ((OldVal != Expr->IVal) && IS_Get (&WarnConstOverflow)) { + Warning ("Implicit conversion of constant overflows %d-bit destination", NewBits); + } } /* Do the integer constant <-> absolute address conversion if necessary */ From 56c715af40ed1cad1a3b2a29de50e7ceaa9911e4 Mon Sep 17 00:00:00 2001 From: bbbradsmith Date: Wed, 3 May 2023 01:14:27 -0400 Subject: [PATCH 05/98] Error for struct/union with a duplicate member #2015 --- src/cc65/symtab.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cc65/symtab.c b/src/cc65/symtab.c index 72a2ac007..d9270f604 100644 --- a/src/cc65/symtab.c +++ b/src/cc65/symtab.c @@ -793,6 +793,8 @@ static int HandleSymRedefinition (SymEntry* Sym, const Type* T, unsigned Flags) */ Error ("Redeclaration of enumerator constant '%s'", Sym->Name); Sym = 0; + } else if (Flags & SC_STRUCTFIELD) { + Error ("Duplicate member '%s'", Sym->Name); } } } From 387d455cb45d7fc7249ffe1e1d927fb0300e897d Mon Sep 17 00:00:00 2001 From: Jeff Tranter Date: Wed, 3 May 2023 11:16:22 -0400 Subject: [PATCH 06/98] Revised patch. Uses code in source listing. Tested on a real OSI C1P machine. --- libsrc/osic1p/bootstrap.s | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/libsrc/osic1p/bootstrap.s b/libsrc/osic1p/bootstrap.s index 52ce31f84..0d8a74eb7 100644 --- a/libsrc/osic1p/bootstrap.s +++ b/libsrc/osic1p/bootstrap.s @@ -35,7 +35,6 @@ ram_top := __MAIN_START__ + __MAIN_SIZE__ .ifdef ASM .include "screen-c1p-24x24.s" - .macpack generic load := $08 ; private variables count := $0A @@ -51,16 +50,14 @@ LINEDIST = $20 ; Offset in video RAM between two lines sta load stx load+1 - lda #load_size - eor #$FF - sta count+1 + ldx #(load_size) + 1 + stx count+1 ; save size with each byte incremented separately -L1: inc count +L1: dec count bne L2 - inc count+1 + dec count+1 beq L3 L2: jsr GETCHAR ; (doesn't change .Y) sta (load),y @@ -114,18 +111,15 @@ CR = $0D hex2 >load_addr .byte CR, "85", CR, "08", CR .byte "86", CR, "09", CR - .byte "A9", CR - hex2 load_size - .byte CR, "49", CR, "FF", CR - .byte "85", CR, "0B", CR - - .byte "E6", CR, "0A", CR + .byte "A2", CR + hex2 (load_size) + 1 + .byte CR, "86", CR, "0B", CR + .byte "C6", CR, "0A", CR .byte "D0", CR, "04", CR - .byte "E6", CR, "0B", CR + .byte "C6", CR, "0B", CR .byte "F0", CR, "16", CR .byte "20", CR, "BF", CR, "FF", CR .byte "91", CR, "08", CR From 9a502c69dc9d3c4c29791b75d9f03796487e3cc7 Mon Sep 17 00:00:00 2001 From: bbbradsmith Date: Wed, 3 May 2023 16:46:59 -0400 Subject: [PATCH 07/98] fix tab, braces for 1-line if, Expr->Ival is signed --- src/cc65/error.c | 2 +- src/cc65/scanner.c | 9 ++++++--- src/cc65/typeconv.c | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/cc65/error.c b/src/cc65/error.c index 6ac3e594b..39b067825 100644 --- a/src/cc65/error.c +++ b/src/cc65/error.c @@ -103,7 +103,7 @@ static WarnMapEntry WarnMap[] = { { &WarnUnusedLabel, "unused-label" }, { &WarnUnusedParam, "unused-param" }, { &WarnUnusedVar, "unused-var" }, - { &WarnConstOverflow, "const-overflow" }, + { &WarnConstOverflow, "const-overflow" }, }; Collection DiagnosticStrBufs; diff --git a/src/cc65/scanner.c b/src/cc65/scanner.c index 055c02450..ec49d0e3c 100644 --- a/src/cc65/scanner.c +++ b/src/cc65/scanner.c @@ -584,17 +584,20 @@ static void NumericConst (void) SB_Clear (&Src); break; } - if ((((unsigned long)(IVal * Base)) / Base) != IVal) + if ((((unsigned long)(IVal * Base)) / Base) != IVal) { Overflow = 1; + } IVal = IVal * Base; - if (((unsigned long)(IVal + DigitVal)) < IVal) + if (((unsigned long)(IVal + DigitVal)) < IVal) { Overflow = 1; + } IVal += DigitVal; SB_Skip (&Src); } - if (Overflow) + if (Overflow) { Error ("Numerical constant \"%s\" too large for internal 32-bit representation", SB_GetConstBuf (&Src)); + } /* Distinguish between integer and floating point constants */ if (!IsFloat) { diff --git a/src/cc65/typeconv.c b/src/cc65/typeconv.c index 49dfcc597..e1d95ff63 100644 --- a/src/cc65/typeconv.c +++ b/src/cc65/typeconv.c @@ -128,7 +128,7 @@ static void DoConversion (ExprDesc* Expr, const Type* NewType) ** internally already represented by a long. */ if (NewBits <= OldBits) { - unsigned long OldVal = Expr->IVal; + long OldVal = Expr->IVal; /* Cut the value to the new size */ Expr->IVal &= (0xFFFFFFFFUL >> (32 - NewBits)); From 49bd5681136fc4afff5f46f796eeb777c0e691d1 Mon Sep 17 00:00:00 2001 From: bbbradsmith Date: Wed, 3 May 2023 17:55:02 -0400 Subject: [PATCH 08/98] error test for integer constant too large for internal representation --- test/err/huge-integer-constant.c | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 test/err/huge-integer-constant.c diff --git a/test/err/huge-integer-constant.c b/test/err/huge-integer-constant.c new file mode 100644 index 000000000..1f423347c --- /dev/null +++ b/test/err/huge-integer-constant.c @@ -0,0 +1,7 @@ +/* too big for internal integer representation */ +unsigned long huge = 4294967296; + +int main(void) +{ + return 0; +} From e3cb8dfb9be6e4f9244fdecba6610f6a72116763 Mon Sep 17 00:00:00 2001 From: bbbradsmith Date: Wed, 3 May 2023 19:27:37 -0400 Subject: [PATCH 09/98] Numerical constant scanner requires explicitly 32-bit sized type for cross-platform consistency --- src/cc65/scanner.c | 16 +++++++++++----- test/val/common.h | 1 + test/val/cq241.c | 19 +++++++++++++++++-- 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/src/cc65/scanner.c b/src/cc65/scanner.c index ec49d0e3c..f747fb458 100644 --- a/src/cc65/scanner.c +++ b/src/cc65/scanner.c @@ -39,6 +39,7 @@ #include #include #include +#include /* common */ #include "chartype.h" @@ -151,6 +152,11 @@ static const struct Keyword { #define IT_ULONG 0x08 +/* Internal type for numeric constant scanning. +** Size must be explicit for cross-platform uniformity. +*/ +typedef uint32_t scan_t; + /*****************************************************************************/ /* code */ @@ -521,7 +527,7 @@ static void NumericConst (void) int IsFloat; char C; unsigned DigitVal; - unsigned long IVal; /* Value */ + scan_t IVal; /* Scanned value. */ int Overflow; /* Get the pp-number first, then parse on it */ @@ -584,19 +590,19 @@ static void NumericConst (void) SB_Clear (&Src); break; } - if ((((unsigned long)(IVal * Base)) / Base) != IVal) { + if (((scan_t)(IVal * Base) / Base) != IVal) { Overflow = 1; } IVal = IVal * Base; - if (((unsigned long)(IVal + DigitVal)) < IVal) { + if (((scan_t)(IVal + DigitVal)) < IVal) { Overflow = 1; } IVal += DigitVal; SB_Skip (&Src); } if (Overflow) { - Error ("Numerical constant \"%s\" too large for internal 32-bit representation", - SB_GetConstBuf (&Src)); + Error ("Numerical constant \"%s\" too large for internal %d-bit representation", + SB_GetConstBuf (&Src), (int)(sizeof(IVal)*8)); } /* Distinguish between integer and floating point constants */ diff --git a/test/val/common.h b/test/val/common.h index dada61a14..61da6c325 100644 --- a/test/val/common.h +++ b/test/val/common.h @@ -20,3 +20,4 @@ #define SIZEOF_LONG_32BIT #define UNSIGNED_CHARS #define UNSIGNED_BITFIELDS +#define INTEGER_CONSTANT_MAX_32BIT diff --git a/test/val/cq241.c b/test/val/cq241.c index 611b5a376..a6d6c5324 100644 --- a/test/val/cq241.c +++ b/test/val/cq241.c @@ -4,6 +4,14 @@ !!LICENCE!! own, freely distributeable for non-profit. read CPYRIGHT.LCC */ +/* INTEGER_CONSTANT_MAX_32BIT +** This suppresses constants longer than 32-bit, which are now an error: +** https://github.com/cc65/cc65/pull/2084 +** Because cc65's internal representation is implicitly/explicitly +** 32-bit in many places, values larger than this aren't representable, +** but also can't be checked for overflow once accepted. +*/ + #include "common.h" struct defs { @@ -62,7 +70,12 @@ long pow2(long n) { return s; } - long d[39], o[39], x[39]; +#ifndef INTEGER_CONSTANT_MAX_32BIT +#define CTCOUNT 39 +#else +#define CTCOUNT 36 +#endif + long d[CTCOUNT], o[CTCOUNT], x[CTCOUNT]; #ifndef NO_OLD_FUNC_DECL s241(pd0) @@ -212,13 +225,15 @@ int s241(struct defs *pd0) { d[33] = 1073741823; o[33] = 07777777777; x[33] = 0x3fffffff; d[34] = 1073741824; o[34] = 010000000000; x[34] = 0x40000000; d[35] = 4294967295; o[35] = 037777777777; x[35] = 0xffffffff; +#if CTCOUNT > 36 d[36] = 4294967296; o[36] = 040000000000; x[36] = 0x100000000; d[37] = 68719476735; o[37] = 0777777777777; x[37] = 0xfffffffff; d[38] = 68719476736; o[38] = 01000000000000; x[38] = 0x1000000000; +#endif /* WHEW! */ - for (j=0; j<39; j++){ + for (j=0; j Date: Wed, 3 May 2023 19:42:05 -0400 Subject: [PATCH 10/98] Suppress overflow warning when conversion is an explicit cast --- src/cc65/typeconv.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cc65/typeconv.c b/src/cc65/typeconv.c index e1d95ff63..6bdb45b5f 100644 --- a/src/cc65/typeconv.c +++ b/src/cc65/typeconv.c @@ -55,7 +55,7 @@ -static void DoConversion (ExprDesc* Expr, const Type* NewType) +static void DoConversion (ExprDesc* Expr, const Type* NewType, int Explicit) /* Emit code to convert the given expression to a new type. */ { const Type* OldType; @@ -141,7 +141,7 @@ static void DoConversion (ExprDesc* Expr, const Type* NewType) } } - if ((OldVal != Expr->IVal) && IS_Get (&WarnConstOverflow)) { + if ((OldVal != Expr->IVal) && IS_Get (&WarnConstOverflow) && !Explicit) { Warning ("Implicit conversion of constant overflows %d-bit destination", NewBits); } } @@ -288,7 +288,7 @@ void TypeConversion (ExprDesc* Expr, const Type* NewType) /* Both types must be complete */ if (!IsIncompleteESUType (NewType) && !IsIncompleteESUType (Expr->Type)) { /* Do the actual conversion */ - DoConversion (Expr, NewType); + DoConversion (Expr, NewType, 0); } else { /* We should have already generated error elsewhere so that we ** could just silently fail here to avoid excess errors, but to @@ -335,7 +335,7 @@ void TypeCast (ExprDesc* Expr) ReplaceType (Expr, NewType); } else if (IsCastType (Expr->Type)) { /* Convert the value. The result has always the new type */ - DoConversion (Expr, NewType); + DoConversion (Expr, NewType, 1); } else { TypeCompatibilityDiagnostic (NewType, Expr->Type, 1, "Cast to incompatible type '%s' from '%s'"); From b5f255f9123dc898e494321406edd434b89a6d49 Mon Sep 17 00:00:00 2001 From: bbbradsmith Date: Wed, 3 May 2023 19:54:40 -0400 Subject: [PATCH 11/98] Test case for const-overflow warnings --- test/err/integer-const-overflow.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 test/err/integer-const-overflow.c diff --git a/test/err/integer-const-overflow.c b/test/err/integer-const-overflow.c new file mode 100644 index 000000000..37cc0f01e --- /dev/null +++ b/test/err/integer-const-overflow.c @@ -0,0 +1,20 @@ +/* Integer constant overflow warnings. */ + +/* Warnings as errors. */ +#pragma warn(error,on) + +/* Warn on const overflow */ +#pragma warn(const-overflow,on) + +unsigned char a = 256; +signed char b = 128; +unsigned char c = -129; +unsigned short int d = 0x00010000; +unsigned short int e = 0x80000000; +signed short int f = 32768L; +signed short int g = -32769L; + +int main(void) +{ + return 0; +} From 84eafb7f9c255d6a82a8062a6d8a8f3c0eb60a72 Mon Sep 17 00:00:00 2001 From: bbbradsmith Date: Wed, 3 May 2023 21:09:03 -0400 Subject: [PATCH 12/98] err test for struct with duplicate member --- test/err/struct-duplicate-member.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 test/err/struct-duplicate-member.c diff --git a/test/err/struct-duplicate-member.c b/test/err/struct-duplicate-member.c new file mode 100644 index 000000000..30cd06207 --- /dev/null +++ b/test/err/struct-duplicate-member.c @@ -0,0 +1,17 @@ +/* Ensure that a duplicate member in a struct produces an error. +** https://github.com/cc65/cc65/issues/2015 +*/ + +struct bads { + int a; + int a; /* this is an error */ +}; + +union badu { + int a, a; /* also an error */ +}; + +int main(void) +{ + return 0; +} From 13f317e660b543ec6037e69c17f3226dbee3d171 Mon Sep 17 00:00:00 2001 From: Bob Andrews Date: Thu, 4 May 2023 09:18:33 +0200 Subject: [PATCH 13/98] Update Contributing.md --- Contributing.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Contributing.md b/Contributing.md index eb26e920b..3b355373c 100644 --- a/Contributing.md +++ b/Contributing.md @@ -74,10 +74,12 @@ color := $0787 The following is still very incomplete - if in doubt please look at existing sourcefiles and adapt to the existing style -* Your files should obey the C89 standard. +* Your files should generally obey the C89 standard, with a few C99 things (this is a bit similar to what cc65 itself supports). The exceptions are: + * use stdint.h for variables that require a certain bit size + * In printf-style functions use the PRIX64 (and similar) macros to deal with 64bit values (from inttypes.h) +This list is not necessarily complete - if in doubt, please ask. * We generally have a "no warnings" policy -* Warnings must not be hidden by using typecasts - fix the code instead - * In printf-style functions use the PRIX64 (and similar) macros to deal with 64bit values + * Warnings must not be hidden by using typecasts - fix the code instead * The normal indentation width should be four spaces. * You must use ANSI C comments (```/* */```); you must not use C++ comments (```//```). * When you add functions to an existing file, you should separate them by the same number of blank lines that separate the functions that already are in that file. From ca8201a314bc0b6539a49518c334cc297e651764 Mon Sep 17 00:00:00 2001 From: bbbradsmith Date: Thu, 4 May 2023 05:44:20 -0400 Subject: [PATCH 14/98] Overflow test optimization suggested by kugelfuhr User CHAR_BIT instead of 8 --- src/cc65/scanner.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/cc65/scanner.c b/src/cc65/scanner.c index f747fb458..54ce02158 100644 --- a/src/cc65/scanner.c +++ b/src/cc65/scanner.c @@ -590,19 +590,15 @@ static void NumericConst (void) SB_Clear (&Src); break; } - if (((scan_t)(IVal * Base) / Base) != IVal) { + if (((scan_t)(IVal * Base + DigitVal) / Base) != IVal) { Overflow = 1; } - IVal = IVal * Base; - if (((scan_t)(IVal + DigitVal)) < IVal) { - Overflow = 1; - } - IVal += DigitVal; + IVal = IVal * Base + DigitVal; SB_Skip (&Src); } if (Overflow) { Error ("Numerical constant \"%s\" too large for internal %d-bit representation", - SB_GetConstBuf (&Src), (int)(sizeof(IVal)*8)); + SB_GetConstBuf (&Src), (int)(sizeof(IVal)*CHAR_BIT)); } /* Distinguish between integer and floating point constants */ From 69f4cd184779925ca399823acc56e50dcff1dc29 Mon Sep 17 00:00:00 2001 From: bbbradsmith Date: Thu, 4 May 2023 05:48:48 -0400 Subject: [PATCH 15/98] limits.h was apparently already included somewhere on windows but not linux --- src/cc65/scanner.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cc65/scanner.c b/src/cc65/scanner.c index 54ce02158..ede77cb2c 100644 --- a/src/cc65/scanner.c +++ b/src/cc65/scanner.c @@ -40,6 +40,7 @@ #include #include #include +#include /* common */ #include "chartype.h" @@ -590,6 +591,7 @@ static void NumericConst (void) SB_Clear (&Src); break; } + /* Test result of adding digit for overflow. */ if (((scan_t)(IVal * Base + DigitVal) / Base) != IVal) { Overflow = 1; } From 0957c36115126f067d42ed5a74210993a6e1e710 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Thu, 4 May 2023 14:19:27 +0200 Subject: [PATCH 16/98] try verbose dry run to see what it does :) --- .github/workflows/snapshot-on-push-master.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/snapshot-on-push-master.yml b/.github/workflows/snapshot-on-push-master.yml index e8be4400e..38158b384 100644 --- a/.github/workflows/snapshot-on-push-master.yml +++ b/.github/workflows/snapshot-on-push-master.yml @@ -111,7 +111,7 @@ jobs: git config push.default simple git add -A git commit -m "Updated from cc65 commit ${GITHUB_SHA}." - #git push -v + git push -n -v # enter secrets under "repository secrets" - name: Upload snapshot to sourceforge From 45258d060dc614a2ed07a08711bb4341d19cdb19 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Thu, 4 May 2023 14:47:02 +0200 Subject: [PATCH 17/98] lets see if this works --- .github/workflows/snapshot-on-push-master.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/snapshot-on-push-master.yml b/.github/workflows/snapshot-on-push-master.yml index 38158b384..dc7e6007e 100644 --- a/.github/workflows/snapshot-on-push-master.yml +++ b/.github/workflows/snapshot-on-push-master.yml @@ -7,6 +7,10 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true +# suggested at https://jonathansoma.com/everything/git/github-actions-403-error/ +permissions: + contents: write + jobs: build_windows: name: Build (Windows) From 7c5595efbc008aa32645cdb12ad52b186e6e0c67 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Thu, 4 May 2023 15:02:32 +0200 Subject: [PATCH 18/98] another try --- .github/workflows/snapshot-on-push-master.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/snapshot-on-push-master.yml b/.github/workflows/snapshot-on-push-master.yml index dc7e6007e..759446dc2 100644 --- a/.github/workflows/snapshot-on-push-master.yml +++ b/.github/workflows/snapshot-on-push-master.yml @@ -39,6 +39,8 @@ jobs: runs-on: ubuntu-latest steps: +# inspired by https://github.com/JuliaRegistries/TagBot/blob/master/example.yml + token: ${{ secrets.GITHUB_TOKEN }} - name: Install Dependencies shell: bash run: | From c0dd3b9d9ac9f5e19c6341ae23e75278b0cecf82 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Thu, 4 May 2023 15:10:10 +0200 Subject: [PATCH 19/98] like this? awesome how everyone does something different :) --- .github/workflows/snapshot-on-push-master.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/snapshot-on-push-master.yml b/.github/workflows/snapshot-on-push-master.yml index 759446dc2..933bc05ba 100644 --- a/.github/workflows/snapshot-on-push-master.yml +++ b/.github/workflows/snapshot-on-push-master.yml @@ -39,8 +39,6 @@ jobs: runs-on: ubuntu-latest steps: -# inspired by https://github.com/JuliaRegistries/TagBot/blob/master/example.yml - token: ${{ secrets.GITHUB_TOKEN }} - name: Install Dependencies shell: bash run: | @@ -108,6 +106,8 @@ jobs: repository: cc65/doc path: doc.git - name: Update the online documents. + with: + github_token: ${{ secrets.GITHUB_TOKEN }} run: | cd doc.git rm *.* From 681c51b37e3fa3be8d6518c40506fd62ef4dff6d Mon Sep 17 00:00:00 2001 From: mrdudz Date: Thu, 4 May 2023 15:12:46 +0200 Subject: [PATCH 20/98] yawn --- .github/workflows/snapshot-on-push-master.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/snapshot-on-push-master.yml b/.github/workflows/snapshot-on-push-master.yml index 933bc05ba..7baa69ba7 100644 --- a/.github/workflows/snapshot-on-push-master.yml +++ b/.github/workflows/snapshot-on-push-master.yml @@ -8,8 +8,13 @@ concurrency: cancel-in-progress: true # suggested at https://jonathansoma.com/everything/git/github-actions-403-error/ +# https://github.com/orgs/community/discussions/26694 permissions: + deployments: write contents: write + statuses: write + actions: write + checks: read jobs: build_windows: @@ -106,8 +111,6 @@ jobs: repository: cc65/doc path: doc.git - name: Update the online documents. - with: - github_token: ${{ secrets.GITHUB_TOKEN }} run: | cd doc.git rm *.* From 20f0427fa42278bac6790f3a1bc0d2d2c8b634e1 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Thu, 4 May 2023 15:20:33 +0200 Subject: [PATCH 21/98] comment out the push again. who knows whats wrong. sigh --- .github/workflows/snapshot-on-push-master.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/snapshot-on-push-master.yml b/.github/workflows/snapshot-on-push-master.yml index 7baa69ba7..75e93b0f8 100644 --- a/.github/workflows/snapshot-on-push-master.yml +++ b/.github/workflows/snapshot-on-push-master.yml @@ -120,7 +120,7 @@ jobs: git config push.default simple git add -A git commit -m "Updated from cc65 commit ${GITHUB_SHA}." - git push -n -v + #git push -n -v # enter secrets under "repository secrets" - name: Upload snapshot to sourceforge From 99a0d64b935ad2c0aaa85d35d4c7cbb68d8d3b18 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Thu, 4 May 2023 20:03:27 +0200 Subject: [PATCH 22/98] lets see if that token stuff works --- .github/workflows/snapshot-on-push-master.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/snapshot-on-push-master.yml b/.github/workflows/snapshot-on-push-master.yml index 75e93b0f8..3a69ab44b 100644 --- a/.github/workflows/snapshot-on-push-master.yml +++ b/.github/workflows/snapshot-on-push-master.yml @@ -109,6 +109,8 @@ jobs: uses: actions/checkout@v3 with: repository: cc65/doc + # this token will expire, if it does, generate a new one as decribed in https://github.com/cc65/cc65/issues/2065 + token: ${{ secrets.DOC_PAT }} # use secret token instead of default path: doc.git - name: Update the online documents. run: | @@ -120,7 +122,7 @@ jobs: git config push.default simple git add -A git commit -m "Updated from cc65 commit ${GITHUB_SHA}." - #git push -n -v + git push -n -v # enter secrets under "repository secrets" - name: Upload snapshot to sourceforge From 3536761110067f79231775d304f73dcccf42e355 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Thu, 4 May 2023 20:30:28 +0200 Subject: [PATCH 23/98] another try --- .github/workflows/snapshot-on-push-master.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/snapshot-on-push-master.yml b/.github/workflows/snapshot-on-push-master.yml index 3a69ab44b..c562ad0dd 100644 --- a/.github/workflows/snapshot-on-push-master.yml +++ b/.github/workflows/snapshot-on-push-master.yml @@ -9,12 +9,12 @@ concurrency: # suggested at https://jonathansoma.com/everything/git/github-actions-403-error/ # https://github.com/orgs/community/discussions/26694 -permissions: - deployments: write - contents: write - statuses: write - actions: write - checks: read +#permissions: +# deployments: write +# contents: write +# statuses: write +# actions: write +# checks: read jobs: build_windows: From 0369838f24aece6035321de618f8992c46e9ee91 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Thu, 4 May 2023 20:45:35 +0200 Subject: [PATCH 24/98] bleh --- .github/workflows/snapshot-on-push-master.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/snapshot-on-push-master.yml b/.github/workflows/snapshot-on-push-master.yml index c562ad0dd..f5f690083 100644 --- a/.github/workflows/snapshot-on-push-master.yml +++ b/.github/workflows/snapshot-on-push-master.yml @@ -122,7 +122,7 @@ jobs: git config push.default simple git add -A git commit -m "Updated from cc65 commit ${GITHUB_SHA}." - git push -n -v + -git push -v # enter secrets under "repository secrets" - name: Upload snapshot to sourceforge From 926d09a14d812509102f722232d6ffd88d18af1f Mon Sep 17 00:00:00 2001 From: mrdudz Date: Thu, 4 May 2023 20:48:52 +0200 Subject: [PATCH 25/98] i'm not patient enough --- .github/workflows/snapshot-on-push-master.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/snapshot-on-push-master.yml b/.github/workflows/snapshot-on-push-master.yml index f5f690083..2b346f1d3 100644 --- a/.github/workflows/snapshot-on-push-master.yml +++ b/.github/workflows/snapshot-on-push-master.yml @@ -66,15 +66,15 @@ jobs: - name: Build the platform libraries. shell: bash run: make -j2 lib QUIET=1 - - name: Run the regression tests. - shell: bash - run: make test QUIET=1 - - name: Test that the samples can be built. - shell: bash - run: make -j2 samples - - name: Remove the output from the samples tests. - shell: bash - run: make -C samples clean +# - name: Run the regression tests. +# shell: bash +# run: make test QUIET=1 +# - name: Test that the samples can be built. +# shell: bash +# run: make -j2 samples +# - name: Remove the output from the samples tests. +# shell: bash +# run: make -C samples clean - name: Remove programs in util directory shell: bash run: make -C util clean From 17f58d934fd2a5bc7b709de36a718e0938cd48d5 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Thu, 4 May 2023 20:52:50 +0200 Subject: [PATCH 26/98] AGAIN --- .github/workflows/snapshot-on-push-master.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/snapshot-on-push-master.yml b/.github/workflows/snapshot-on-push-master.yml index 2b346f1d3..f5340495e 100644 --- a/.github/workflows/snapshot-on-push-master.yml +++ b/.github/workflows/snapshot-on-push-master.yml @@ -122,7 +122,7 @@ jobs: git config push.default simple git add -A git commit -m "Updated from cc65 commit ${GITHUB_SHA}." - -git push -v + git push -v # enter secrets under "repository secrets" - name: Upload snapshot to sourceforge From ea90c934d7fd1fccfce4302c2ed0426297ccbc1e Mon Sep 17 00:00:00 2001 From: mrdudz Date: Thu, 4 May 2023 20:59:18 +0200 Subject: [PATCH 27/98] try gain with classic token --- .github/workflows/snapshot-on-push-master.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/snapshot-on-push-master.yml b/.github/workflows/snapshot-on-push-master.yml index f5340495e..d859054ec 100644 --- a/.github/workflows/snapshot-on-push-master.yml +++ b/.github/workflows/snapshot-on-push-master.yml @@ -122,7 +122,7 @@ jobs: git config push.default simple git add -A git commit -m "Updated from cc65 commit ${GITHUB_SHA}." - git push -v + git push -n -v # enter secrets under "repository secrets" - name: Upload snapshot to sourceforge From 610dfbb41ca54b6d0fc8a4661b2f88d79b101ca5 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Thu, 4 May 2023 21:07:23 +0200 Subject: [PATCH 28/98] try normal push, also try actions/upload-artifact@v3 --- .github/workflows/snapshot-on-push-master.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/snapshot-on-push-master.yml b/.github/workflows/snapshot-on-push-master.yml index d859054ec..20b1ea8f7 100644 --- a/.github/workflows/snapshot-on-push-master.yml +++ b/.github/workflows/snapshot-on-push-master.yml @@ -95,12 +95,12 @@ jobs: mv cc65.zip cc65-snapshot-win32.zip - name: Upload a 32-bit Snapshot Zip - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: cc65-snapshot-win32.zip path: cc65-snapshot-win32.zip - name: Upload a 64-bit Snapshot Zip - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: cc65-snapshot-win64.zip path: cc65-snapshot-win64.zip @@ -122,7 +122,7 @@ jobs: git config push.default simple git add -A git commit -m "Updated from cc65 commit ${GITHUB_SHA}." - git push -n -v + git push # enter secrets under "repository secrets" - name: Upload snapshot to sourceforge From 7053dac3a99625d169b25a1b7a479d1a17a87091 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Thu, 4 May 2023 21:13:37 +0200 Subject: [PATCH 29/98] remove token from cc65/doc, reenable the tests again --- .github/workflows/snapshot-on-push-master.yml | 29 +++++++------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/.github/workflows/snapshot-on-push-master.yml b/.github/workflows/snapshot-on-push-master.yml index 20b1ea8f7..62d6c6adb 100644 --- a/.github/workflows/snapshot-on-push-master.yml +++ b/.github/workflows/snapshot-on-push-master.yml @@ -7,15 +7,6 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true -# suggested at https://jonathansoma.com/everything/git/github-actions-403-error/ -# https://github.com/orgs/community/discussions/26694 -#permissions: -# deployments: write -# contents: write -# statuses: write -# actions: write -# checks: read - jobs: build_windows: name: Build (Windows) @@ -66,15 +57,15 @@ jobs: - name: Build the platform libraries. shell: bash run: make -j2 lib QUIET=1 -# - name: Run the regression tests. -# shell: bash -# run: make test QUIET=1 -# - name: Test that the samples can be built. -# shell: bash -# run: make -j2 samples -# - name: Remove the output from the samples tests. -# shell: bash -# run: make -C samples clean + - name: Run the regression tests. + shell: bash + run: make test QUIET=1 + - name: Test that the samples can be built. + shell: bash + run: make -j2 samples + - name: Remove the output from the samples tests. + shell: bash + run: make -C samples clean - name: Remove programs in util directory shell: bash run: make -C util clean @@ -110,6 +101,8 @@ jobs: with: repository: cc65/doc # this token will expire, if it does, generate a new one as decribed in https://github.com/cc65/cc65/issues/2065 + # - apparently only a "classic" token works here + # - the token must exist in the cc65/cc65 repo token: ${{ secrets.DOC_PAT }} # use secret token instead of default path: doc.git - name: Update the online documents. From 769b31637689c0ead7983cddf85b5ca019804f3b Mon Sep 17 00:00:00 2001 From: mrdudz Date: Thu, 4 May 2023 21:27:48 +0200 Subject: [PATCH 30/98] lets see if this will not fail when there are no changes in the docs --- .github/workflows/snapshot-on-push-master.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/snapshot-on-push-master.yml b/.github/workflows/snapshot-on-push-master.yml index 62d6c6adb..9883003fb 100644 --- a/.github/workflows/snapshot-on-push-master.yml +++ b/.github/workflows/snapshot-on-push-master.yml @@ -114,8 +114,8 @@ jobs: git config user.email "cc65.nomail@github.com" git config push.default simple git add -A - git commit -m "Updated from cc65 commit ${GITHUB_SHA}." - git push + git diff-index --quiet HEAD || git commit -m "Updated from cc65 commit ${GITHUB_SHA}." + git diff-index --quiet HEAD || git push # enter secrets under "repository secrets" - name: Upload snapshot to sourceforge From 4ef849cb81c2a00e8716d8827eb45e27e8575269 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Thu, 4 May 2023 21:44:57 +0200 Subject: [PATCH 31/98] Force background image to snap left, adapted from https://github.com/cc65/doc/pull/1 --- doc/doc.css | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/doc/doc.css b/doc/doc.css index e4c316e16..6bd538681 100644 --- a/doc/doc.css +++ b/doc/doc.css @@ -2,12 +2,14 @@ body { font-family: arial, helvetica, sans-serif; font-size: 100%; text-align: justify; - margin-left: 110px; - margin-top: 10px; - margin-right: 30px; - margin-bottom: 10px; + margin: 0px; + padding-left: 110px; + padding-top: 10px; + padding-right: 30px; + padding-bottom: 10px; background-image: url(doc.png); background-repeat: repeat-y; + background-position:left top; } h1, h2, h2 a:link, h2 a:active, h2 a:visited { From e228e4d65c3edd22488a90a8878fb6aa71f42a9f Mon Sep 17 00:00:00 2001 From: mrdudz Date: Thu, 4 May 2023 21:58:37 +0200 Subject: [PATCH 32/98] try something else, again --- .github/workflows/snapshot-on-push-master.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/snapshot-on-push-master.yml b/.github/workflows/snapshot-on-push-master.yml index 9883003fb..fb42bfcb3 100644 --- a/.github/workflows/snapshot-on-push-master.yml +++ b/.github/workflows/snapshot-on-push-master.yml @@ -114,8 +114,9 @@ jobs: git config user.email "cc65.nomail@github.com" git config push.default simple git add -A - git diff-index --quiet HEAD || git commit -m "Updated from cc65 commit ${GITHUB_SHA}." - git diff-index --quiet HEAD || git push + if git commit -m "Updated from cc65 commit ${GITHUB_SHA}." ; then + git push + fi # enter secrets under "repository secrets" - name: Upload snapshot to sourceforge From 71bb11bee120872d911b98e58ce869df60b3610f Mon Sep 17 00:00:00 2001 From: mrdudz Date: Thu, 4 May 2023 22:09:22 +0200 Subject: [PATCH 33/98] make the commit message a url, also check if it really doesnt fail when there is nothing to commit --- .github/workflows/snapshot-on-push-master.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/snapshot-on-push-master.yml b/.github/workflows/snapshot-on-push-master.yml index fb42bfcb3..50f5cd296 100644 --- a/.github/workflows/snapshot-on-push-master.yml +++ b/.github/workflows/snapshot-on-push-master.yml @@ -114,7 +114,8 @@ jobs: git config user.email "cc65.nomail@github.com" git config push.default simple git add -A - if git commit -m "Updated from cc65 commit ${GITHUB_SHA}." ; then + # prevent failure when there is nothing to commit + if git commit -m "Updated from https://github.com/cc65/cc65/commit/${GITHUB_SHA}" ; then git push fi From 69fd3d79985f09b41edb59c83fdc7c9b0bdfe9dc Mon Sep 17 00:00:00 2001 From: mrdudz Date: Thu, 4 May 2023 22:21:36 +0200 Subject: [PATCH 34/98] tweak --- doc/doc.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/doc.css b/doc/doc.css index 6bd538681..0f6e90d67 100644 --- a/doc/doc.css +++ b/doc/doc.css @@ -27,7 +27,7 @@ h1 { } h2 { - font-size: 160%; + font-size: 150%; text-shadow: 1px 1px 3px #303030; letter-spacing: 1px; margin-top: 2em; From cfc8a41a031c244ebf5162b08ac88817e7dd175e Mon Sep 17 00:00:00 2001 From: bbbradsmith Date: Thu, 4 May 2023 17:07:34 -0400 Subject: [PATCH 35/98] guard test to ensure 3-byte struct isn't re-enabled without evaluation by accident --- test/misc/Makefile | 5 ++ test/misc/struct-by-value.c | 156 ++++++++++++++++++++++++++++++++++++ 2 files changed, 161 insertions(+) create mode 100644 test/misc/struct-by-value.c diff --git a/test/misc/Makefile b/test/misc/Makefile index d0b8979b0..c708b160b 100644 --- a/test/misc/Makefile +++ b/test/misc/Makefile @@ -163,6 +163,11 @@ $(WORKDIR)/goto.$1.$2.prg: goto.c $(ISEQUAL) | $(WORKDIR) $(CC65) -t sim$2 -$1 -o $$@ $$< 2>$(WORKDIR)/goto.$1.$2.out $(ISEQUAL) $(WORKDIR)/goto.$1.$2.out goto.ref +# should not compile until 3-byte struct by value tests are re-enabled +$(WORKDIR)/struct-by-value.$1.$2.prg: struct-by-value.c | $(WORKDIR) + $(if $(QUIET),echo misc/struct-by-value.$1.$2.prg) + $(NOT) $(CC65) -t sim$2 -$1 -o $$@ $$< $(NULLERR) + # the rest are tests that fail currently for one reason or another $(WORKDIR)/sitest.$1.$2.prg: sitest.c | $(WORKDIR) @echo "FIXME: " $$@ "currently does not compile." diff --git a/test/misc/struct-by-value.c b/test/misc/struct-by-value.c new file mode 100644 index 000000000..fc44f8729 --- /dev/null +++ b/test/misc/struct-by-value.c @@ -0,0 +1,156 @@ +/* This test ensures that compilation fails if a 3-byte struct by value +** is attempted, to avoid re-introducting a bug by accident: +** https://github.com/cc65/cc65/issues/2022 +** When 3-byte structs are re-enabled, this test will compile, +** which should trigger a "misc" test failure. +** When this happens: +** Delete this comment from the top. +** Replace test/val/struct-by-value.c with this one. +** See: +** https://github.com/cc65/cc65/issues/2086 +*/ + +/* Test of passing and returning structs by value. + Structs of 1, 2, 3, 4 bytes are supported. + Note that structs of 3 bytes had a past issue: + https://github.com/cc65/cc65/issues/2022 +*/ + +int fail = 0; + +struct s1 { char a; }; +struct s2 { char a, b; }; +struct s3 { char a, b, c; }; +struct s4 { char a, b, c, d; }; + +const struct s1 c1 = { 1 }; +const struct s2 c2 = { 2, 3 }; +const struct s3 c3 = { 4, 5, 6 }; +const struct s4 c4 = { 7, 8, 9, 10 }; + +struct s1 return1() { return c1; } +struct s2 return2() { return c2; } +struct s3 return3() { return c3; } +struct s4 return4() { return c4; } + +int compare1(struct s1 a, struct s1 b) +{ + if (a.a != b.a) return 1; + return 0; +} + +int compare2(struct s2 a, struct s2 b) +{ + if (a.a != b.a) return 1; + if (a.b != b.b) return 1; + return 0; +} + +int compare3(struct s3 a, struct s3 b) +{ + if (a.a != b.a) return 1; + if (a.b != b.b) return 1; + if (a.c != b.c) return 1; + return 0; +} + +int compare4(struct s4 a, struct s4 b) +{ + if (a.a != b.a) return 1; + if (a.b != b.b) return 1; + if (a.c != b.c) return 1; + if (a.d != b.d) return 1; + return 0; +} + +int pass1(struct s1 p1) +{ + struct s1 a1; + a1 = p1; + if (a1.a != c1.a) return 1; + return 0; +} + +int pass2(struct s2 p2) +{ + struct s2 a2; + a2 = p2; + if (a2.a != c2.a) return 1; + if (a2.b != c2.b) return 1; + return 0; +} + +int pass3(struct s3 p3) +{ + struct s3 a3; + a3 = p3; + if (a3.a != c3.a) return 1; + if (a3.b != c3.b) return 1; + if (a3.c != c3.c) return 1; + return 0; +} + +int pass4(struct s4 p4) +{ + struct s4 a4; + a4 = p4; + if (a4.a != c4.a) return 1; + if (a4.b != c4.b) return 1; + if (a4.c != c4.c) return 1; + if (a4.d != c4.d) return 1; + return 0; +} + +void reset(char* gg) +{ + char i; + for (i=0;i<5;++i) gg[i] = 128+i; +} + +int test(char* gg, char start) +{ + char i; + for (i=start;i<5;++i) + if (gg[i] != 128+i) return 1; + return 0; +} + +int main() +{ + /* Used to check #2022 bug condition of extra bytes being overwritten. */ + union + { + char gg[5]; + struct s1 g1; + struct s2 g2; + struct s3 g3; + struct s4 g4; + } guard; + + reset(guard.gg); + guard.g1 = return1(); + fail += compare1(guard.g1,c1); + fail += test(guard.gg,1); + + reset(guard.gg); + guard.g2 = return2(); + fail += compare2(guard.g2,c2); + fail += test(guard.gg,2); + + reset(guard.gg); + guard.g3 = return3(); + fail += compare3(guard.g3,c3); + fail += test(guard.gg,3); + + reset(guard.gg); + guard.g4 = return4(); + fail += compare4(guard.g4,c4); + fail += test(guard.gg,4); + + fail += pass1(c1); + fail += pass2(c2); + fail += pass3(c3); + fail += pass4(c4); + + return fail; +} From e57c991de791a0677177cd2e68ab02a05414aa9f Mon Sep 17 00:00:00 2001 From: bbbradsmith Date: Fri, 5 May 2023 10:56:43 -0400 Subject: [PATCH 36/98] master push workflow can include a docs snapshot --- .github/workflows/snapshot-on-push-master.yml | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/.github/workflows/snapshot-on-push-master.yml b/.github/workflows/snapshot-on-push-master.yml index 50f5cd296..5b37e3645 100644 --- a/.github/workflows/snapshot-on-push-master.yml +++ b/.github/workflows/snapshot-on-push-master.yml @@ -118,9 +118,16 @@ jobs: if git commit -m "Updated from https://github.com/cc65/cc65/commit/${GITHUB_SHA}" ; then git push fi + - name: Package offline documents. + run: 7z a cc65-snapshot-docs.zip ./html/*.* + - name: Upload a Documents Snapshot Zip + uses: actions/upload-artifact@v3 + with: + name: cc65-snapshot-docs.zip + path: cc65-snapshot-docs.zip # enter secrets under "repository secrets" - - name: Upload snapshot to sourceforge + - name: Upload 32-bit Windows snapshot to sourceforge uses: nogsantos/scp-deploy@master with: src: cc65-snapshot-win32.zip @@ -129,5 +136,14 @@ jobs: port: ${{ secrets.SSH_PORT }} user: ${{ secrets.SSH_USER }} key: ${{ secrets.SSH_KEY }} + - name: Upload documents snapshot to sourceforge + uses: nogsantos/scp-deploy@master + with: + src: cc65-snapshot-docs.zip + host: ${{ secrets.SSH_HOST }} + remote: ${{ secrets.SSH_DIR }} + port: ${{ secrets.SSH_PORT }} + user: ${{ secrets.SSH_USER }} + key: ${{ secrets.SSH_KEY }} # TODO: Publish snapshot zip at https://github.com/cc65/cc65.github.io From 0cad5bef8169b634f288874e324f838a5da89884 Mon Sep 17 00:00:00 2001 From: bbbradsmith Date: Fri, 5 May 2023 10:58:18 -0400 Subject: [PATCH 37/98] include docs snapshot with pull request build so that PRs can preview it easily --- .github/workflows/build-on-pull-request.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/build-on-pull-request.yml b/.github/workflows/build-on-pull-request.yml index 05d6a4a39..55be5db1e 100644 --- a/.github/workflows/build-on-pull-request.yml +++ b/.github/workflows/build-on-pull-request.yml @@ -43,6 +43,11 @@ jobs: - name: Build the document files. shell: bash run: make -j2 doc + - name: Upload a documents snapshot. + uses: actions/upload-artifact@v3 + with: + name: docs + path: ./html - name: Build 64-bit Windows versions of the tools. run: | make -C src clean From 8f356f5093e7c9bbae33fe5103e3812f73eb8c30 Mon Sep 17 00:00:00 2001 From: bbbradsmith Date: Fri, 5 May 2023 11:00:06 -0400 Subject: [PATCH 38/98] artifact upload should not end with .zip as it is appended automatically fixes ".zip.zip" artifact filenames --- .github/workflows/snapshot-on-push-master.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/snapshot-on-push-master.yml b/.github/workflows/snapshot-on-push-master.yml index 5b37e3645..408bdbb63 100644 --- a/.github/workflows/snapshot-on-push-master.yml +++ b/.github/workflows/snapshot-on-push-master.yml @@ -88,12 +88,12 @@ jobs: - name: Upload a 32-bit Snapshot Zip uses: actions/upload-artifact@v3 with: - name: cc65-snapshot-win32.zip + name: cc65-snapshot-win32 path: cc65-snapshot-win32.zip - name: Upload a 64-bit Snapshot Zip uses: actions/upload-artifact@v3 with: - name: cc65-snapshot-win64.zip + name: cc65-snapshot-win64 path: cc65-snapshot-win64.zip - name: Get the online documents repo. @@ -123,7 +123,7 @@ jobs: - name: Upload a Documents Snapshot Zip uses: actions/upload-artifact@v3 with: - name: cc65-snapshot-docs.zip + name: cc65-snapshot-docs path: cc65-snapshot-docs.zip # enter secrets under "repository secrets" From 9f3e47e9c93d1aa5b439a5ecf2f38ec0a5a41b4c Mon Sep 17 00:00:00 2001 From: bbbradsmith Date: Fri, 5 May 2023 11:04:31 -0400 Subject: [PATCH 39/98] test/standard was never added to test makefile --- test/Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/Makefile b/test/Makefile index abc70d58f..22e425c9c 100644 --- a/test/Makefile +++ b/test/Makefile @@ -22,6 +22,7 @@ continue: @$(MAKE) -C val all @$(MAKE) -C ref all @$(MAKE) -C err all + @$(MAKE) -C standard all @$(MAKE) -C misc all @$(MAKE) -C todo all @@ -31,6 +32,7 @@ mostlyclean: @$(MAKE) -C val clean @$(MAKE) -C ref clean @$(MAKE) -C err clean + @$(MAKE) -C standard clean @$(MAKE) -C misc clean @$(MAKE) -C todo clean From 5c20fb28123bd938c18618d321766d85b9ecb4fc Mon Sep 17 00:00:00 2001 From: bbbradsmith Date: Fri, 5 May 2023 11:28:42 -0400 Subject: [PATCH 40/98] test/todo makefile uses testwrk/val by mistake --- test/todo/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/todo/Makefile b/test/todo/Makefile index 17561f8f4..062b899ce 100644 --- a/test/todo/Makefile +++ b/test/todo/Makefile @@ -31,7 +31,7 @@ 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) -WORKDIR = ../../testwrk/val +WORKDIR = ../../testwrk/todo OPTIONS = g O Os Osi Osir Osr Oi Oir Or @@ -49,7 +49,7 @@ $(WORKDIR): define PRG_template $(WORKDIR)/%.$1.$2.prg: %.c | $(WORKDIR) - $(if $(QUIET),echo val/$$*.$1.$2.prg) + $(if $(QUIET),echo todo/$$*.$1.$2.prg) $(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) From c662c7a36f6c31c15858e7656c652f864c9d5aaf Mon Sep 17 00:00:00 2001 From: bbbradsmith Date: Fri, 5 May 2023 12:02:50 -0400 Subject: [PATCH 41/98] use diff-index to prevent commit instead of bash if preferred because the if suppresses all git commit errors, instead of the one error we need to suppress (commit with no changes) --- .github/workflows/snapshot-on-push-master.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/snapshot-on-push-master.yml b/.github/workflows/snapshot-on-push-master.yml index 50f5cd296..cba5b89dd 100644 --- a/.github/workflows/snapshot-on-push-master.yml +++ b/.github/workflows/snapshot-on-push-master.yml @@ -115,9 +115,8 @@ jobs: git config push.default simple git add -A # prevent failure when there is nothing to commit - if git commit -m "Updated from https://github.com/cc65/cc65/commit/${GITHUB_SHA}" ; then - git push - fi + git diff-index --quiet HEAD || git commit -m "Updated from https://github.com/cc65/cc65/commit/${GITHUB_SHA}" + git push # enter secrets under "repository secrets" - name: Upload snapshot to sourceforge From 1c58b302d8857928832931dfb2fd23a7c448919a Mon Sep 17 00:00:00 2001 From: mvax Date: Fri, 5 May 2023 12:31:19 -0400 Subject: [PATCH 42/98] Bugfix for the .ISMNEMONIC, .ISMNEM builtin function --- src/ca65/expr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ca65/expr.c b/src/ca65/expr.c index 812b6e90c..5dcf5ca71 100644 --- a/src/ca65/expr.c +++ b/src/ca65/expr.c @@ -496,7 +496,7 @@ static ExprNode* FuncIsMnemonic (void) /* Skip the name */ NextTok (); - return GenLiteralExpr (Instr > 0); + return GenLiteralExpr (Instr >= 0); } From 17706208e80de82dff33a6e5feef53d330de4d9d Mon Sep 17 00:00:00 2001 From: Jeff Tranter Date: Fri, 5 May 2023 18:02:42 -0400 Subject: [PATCH 43/98] Add support for 48x12 video mode on Challenger 1P. Tested on real C1P hardware. --- doc/osi.sgml | 13 +++++++++++++ libsrc/osic1p/extra/screen-c1p-48x12.s | 16 ++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 libsrc/osic1p/extra/screen-c1p-48x12.s diff --git a/doc/osi.sgml b/doc/osi.sgml index eeaee4a97..62d466406 100644 --- a/doc/osi.sgml +++ b/doc/osi.sgml @@ -187,8 +187,21 @@ Currently the following extra screen configuration modules are implemented: osic1p-screen-s3-32x28.o: 32 columns by 28 lines mode for Briel Superboard /// +osic1p-screen-c1p-48x12.s: 48 columns by 12 lines mode +for Challenger 1P +On the Briel Superboard /// you enter 32 column mode by holding down +the BREAK key on powerup. + +On the Challenger 1P you can enable 48 column mode by writing a 1 to +bit 0 of address $D800, and writing a 0 to go back to 24 column mode. +You can use code like the following to do this: + + +*(char*)0xd800 = 1; /* Switch to 48 column mode */ + + Limitations

stdio implementation

diff --git a/libsrc/osic1p/extra/screen-c1p-48x12.s b/libsrc/osic1p/extra/screen-c1p-48x12.s new file mode 100644 index 000000000..91a61338b --- /dev/null +++ b/libsrc/osic1p/extra/screen-c1p-48x12.s @@ -0,0 +1,16 @@ +; +; Implementation of screen-layout related functions for Challenger 1P in 48x12 mode. +; + + .include "../osiscreen.inc" + +C1P_SCR_BASE := $D000 ; Base of C1P video RAM +C1P_VRAM_SIZE = $0400 ; Size of C1P video RAM (1 kB) +C1P_SCR_WIDTH = $30 ; Screen width +C1P_SCR_HEIGHT = $0C ; Screen height +C1P_SCR_FIRSTCHAR = $8B ; Offset of cursor position (0, 0) from base + ; of video RAM +C1P_SCROLL_DIST = $40 ; Memory distance for scrolling by one line + +osi_screen_funcs C1P_SCR_BASE, C1P_VRAM_SIZE, C1P_SCR_FIRSTCHAR, \ + C1P_SCR_WIDTH, C1P_SCR_HEIGHT, C1P_SCROLL_DIST From 18570d18b811ed325972db70b8a21d3668e1e80a Mon Sep 17 00:00:00 2001 From: mvax Date: Fri, 5 May 2023 18:43:10 -0400 Subject: [PATCH 44/98] add test --- test/asm/err/ismnemonic.s | 808 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 808 insertions(+) create mode 100644 test/asm/err/ismnemonic.s diff --git a/test/asm/err/ismnemonic.s b/test/asm/err/ismnemonic.s new file mode 100644 index 000000000..438afed70 --- /dev/null +++ b/test/asm/err/ismnemonic.s @@ -0,0 +1,808 @@ +; Tests to ensure .ismnemonic is working correctly +; The .ismnemonic function calls FindInstruction internally, +; which is how the assembler detects all instructions +; +; Currently supported CPUs: +; "6502" +; "6502X" +; "6502DTV" +; "65SC02" +; "65C02" +; "4510" +; "huc6280" +; "65816" +; "sweet16" + +.macro test_Ismnemonic instr + .if .ismnemonic(instr) + ; do nothing + .else + .error .sprintf(".ISMNEMONIC failed for instruction: %s", .string(instr)) + .endif +.endmacro + +; there is no instruction table for "none", make sure 'adc' (common to all CPUs) and 'add' (sweet16) doesn't match +.setcpu "none" +.if .ismnemonic(adc) || .ismnemonic(add) + .error ".ISMNEMONIC with CPU set to 'none' should not match any instructions." +.endif + +.setcpu "6502" +test_Ismnemonic adc +test_Ismnemonic and +test_Ismnemonic asl +test_Ismnemonic bcc +test_Ismnemonic bcs +test_Ismnemonic beq +test_Ismnemonic bit +test_Ismnemonic bmi +test_Ismnemonic bne +test_Ismnemonic bpl +test_Ismnemonic brk +test_Ismnemonic bvc +test_Ismnemonic bvs +test_Ismnemonic clc +test_Ismnemonic cld +test_Ismnemonic cli +test_Ismnemonic clv +test_Ismnemonic cmp +test_Ismnemonic cpx +test_Ismnemonic cpy +test_Ismnemonic dec +test_Ismnemonic dex +test_Ismnemonic dey +test_Ismnemonic eor +test_Ismnemonic inc +test_Ismnemonic inx +test_Ismnemonic iny +test_Ismnemonic jmp +test_Ismnemonic jsr +test_Ismnemonic lda +test_Ismnemonic ldx +test_Ismnemonic ldy +test_Ismnemonic lsr +test_Ismnemonic nop +test_Ismnemonic ora +test_Ismnemonic pha +test_Ismnemonic php +test_Ismnemonic pla +test_Ismnemonic plp +test_Ismnemonic rol +test_Ismnemonic ror +test_Ismnemonic rti +test_Ismnemonic rts +test_Ismnemonic sbc +test_Ismnemonic sec +test_Ismnemonic sed +test_Ismnemonic sei +test_Ismnemonic sta +test_Ismnemonic stx +test_Ismnemonic sty +test_Ismnemonic tax +test_Ismnemonic tay +test_Ismnemonic tsx +test_Ismnemonic txa +test_Ismnemonic txs +test_Ismnemonic tya + +.setcpu "6502X" +test_Ismnemonic adc +test_Ismnemonic alr +test_Ismnemonic anc +test_Ismnemonic and +test_Ismnemonic ane +test_Ismnemonic arr +test_Ismnemonic asl +test_Ismnemonic axs +test_Ismnemonic bcc +test_Ismnemonic bcs +test_Ismnemonic beq +test_Ismnemonic bit +test_Ismnemonic bmi +test_Ismnemonic bne +test_Ismnemonic bpl +test_Ismnemonic brk +test_Ismnemonic bvc +test_Ismnemonic bvs +test_Ismnemonic clc +test_Ismnemonic cld +test_Ismnemonic cli +test_Ismnemonic clv +test_Ismnemonic cmp +test_Ismnemonic cpx +test_Ismnemonic cpy +test_Ismnemonic dcp +test_Ismnemonic dec +test_Ismnemonic dex +test_Ismnemonic dey +test_Ismnemonic eor +test_Ismnemonic inc +test_Ismnemonic inx +test_Ismnemonic iny +test_Ismnemonic isc +test_Ismnemonic jam +test_Ismnemonic jmp +test_Ismnemonic jsr +test_Ismnemonic las +test_Ismnemonic lax +test_Ismnemonic lda +test_Ismnemonic ldx +test_Ismnemonic ldy +test_Ismnemonic lsr +test_Ismnemonic nop +test_Ismnemonic ora +test_Ismnemonic pha +test_Ismnemonic php +test_Ismnemonic pla +test_Ismnemonic plp +test_Ismnemonic rla +test_Ismnemonic rol +test_Ismnemonic ror +test_Ismnemonic rra +test_Ismnemonic rti +test_Ismnemonic rts +test_Ismnemonic sax +test_Ismnemonic sbc +test_Ismnemonic sec +test_Ismnemonic sed +test_Ismnemonic sei +test_Ismnemonic sha +test_Ismnemonic shx +test_Ismnemonic shy +test_Ismnemonic slo +test_Ismnemonic sre +test_Ismnemonic sta +test_Ismnemonic stx +test_Ismnemonic sty +test_Ismnemonic tas +test_Ismnemonic tax +test_Ismnemonic tay +test_Ismnemonic tsx +test_Ismnemonic txa +test_Ismnemonic txs +test_Ismnemonic tya + +.setcpu "6502DTV" +test_Ismnemonic adc +test_Ismnemonic alr +test_Ismnemonic anc +test_Ismnemonic and +test_Ismnemonic ane +test_Ismnemonic arr +test_Ismnemonic asl +test_Ismnemonic axs +test_Ismnemonic bcc +test_Ismnemonic bcs +test_Ismnemonic beq +test_Ismnemonic bit +test_Ismnemonic bmi +test_Ismnemonic bne +test_Ismnemonic bpl +test_Ismnemonic bra +test_Ismnemonic brk +test_Ismnemonic bvc +test_Ismnemonic bvs +test_Ismnemonic clc +test_Ismnemonic cld +test_Ismnemonic cli +test_Ismnemonic clv +test_Ismnemonic cmp +test_Ismnemonic cpx +test_Ismnemonic cpy +test_Ismnemonic dec +test_Ismnemonic dex +test_Ismnemonic dey +test_Ismnemonic eor +test_Ismnemonic inc +test_Ismnemonic inx +test_Ismnemonic iny +test_Ismnemonic jmp +test_Ismnemonic jsr +test_Ismnemonic las +test_Ismnemonic lax +test_Ismnemonic lda +test_Ismnemonic ldx +test_Ismnemonic ldy +test_Ismnemonic lsr +test_Ismnemonic nop +test_Ismnemonic ora +test_Ismnemonic pha +test_Ismnemonic php +test_Ismnemonic pla +test_Ismnemonic plp +test_Ismnemonic rla +test_Ismnemonic rol +test_Ismnemonic ror +test_Ismnemonic rra +test_Ismnemonic rti +test_Ismnemonic rts +test_Ismnemonic sac +test_Ismnemonic sbc +test_Ismnemonic sec +test_Ismnemonic sed +test_Ismnemonic sei +test_Ismnemonic sha +test_Ismnemonic shx +test_Ismnemonic shy +test_Ismnemonic sir +test_Ismnemonic sta +test_Ismnemonic stx +test_Ismnemonic sty +test_Ismnemonic tax +test_Ismnemonic tay +test_Ismnemonic tsx +test_Ismnemonic txa +test_Ismnemonic txs +test_Ismnemonic tya + +.setcpu "65SC02" +test_Ismnemonic adc +test_Ismnemonic and +test_Ismnemonic asl +test_Ismnemonic bcc +test_Ismnemonic bcs +test_Ismnemonic beq +test_Ismnemonic bit +test_Ismnemonic bmi +test_Ismnemonic bne +test_Ismnemonic bpl +test_Ismnemonic bra +test_Ismnemonic brk +test_Ismnemonic bvc +test_Ismnemonic bvs +test_Ismnemonic clc +test_Ismnemonic cld +test_Ismnemonic cli +test_Ismnemonic clv +test_Ismnemonic cmp +test_Ismnemonic cpx +test_Ismnemonic cpy +test_Ismnemonic dea +test_Ismnemonic dec +test_Ismnemonic dex +test_Ismnemonic dey +test_Ismnemonic eor +test_Ismnemonic ina +test_Ismnemonic inc +test_Ismnemonic inx +test_Ismnemonic iny +test_Ismnemonic jmp +test_Ismnemonic jsr +test_Ismnemonic lda +test_Ismnemonic ldx +test_Ismnemonic ldy +test_Ismnemonic lsr +test_Ismnemonic nop +test_Ismnemonic ora +test_Ismnemonic pha +test_Ismnemonic php +test_Ismnemonic phx +test_Ismnemonic phy +test_Ismnemonic pla +test_Ismnemonic plp +test_Ismnemonic plx +test_Ismnemonic ply +test_Ismnemonic rol +test_Ismnemonic ror +test_Ismnemonic rti +test_Ismnemonic rts +test_Ismnemonic sbc +test_Ismnemonic sec +test_Ismnemonic sed +test_Ismnemonic sei +test_Ismnemonic sta +test_Ismnemonic stx +test_Ismnemonic sty +test_Ismnemonic stz +test_Ismnemonic tax +test_Ismnemonic tay +test_Ismnemonic trb +test_Ismnemonic tsb +test_Ismnemonic tsx +test_Ismnemonic txa +test_Ismnemonic txs +test_Ismnemonic tya + +.setcpu "65C02" +test_Ismnemonic adc +test_Ismnemonic and +test_Ismnemonic asl +test_Ismnemonic bbr0 +test_Ismnemonic bbr1 +test_Ismnemonic bbr2 +test_Ismnemonic bbr3 +test_Ismnemonic bbr4 +test_Ismnemonic bbr5 +test_Ismnemonic bbr6 +test_Ismnemonic bbr7 +test_Ismnemonic bbs0 +test_Ismnemonic bbs1 +test_Ismnemonic bbs2 +test_Ismnemonic bbs3 +test_Ismnemonic bbs4 +test_Ismnemonic bbs5 +test_Ismnemonic bbs6 +test_Ismnemonic bbs7 +test_Ismnemonic bcc +test_Ismnemonic bcs +test_Ismnemonic beq +test_Ismnemonic bit +test_Ismnemonic bmi +test_Ismnemonic bne +test_Ismnemonic bpl +test_Ismnemonic bra +test_Ismnemonic brk +test_Ismnemonic bvc +test_Ismnemonic bvs +test_Ismnemonic clc +test_Ismnemonic cld +test_Ismnemonic cli +test_Ismnemonic clv +test_Ismnemonic cmp +test_Ismnemonic cpx +test_Ismnemonic cpy +test_Ismnemonic dea +test_Ismnemonic dec +test_Ismnemonic dex +test_Ismnemonic dey +test_Ismnemonic eor +test_Ismnemonic ina +test_Ismnemonic inc +test_Ismnemonic inx +test_Ismnemonic iny +test_Ismnemonic jmp +test_Ismnemonic jsr +test_Ismnemonic lda +test_Ismnemonic ldx +test_Ismnemonic ldy +test_Ismnemonic lsr +test_Ismnemonic nop +test_Ismnemonic ora +test_Ismnemonic pha +test_Ismnemonic php +test_Ismnemonic phx +test_Ismnemonic phy +test_Ismnemonic pla +test_Ismnemonic plp +test_Ismnemonic plx +test_Ismnemonic ply +test_Ismnemonic rmb0 +test_Ismnemonic rmb1 +test_Ismnemonic rmb2 +test_Ismnemonic rmb3 +test_Ismnemonic rmb4 +test_Ismnemonic rmb5 +test_Ismnemonic rmb6 +test_Ismnemonic rmb7 +test_Ismnemonic rol +test_Ismnemonic ror +test_Ismnemonic rti +test_Ismnemonic rts +test_Ismnemonic sbc +test_Ismnemonic sec +test_Ismnemonic sed +test_Ismnemonic sei +test_Ismnemonic smb0 +test_Ismnemonic smb1 +test_Ismnemonic smb2 +test_Ismnemonic smb3 +test_Ismnemonic smb4 +test_Ismnemonic smb5 +test_Ismnemonic smb6 +test_Ismnemonic smb7 +test_Ismnemonic sta +test_Ismnemonic stp +test_Ismnemonic stx +test_Ismnemonic sty +test_Ismnemonic stz +test_Ismnemonic tax +test_Ismnemonic tay +test_Ismnemonic trb +test_Ismnemonic tsb +test_Ismnemonic tsx +test_Ismnemonic txa +test_Ismnemonic txs +test_Ismnemonic tya +test_Ismnemonic wai + +.setcpu "4510" +test_Ismnemonic adc +test_Ismnemonic and +test_Ismnemonic asl +test_Ismnemonic asr +test_Ismnemonic asw +test_Ismnemonic bbr0 +test_Ismnemonic bbr1 +test_Ismnemonic bbr2 +test_Ismnemonic bbr3 +test_Ismnemonic bbr4 +test_Ismnemonic bbr5 +test_Ismnemonic bbr6 +test_Ismnemonic bbr7 +test_Ismnemonic bbs0 +test_Ismnemonic bbs1 +test_Ismnemonic bbs2 +test_Ismnemonic bbs3 +test_Ismnemonic bbs4 +test_Ismnemonic bbs5 +test_Ismnemonic bbs6 +test_Ismnemonic bbs7 +test_Ismnemonic bcc +test_Ismnemonic bcs +test_Ismnemonic beq +test_Ismnemonic bit +test_Ismnemonic bmi +test_Ismnemonic bne +test_Ismnemonic bpl +test_Ismnemonic bra +test_Ismnemonic brk +test_Ismnemonic bsr +test_Ismnemonic bvc +test_Ismnemonic bvs +test_Ismnemonic clc +test_Ismnemonic cld +test_Ismnemonic cle +test_Ismnemonic cli +test_Ismnemonic clv +test_Ismnemonic cmp +test_Ismnemonic cpx +test_Ismnemonic cpy +test_Ismnemonic cpz +test_Ismnemonic dea +test_Ismnemonic dec +test_Ismnemonic dew +test_Ismnemonic dex +test_Ismnemonic dey +test_Ismnemonic dez +test_Ismnemonic eom +test_Ismnemonic eor +test_Ismnemonic ina +test_Ismnemonic inc +test_Ismnemonic inw +test_Ismnemonic inx +test_Ismnemonic iny +test_Ismnemonic inz +test_Ismnemonic jmp +test_Ismnemonic jsr +test_Ismnemonic lbcc +test_Ismnemonic lbcs +test_Ismnemonic lbeq +test_Ismnemonic lbmi +test_Ismnemonic lbne +test_Ismnemonic lbpl +test_Ismnemonic lbra +test_Ismnemonic lbvc +test_Ismnemonic lbvs +test_Ismnemonic lda +test_Ismnemonic ldx +test_Ismnemonic ldy +test_Ismnemonic ldz +test_Ismnemonic lsr +test_Ismnemonic map +test_Ismnemonic neg +test_Ismnemonic nop +test_Ismnemonic ora +test_Ismnemonic pha +test_Ismnemonic phd +test_Ismnemonic php +test_Ismnemonic phw +test_Ismnemonic phx +test_Ismnemonic phy +test_Ismnemonic phz +test_Ismnemonic pla +test_Ismnemonic plp +test_Ismnemonic plx +test_Ismnemonic ply +test_Ismnemonic plz +test_Ismnemonic rmb0 +test_Ismnemonic rmb1 +test_Ismnemonic rmb2 +test_Ismnemonic rmb3 +test_Ismnemonic rmb4 +test_Ismnemonic rmb5 +test_Ismnemonic rmb6 +test_Ismnemonic rmb7 +test_Ismnemonic rol +test_Ismnemonic ror +test_Ismnemonic row +test_Ismnemonic rti +test_Ismnemonic rtn +test_Ismnemonic rts +test_Ismnemonic sbc +test_Ismnemonic sec +test_Ismnemonic sed +test_Ismnemonic see +test_Ismnemonic sei +test_Ismnemonic smb0 +test_Ismnemonic smb1 +test_Ismnemonic smb2 +test_Ismnemonic smb3 +test_Ismnemonic smb4 +test_Ismnemonic smb5 +test_Ismnemonic smb6 +test_Ismnemonic smb7 +test_Ismnemonic sta +test_Ismnemonic stx +test_Ismnemonic sty +test_Ismnemonic stz +test_Ismnemonic tab +test_Ismnemonic tax +test_Ismnemonic tay +test_Ismnemonic taz +test_Ismnemonic tba +test_Ismnemonic trb +test_Ismnemonic tsb +test_Ismnemonic tsx +test_Ismnemonic tsy +test_Ismnemonic txa +test_Ismnemonic txs +test_Ismnemonic tya +test_Ismnemonic tys +test_Ismnemonic tza + +.setcpu "HuC6280" +test_Ismnemonic adc +test_Ismnemonic and +test_Ismnemonic asl +test_Ismnemonic bbr0 +test_Ismnemonic bbr1 +test_Ismnemonic bbr2 +test_Ismnemonic bbr3 +test_Ismnemonic bbr4 +test_Ismnemonic bbr5 +test_Ismnemonic bbr6 +test_Ismnemonic bbr7 +test_Ismnemonic bbs0 +test_Ismnemonic bbs1 +test_Ismnemonic bbs2 +test_Ismnemonic bbs3 +test_Ismnemonic bbs4 +test_Ismnemonic bbs5 +test_Ismnemonic bbs6 +test_Ismnemonic bbs7 +test_Ismnemonic bcc +test_Ismnemonic bcs +test_Ismnemonic beq +test_Ismnemonic bit +test_Ismnemonic bmi +test_Ismnemonic bne +test_Ismnemonic bpl +test_Ismnemonic bra +test_Ismnemonic brk +test_Ismnemonic bsr +test_Ismnemonic bvc +test_Ismnemonic bvs +test_Ismnemonic cla +test_Ismnemonic clc +test_Ismnemonic cld +test_Ismnemonic cli +test_Ismnemonic clv +test_Ismnemonic clx +test_Ismnemonic cly +test_Ismnemonic cmp +test_Ismnemonic cpx +test_Ismnemonic cpy +test_Ismnemonic csh +test_Ismnemonic csl +test_Ismnemonic dea +test_Ismnemonic dec +test_Ismnemonic dex +test_Ismnemonic dey +test_Ismnemonic eor +test_Ismnemonic ina +test_Ismnemonic inc +test_Ismnemonic inx +test_Ismnemonic iny +test_Ismnemonic jmp +test_Ismnemonic jsr +test_Ismnemonic lda +test_Ismnemonic ldx +test_Ismnemonic ldy +test_Ismnemonic lsr +test_Ismnemonic nop +test_Ismnemonic ora +test_Ismnemonic pha +test_Ismnemonic php +test_Ismnemonic phx +test_Ismnemonic phy +test_Ismnemonic pla +test_Ismnemonic plp +test_Ismnemonic plx +test_Ismnemonic ply +test_Ismnemonic rmb0 +test_Ismnemonic rmb1 +test_Ismnemonic rmb2 +test_Ismnemonic rmb3 +test_Ismnemonic rmb4 +test_Ismnemonic rmb5 +test_Ismnemonic rmb6 +test_Ismnemonic rmb7 +test_Ismnemonic rol +test_Ismnemonic ror +test_Ismnemonic rti +test_Ismnemonic rts +test_Ismnemonic sax +test_Ismnemonic say +test_Ismnemonic sbc +test_Ismnemonic sec +test_Ismnemonic sed +test_Ismnemonic sei +test_Ismnemonic set +test_Ismnemonic smb0 +test_Ismnemonic smb1 +test_Ismnemonic smb2 +test_Ismnemonic smb3 +test_Ismnemonic smb4 +test_Ismnemonic smb5 +test_Ismnemonic smb6 +test_Ismnemonic smb7 +test_Ismnemonic st0 +test_Ismnemonic st1 +test_Ismnemonic st2 +test_Ismnemonic sta +test_Ismnemonic stx +test_Ismnemonic sty +test_Ismnemonic stz +test_Ismnemonic sxy +test_Ismnemonic tai +test_Ismnemonic tam +test_Ismnemonic tam0 +test_Ismnemonic tam1 +test_Ismnemonic tam2 +test_Ismnemonic tam3 +test_Ismnemonic tam4 +test_Ismnemonic tam5 +test_Ismnemonic tam6 +test_Ismnemonic tam7 +test_Ismnemonic tax +test_Ismnemonic tay +test_Ismnemonic tdd +test_Ismnemonic tia +test_Ismnemonic tii +test_Ismnemonic tin +test_Ismnemonic tma +test_Ismnemonic tma0 +test_Ismnemonic tma1 +test_Ismnemonic tma2 +test_Ismnemonic tma3 +test_Ismnemonic tma4 +test_Ismnemonic tma5 +test_Ismnemonic tma6 +test_Ismnemonic tma7 +test_Ismnemonic trb +test_Ismnemonic tsb +test_Ismnemonic tst +test_Ismnemonic tsx +test_Ismnemonic txa +test_Ismnemonic txs +test_Ismnemonic tya + +.setcpu "65816" +test_Ismnemonic adc +test_Ismnemonic and +test_Ismnemonic asl +test_Ismnemonic bcc +test_Ismnemonic bcs +test_Ismnemonic beq +test_Ismnemonic bit +test_Ismnemonic bmi +test_Ismnemonic bne +test_Ismnemonic bpl +test_Ismnemonic bra +test_Ismnemonic brk +test_Ismnemonic brl +test_Ismnemonic bvc +test_Ismnemonic bvs +test_Ismnemonic clc +test_Ismnemonic cld +test_Ismnemonic cli +test_Ismnemonic clv +test_Ismnemonic cmp +test_Ismnemonic cop +test_Ismnemonic cpa +test_Ismnemonic cpx +test_Ismnemonic cpy +test_Ismnemonic dea +test_Ismnemonic dec +test_Ismnemonic dex +test_Ismnemonic dey +test_Ismnemonic eor +test_Ismnemonic ina +test_Ismnemonic inc +test_Ismnemonic inx +test_Ismnemonic iny +test_Ismnemonic jml +test_Ismnemonic jmp +test_Ismnemonic jsl +test_Ismnemonic jsr +test_Ismnemonic lda +test_Ismnemonic ldx +test_Ismnemonic ldy +test_Ismnemonic lsr +test_Ismnemonic mvn +test_Ismnemonic mvp +test_Ismnemonic nop +test_Ismnemonic ora +test_Ismnemonic pea +test_Ismnemonic pei +test_Ismnemonic per +test_Ismnemonic pha +test_Ismnemonic phb +test_Ismnemonic phd +test_Ismnemonic phk +test_Ismnemonic php +test_Ismnemonic phx +test_Ismnemonic phy +test_Ismnemonic pla +test_Ismnemonic plb +test_Ismnemonic pld +test_Ismnemonic plp +test_Ismnemonic plx +test_Ismnemonic ply +test_Ismnemonic rep +test_Ismnemonic rol +test_Ismnemonic ror +test_Ismnemonic rti +test_Ismnemonic rtl +test_Ismnemonic rts +test_Ismnemonic sbc +test_Ismnemonic sec +test_Ismnemonic sed +test_Ismnemonic sei +test_Ismnemonic sep +test_Ismnemonic sta +test_Ismnemonic stp +test_Ismnemonic stx +test_Ismnemonic sty +test_Ismnemonic stz +test_Ismnemonic swa +test_Ismnemonic tad +test_Ismnemonic tas +test_Ismnemonic tax +test_Ismnemonic tay +test_Ismnemonic tcd +test_Ismnemonic tcs +test_Ismnemonic tda +test_Ismnemonic tdc +test_Ismnemonic trb +test_Ismnemonic tsa +test_Ismnemonic tsb +test_Ismnemonic tsc +test_Ismnemonic tsx +test_Ismnemonic txa +test_Ismnemonic txs +test_Ismnemonic txy +test_Ismnemonic tya +test_Ismnemonic tyx +test_Ismnemonic wai +test_Ismnemonic wdm +test_Ismnemonic xba +test_Ismnemonic xce + +.setcpu "sweet16" +test_Ismnemonic add +test_Ismnemonic bc +test_Ismnemonic bk +test_Ismnemonic bm +test_Ismnemonic bm1 +test_Ismnemonic bnc +test_Ismnemonic bnm1 +test_Ismnemonic bnz +test_Ismnemonic bp +test_Ismnemonic br +test_Ismnemonic bs +test_Ismnemonic bz +test_Ismnemonic cpr +test_Ismnemonic dcr +test_Ismnemonic inr +test_Ismnemonic ld +test_Ismnemonic ldd +test_Ismnemonic pop +test_Ismnemonic popd +test_Ismnemonic rs +test_Ismnemonic rtn +test_Ismnemonic set +test_Ismnemonic st +test_Ismnemonic std +test_Ismnemonic stp +test_Ismnemonic sub From c5cf32ac47836b770e73323c10a5aa6b5e8d1195 Mon Sep 17 00:00:00 2001 From: mvax Date: Fri, 5 May 2023 18:50:44 -0400 Subject: [PATCH 45/98] add test - fix --- test/asm/{err => val}/ismnemonic.s | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test/asm/{err => val}/ismnemonic.s (100%) diff --git a/test/asm/err/ismnemonic.s b/test/asm/val/ismnemonic.s similarity index 100% rename from test/asm/err/ismnemonic.s rename to test/asm/val/ismnemonic.s From 7994889213352a82c904efd06f5b82bbfdf193e7 Mon Sep 17 00:00:00 2001 From: mvax Date: Fri, 5 May 2023 19:07:14 -0400 Subject: [PATCH 46/98] add test - fix again --- test/asm/val/ismnemonic.s | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/test/asm/val/ismnemonic.s b/test/asm/val/ismnemonic.s index 438afed70..4ba74c97f 100644 --- a/test/asm/val/ismnemonic.s +++ b/test/asm/val/ismnemonic.s @@ -13,18 +13,22 @@ ; "65816" ; "sweet16" +; count any errors: +ismnemonic_error .set 0 + +; macro to test an instruction .macro test_Ismnemonic instr .if .ismnemonic(instr) ; do nothing .else - .error .sprintf(".ISMNEMONIC failed for instruction: %s", .string(instr)) + ismnemonic_error .set ismnemonic_error + 1 .endif .endmacro ; there is no instruction table for "none", make sure 'adc' (common to all CPUs) and 'add' (sweet16) doesn't match .setcpu "none" .if .ismnemonic(adc) || .ismnemonic(add) - .error ".ISMNEMONIC with CPU set to 'none' should not match any instructions." + ismnemonic_error .set ismnemonic_error + 1 .endif .setcpu "6502" @@ -806,3 +810,17 @@ test_Ismnemonic st test_Ismnemonic std test_Ismnemonic stp test_Ismnemonic sub + + .setcpu "6502" + + .import _exit + .export _main + +_main: + .if ismnemonic_error + ldx #$01 + .else + ldx #$00 + .endif + txa + jmp _exit From dd0a2bf1bc78188b75a22003590f20a4fedac941 Mon Sep 17 00:00:00 2001 From: mvax Date: Fri, 5 May 2023 19:10:16 -0400 Subject: [PATCH 47/98] add test - fix stlye --- test/asm/val/ismnemonic.s | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/asm/val/ismnemonic.s b/test/asm/val/ismnemonic.s index 4ba74c97f..a4534a9c4 100644 --- a/test/asm/val/ismnemonic.s +++ b/test/asm/val/ismnemonic.s @@ -815,7 +815,7 @@ test_Ismnemonic sub .import _exit .export _main - + _main: .if ismnemonic_error ldx #$01 From 8d048699ee6b33c68f06bc6d0a16e521a733a386 Mon Sep 17 00:00:00 2001 From: bbbradsmith Date: Fri, 5 May 2023 21:32:34 -0400 Subject: [PATCH 48/98] grc65 fix flawed text parsing Was using fseek(F,-1,SEEK_CUR) which is invalid for text files, behaviour unreliable across platforms. Added check for internal buffer overflow. --- src/grc65/main.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/grc65/main.c b/src/grc65/main.c index 349b5c110..ac654300d 100644 --- a/src/grc65/main.c +++ b/src/grc65/main.c @@ -850,8 +850,12 @@ static char *filterInput (FILE *F, char *tbl) /* loads file into buffer filtering it out */ int a, prevchar = -1, i = 0, bracket = 0, quote = 1; - for (;;) { - a = getc(F); + a = getc(F); + while (1) + { + if (i >= BLOODY_BIG_BUFFER) { + AbEnd ("File too large for internal parsing buffer (%d bytes).",BLOODY_BIG_BUFFER); + } if ((a == '\n') || (a == '\015')) a = ' '; if (a == ',' && quote) a = ' '; if (a == '\042') quote =! quote; @@ -873,13 +877,18 @@ static char *filterInput (FILE *F, char *tbl) if (a == ';' && quote) { do { a = getc (F); - } while (a != '\n'); - fseek (F, -1, SEEK_CUR); + } while (a != '\n' && a != EOF); + /* Don't discard this newline/EOF, continue to next loop. + ** A previous implementation used fseek(F,-1,SEEK_CUR), + ** which is invalid for text mode files, and was unreliable across platforms. + */ + continue; } else { tbl[i++] = a; prevchar = a; } } + a = getc(F); } if (bracket != 0) AbEnd ("There are unclosed brackets!"); From f2e7609046b4febb23a5726f2f4dbd1489aac929 Mon Sep 17 00:00:00 2001 From: bbbradsmith Date: Fri, 5 May 2023 21:45:57 -0400 Subject: [PATCH 49/98] sim65 cycles 32-bit range fix long is 64-bit on some platforms, making this inconsistent, added range check to catch overflow. reduced tests requesting 5 billion cycles to 2^32-1 so they can fun on 32-bit long sim65. --- src/sim65/main.c | 5 +++++ test/asm/val/Makefile | 3 ++- test/standard/Makefile | 3 ++- test/val/Makefile | 3 ++- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/sim65/main.c b/src/sim65/main.c index f2daf9295..9e371fd5d 100644 --- a/src/sim65/main.c +++ b/src/sim65/main.c @@ -36,6 +36,7 @@ #include #include #include +#include /* common */ #include "abend.h" @@ -140,6 +141,10 @@ static void OptQuitXIns (const char* Opt attribute ((unused)), /* quit after MaxCycles cycles */ { MaxCycles = strtoul(Arg, NULL, 0); + /* Guard against overflow. */ + if (MaxCycles == ULONG_MAX && errno == ERANGE) { + Error("'-x parameter out of range. Max: %lu",ULONG_MAX); + } } static unsigned char ReadProgramFile (void) diff --git a/test/asm/val/Makefile b/test/asm/val/Makefile index 91dae9afd..49b6d5290 100644 --- a/test/asm/val/Makefile +++ b/test/asm/val/Makefile @@ -22,7 +22,8 @@ ifdef QUIET NULLERR = 2>$(NULLDEV) 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 4294967295 CA65 := $(if $(wildcard ../../../bin/ca65*),..$S..$S..$Sbin$Sca65,ca65) LD65 := $(if $(wildcard ../../../bin/ld65*),..$S..$S..$Sbin$Sld65,ld65) diff --git a/test/standard/Makefile b/test/standard/Makefile index 054623b79..9993ba699 100644 --- a/test/standard/Makefile +++ b/test/standard/Makefile @@ -22,7 +22,8 @@ ifdef QUIET NULLERR = 2>$(NULLDEV) 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 4294967295 -c CC65 := $(if $(wildcard ../../bin/cc65*),..$S..$Sbin$Scc65,cc65) CA65 := $(if $(wildcard ../../bin/ca65*),..$S..$Sbin$Sca65,ca65) diff --git a/test/val/Makefile b/test/val/Makefile index a3722f7bf..8820e535a 100644 --- a/test/val/Makefile +++ b/test/val/Makefile @@ -24,7 +24,8 @@ ifdef QUIET NULLERR = 2>$(NULLDEV) 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 4294967295 -c CC65 := $(if $(wildcard ../../bin/cc65*),..$S..$Sbin$Scc65,cc65) CA65 := $(if $(wildcard ../../bin/ca65*),..$S..$Sbin$Sca65,ca65) From 773716c32ae0f19a78264c511d89758600288dce Mon Sep 17 00:00:00 2001 From: bbbradsmith Date: Fri, 5 May 2023 21:46:11 -0400 Subject: [PATCH 50/98] sim65 close(-1) crash fix test/val/constexpr.c relies on close(-1) to return -1 for some reason (comment says "abuse"), but on MSVC close(-1) is treated as a security issue and terminates the program instead of returning -1 simulating this desire for sim65, though constexpr.c may also warrant a review --- src/sim65/paravirt.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/sim65/paravirt.c b/src/sim65/paravirt.c index 9e5c28432..0b16f89e9 100644 --- a/src/sim65/paravirt.c +++ b/src/sim65/paravirt.c @@ -242,7 +242,15 @@ static void PVClose (CPURegs* Regs) 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); } From c03d00bc805ffdda6afe1866d6263e7eef098a39 Mon Sep 17 00:00:00 2001 From: bbbradsmith Date: Fri, 5 May 2023 21:46:42 -0400 Subject: [PATCH 51/98] sim65 suppress uninitialized variable warning the EOF check was protecting uninitialized Val2 but the compiler can't figure that out --- src/sim65/main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/sim65/main.c b/src/sim65/main.c index 9e371fd5d..27299168e 100644 --- a/src/sim65/main.c +++ b/src/sim65/main.c @@ -189,6 +189,7 @@ static unsigned char ReadProgramFile (void) } /* Get load address */ + Val2 = 0; /* suppress uninitialized variable warning */ if (((Val = fgetc(F)) == EOF) || ((Val2 = fgetc(F)) == EOF)) { Error ("'%s': Header missing load address", ProgramFile); From df749abbfba01458907fd954beb47e96756d4fe7 Mon Sep 17 00:00:00 2001 From: bbbradsmith Date: Fri, 5 May 2023 21:56:52 -0400 Subject: [PATCH 52/98] libtest target alternative to libs saves me about 20 minutes if I only want to run tests --- Makefile | 4 ++-- libsrc/Makefile | 8 +++++++- test/readme.txt | 6 +++++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 909de81ec..29fcbbf96 100644 --- a/Makefile +++ b/Makefile @@ -21,7 +21,7 @@ mostlyclean clean: avail unavail bin: @$(MAKE) -C src --no-print-directory $@ -lib: +lib libtest: @$(MAKE) -C libsrc --no-print-directory $@ doc html info: @@ -43,7 +43,7 @@ util: checkstyle: @$(MAKE) -C .github/checks --no-print-directory $@ -# simple "test" target, only run regression tests for c64 target +# runs regression tests, requires libtest target libraries test: @$(MAKE) -C test --no-print-directory $@ diff --git a/libsrc/Makefile b/libsrc/Makefile index 627897d9b..732fa1d0e 100644 --- a/libsrc/Makefile +++ b/libsrc/Makefile @@ -39,6 +39,10 @@ TARGETS = apple2 \ sym1 \ telestrat +TARGETTEST = none \ + sim6502 \ + sim65c02 + DRVTYPES = emd \ joy \ mou \ @@ -53,7 +57,7 @@ OUTPUTDIRS := lib $(subst ../,,$(wildcard ../target/*/drv/*)) \ $(subst ../,,$(wildcard ../target/*/util)) -.PHONY: all mostlyclean clean install zip lib $(TARGETS) +.PHONY: all mostlyclean clean install zip lib libtest $(TARGETS) .SUFFIXES: @@ -81,6 +85,8 @@ datadir = $(PREFIX)/share/cc65 all lib: $(TARGETS) +libtest: $(TARGETTEST) + mostlyclean: $(call RMDIR,../libwrk) diff --git a/test/readme.txt b/test/readme.txt index 41d19aee3..d3f17148e 100644 --- a/test/readme.txt +++ b/test/readme.txt @@ -68,7 +68,11 @@ compiler is working as expected (when the tests behave as described): which will require additional changes to the makefile(s). -To run the tests use "make" in this (top) directory, the makefile should exit +These tests only require a subset of the platform libraries. In the (top) +directory above this one, "make libtest" can be used to build only those +libraries needed for testing, instead of "make lib". + +To run the tests use "make" in this (test) directory, the makefile should exit with no error. When a test failed you can use "make continue" to run further tests. From a022f7203dca1b7b4a00a2fdfff577b9f08ec90d Mon Sep 17 00:00:00 2001 From: bbbradsmith Date: Fri, 5 May 2023 22:05:10 -0400 Subject: [PATCH 53/98] workflow for manually dispatched Windows build and test --- .github/workflows/build-on-pull-request.yml | 4 ++ .github/workflows/snapshot-on-push-master.yml | 4 ++ .github/workflows/windows-test-manual.yml | 43 +++++++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 .github/workflows/windows-test-manual.yml diff --git a/.github/workflows/build-on-pull-request.yml b/.github/workflows/build-on-pull-request.yml index 05d6a4a39..57f00751d 100644 --- a/.github/workflows/build-on-pull-request.yml +++ b/.github/workflows/build-on-pull-request.yml @@ -67,3 +67,7 @@ jobs: - name: Build app (release) run: msbuild src\cc65.sln -t:rebuild -property:Configuration=Release + + # The regression tests are currently too slow to run for this Windows build, + # but the "Windows Test Manual" workflow (windows-test-manual.yml) can by + # manually dispatched from the Actions menu to test as needed. diff --git a/.github/workflows/snapshot-on-push-master.yml b/.github/workflows/snapshot-on-push-master.yml index 50f5cd296..43fcce0a8 100644 --- a/.github/workflows/snapshot-on-push-master.yml +++ b/.github/workflows/snapshot-on-push-master.yml @@ -29,6 +29,10 @@ jobs: - name: Build app (release) run: msbuild src\cc65.sln -t:rebuild -property:Configuration=Release + # The regression tests are currently too slow to run for this Windows build, + # but the "Windows Test Manual" workflow (windows-test-manual.yml) can by + # manually dispatched from the Actions menu to test as needed. + build_linux: name: Build, Test, and Snapshot (Linux) if: github.repository == 'cc65/cc65' diff --git a/.github/workflows/windows-test-manual.yml b/.github/workflows/windows-test-manual.yml new file mode 100644 index 000000000..854327726 --- /dev/null +++ b/.github/workflows/windows-test-manual.yml @@ -0,0 +1,43 @@ +name: Windows Test Manual +# Manually dispatched because it's much slower than the Linux test. + +on: + workflow_dispatch: + +jobs: + build_windows: + name: Build, Test (Windows MSVC) + runs-on: windows-latest + + steps: + - name: Git Setup + shell: bash + run: git config --global core.autocrlf input + + - name: Checkout source + uses: actions/checkout@v3 + + - name: Add msbuild to PATH + uses: microsoft/setup-msbuild@v1.1 + + - name: Build app (MSVC debug) + run: msbuild src\cc65.sln -t:rebuild -property:Configuration=Debug + + - name: Build app (MSVC release) + run: msbuild src\cc65.sln -t:rebuild -property:Configuration=Release + + - name: Build utils (MinGW) + shell: cmd + run: make -j2 util + + - name: Build the platform libraries (make lib) + shell: cmd + run: make -j2 lib QUIET=1 + + - name: Run the regression tests (make test) + shell: cmd + run: make test QUIET=1 + + - name: Test that the samples can be built (make samples) + shell: cmd + run: make -j2 samples From 1df7ab0352a43546c6ece76830594a687681c938 Mon Sep 17 00:00:00 2001 From: bbbradsmith Date: Sat, 6 May 2023 11:55:21 -0400 Subject: [PATCH 54/98] opening brace on same line as while other AbEnd messages don't end in . --- src/grc65/main.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/grc65/main.c b/src/grc65/main.c index ac654300d..adce3dc47 100644 --- a/src/grc65/main.c +++ b/src/grc65/main.c @@ -851,10 +851,9 @@ static char *filterInput (FILE *F, char *tbl) int a, prevchar = -1, i = 0, bracket = 0, quote = 1; a = getc(F); - while (1) - { + while (1) { if (i >= BLOODY_BIG_BUFFER) { - AbEnd ("File too large for internal parsing buffer (%d bytes).",BLOODY_BIG_BUFFER); + AbEnd ("File too large for internal parsing buffer (%d bytes)",BLOODY_BIG_BUFFER); } if ((a == '\n') || (a == '\015')) a = ' '; if (a == ',' && quote) a = ' '; From 532681c9613af15b1993e08db12761855c9707c6 Mon Sep 17 00:00:00 2001 From: bbbradsmith Date: Sat, 6 May 2023 12:06:06 -0400 Subject: [PATCH 55/98] braces were requested combining the two a = ' ' cases was requested --- src/grc65/main.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/grc65/main.c b/src/grc65/main.c index adce3dc47..7d31bfc52 100644 --- a/src/grc65/main.c +++ b/src/grc65/main.c @@ -855,12 +855,20 @@ static char *filterInput (FILE *F, char *tbl) if (i >= BLOODY_BIG_BUFFER) { AbEnd ("File too large for internal parsing buffer (%d bytes)",BLOODY_BIG_BUFFER); } - if ((a == '\n') || (a == '\015')) a = ' '; - if (a == ',' && quote) a = ' '; - if (a == '\042') quote =! quote; + if (((a == '\n') || (a == '\015')) || + (a == ',' && quote)) { + a = ' '; + } + if (a == '\042') { + quote =! quote; + } if (quote) { - if ((a == '{') || (a == '(')) bracket++; - if ((a == '}') || (a == ')')) bracket--; + if ((a == '{') || (a == '(')) { + bracket++; + } + if ((a == '}') || (a == ')')) { + bracket--; + } } if (a == EOF) { tbl[i] = '\0'; From fe35386b794b5359c726a5867b26f8dc58c26615 Mon Sep 17 00:00:00 2001 From: mvax Date: Sat, 6 May 2023 12:56:34 -0400 Subject: [PATCH 56/98] add test - add overloading instruction test --- test/asm/val/ismnemonic.s | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/test/asm/val/ismnemonic.s b/test/asm/val/ismnemonic.s index a4534a9c4..2d131e7a9 100644 --- a/test/asm/val/ismnemonic.s +++ b/test/asm/val/ismnemonic.s @@ -21,14 +21,34 @@ ismnemonic_error .set 0 .if .ismnemonic(instr) ; do nothing .else - ismnemonic_error .set ismnemonic_error + 1 + ismnemonic_error .set 1 .endif .endmacro +; test .feature ubiquitous_idents + + ; allow overloading mnemonics +.feature ubiquitous_idents + +.setcpu "6502" + +; make an adc macro +.macro adc +.endmacro + +; should not match +.if .ismnemonic(adc) + ismnemonic_error .set 1 +.endif + +.delmac adc + +; test all instructions: + ; there is no instruction table for "none", make sure 'adc' (common to all CPUs) and 'add' (sweet16) doesn't match .setcpu "none" .if .ismnemonic(adc) || .ismnemonic(add) - ismnemonic_error .set ismnemonic_error + 1 + ismnemonic_error .set 1 .endif .setcpu "6502" From 84f0ab322d4b056191fd09d8fbc792ba1e045453 Mon Sep 17 00:00:00 2001 From: bbbradsmith Date: Sat, 6 May 2023 13:54:28 -0400 Subject: [PATCH 57/98] sim65: cycles does not increment 1 at a time, so some small overhead is needed in range check --- src/sim65/main.c | 11 ++++++++--- test/asm/val/Makefile | 2 +- test/standard/Makefile | 2 +- test/val/Makefile | 2 +- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/sim65/main.c b/src/sim65/main.c index 27299168e..d92d52ef6 100644 --- a/src/sim65/main.c +++ b/src/sim65/main.c @@ -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); } } diff --git a/test/asm/val/Makefile b/test/asm/val/Makefile index 49b6d5290..09a6b91bc 100644 --- a/test/asm/val/Makefile +++ b/test/asm/val/Makefile @@ -23,7 +23,7 @@ ifdef QUIET endif # sim65 can support 64-bit cycle counts on some platforms, but not all. This must fit in 32-bit. -SIM65FLAGS = -x 4294967295 +SIM65FLAGS = -x 4000000000 CA65 := $(if $(wildcard ../../../bin/ca65*),..$S..$S..$Sbin$Sca65,ca65) LD65 := $(if $(wildcard ../../../bin/ld65*),..$S..$S..$Sbin$Sld65,ld65) diff --git a/test/standard/Makefile b/test/standard/Makefile index 9993ba699..40299c1bf 100644 --- a/test/standard/Makefile +++ b/test/standard/Makefile @@ -23,7 +23,7 @@ ifdef QUIET endif # sim65 can support 64-bit cycle counts on some platforms, but not all. This must fit in 32-bit. -SIM65FLAGS = -x 4294967295 -c +SIM65FLAGS = -x 4000000000 -c CC65 := $(if $(wildcard ../../bin/cc65*),..$S..$Sbin$Scc65,cc65) CA65 := $(if $(wildcard ../../bin/ca65*),..$S..$Sbin$Sca65,ca65) diff --git a/test/val/Makefile b/test/val/Makefile index 8820e535a..158967f9e 100644 --- a/test/val/Makefile +++ b/test/val/Makefile @@ -25,7 +25,7 @@ ifdef QUIET endif # sim65 can support 64-bit cycle counts on some platforms, but not all. This must fit in 32-bit. -SIM65FLAGS = -x 4294967295 -c +SIM65FLAGS = -x 4000000000 -c CC65 := $(if $(wildcard ../../bin/cc65*),..$S..$Sbin$Scc65,cc65) CA65 := $(if $(wildcard ../../bin/ca65*),..$S..$Sbin$Sca65,ca65) From 11cc5b6f06ca9bf1341eb6cc6e5055e5d01c2bc8 Mon Sep 17 00:00:00 2001 From: mvax Date: Sat, 6 May 2023 14:24:53 -0400 Subject: [PATCH 58/98] remove .feature requirment for addrsize function, silently ignore '.feature addrsize' --- doc/ca65.sgml | 10 ---------- src/ca65/feature.c | 3 ++- src/ca65/global.c | 1 - src/ca65/global.h | 1 - src/ca65/scanner.c | 17 ----------------- 5 files changed, 2 insertions(+), 30 deletions(-) diff --git a/doc/ca65.sgml b/doc/ca65.sgml index 258808998..b4ef3e188 100644 --- a/doc/ca65.sgml +++ b/doc/ca65.sgml @@ -1409,10 +1409,6 @@ either a string or an expression value. .endmacro - This command is new and must be enabled with the - .BANK

@@ -2795,12 +2791,6 @@ See: , - - Enables the .ADDRSIZE pseudo function. This function is experimental and not enabled by default. - - See also: - at_in_identifiers Accept the at character ('@') as a valid character in identifiers. The diff --git a/src/ca65/feature.c b/src/ca65/feature.c index 41177d66b..8b915cfda 100644 --- a/src/ca65/feature.c +++ b/src/ca65/feature.c @@ -118,10 +118,11 @@ void SetFeature (feature_t Feature, unsigned char On) case FEAT_C_COMMENTS: CComments = On; break; case FEAT_FORCE_RANGE: ForceRange = On; break; case FEAT_UNDERLINE_IN_NUMBERS: UnderlineInNumbers= On; break; - case FEAT_ADDRSIZE: AddrSize = On; break; case FEAT_BRACKET_AS_INDIRECT: BracketAsIndirect = On; break; case FEAT_STRING_ESCAPES: StringEscapes = On; break; case FEAT_LONG_JSR_JMP_RTS: LongJsrJmpRts = On; break; + /* Accept, but ignore addrsize */ + case FEAT_ADDRSIZE: break; default: break; } } diff --git a/src/ca65/global.c b/src/ca65/global.c index 337677e31..050d19e09 100644 --- a/src/ca65/global.c +++ b/src/ca65/global.c @@ -85,5 +85,4 @@ unsigned char OrgPerSeg = 0; /* Make .org local to current seg */ unsigned char CComments = 0; /* Allow C like comments */ unsigned char ForceRange = 0; /* Force values into expected range */ unsigned char UnderlineInNumbers = 0; /* Allow underlines in numbers */ -unsigned char AddrSize = 0; /* Allow .ADDRSIZE function */ unsigned char BracketAsIndirect = 0; /* Use '[]' not '()' for indirection */ diff --git a/src/ca65/global.h b/src/ca65/global.h index 46fb6c763..b3de99df5 100644 --- a/src/ca65/global.h +++ b/src/ca65/global.h @@ -87,7 +87,6 @@ extern unsigned char OrgPerSeg; /* Make .org local to current seg */ extern unsigned char CComments; /* Allow C like comments */ extern unsigned char ForceRange; /* Force values into expected range */ extern unsigned char UnderlineInNumbers; /* Allow underlines in numbers */ -extern unsigned char AddrSize; /* Allow .ADDRSIZE function */ extern unsigned char BracketAsIndirect; /* Use '[]' not '()' for indirection */ diff --git a/src/ca65/scanner.c b/src/ca65/scanner.c index add365e84..185100025 100644 --- a/src/ca65/scanner.c +++ b/src/ca65/scanner.c @@ -748,24 +748,7 @@ static token_t FindDotKeyword (void) R = bsearch (&K, DotKeywords, sizeof (DotKeywords) / sizeof (DotKeywords [0]), sizeof (DotKeywords [0]), CmpDotKeyword); if (R != 0) { - - /* By default, disable any somewhat experiemental DotKeyword. */ - - switch (R->Tok) { - - case TOK_ADDRSIZE: - /* Disallow .ADDRSIZE function by default */ - if (AddrSize == 0) { - return TOK_NONE; - } - break; - - default: - break; - } - return R->Tok; - } else { return TOK_NONE; } From 560085cb1763c331ab5e0e47272b66026e59a36b Mon Sep 17 00:00:00 2001 From: mvax Date: Sat, 6 May 2023 16:22:04 -0400 Subject: [PATCH 59/98] modify and add tests --- test/asm/val/addrsize.s | 32 ++++++++++++++++++++++++++++++++ test/asm/val/feature.s | 13 ------------- 2 files changed, 32 insertions(+), 13 deletions(-) create mode 100644 test/asm/val/addrsize.s diff --git a/test/asm/val/addrsize.s b/test/asm/val/addrsize.s new file mode 100644 index 000000000..932090df0 --- /dev/null +++ b/test/asm/val/addrsize.s @@ -0,0 +1,32 @@ +; test .addrsize and ensure .feature addrsize is allowed, but inactive + +.export _main + +.segment "ZEROPAGE" +zplabel: + +.segment "CODE" +abslabel: + +; exit with 0 + +_main: + lda #0 + tax + rts + + +.assert .addrsize(zplabel) = 1, error, ".addrsize 1 expected for ZEROPAGE" +.assert .addrsize(abslabel) = 2, error, ".addrsize 2 expected for absolute" + +.feature addrsize +.assert .addrsize(zplabel) = 1, error, ".addrsize 1 expected for ZEROPAGE" +.assert .addrsize(abslabel) = 2, error, ".addrsize 2 expected for absolute" + +.feature addrsize + +.assert .addrsize(zplabel) = 1, error, ".addrsize 1 expected for ZEROPAGE" +.assert .addrsize(abslabel) = 2, error, ".addrsize 2 expected for absolute" + +.feature addrsize - +.assert .addrsize(zplabel) = 1, error, ".addrsize 1 expected for ZEROPAGE" +.assert .addrsize(abslabel) = 2, error, ".addrsize 2 expected for absolute" diff --git a/test/asm/val/feature.s b/test/asm/val/feature.s index 4428cf4c2..39e3a7862 100644 --- a/test/asm/val/feature.s +++ b/test/asm/val/feature.s @@ -2,12 +2,6 @@ .export _main -.segment "ZEROPAGE" -zplabel: - -.segment "CODE" -abslabel: - ; exit with 0 _main: @@ -17,13 +11,6 @@ _main: tax rts - -.feature addrsize + -.assert .addrsize(zplabel) = 1, error, ".addrsize 1 expected for ZEROPAGE" -.assert .addrsize(abslabel) = 2, error, ".addrsize 2 expected for absolute" -.feature addrsize - - - .feature at_in_identifiers on ident@with@at: rts From bee29dedd17841d77c861fb737874e8905ebe7d3 Mon Sep 17 00:00:00 2001 From: mvax Date: Sat, 6 May 2023 17:11:57 -0400 Subject: [PATCH 60/98] fix feature.s test --- test/asm/val/feature.s | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/asm/val/feature.s b/test/asm/val/feature.s index 39e3a7862..0def9d92c 100644 --- a/test/asm/val/feature.s +++ b/test/asm/val/feature.s @@ -2,6 +2,11 @@ .export _main +.segment "ZEROPAGE" +zplabel: + +.segment "CODE" + ; exit with 0 _main: From 56df849101318a9a2aa61b407d5c0f9fb7fd2eb6 Mon Sep 17 00:00:00 2001 From: mvax Date: Sun, 7 May 2023 14:53:44 -0400 Subject: [PATCH 61/98] add warning for .feature addrsize, clean up switch in SetFeature --- src/ca65/feature.c | 2 -- src/ca65/pseudo.c | 6 ++++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/ca65/feature.c b/src/ca65/feature.c index 8b915cfda..9f5ca5876 100644 --- a/src/ca65/feature.c +++ b/src/ca65/feature.c @@ -121,8 +121,6 @@ void SetFeature (feature_t Feature, unsigned char On) case FEAT_BRACKET_AS_INDIRECT: BracketAsIndirect = On; break; case FEAT_STRING_ESCAPES: StringEscapes = On; break; case FEAT_LONG_JSR_JMP_RTS: LongJsrJmpRts = On; break; - /* Accept, but ignore addrsize */ - case FEAT_ADDRSIZE: break; default: break; } } diff --git a/src/ca65/pseudo.c b/src/ca65/pseudo.c index 1877512d5..cf4d1f64b 100644 --- a/src/ca65/pseudo.c +++ b/src/ca65/pseudo.c @@ -1043,6 +1043,12 @@ static void DoFeature (void) ErrorSkip ("Invalid feature: '%m%p'", &CurTok.SVal); return; } + + if (Feature == FEAT_ADDRSIZE) { + /* Warn for depreciated .feature addrsize */ + Warning (1, "Depreciated feature: '.feature addrsize'. Pseudo function .addrsize is always available."); + } + NextTok (); /* Optional +/- or ON/OFF */ From 0081fe548ce3908dee2624a322d89af8d06ed4bb Mon Sep 17 00:00:00 2001 From: bbbradsmith Date: Sun, 7 May 2023 16:26:42 -0400 Subject: [PATCH 62/98] sim64 universal 64-bit cycle count support: MaxCycleCount is accounted by countdown, eliminating the 1-instruction-overhead issue, and removing the need to compare against a growing TotalCycles. Makes main.c responsible for counting total cycles, instead of 6502.c, so the size of MaxCycleCount etc. is fully determined in one location. Makes error.c responsible for PrintCycles instead of paravirt.c, so that it can be treated globally instead of Return value of main() should be SIM65_ERROR because it is unreachable by design. --- src/sim65/6502.c | 18 ------------------ src/sim65/6502.h | 6 ------ src/sim65/error.c | 25 +++++++++++++++++++++++++ src/sim65/error.h | 6 ++++++ src/sim65/main.c | 40 +++++++++++++++++++++------------------- src/sim65/paravirt.c | 6 +----- 6 files changed, 53 insertions(+), 48 deletions(-) diff --git a/src/sim65/6502.c b/src/sim65/6502.c index 6c23b0dfc..9d2c93da8 100644 --- a/src/sim65/6502.c +++ b/src/sim65/6502.c @@ -64,18 +64,12 @@ static CPURegs Regs; /* Cycles for the current insn */ static unsigned Cycles; -/* Total number of CPU cycles exec'd */ -static unsigned long TotalCycles; - /* NMI request active */ static unsigned HaveNMIRequest; /* IRQ request active */ static unsigned HaveIRQRequest; -/* flag to print cycles at program termination */ -int PrintCycles; - /*****************************************************************************/ /* Helper functions and macros */ @@ -3277,18 +3271,6 @@ unsigned ExecuteInsn (void) Handlers[CPU][OPC] (); } - /* Count cycles */ - TotalCycles += Cycles; - /* Return the number of clock cycles needed by this insn */ return Cycles; } - - - -unsigned long GetCycles (void) -/* Return the total number of cycles executed */ -{ - /* Return the total number of cycles */ - return TotalCycles; -} diff --git a/src/sim65/6502.h b/src/sim65/6502.h index f8e894567..39b995793 100644 --- a/src/sim65/6502.h +++ b/src/sim65/6502.h @@ -96,12 +96,6 @@ unsigned ExecuteInsn (void); ** executed instruction. */ -unsigned long GetCycles (void); -/* Return the total number of clock cycles executed */ - -extern int PrintCycles; -/* flag to print cycles at program termination */ - /* End of 6502.h */ diff --git a/src/sim65/error.c b/src/sim65/error.c index 441b07d2a..fc24ca006 100644 --- a/src/sim65/error.c +++ b/src/sim65/error.c @@ -41,6 +41,20 @@ +/*****************************************************************************/ +/* Data */ +/*****************************************************************************/ + + + +/* flag to print cycles at program termination */ +int PrintCycles = 0; + +/* cycles are counted by main.c */ +extern unsigned long long TotalCycles; + + + /*****************************************************************************/ /* Code */ /*****************************************************************************/ @@ -99,3 +113,14 @@ void Internal (const char* Format, ...) va_end (ap); exit (SIM65_ERROR); } + + + +void SimExit (int Code) +/* Exit the simulation with an exit code */ +{ + if (PrintCycles) { + fprintf (stdout, "%llu cycles\n", TotalCycles); + } + exit (Code); +} diff --git a/src/sim65/error.h b/src/sim65/error.h index ea54fa048..a016881c6 100644 --- a/src/sim65/error.h +++ b/src/sim65/error.h @@ -55,6 +55,9 @@ #define SIM65_ERROR_TIMEOUT 0x7E /* An error result for max CPU instructions exceeded. */ +extern int PrintCycles; +/* flag to print cycles at program termination */ + /*****************************************************************************/ @@ -75,6 +78,9 @@ void ErrorCode (int Code, const char* Format, ...) attribute((noreturn, format(p void Internal (const char* Format, ...) attribute((noreturn, format(printf,1,2))); /* Print an internal error message and die */ +void SimExit (int Code); +/* Exit the simulation with an exit code */ + /* End of error.h */ diff --git a/src/sim65/main.c b/src/sim65/main.c index d92d52ef6..f5ace1909 100644 --- a/src/sim65/main.c +++ b/src/sim65/main.c @@ -36,7 +36,6 @@ #include #include #include -#include /* common */ #include "abend.h" @@ -61,14 +60,14 @@ /* Name of program file */ const char* ProgramFile; -/* exit simulator after MaxCycles Cycles */ -unsigned long MaxCycles; +/* count of total cycles executed */ +unsigned long long TotalCycles = 0; -/* 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) +/* exit simulator after MaxCycles Cccles */ +unsigned long long MaxCycles = 0; + +/* countdown from MaxCycles */ +unsigned long long RemainCycles; /* Header signature 'sim65' */ static const unsigned char HeaderSignature[] = { @@ -145,11 +144,7 @@ static void OptQuitXIns (const char* Opt attribute ((unused)), const char* Arg attribute ((unused))) /* quit after MaxCycles cycles */ { - MaxCycles = strtoul(Arg, NULL, 0); - /* Guard against overflow. */ - if (MaxCycles >= MAXCYCLES_LIMIT) { - Error("'-x parameter out of range. Max: %lu",MAXCYCLES_LIMIT); - } + MaxCycles = strtoull(Arg, NULL, 0); } static unsigned char ReadProgramFile (void) @@ -247,6 +242,7 @@ int main (int argc, char* argv[]) unsigned I; unsigned char SPAddr; + unsigned int Cycles; /* Initialize the cmdline module */ InitCmdLine (&argc, &argv, "sim65"); @@ -309,18 +305,24 @@ int main (int argc, char* argv[]) MemInit (); SPAddr = ReadProgramFile (); - ParaVirtInit (I, SPAddr); Reset (); + RemainCycles = MaxCycles; while (1) { - ExecuteInsn (); - if (MaxCycles && (GetCycles () >= MaxCycles)) { - ErrorCode (SIM65_ERROR_TIMEOUT, "Maximum number of cycles reached."); + Cycles = ExecuteInsn (); + TotalCycles += Cycles; + if (MaxCycles) { + if (Cycles > RemainCycles) { + ErrorCode (SIM65_ERROR_TIMEOUT, "Maximum number of cycles (%llu) reached.", MaxCycles); + } + RemainCycles -= Cycles; } } - /* Return an apropriate exit code */ - return EXIT_SUCCESS; + /* Unreachable. sim65 program must exit through paravirtual PVExit + ** or timeout from MaxCycles producing an error. + */ + return SIM65_ERROR; } diff --git a/src/sim65/paravirt.c b/src/sim65/paravirt.c index 0b16f89e9..af162acfa 100644 --- a/src/sim65/paravirt.c +++ b/src/sim65/paravirt.c @@ -124,11 +124,7 @@ static unsigned PopParam (unsigned char Incr) static void PVExit (CPURegs* Regs) { Print (stderr, 1, "PVExit ($%02X)\n", Regs->AC); - if (PrintCycles) { - Print (stdout, 0, "%lu cycles\n", GetCycles ()); - } - - exit (Regs->AC); + SimExit (Regs->AC); } From aad64063c97d2b379955f90d006c244c744c559e Mon Sep 17 00:00:00 2001 From: bbbradsmith Date: Sun, 7 May 2023 16:33:07 -0400 Subject: [PATCH 63/98] makefiles no longer need comment about sim65 64-bit support --- test/asm/val/Makefile | 1 - test/standard/Makefile | 1 - test/val/Makefile | 1 - 3 files changed, 3 deletions(-) diff --git a/test/asm/val/Makefile b/test/asm/val/Makefile index 09a6b91bc..54b1100ec 100644 --- a/test/asm/val/Makefile +++ b/test/asm/val/Makefile @@ -22,7 +22,6 @@ ifdef QUIET NULLERR = 2>$(NULLDEV) endif -# 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) diff --git a/test/standard/Makefile b/test/standard/Makefile index 40299c1bf..bf513c84e 100644 --- a/test/standard/Makefile +++ b/test/standard/Makefile @@ -22,7 +22,6 @@ ifdef QUIET NULLERR = 2>$(NULLDEV) endif -# 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) diff --git a/test/val/Makefile b/test/val/Makefile index 158967f9e..56d8e5ff9 100644 --- a/test/val/Makefile +++ b/test/val/Makefile @@ -24,7 +24,6 @@ ifdef QUIET NULLERR = 2>$(NULLDEV) endif -# 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) From 3419cbd3484427ad732289c5ff7cab41639cf1ca Mon Sep 17 00:00:00 2001 From: bbbradsmith Date: Sun, 7 May 2023 16:33:47 -0400 Subject: [PATCH 64/98] sim65 64-bit cycle count tests These take ~10 seconds to run locally --- test/asm/Makefile | 2 +- test/asm/misc/Makefile | 70 +++++++++++++++++++++++++++++++ test/asm/misc/sim65-time-wait.inc | 55 ++++++++++++++++++++++++ test/asm/misc/sim65-timein.s | 17 ++++++++ test/asm/misc/sim65-timeout.s | 17 ++++++++ test/asm/readme.txt | 6 +++ 6 files changed, 166 insertions(+), 1 deletion(-) create mode 100644 test/asm/misc/Makefile create mode 100644 test/asm/misc/sim65-time-wait.inc create mode 100644 test/asm/misc/sim65-timein.s create mode 100644 test/asm/misc/sim65-timeout.s diff --git a/test/asm/Makefile b/test/asm/Makefile index 3481dae78..dea53f6b2 100644 --- a/test/asm/Makefile +++ b/test/asm/Makefile @@ -12,7 +12,7 @@ endif WORKDIR = ../testwrk/asm -SUBDIRS = cpudetect opcodes listing val err +SUBDIRS = cpudetect opcodes listing val err misc .PHONY: all continue mostlyclean clean diff --git a/test/asm/misc/Makefile b/test/asm/misc/Makefile new file mode 100644 index 000000000..5a9d4f3ef --- /dev/null +++ b/test/asm/misc/Makefile @@ -0,0 +1,70 @@ +# Makefile for the remaining asm tests that need special care in one way or another + +ifneq ($(shell echo),) + CMD_EXE = 1 +endif + +ifdef CMD_EXE + S = $(subst /,\,/) + NOT = - # Hack + EXE = .exe + NULLDEV = nul: + MKDIR = mkdir $(subst /,\,$1) + RMDIR = -rmdir /s /q $(subst /,\,$1) +else + S = / + NOT = ! + EXE = + NULLDEV = /dev/null + MKDIR = mkdir -p $1 + RMDIR = $(RM) -r $1 +endif + +ifdef QUIET + .SILENT: + NULLOUT = >$(NULLDEV) + NULLERR = 2>$(NULLDEV) +endif + +SIM65FLAGS = -x 200000000 + +CA65 := $(if $(wildcard ../../../bin/ca65*),..$S..$S..$Sbin$Sca65,ca65) +LD65 := $(if $(wildcard ../../../bin/ld65*),..$S..$S..$Sbin$Sld65,ld65) +SIM65 := $(if $(wildcard ../../../bin/sim65*),..$S..$S..$Sbin$Ssim65,sim65) + +WORKDIR = ..$S..$S..$Stestwrk$Sasm$Smisc + +.PHONY: all clean + +SOURCES := $(wildcard *.s) +TESTS = $(SOURCES:%.s=$(WORKDIR)/%.6502.prg) +TESTS += $(SOURCES:%.s=$(WORKDIR)/%.65c02.prg) + +all: $(TESTS) + +$(WORKDIR): + $(call MKDIR,$(WORKDIR)) + +define PRG_template + +# sim65 ensure 64-bit wait time does not timeout +$(WORKDIR)/sim65-timein.$1.prg: sim65-timein.s | $(WORKDIR) + $(if $(QUIET),echo misc/sim65-timein.$1.prg) + $(CA65) -t sim$1 -o $$(@:.prg=.o) $$< $(NULLERR) + $(LD65) -t sim$1 -o $$@ $$(@:.prg=.o) sim$1.lib $(NULLERR) + $(SIM65) -x 4400000000 -c $$@ $(NULLOUT) $(NULLERR) + +# sim65 ensure 64-bit wait time does timeout +$(WORKDIR)/sim65-timeout.$1.prg: sim65-timeout.s | $(WORKDIR) + $(if $(QUIET),echo misc/sim65-timeout.$1.prg) + $(CA65) -t sim$1 -o $$(@:.prg=.o) $$< $(NULLERR) + $(LD65) -t sim$1 -o $$@ $$(@:.prg=.o) sim$1.lib $(NULLERR) + $(NOT) $(SIM65) -x 4400000000 -c $$@ $(NULLOUT) $(NULLERR) + +endef # PRG_template + +$(eval $(call PRG_template,6502)) +$(eval $(call PRG_template,65c02)) + +clean: + @$(call RMDIR,$(WORKDIR)) diff --git a/test/asm/misc/sim65-time-wait.inc b/test/asm/misc/sim65-time-wait.inc new file mode 100644 index 000000000..bc761ac16 --- /dev/null +++ b/test/asm/misc/sim65-time-wait.inc @@ -0,0 +1,55 @@ +; Shared timer for: +; sim65-timein.s +; sim65-timeout.s + +; wait A * 100,000,000 cycles, plus small amount of overhead +wait100m: + tay + bne :+ + rts ; return quickly if A=0 +: + jsr wait50331648 ; 50331648 + jsr wait25165824 ; 75497472 + jsr wait12582912 ; 88080384 + jsr wait6291456 ; 94371840 + jsr wait3145728 ; 97517568 + jsr wait1572864 ; 99090432 + jsr wait786432 ; 99876864 + jsr wait98304 ; 99975168 + jsr wait24576 ; 99999744 + jsr wait192 ; 99999936 + jsr wait48 ; 99999984 + nop ; 99999986 + nop ; 99999988 + php ; 99999991 + plp ; 99999995 + dey ; 99999997 + bne :- ; 100000000 + rts +; Note that this branch could cross a page if poorly aligned, +; adding an additional 1 cycle per loop. +; This precision is not important for the tests used. + +wait50331648: jsr wait25165824 +wait25165824: jsr wait12582912 +wait12582912: jsr wait6291456 +wait6291456: jsr wait3145728 +wait3145728: jsr wait1572864 +wait1572864: jsr wait786432 +wait786432: jsr wait393216 +wait393216: jsr wait196608 +wait196608: jsr wait98304 +wait98304: jsr wait49152 +wait49152: jsr wait24576 +wait24576: jsr wait12288 +wait12288: jsr wait6144 +wait6144: jsr wait3072 +wait3072: jsr wait1536 +wait1536: jsr wait768 +wait768: jsr wait384 +wait384: jsr wait192 +wait192: jsr wait96 +wait96: jsr wait48 +wait48: jsr wait24 +wait24: jsr wait12 +wait12: rts diff --git a/test/asm/misc/sim65-timein.s b/test/asm/misc/sim65-timein.s new file mode 100644 index 000000000..13365f0a8 --- /dev/null +++ b/test/asm/misc/sim65-timein.s @@ -0,0 +1,17 @@ +; Verifies that sim65 can handle 64-bit timeout counter. +; sim65 sim65-timein.prg -x 4400000000 + +.export _main +.import exit + +_main: + ; wait ~4,300,000,000 cycles + lda #43 + jsr wait100m + ; This is a positive test. + ; If the timeout did not occur, returning 0 reports success. + lda #0 + rts + +; wait100m +.include "sim65-time-wait.inc" diff --git a/test/asm/misc/sim65-timeout.s b/test/asm/misc/sim65-timeout.s new file mode 100644 index 000000000..6f1778dcd --- /dev/null +++ b/test/asm/misc/sim65-timeout.s @@ -0,0 +1,17 @@ +; Verifies that sim65 can handle 64-bit timeout counter. +; sim65 sim65-timeout.prg -x 4400000000 + +.export _main +.import exit + +_main: + ; wait ~4,500,000,000 cycles + lda #45 + jsr wait100m + ; This is a negative test. + ; If the timeout did not occur, returning 0 reports failure. + lda #0 + rts + +; wait100m +.include "sim65-time-wait.inc" diff --git a/test/asm/readme.txt b/test/asm/readme.txt index 49b530d1c..9b716e60c 100644 --- a/test/asm/readme.txt +++ b/test/asm/readme.txt @@ -36,3 +36,9 @@ val: Runtime assembly tests using sim65 that should end with an exit code of 0 if they pass. If they fail the exit code should be either -1, or a number indicating what part of the test failed. + + +misc: +----- + +This is for tests that require special make steps or conditions. From 7f0baff792bd4f5b4937dc1d19811f310ba7b29f Mon Sep 17 00:00:00 2001 From: bbbradsmith Date: Sun, 7 May 2023 16:35:05 -0400 Subject: [PATCH 65/98] document how to return from assembly sim65 test --- doc/sim65.sgml | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/doc/sim65.sgml b/doc/sim65.sgml index 310de4667..c838cd3b0 100644 --- a/doc/sim65.sgml +++ b/doc/sim65.sgml @@ -126,9 +126,17 @@ a set of built-in paravirtualization functions (Creating a Test in Assembly

Assembly tests may similarly be assembled and linked with - + +Return from The binary file has a 12 byte header: From 2cb457b85f8019e6437907ddd19e3d2c5f2546c6 Mon Sep 17 00:00:00 2001 From: bbbradsmith Date: Sun, 7 May 2023 16:51:12 -0400 Subject: [PATCH 66/98] sim65 use error codes outside the simulated program's range for non-sim errors --- doc/sim65.sgml | 7 +++++++ src/sim65/error.h | 8 +++++--- src/sim65/paravirt.c | 2 +- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/doc/sim65.sgml b/doc/sim65.sgml index c838cd3b0..b1e5afbdc 100644 --- a/doc/sim65.sgml +++ b/doc/sim65.sgml @@ -44,6 +44,13 @@ The simulator is called as follows: --version Print the simulator version number +sim65 will exit with the error code of the simulated program, +which is limited to an 8-bit result 0-255. + +An error in sim65, like bad arguments or an internal problem will exit with Command line options in detail

diff --git a/src/sim65/error.h b/src/sim65/error.h index a016881c6..6dbee974c 100644 --- a/src/sim65/error.h +++ b/src/sim65/error.h @@ -49,10 +49,12 @@ -#define SIM65_ERROR 0x7F -/* Does not use EXIT_FAILURE because it may overlap with test results. */ +#define SIM65_ERROR -1 +/* An error result for errors that are not part of the simulated test. +** Note that set simulated test can only return 8-bit errors 0-255. +*/ -#define SIM65_ERROR_TIMEOUT 0x7E +#define SIM65_ERROR_TIMEOUT -2 /* An error result for max CPU instructions exceeded. */ extern int PrintCycles; diff --git a/src/sim65/paravirt.c b/src/sim65/paravirt.c index af162acfa..2e52d6e7e 100644 --- a/src/sim65/paravirt.c +++ b/src/sim65/paravirt.c @@ -124,7 +124,7 @@ static unsigned PopParam (unsigned char Incr) static void PVExit (CPURegs* Regs) { Print (stderr, 1, "PVExit ($%02X)\n", Regs->AC); - SimExit (Regs->AC); + SimExit (Regs->AC); /* Error code in range 0-255. */ } From f15e9c41593cec0aed3eb17b01a91985e778f1e7 Mon Sep 17 00:00:00 2001 From: bbbradsmith Date: Sun, 7 May 2023 17:41:54 -0400 Subject: [PATCH 67/98] Linux build rejects %llu in ErrorCode --- src/sim65/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sim65/main.c b/src/sim65/main.c index f5ace1909..3c7cdc157 100644 --- a/src/sim65/main.c +++ b/src/sim65/main.c @@ -315,7 +315,7 @@ int main (int argc, char* argv[]) TotalCycles += Cycles; if (MaxCycles) { if (Cycles > RemainCycles) { - ErrorCode (SIM65_ERROR_TIMEOUT, "Maximum number of cycles (%llu) reached.", MaxCycles); + ErrorCode (SIM65_ERROR_TIMEOUT, "Maximum number of cycles reached."); } RemainCycles -= Cycles; } From 02d38ae17eb9705f9afeb8a50661b3ab8860971b Mon Sep 17 00:00:00 2001 From: Irgendwer Date: Mon, 8 May 2023 15:28:22 +0200 Subject: [PATCH 68/98] Fixed comments for Atari OS memory location --- include/_atarios.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/include/_atarios.h b/include/_atarios.h index ec33b98c9..cbf33bda6 100644 --- a/include/_atarios.h +++ b/include/_atarios.h @@ -334,17 +334,17 @@ struct __os { void (*vserin)(void); // = $020A/$020B POKEY SERIAL INPUT READY IRQ void (*vseror)(void); // = $020C/$020D POKEY SERIAL OUTPUT READY IRQ void (*vseroc)(void); // = $020E/$020F POKEY SERIAL OUTPUT COMPLETE IRQ - void (*vtimr1)(void); // = $0210/$0201 POKEY TIMER 1 IRQ - void (*vtimr2)(void); // = $0212/$0203 POKEY TIMER 2 IRQ - void (*vtimr4)(void); // = $0214/$0205 POKEY TIMER 4 IRQ - void (*vimirq)(void); // = $0216/$0207 IMMEDIATE IRQ VECTOR - unsigned int cdtmv1; // = $0218/$0210 COUNT DOWN TIMER 1 + void (*vtimr1)(void); // = $0210/$0211 POKEY TIMER 1 IRQ + void (*vtimr2)(void); // = $0212/$0213 POKEY TIMER 2 IRQ + void (*vtimr4)(void); // = $0214/$0215 POKEY TIMER 4 IRQ + void (*vimirq)(void); // = $0216/$0217 IMMEDIATE IRQ VECTOR + unsigned int cdtmv1; // = $0218/$0219 COUNT DOWN TIMER 1 unsigned int cdtmv2; // = $021A/$021B COUNT DOWN TIMER 2 unsigned int cdtmv3; // = $021C/$021D COUNT DOWN TIMER 3 unsigned int cdtmv4; // = $021E/$021F COUNT DOWN TIMER 4 unsigned int cdtmv5; // = $0220/$0221 COUNT DOWN TIMER 5 void (*vvblki)(void); // = $0222/$0223 IMMEDIATE VERTICAL BLANK NMI VECTOR - void (*vvblkd)(void); // = $0224/$0224 DEFERRED VERTICAL BLANK NMI VECTOR + void (*vvblkd)(void); // = $0224/$0225 DEFERRED VERTICAL BLANK NMI VECTOR void (*cdtma1)(void); // = $0226/$0227 COUNT DOWN TIMER 1 JSR ADDRESS void (*cdtma2)(void); // = $0228/$0229 COUNT DOWN TIMER 2 JSR ADDRESS unsigned char cdtmf3; // = $022A COUNT DOWN TIMER 3 FLAG From a058d4a2f3bd0361a0b03ffecb39b22d8cc0eb93 Mon Sep 17 00:00:00 2001 From: Movax12 Date: Mon, 8 May 2023 16:55:54 -0400 Subject: [PATCH 69/98] Fix warning message, remove comment --- src/ca65/pseudo.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/ca65/pseudo.c b/src/ca65/pseudo.c index cf4d1f64b..2ce1ae087 100644 --- a/src/ca65/pseudo.c +++ b/src/ca65/pseudo.c @@ -1045,8 +1045,7 @@ static void DoFeature (void) } if (Feature == FEAT_ADDRSIZE) { - /* Warn for depreciated .feature addrsize */ - Warning (1, "Depreciated feature: '.feature addrsize'. Pseudo function .addrsize is always available."); + Warning (1, "Deprecated feature: '.feature addrsize'. Pseudo function .addrsize is always available."); } NextTok (); From ce6097ea7ebf4d37abc6865c1afc806876e5e2f5 Mon Sep 17 00:00:00 2001 From: bbbradsmith Date: Mon, 8 May 2023 18:12:57 -0400 Subject: [PATCH 70/98] rename windows-test-manual to windows-test-scheduled --- .../{windows-test-manual.yml => windows-test-scheduled.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{windows-test-manual.yml => windows-test-scheduled.yml} (100%) diff --git a/.github/workflows/windows-test-manual.yml b/.github/workflows/windows-test-scheduled.yml similarity index 100% rename from .github/workflows/windows-test-manual.yml rename to .github/workflows/windows-test-scheduled.yml From 07963abd52ff5ccf3c5ef7790451454e1c0f3d0b Mon Sep 17 00:00:00 2001 From: bbbradsmith Date: Mon, 8 May 2023 18:21:21 -0400 Subject: [PATCH 71/98] replace manual-only tests with scheduled test and manual dispatch cache is used to prevent unnecessary rebuild if the previous build was successful make steps now use SHELL=cmd to provide cmd.exe subshell --- .github/workflows/windows-test-scheduled.yml | 48 +++++++++++++++++--- 1 file changed, 42 insertions(+), 6 deletions(-) diff --git a/.github/workflows/windows-test-scheduled.yml b/.github/workflows/windows-test-scheduled.yml index 854327726..c3516772b 100644 --- a/.github/workflows/windows-test-scheduled.yml +++ b/.github/workflows/windows-test-scheduled.yml @@ -1,8 +1,16 @@ -name: Windows Test Manual -# Manually dispatched because it's much slower than the Linux test. +name: Windows Test Scheduled +# Scheduled or manually dispatched because it's slower than the Linux test. on: + schedule: + - cron: '0 0 */1 * *' + # every 1 days workflow_dispatch: + # allow manual dispatch +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + # don't run more than once at a time jobs: build_windows: @@ -10,34 +18,62 @@ jobs: runs-on: windows-latest steps: + + # This cache is used to remember the last build. + # If there are no changes and the last build was successful, + # the build and test steps will be omitted. + # If the last build failed, the full attempt will be repeated. + # Github Actions will retain the last build cache for up to 7 days. + + - name: Create Cache + shell: bash + run: mkdir ~/.cache-sha + + - name: Cache SHA + uses: actions/cache@v3 + id: check-sha + with: + path: ~/.cache-sha + key: cache-sha-wintest-${{ github.sha }} + - name: Git Setup + if: steps.check-sha.outputs.cache-hit != 'true' shell: bash run: git config --global core.autocrlf input - name: Checkout source + if: steps.check-sha.outputs.cache-hit != 'true' uses: actions/checkout@v3 - name: Add msbuild to PATH + if: steps.check-sha.outputs.cache-hit != 'true' uses: microsoft/setup-msbuild@v1.1 - name: Build app (MSVC debug) + if: steps.check-sha.outputs.cache-hit != 'true' run: msbuild src\cc65.sln -t:rebuild -property:Configuration=Debug - name: Build app (MSVC release) + if: steps.check-sha.outputs.cache-hit != 'true' run: msbuild src\cc65.sln -t:rebuild -property:Configuration=Release - name: Build utils (MinGW) + if: steps.check-sha.outputs.cache-hit != 'true' shell: cmd - run: make -j2 util + run: make -j2 util SHELL=cmd - name: Build the platform libraries (make lib) + if: steps.check-sha.outputs.cache-hit != 'true' shell: cmd - run: make -j2 lib QUIET=1 + run: make lib QUIET=1 SHELL=cmd + # make -j2 lib fails with SHELL=cmd (not sure why) - name: Run the regression tests (make test) + if: steps.check-sha.outputs.cache-hit != 'true' shell: cmd - run: make test QUIET=1 + run: make test QUIET=1 SHELL=cmd - name: Test that the samples can be built (make samples) + if: steps.check-sha.outputs.cache-hit != 'true' shell: cmd - run: make -j2 samples + run: make -j2 samples SHELL=cmd From 76328da6824493b75a0d9863c1730e0dcf418ad5 Mon Sep 17 00:00:00 2001 From: bbbradsmith Date: Mon, 8 May 2023 20:57:50 -0400 Subject: [PATCH 72/98] librsc/Makefile: ../lib directory must be created globally before make lib targets in parallel prevents conflict of individual targets each trying to create ../lib enable -j2 in make lib windows action --- .github/workflows/windows-test-scheduled.yml | 3 +-- libsrc/Makefile | 10 ++++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/windows-test-scheduled.yml b/.github/workflows/windows-test-scheduled.yml index c3516772b..451b37f79 100644 --- a/.github/workflows/windows-test-scheduled.yml +++ b/.github/workflows/windows-test-scheduled.yml @@ -65,8 +65,7 @@ jobs: - name: Build the platform libraries (make lib) if: steps.check-sha.outputs.cache-hit != 'true' shell: cmd - run: make lib QUIET=1 SHELL=cmd - # make -j2 lib fails with SHELL=cmd (not sure why) + run: make -j2 lib QUIET=1 SHELL=cmd - name: Run the regression tests (make test) if: steps.check-sha.outputs.cache-hit != 'true' diff --git a/libsrc/Makefile b/libsrc/Makefile index 732fa1d0e..0873d019f 100644 --- a/libsrc/Makefile +++ b/libsrc/Makefile @@ -122,9 +122,13 @@ endef # ZIP_recipe zip: $(foreach dir,$(OUTPUTDIRS),$(ZIP_recipe)) -$(TARGETS): +$(TARGETS): | ../lib @$(MAKE) --no-print-directory $@ +# ../lib must be created globally before doing lib targets in parallel +../lib: + @$(call MKDIR,$@) + else # TARGET CA65FLAGS = @@ -293,10 +297,12 @@ $(EXTRA_OBJPAT): $(EXTRA_SRCPAT) | ../libwrk/$(TARGET) ../lib @echo $(TARGET) - $( Date: Mon, 8 May 2023 21:22:18 -0400 Subject: [PATCH 73/98] remove workflow comments this obsoletes --- .github/workflows/build-on-pull-request.yml | 4 ---- .github/workflows/snapshot-on-push-master.yml | 4 ---- 2 files changed, 8 deletions(-) diff --git a/.github/workflows/build-on-pull-request.yml b/.github/workflows/build-on-pull-request.yml index 1ad810382..55be5db1e 100644 --- a/.github/workflows/build-on-pull-request.yml +++ b/.github/workflows/build-on-pull-request.yml @@ -72,7 +72,3 @@ jobs: - name: Build app (release) run: msbuild src\cc65.sln -t:rebuild -property:Configuration=Release - - # The regression tests are currently too slow to run for this Windows build, - # but the "Windows Test Manual" workflow (windows-test-manual.yml) can by - # manually dispatched from the Actions menu to test as needed. diff --git a/.github/workflows/snapshot-on-push-master.yml b/.github/workflows/snapshot-on-push-master.yml index 6ba6b63ed..2aedb0e25 100644 --- a/.github/workflows/snapshot-on-push-master.yml +++ b/.github/workflows/snapshot-on-push-master.yml @@ -29,10 +29,6 @@ jobs: - name: Build app (release) run: msbuild src\cc65.sln -t:rebuild -property:Configuration=Release - # The regression tests are currently too slow to run for this Windows build, - # but the "Windows Test Manual" workflow (windows-test-manual.yml) can by - # manually dispatched from the Actions menu to test as needed. - build_linux: name: Build, Test, and Snapshot (Linux) if: github.repository == 'cc65/cc65' From 3b7be09a7f7a70bff6ee463b24d5514ec52ca1d4 Mon Sep 17 00:00:00 2001 From: bbbradsmith Date: Thu, 11 May 2023 19:50:58 -0400 Subject: [PATCH 74/98] extern redeclared as static = error (C spec: undefined) static redeclared as extern = warning (C spec: ignore extern) See: #2111 --- src/cc65/symtab.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/cc65/symtab.c b/src/cc65/symtab.c index d9270f604..a2bbf13dd 100644 --- a/src/cc65/symtab.c +++ b/src/cc65/symtab.c @@ -1340,15 +1340,14 @@ SymEntry* AddGlobalSym (const char* Name, const Type* T, unsigned Flags) Name); Entry = 0; } else if ((Flags & SC_ESUTYPEMASK) != SC_TYPEDEF) { - /* If a static declaration follows a non-static declaration, then - ** diagnose the conflict. It will warn and compile an extern - ** declaration if both declarations are global, otherwise give an - ** error. + /* If a static declaration follows a non-static declaration, then the result is undefined. + ** Most compilers choose to either give an error at compile time, + ** or remove the extern property for a link time error if used. */ if (SymTab == SymTab0 && (Flags & SC_EXTERN) == 0 && (Entry->Flags & SC_EXTERN) != 0) { - Warning ("Static declaration of '%s' follows non-static declaration", Name); + Error ("Static declaration of '%s' follows non-static declaration", Name); } else if ((Flags & SC_EXTERN) != 0 && (Entry->Owner == SymTab0 || (Entry->Flags & SC_DEF) != 0) && (Entry->Flags & SC_EXTERN) == 0) { @@ -1360,8 +1359,12 @@ SymEntry* AddGlobalSym (const char* Name, const Type* T, unsigned Flags) */ if (Entry->Owner == SymTab0) { if ((Flags & SC_STORAGE) == 0) { - /* Linkage must be unchanged */ + /* Linkage must be unchanged. + ** The C standard specifies that a later extern declaration will be ignored, + ** and will use the previous linkage instead. Giving a warning for this case. + */ Flags &= ~SC_EXTERN; + Warning ("Extern declaration of '%s' follows static declaration, extern ignored", Name); } else { Error ("Non-static declaration of '%s' follows static declaration", Name); } From 5a30d746b404d00463efe909a9d69b3d23f3a30b Mon Sep 17 00:00:00 2001 From: bbbradsmith Date: Thu, 11 May 2023 20:15:27 -0400 Subject: [PATCH 75/98] extern/static conflict test: remove warning as errors to match the new expected cases --- test/val/decl-static-extern.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/test/val/decl-static-extern.c b/test/val/decl-static-extern.c index 6918e0033..2be4d336f 100644 --- a/test/val/decl-static-extern.c +++ b/test/val/decl-static-extern.c @@ -7,13 +7,12 @@ /* see: https://github.com/cc65/cc65/issues/191 + https://github.com/cc65/cc65/issues/2111 */ -#pragma warn(error, on) - static int n = 0; -extern int n; /* should not give an error */ -static int n; /* should not give an error */ +extern int n; /* extern is ignored, gives a warning but keeps previous static definiton */ +static int n; /* no error or warning, the previous static is still in effect */ int main(void) { From 5d9306fed35babfe0061ae31e7f90d5228367203 Mon Sep 17 00:00:00 2001 From: polluks2 <74630735+polluks2@users.noreply.github.com> Date: Fri, 12 May 2023 02:32:14 +0200 Subject: [PATCH 76/98] Fixed header #2110 --- include/stdlib.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/include/stdlib.h b/include/stdlib.h index 4e7ffbd6a..05148d7da 100644 --- a/include/stdlib.h +++ b/include/stdlib.h @@ -44,6 +44,12 @@ typedef unsigned size_t; #define _HAVE_size_t #endif +/* NULL pointer */ +#ifndef _HAVE_NULL +#define NULL ((void *) 0) +#define _HAVE_NULL +#endif + /* Standard exit codes */ #define EXIT_SUCCESS 0 #define EXIT_FAILURE 1 @@ -167,6 +173,3 @@ int __fastcall__ putenv (char* s); /* End of stdlib.h */ #endif - - - From 6579df4e91981e0516da5216e7cb9a8b82a288b9 Mon Sep 17 00:00:00 2001 From: polluks2 <74630735+polluks2@users.noreply.github.com> Date: Sun, 14 May 2023 02:43:35 +0200 Subject: [PATCH 77/98] Update stdlib.h --- include/stdlib.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/include/stdlib.h b/include/stdlib.h index 05148d7da..e789f732b 100644 --- a/include/stdlib.h +++ b/include/stdlib.h @@ -45,9 +45,8 @@ typedef unsigned size_t; #endif /* NULL pointer */ -#ifndef _HAVE_NULL -#define NULL ((void *) 0) -#define _HAVE_NULL +#ifndef NULL +#define NULL ((void *) 0) #endif /* Standard exit codes */ From 680ddaf37d034deededf7a9c814d7a9a6d3ee7c5 Mon Sep 17 00:00:00 2001 From: polluks2 <74630735+polluks2@users.noreply.github.com> Date: Sun, 14 May 2023 17:27:04 +0200 Subject: [PATCH 78/98] Update locale.h --- include/locale.h | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/include/locale.h b/include/locale.h index 3f23e01d2..f408e1ef3 100644 --- a/include/locale.h +++ b/include/locale.h @@ -39,9 +39,8 @@ /* NULL pointer */ -#ifndef _HAVE_NULL -#define NULL 0 -#define _HAVE_NULL +#ifndef NULL +#define NULL ((void *) 0) #endif /* Locale information constants */ @@ -82,6 +81,3 @@ char* __fastcall__ setlocale (int category, const char* locale); /* End of locale.h */ #endif - - - From fd74e6b005bb2d5482310cb5286081065e750310 Mon Sep 17 00:00:00 2001 From: polluks2 <74630735+polluks2@users.noreply.github.com> Date: Sun, 14 May 2023 17:28:09 +0200 Subject: [PATCH 79/98] Update stdio.h --- include/stdio.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/include/stdio.h b/include/stdio.h index 858dd5059..012b8e2ba 100644 --- a/include/stdio.h +++ b/include/stdio.h @@ -38,9 +38,8 @@ /* NULL pointer */ -#ifndef _HAVE_NULL -#define NULL 0 -#define _HAVE_NULL +#ifndef NULL +#define NULL ((void *) 0) #endif /* size_t is needed */ From c55459b287ec0c5fddbb6c695ea14e7222db1052 Mon Sep 17 00:00:00 2001 From: polluks2 <74630735+polluks2@users.noreply.github.com> Date: Sun, 14 May 2023 17:28:48 +0200 Subject: [PATCH 80/98] Update string.h --- include/string.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/include/string.h b/include/string.h index 854359dad..abaf80e7d 100644 --- a/include/string.h +++ b/include/string.h @@ -37,9 +37,8 @@ #define _STRING_H /* NULL pointer */ -#ifndef _HAVE_NULL -#define NULL 0 -#define _HAVE_NULL +#ifndef NULL +#define NULL ((void *) 0) #endif /* size_t is needed */ From ba6747f5da0dd0c3c0cfab96098ad8cc4bfec11a Mon Sep 17 00:00:00 2001 From: polluks2 <74630735+polluks2@users.noreply.github.com> Date: Sun, 14 May 2023 17:29:42 +0200 Subject: [PATCH 81/98] Update time.h --- include/time.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/include/time.h b/include/time.h index 642d68c4e..bfc2ac435 100644 --- a/include/time.h +++ b/include/time.h @@ -39,9 +39,8 @@ /* NULL pointer */ -#ifndef _HAVE_NULL -#define NULL 0 -#define _HAVE_NULL +#ifndef NULL +#define NULL ((void *) 0) #endif /* size_t is needed */ From dd58c7ff5002ad1da1522c2764d60acac27a5546 Mon Sep 17 00:00:00 2001 From: polluks2 <74630735+polluks2@users.noreply.github.com> Date: Sun, 14 May 2023 17:32:30 +0200 Subject: [PATCH 82/98] Update stddef.h --- include/stddef.h | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/include/stddef.h b/include/stddef.h index ca93edf62..d2bfd6138 100644 --- a/include/stddef.h +++ b/include/stddef.h @@ -53,9 +53,8 @@ typedef unsigned size_t; #endif /* NULL pointer */ -#ifndef _HAVE_NULL -#define NULL ((void *) 0) -#define _HAVE_NULL +#ifndef NULL +#define NULL ((void *) 0) #endif /* offsetof macro */ @@ -65,6 +64,3 @@ typedef unsigned size_t; /* End of stddef.h */ #endif - - - From 19436f515938e4b16afc214073ff40f5e1e9a45e Mon Sep 17 00:00:00 2001 From: polluks2 <74630735+polluks2@users.noreply.github.com> Date: Wed, 17 May 2023 20:24:36 +0200 Subject: [PATCH 83/98] Update gconst.h --- include/geos/gconst.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/geos/gconst.h b/include/geos/gconst.h index e70eb9304..55a99a21f 100644 --- a/include/geos/gconst.h +++ b/include/geos/gconst.h @@ -4,14 +4,14 @@ reassembled by Maciej 'YTM/Elysium' Witkowiak */ -/* Here are constants which didn't fit into any other cathegory... */ +/* Here are constants which didn't fit into any other category... */ #ifndef _GCONST_H #define _GCONST_H -#define NULL 0 -#define FALSE NULL +#define NULL ((void *) 0) #define TRUE 0xff +#define FALSE ~TRUE #define MOUSE_SPRNUM 0 #define DISK_DRV_LGH 0x0d80 From 767875b5a73f5630e75fe60a70473a17dda6a10f Mon Sep 17 00:00:00 2001 From: polluks2 <74630735+polluks2@users.noreply.github.com> Date: Thu, 18 May 2023 00:08:26 +0200 Subject: [PATCH 84/98] Added guard --- include/geos/gconst.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/geos/gconst.h b/include/geos/gconst.h index 55a99a21f..a1b6a1d86 100644 --- a/include/geos/gconst.h +++ b/include/geos/gconst.h @@ -9,7 +9,9 @@ #ifndef _GCONST_H #define _GCONST_H +#ifndef NULL #define NULL ((void *) 0) +#endif #define TRUE 0xff #define FALSE ~TRUE #define MOUSE_SPRNUM 0 From 8ff008722b97790fa65aa464b01107b8ba58967d Mon Sep 17 00:00:00 2001 From: polluks2 <74630735+polluks2@users.noreply.github.com> Date: Fri, 19 May 2023 02:49:49 +0200 Subject: [PATCH 85/98] Fixed test Don't define NULL yourself. QED --- test/val/add4.c | 1 - 1 file changed, 1 deletion(-) diff --git a/test/val/add4.c b/test/val/add4.c index f02a7fb9c..2371aea69 100644 --- a/test/val/add4.c +++ b/test/val/add4.c @@ -22,7 +22,6 @@ long long0 = 0; long long1 = 0; unsigned long ulong0 = 0; unsigned long ulong1 = 0; -#define NULL 0 char *cP0=NULL; char *cP1=NULL; int *iP0=NULL; From accd57460b5b7961b579368a49969f0888ccbbc1 Mon Sep 17 00:00:00 2001 From: polluks2 <74630735+polluks2@users.noreply.github.com> Date: Fri, 19 May 2023 15:48:31 +0200 Subject: [PATCH 86/98] Reverted gconst.h --- include/geos/gconst.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/geos/gconst.h b/include/geos/gconst.h index a1b6a1d86..3e42feed7 100644 --- a/include/geos/gconst.h +++ b/include/geos/gconst.h @@ -12,8 +12,8 @@ #ifndef NULL #define NULL ((void *) 0) #endif +#define FALSE 0 #define TRUE 0xff -#define FALSE ~TRUE #define MOUSE_SPRNUM 0 #define DISK_DRV_LGH 0x0d80 From 40ff9281c6ea020726cd8deb1ffb7b0a2b8bf6e9 Mon Sep 17 00:00:00 2001 From: polluks2 <74630735+polluks2@users.noreply.github.com> Date: Fri, 19 May 2023 16:36:19 +0200 Subject: [PATCH 87/98] Fixed typo --- doc/funcref.sgml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/funcref.sgml b/doc/funcref.sgml index 6418723b5..2a6d77adc 100644 --- a/doc/funcref.sgml +++ b/doc/funcref.sgml @@ -976,7 +976,7 @@ previously been allocated by /, / or /. Passing a pointer to a block that was is not the result of one of the -allocation functions, or that has been free'd will give unpredicable results. +allocation functions, or that has been free'd will give unpredictable results. The function is available only as a fastcall function; so, it may be used only in the presence of a prototype. From 1377ba0d360aaa0cb505c7bd78129c2c7d4c4cb4 Mon Sep 17 00:00:00 2001 From: jede Date: Tue, 23 May 2023 23:08:56 +0200 Subject: [PATCH 88/98] fix compute length for read and write for telestrat target --- libsrc/telestrat/read.s | 15 ++++++++------- libsrc/telestrat/write.s | 16 ++++++++-------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/libsrc/telestrat/read.s b/libsrc/telestrat/read.s index f31909f45..b89f246cc 100644 --- a/libsrc/telestrat/read.s +++ b/libsrc/telestrat/read.s @@ -30,13 +30,14 @@ ldy ptr1+1 BRK_TELEMON XFREAD ; compute nb of bytes read - lda PTR_READ_DEST+1 sec - sbc ptr2+1 - tax - lda PTR_READ_DEST - sec - sbc ptr2 - ; here A and X contains number of bytes read + lda PTR_READ_DEST + sbc ptr2 + sta tmp1 + lda PTR_READ_DEST+1 + sbc ptr2+1 + tax + lda tmp1 + rts .endproc diff --git a/libsrc/telestrat/write.s b/libsrc/telestrat/write.s index 2ce2657ac..06524f749 100644 --- a/libsrc/telestrat/write.s +++ b/libsrc/telestrat/write.s @@ -42,16 +42,16 @@ next: ldy ptr3+1 ldx tmp1 ; send fd in X BRK_TELEMON XFWRITE + ; compute nb of bytes written - - - lda PTR_READ_DEST+1 sec - sbc ptr1+1 - tax - lda PTR_READ_DEST - sec - sbc ptr1 + lda PTR_READ_DEST + sbc ptr1 + sta tmp1 + lda PTR_READ_DEST+1 + sbc ptr1+1 + tax + lda tmp1 rts From 1ca9d7e9e707658e2777784fb607d3cabb48b25c Mon Sep 17 00:00:00 2001 From: jede Date: Tue, 23 May 2023 23:15:23 +0200 Subject: [PATCH 89/98] fix tab --- libsrc/telestrat/read.s | 12 ++++++------ libsrc/telestrat/write.s | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/libsrc/telestrat/read.s b/libsrc/telestrat/read.s index b89f246cc..1d2315dce 100644 --- a/libsrc/telestrat/read.s +++ b/libsrc/telestrat/read.s @@ -31,12 +31,12 @@ BRK_TELEMON XFREAD ; compute nb of bytes read sec - lda PTR_READ_DEST - sbc ptr2 - sta tmp1 - lda PTR_READ_DEST+1 - sbc ptr2+1 - tax + lda PTR_READ_DEST + sbc ptr2 + sta tmp1 + lda PTR_READ_DEST+1 + sbc ptr2+1 + tax lda tmp1 rts diff --git a/libsrc/telestrat/write.s b/libsrc/telestrat/write.s index 06524f749..16bc64d69 100644 --- a/libsrc/telestrat/write.s +++ b/libsrc/telestrat/write.s @@ -45,12 +45,12 @@ next: ; compute nb of bytes written sec - lda PTR_READ_DEST - sbc ptr1 - sta tmp1 - lda PTR_READ_DEST+1 - sbc ptr1+1 - tax + lda PTR_READ_DEST + sbc ptr1 + sta tmp1 + lda PTR_READ_DEST+1 + sbc ptr1+1 + tax lda tmp1 rts From 480600093cef2d67d5e39253364c258d6266300e Mon Sep 17 00:00:00 2001 From: jede Date: Thu, 25 May 2023 18:09:03 +0200 Subject: [PATCH 90/98] fix pla/pha instead of tmp1 --- libsrc/telestrat/read.s | 4 ++-- libsrc/telestrat/write.s | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libsrc/telestrat/read.s b/libsrc/telestrat/read.s index 1d2315dce..736546363 100644 --- a/libsrc/telestrat/read.s +++ b/libsrc/telestrat/read.s @@ -33,11 +33,11 @@ sec lda PTR_READ_DEST sbc ptr2 - sta tmp1 + pha lda PTR_READ_DEST+1 sbc ptr2+1 tax - lda tmp1 + pla rts .endproc diff --git a/libsrc/telestrat/write.s b/libsrc/telestrat/write.s index 16bc64d69..37a896696 100644 --- a/libsrc/telestrat/write.s +++ b/libsrc/telestrat/write.s @@ -47,11 +47,11 @@ next: sec lda PTR_READ_DEST sbc ptr1 - sta tmp1 + pha lda PTR_READ_DEST+1 sbc ptr1+1 tax - lda tmp1 + pla rts From c8aa9cc70372accedf5c506ab48090d0890caf4f Mon Sep 17 00:00:00 2001 From: mrdudz Date: Mon, 29 May 2023 17:20:09 +0200 Subject: [PATCH 91/98] add struct assign check related to #2079 --- test/val/bug2079-struct-assign.c | 66 ++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 test/val/bug2079-struct-assign.c diff --git a/test/val/bug2079-struct-assign.c b/test/val/bug2079-struct-assign.c new file mode 100644 index 000000000..b8a41fe8b --- /dev/null +++ b/test/val/bug2079-struct-assign.c @@ -0,0 +1,66 @@ + +/* test struct assignment, of structs with a length of 3, which happen to be + a special case eg when passing/returning structs + related to bugs #2022, #2079 */ + +#include +#include + +int failures = 0; + +struct foo { char a; char b; char c; }; +struct foo foo, bar; +void f3(void) +{ + foo.a = 6; + foo.b = 6; + foo.c = 6; + bar.a = 1; + bar.b = 2; + bar.c = 3; + foo = bar; + printf("%d %d %d, %d %d %d (1,2,3 1,2,3)\n", + foo.a, foo.b, foo.c, + bar.a, bar.b, bar.c); + if ((foo.a != 1) || (foo.b != 2) || (foo.c != 3) || + (bar.a != 1) || (bar.b != 2) || (bar.c != 3)) { + failures++; + } + foo.a = 3; + foo.b = 2; + foo.c = 1; + printf("%d %d %d, %d %d %d (3,2,1 1,2,3)\n", + foo.a, foo.b, foo.c, + bar.a, bar.b, bar.c); + if ((foo.a != 3) || (foo.b != 2) || (foo.c != 1) || + (bar.a != 1) || (bar.b != 2) || (bar.c != 3)) { + failures++; + } + bar.a = 5; + bar.b = 6; + bar.c = 7; + printf("%d %d %d, %d %d %d (3,2,1 5,6,7)\n", + foo.a, foo.b, foo.c, + bar.a, bar.b, bar.c); + if ((foo.a != 3) || (foo.b != 2) || (foo.c != 1) || + (bar.a != 5) || (bar.b != 6) || (bar.c != 7)) { + failures++; + } + bar = foo; + foo.a = 6; + foo.b = 6; + foo.c = 6; + printf("%d %d %d, %d %d %d (6,6,6 3,2,1)\n", + foo.a, foo.b, foo.c, + bar.a, bar.b, bar.c); + if ((foo.a != 6) || (foo.b != 6) || (foo.c != 6) || + (bar.a != 3) || (bar.b != 2) || (bar.c != 1)) { + failures++; + } +} + +int main(void) +{ + f3(); + return failures; +} From 59941d94642a6fc25c6392486fca2b7e4aae46bf Mon Sep 17 00:00:00 2001 From: MooingLemur Date: Thu, 15 Jun 2023 21:30:26 -0400 Subject: [PATCH 92/98] cx16: use KERNAL memsiz for MEMSIZE in asminc/cx16.inc --- asminc/cx16.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/asminc/cx16.inc b/asminc/cx16.inc index be63780c8..d264add38 100644 --- a/asminc/cx16.inc +++ b/asminc/cx16.inc @@ -259,7 +259,7 @@ NLINES := $0387 ; Number of screen lines ; BASIC VARTAB := $03E1 ; Pointer to start of BASIC variables -MEMSIZE := $03E9 ; Pointer to highest BASIC RAM location (+1) +MEMSIZE := $0259 ; Pointer to highest BASIC RAM location (+1) ; --------------------------------------------------------------------------- ; Vector and other locations From 3e166c760dcd7dd071aa86f464ce480bf07504e9 Mon Sep 17 00:00:00 2001 From: baktragh Date: Mon, 26 Jun 2023 16:38:41 +0200 Subject: [PATCH 93/98] Update _atari5200os.h with POT shadows Update the OS struct with POT shadow registers, according to the https://web.archive.org/web/20120830055323/http://www.atarimuseum.com/videogames/consoles/5200/conv_to_5200.html document --- include/_atari5200os.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/include/_atari5200os.h b/include/_atari5200os.h index 5bba43016..88636dc7f 100644 --- a/include/_atari5200os.h +++ b/include/_atari5200os.h @@ -54,7 +54,15 @@ struct __os { unsigned char color2; // = $0E PF color 2 unsigned char color3; // = $0F PF color 3 unsigned char color4; // = $10 PF color 4 - unsigned char _free_1[0xEF]; // = $11-$FF User space + unsigned char pot0; // = $11 POT0 shadow + unsigned char pot1; // = $12 POT1 shadow + unsigned char pot2; // = $13 POT2 shadow + unsigned char pot3; // = $14 POT3 shadow + unsigned char pot4; // = $15 POT4 shadow + unsigned char pot5; // = $16 POT5 shadow + unsigned char pot6; // = $17 POT6 shadow + unsigned char pot7; // = $18 POT7 shadow + unsigned char _free_1[0xE7]; // = $19-$FF User space /*Stack*/ unsigned char stack[0x100]; // = $100-$1FF Stack From aaec2a627092f4bad90aa408258559ec341a209a Mon Sep 17 00:00:00 2001 From: baktragh Date: Mon, 26 Jun 2023 16:46:42 +0200 Subject: [PATCH 94/98] Update _atari5200os.h - Remove dangling spaces --- include/_atari5200os.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/include/_atari5200os.h b/include/_atari5200os.h index 88636dc7f..2e861e797 100644 --- a/include/_atari5200os.h +++ b/include/_atari5200os.h @@ -54,14 +54,14 @@ struct __os { unsigned char color2; // = $0E PF color 2 unsigned char color3; // = $0F PF color 3 unsigned char color4; // = $10 PF color 4 - unsigned char pot0; // = $11 POT0 shadow - unsigned char pot1; // = $12 POT1 shadow - unsigned char pot2; // = $13 POT2 shadow - unsigned char pot3; // = $14 POT3 shadow - unsigned char pot4; // = $15 POT4 shadow - unsigned char pot5; // = $16 POT5 shadow - unsigned char pot6; // = $17 POT6 shadow - unsigned char pot7; // = $18 POT7 shadow + unsigned char pot0; // = $11 POT0 shadow + unsigned char pot1; // = $12 POT1 shadow + unsigned char pot2; // = $13 POT2 shadow + unsigned char pot3; // = $14 POT3 shadow + unsigned char pot4; // = $15 POT4 shadow + unsigned char pot5; // = $16 POT5 shadow + unsigned char pot6; // = $17 POT6 shadow + unsigned char pot7; // = $18 POT7 shadow unsigned char _free_1[0xE7]; // = $19-$FF User space /*Stack*/ From 6c127d6a836ee409f9839224cf74f35eeafb96d7 Mon Sep 17 00:00:00 2001 From: baktragh Date: Sun, 2 Jul 2023 14:59:00 +0200 Subject: [PATCH 95/98] Update _atari5200os.h Update the page 0 symbols, synchronize the names with the _atarios.h, add locations used by Atari 5200 conio --- include/_atari5200os.h | 44 ++++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/include/_atari5200os.h b/include/_atari5200os.h index 2e861e797..d6f7d3875 100644 --- a/include/_atari5200os.h +++ b/include/_atari5200os.h @@ -44,25 +44,31 @@ struct __os { void* sdlst; // = $05,$06 Display list shadow }; - unsigned char sdmctl; // = $07 DMACTL shadow - unsigned char pcolr0; // = $08 PM color 0 - unsigned char pcolr1; // = $09 PM color 1 - unsigned char pcolr2; // = $0A PM color 2 - unsigned char pcolr3; // = $0B PM color 3 - unsigned char color0; // = $0C PF color 0 - unsigned char color1; // = $0D PF color 1 - unsigned char color2; // = $0E PF color 2 - unsigned char color3; // = $0F PF color 3 - unsigned char color4; // = $10 PF color 4 - unsigned char pot0; // = $11 POT0 shadow - unsigned char pot1; // = $12 POT1 shadow - unsigned char pot2; // = $13 POT2 shadow - unsigned char pot3; // = $14 POT3 shadow - unsigned char pot4; // = $15 POT4 shadow - unsigned char pot5; // = $16 POT5 shadow - unsigned char pot6; // = $17 POT6 shadow - unsigned char pot7; // = $18 POT7 shadow - unsigned char _free_1[0xE7]; // = $19-$FF User space + unsigned char sdmctl; // = $07 DMACTL shadow + unsigned char pcolr0; // = $08 PM color 0 + unsigned char pcolr1; // = $09 PM color 1 + unsigned char pcolr2; // = $0A PM color 2 + unsigned char pcolr3; // = $0B PM color 3 + unsigned char color0; // = $0C PF color 0 + unsigned char color1; // = $0D PF color 1 + unsigned char color2; // = $0E PF color 2 + unsigned char color3; // = $0F PF color 3 + unsigned char color4; // = $10 PF color 4 + unsigned char paddl0; // = $11 POT0 Shadow + unsigned char paddl1; // = $12 POT1 Shadow + unsigned char paddl2; // = $13 POT2 Shadow + unsigned char paddl3; // = $14 POT3 Shadow + unsigned char paddl4; // = $15 POT4 Shadow + unsigned char paddl5; // = $16 POT5 Shadow + unsigned char paddl6; // = $17 POT6 Shadow + unsigned char paddl7; // = $18 POT7 Shadow + + /*cc65 runtime zero page variables*/ + unsigned char rowcrs_5200; // = $19 Cursor row (conio) + unsigned char colcrs_5200; // = $1A Cursor column (conio) + unsigned char* savmsc; // = $1B/$1C Pointer to screen memory (conio) + + unsigned char _filler_1[0xE3]; // = $1D-$FF Filler /*Stack*/ unsigned char stack[0x100]; // = $100-$1FF Stack From 7a85473cb0dfcc180048c1c8892cb9bf039ca406 Mon Sep 17 00:00:00 2001 From: baktragh Date: Sun, 2 Jul 2023 15:16:33 +0200 Subject: [PATCH 96/98] Update _atari5200os.h Remove dangling spaces --- include/_atari5200os.h | 50 +++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/include/_atari5200os.h b/include/_atari5200os.h index d6f7d3875..196b69e56 100644 --- a/include/_atari5200os.h +++ b/include/_atari5200os.h @@ -44,31 +44,31 @@ struct __os { void* sdlst; // = $05,$06 Display list shadow }; - unsigned char sdmctl; // = $07 DMACTL shadow - unsigned char pcolr0; // = $08 PM color 0 - unsigned char pcolr1; // = $09 PM color 1 - unsigned char pcolr2; // = $0A PM color 2 - unsigned char pcolr3; // = $0B PM color 3 - unsigned char color0; // = $0C PF color 0 - unsigned char color1; // = $0D PF color 1 - unsigned char color2; // = $0E PF color 2 - unsigned char color3; // = $0F PF color 3 - unsigned char color4; // = $10 PF color 4 - unsigned char paddl0; // = $11 POT0 Shadow - unsigned char paddl1; // = $12 POT1 Shadow - unsigned char paddl2; // = $13 POT2 Shadow - unsigned char paddl3; // = $14 POT3 Shadow - unsigned char paddl4; // = $15 POT4 Shadow - unsigned char paddl5; // = $16 POT5 Shadow - unsigned char paddl6; // = $17 POT6 Shadow - unsigned char paddl7; // = $18 POT7 Shadow - - /*cc65 runtime zero page variables*/ - unsigned char rowcrs_5200; // = $19 Cursor row (conio) - unsigned char colcrs_5200; // = $1A Cursor column (conio) - unsigned char* savmsc; // = $1B/$1C Pointer to screen memory (conio) - - unsigned char _filler_1[0xE3]; // = $1D-$FF Filler + unsigned char sdmctl; // = $07 DMACTL shadow + unsigned char pcolr0; // = $08 PM color 0 + unsigned char pcolr1; // = $09 PM color 1 + unsigned char pcolr2; // = $0A PM color 2 + unsigned char pcolr3; // = $0B PM color 3 + unsigned char color0; // = $0C PF color 0 + unsigned char color1; // = $0D PF color 1 + unsigned char color2; // = $0E PF color 2 + unsigned char color3; // = $0F PF color 3 + unsigned char color4; // = $10 PF color 4 + unsigned char paddl0; // = $11 POT0 Shadow + unsigned char paddl1; // = $12 POT1 Shadow + unsigned char paddl2; // = $13 POT2 Shadow + unsigned char paddl3; // = $14 POT3 Shadow + unsigned char paddl4; // = $15 POT4 Shadow + unsigned char paddl5; // = $16 POT5 Shadow + unsigned char paddl6; // = $17 POT6 Shadow + unsigned char paddl7; // = $18 POT7 Shadow + + /*cc65 runtime zero page variables*/ + unsigned char rowcrs_5200; // = $19 Cursor row (conio) + unsigned char colcrs_5200; // = $1A Cursor column (conio) + unsigned char* savmsc; // = $1B/$1C Pointer to screen memory (conio) + + unsigned char _filler_1[0xE3]; // = $1D-$FF Filler /*Stack*/ unsigned char stack[0x100]; // = $100-$1FF Stack From 1f68846116fd1b1bb6b7ca1ae8e9c45974bce6b9 Mon Sep 17 00:00:00 2001 From: Colin Leroy-Mira Date: Fri, 18 Aug 2023 11:12:16 +0200 Subject: [PATCH 97/98] Avoid using mli.s to initcwd --- libsrc/apple2/initcwd.s | 43 ++++++++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/libsrc/apple2/initcwd.s b/libsrc/apple2/initcwd.s index 7a12bc52a..75224d019 100644 --- a/libsrc/apple2/initcwd.s +++ b/libsrc/apple2/initcwd.s @@ -3,22 +3,39 @@ ; .export initcwd - .import __cwd + .import __cwd, __dos_type .include "zeropage.inc" + .include "apple2.inc" .include "mli.inc" -initcwd: - ; Set static prefix buffer - lda #<__cwd - ldx #>__cwd - sta mliparam + MLI::PREFIX::PATHNAME - stx mliparam + MLI::PREFIX::PATHNAME+1 +mli_parameters: + .byte $01 ; number of parameters + .addr __cwd ; address of parameter - ; Get current working directory - lda #GET_PREFIX_CALL - ldx #PREFIX_COUNT - jsr callmli +initcwd: + ; Check for ProDOS 8 + lda __dos_type + beq oserr + + ; Save random counter + lda RNDL + pha + lda RNDH + pha + + ; Call MLI + jsr $BF00 ; MLI call entry point + .byte GET_PREFIX_CALL ; MLI command + .addr mli_parameters ; MLI parameter + + ; Restore random counter + tax + pla + sta RNDH + pla + sta RNDL + txa ; Check for null prefix ldx __cwd @@ -39,3 +56,7 @@ initcwd: sta __cwd,x done: rts + +oserr: lda #$01 ; "Bad system call number" + sec + rts From 148be69f9705ce78900b2f9bbfb560da8c027b39 Mon Sep 17 00:00:00 2001 From: Colin Leroy-Mira Date: Fri, 18 Aug 2023 14:36:52 +0200 Subject: [PATCH 98/98] Optimize and fix comments (thanks to Oliver Schmidt) --- libsrc/apple2/initcwd.s | 20 ++++++++++---------- libsrc/apple2/syschdir.s | 3 ++- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/libsrc/apple2/initcwd.s b/libsrc/apple2/initcwd.s index 75224d019..03e13bcfb 100644 --- a/libsrc/apple2/initcwd.s +++ b/libsrc/apple2/initcwd.s @@ -9,14 +9,10 @@ .include "apple2.inc" .include "mli.inc" -mli_parameters: - .byte $01 ; number of parameters - .addr __cwd ; address of parameter - initcwd: ; Check for ProDOS 8 lda __dos_type - beq oserr + beq done ; Save random counter lda RNDL @@ -25,17 +21,19 @@ initcwd: pha ; Call MLI + ; We're not using mli.s' callmli because its + ; mliparam is in BSS and this will be called + ; before LC code is moved to the Language Card. + jsr $BF00 ; MLI call entry point .byte GET_PREFIX_CALL ; MLI command .addr mli_parameters ; MLI parameter ; Restore random counter - tax pla sta RNDH pla sta RNDL - txa ; Check for null prefix ldx __cwd @@ -57,6 +55,8 @@ initcwd: done: rts -oserr: lda #$01 ; "Bad system call number" - sec - rts + .rodata + +mli_parameters: + .byte $01 ; Number of parameters + .addr __cwd ; Address of parameter diff --git a/libsrc/apple2/syschdir.s b/libsrc/apple2/syschdir.s index 8afc3af0b..b3f81e2a5 100644 --- a/libsrc/apple2/syschdir.s +++ b/libsrc/apple2/syschdir.s @@ -29,7 +29,8 @@ __syschdir: bcs cleanup ; Update current working directory - jsr initcwd ; Returns with A = 0 + jsr initcwd + lda #$00 ; Cleanup name cleanup:jsr popname ; Preserves A