diff --git a/test/val/postdec-16-16.c b/test/val/postdec-16-16.c new file mode 100644 index 000000000..e55b5765f --- /dev/null +++ b/test/val/postdec-16-16.c @@ -0,0 +1,86 @@ + +#include +#include +#include +#ifdef __C64__ +#include +#endif + +/* apparently we dont trigger the bug when not using absolute addresses? */ +#ifdef __C64__ +#define TARGETMEM 0x4c8 +#define SOURCEMEM 0x702 +#elif __SIM6502__ +#define TARGETMEM 0xc4c8 +#define SOURCEMEM 0xc702 +#elif __SIM65C02__ +#define TARGETMEM 0xc4c8 +#define SOURCEMEM 0xc702 +#else +static unsigned char mem[0x10]; +#define TARGETMEM &mem[0] +#define SOURCEMEM &mem[8] +#endif + +/* do not put at pos. 1, and 1 byte apart - so we can eventually notice + off-by-one errors */ +static unsigned short u16w = 3; +static unsigned short u16r = 5; + +static unsigned char target[8] = { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7 }; +static unsigned char source[8] = { 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf }; +static unsigned char expect[8] = { 0x0, 0x1, 0xc, 0xd, 0x4, 0x5, 0x6, 0x7 }; + +static unsigned char i; +static unsigned char err = EXIT_SUCCESS; + +void test1(void) +{ + ((unsigned char*)TARGETMEM)[u16w--] = ((unsigned char*)SOURCEMEM)[u16r--]; +} + +void dotest(void) +{ + + memcpy(TARGETMEM, target, 8); + memcpy(SOURCEMEM, source, 8); + + test1(); + + memcpy(target, TARGETMEM, 8); + memcpy(source, SOURCEMEM, 8); +#ifdef __C64__ + clrscr(); +#endif + printf("source:"); + for(i = 0; i < 8; ++i) { + printf("%0x ", source[i]); + } + printf("\n\rtarget:"); + for(i = 0; i < 8; ++i) { + printf("%0x ", target[i]); + } + printf("\n\r"); + + printf("u16w: %d\n\r", u16w); + printf("u16r: %d\n\r", u16r); + +} + +int main(void) +{ + dotest(); + dotest(); + if (memcmp(target, expect, 8) != 0) { + printf("buffer data error\n\r"); + err = EXIT_FAILURE; + } + if (u16w != 1) { + err = EXIT_FAILURE; + } + if (u16r != 3) { + err = EXIT_FAILURE; + } + printf("return: %d\n\r", err); + return err; +} diff --git a/test/val/postdec-16-8.c b/test/val/postdec-16-8.c new file mode 100644 index 000000000..76a64d769 --- /dev/null +++ b/test/val/postdec-16-8.c @@ -0,0 +1,86 @@ + +#include +#include +#include +#ifdef __C64__ +#include +#endif + +/* apparently we dont trigger the bug when not using absolute addresses? */ +#ifdef __C64__ +#define TARGETMEM 0x4c8 +#define SOURCEMEM 0x702 +#elif __SIM6502__ +#define TARGETMEM 0xc4c8 +#define SOURCEMEM 0xc702 +#elif __SIM65C02__ +#define TARGETMEM 0xc4c8 +#define SOURCEMEM 0xc702 +#else +static unsigned char mem[0x10]; +#define TARGETMEM &mem[0] +#define SOURCEMEM &mem[8] +#endif + +/* do not put at pos. 1, and 1 byte apart - so we can eventually notice + off-by-one errors */ +static unsigned short u16w = 3; +static unsigned char u8r = 5; + +static unsigned char target[8] = { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7 }; +static unsigned char source[8] = { 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf }; +static unsigned char expect[8] = { 0x0, 0x1, 0xc, 0xd, 0x4, 0x5, 0x6, 0x7 }; + +static unsigned char i; +static unsigned char err = EXIT_SUCCESS; + +void test1(void) +{ + ((unsigned char*)TARGETMEM)[u16w--] = ((unsigned char*)SOURCEMEM)[u8r--]; +} + +void dotest(void) +{ + + memcpy(TARGETMEM, target, 8); + memcpy(SOURCEMEM, source, 8); + + test1(); + + memcpy(target, TARGETMEM, 8); + memcpy(source, SOURCEMEM, 8); +#ifdef __C64__ + clrscr(); +#endif + printf("source:"); + for(i = 0; i < 8; ++i) { + printf("%0x ", source[i]); + } + printf("\n\rtarget:"); + for(i = 0; i < 8; ++i) { + printf("%0x ", target[i]); + } + printf("\n\r"); + + printf("u16w: %d\n\r", u16w); + printf("u8r: %d\n\r", u8r); + +} + +int main(void) +{ + dotest(); + dotest(); + if (memcmp(target, expect, 8) != 0) { + printf("buffer data error\n\r"); + err = EXIT_FAILURE; + } + if (u16w != 1) { + err = EXIT_FAILURE; + } + if (u8r != 3) { + err = EXIT_FAILURE; + } + printf("return: %d\n\r", err); + return err; +} diff --git a/test/val/postdec-8-16.c b/test/val/postdec-8-16.c new file mode 100644 index 000000000..f7716ae89 --- /dev/null +++ b/test/val/postdec-8-16.c @@ -0,0 +1,86 @@ + +#include +#include +#include +#ifdef __C64__ +#include +#endif + +/* apparently we dont trigger the bug when not using absolute addresses? */ +#ifdef __C64__ +#define TARGETMEM 0x4c8 +#define SOURCEMEM 0x702 +#elif __SIM6502__ +#define TARGETMEM 0xc4c8 +#define SOURCEMEM 0xc702 +#elif __SIM65C02__ +#define TARGETMEM 0xc4c8 +#define SOURCEMEM 0xc702 +#else +static unsigned char mem[0x10]; +#define TARGETMEM &mem[0] +#define SOURCEMEM &mem[8] +#endif + +/* do not put at pos. 1, and 1 byte apart - so we can eventually notice + off-by-one errors */ +static unsigned char u8w = 3; +static unsigned short u16r = 5; + +static unsigned char target[8] = { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7 }; +static unsigned char source[8] = { 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf }; +static unsigned char expect[8] = { 0x0, 0x1, 0xc, 0xd, 0x4, 0x5, 0x6, 0x7 }; + +static unsigned char i; +static unsigned char err = EXIT_SUCCESS; + +void test1(void) +{ + ((unsigned char*)TARGETMEM)[u8w--] = ((unsigned char*)SOURCEMEM)[u16r--]; +} + +void dotest(void) +{ + + memcpy(TARGETMEM, target, 8); + memcpy(SOURCEMEM, source, 8); + + test1(); + + memcpy(target, TARGETMEM, 8); + memcpy(source, SOURCEMEM, 8); +#ifdef __C64__ + clrscr(); +#endif + printf("source:"); + for(i = 0; i < 8; ++i) { + printf("%0x ", source[i]); + } + printf("\n\rtarget:"); + for(i = 0; i < 8; ++i) { + printf("%0x ", target[i]); + } + printf("\n\r"); + + printf("u8w: %d\n\r", u8w); + printf("u16r: %d\n\r", u16r); + +} + +int main(void) +{ + dotest(); + dotest(); + if (memcmp(target, expect, 8) != 0) { + printf("buffer data error\n\r"); + err = EXIT_FAILURE; + } + if (u8w != 1) { + err = EXIT_FAILURE; + } + if (u16r != 3) { + err = EXIT_FAILURE; + } + printf("return: %d\n\r", err); + return err; +} diff --git a/test/val/postdec-8-8.c b/test/val/postdec-8-8.c new file mode 100644 index 000000000..b620c46dc --- /dev/null +++ b/test/val/postdec-8-8.c @@ -0,0 +1,86 @@ + +#include +#include +#include +#ifdef __C64__ +#include +#endif + +/* apparently we dont trigger the bug when not using absolute addresses? */ +#ifdef __C64__ +#define TARGETMEM 0x4c8 +#define SOURCEMEM 0x702 +#elif __SIM6502__ +#define TARGETMEM 0xc4c8 +#define SOURCEMEM 0xc702 +#elif __SIM65C02__ +#define TARGETMEM 0xc4c8 +#define SOURCEMEM 0xc702 +#else +static unsigned char mem[0x10]; +#define TARGETMEM &mem[0] +#define SOURCEMEM &mem[8] +#endif + +/* do not put at pos. 1, and 1 byte apart - so we can eventually notice + off-by-one errors */ +static unsigned char u8w = 3; +static unsigned char u8r = 5; + +static unsigned char target[8] = { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7 }; +static unsigned char source[8] = { 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf }; +static unsigned char expect[8] = { 0x0, 0x1, 0xc, 0xd, 0x4, 0x5, 0x6, 0x7 }; + +static unsigned char i; +static unsigned char err = EXIT_SUCCESS; + +void test1(void) +{ + ((unsigned char*)TARGETMEM)[u8w--] = ((unsigned char*)SOURCEMEM)[u8r--]; +} + +void dotest(void) +{ + + memcpy(TARGETMEM, target, 8); + memcpy(SOURCEMEM, source, 8); + + test1(); + + memcpy(target, TARGETMEM, 8); + memcpy(source, SOURCEMEM, 8); +#ifdef __C64__ + clrscr(); +#endif + printf("source:"); + for(i = 0; i < 8; ++i) { + printf("%0x ", source[i]); + } + printf("\n\rtarget:"); + for(i = 0; i < 8; ++i) { + printf("%0x ", target[i]); + } + printf("\n\r"); + + printf("u8w: %d\n\r", u8w); + printf("u8r: %d\n\r", u8r); + +} + +int main(void) +{ + dotest(); + dotest(); + if (memcmp(target, expect, 8) != 0) { + printf("buffer data error\n\r"); + err = EXIT_FAILURE; + } + if (u8w != 1) { + err = EXIT_FAILURE; + } + if (u8r != 3) { + err = EXIT_FAILURE; + } + printf("return: %d\n\r", err); + return err; +} diff --git a/test/val/postinc-16-16.c b/test/val/postinc-16-16.c new file mode 100644 index 000000000..286e0364b --- /dev/null +++ b/test/val/postinc-16-16.c @@ -0,0 +1,86 @@ + +#include +#include +#include +#ifdef __C64__ +#include +#endif + +/* apparently we dont trigger the bug when not using absolute addresses? */ +#ifdef __C64__ +#define TARGETMEM 0x4c8 +#define SOURCEMEM 0x702 +#elif __SIM6502__ +#define TARGETMEM 0xc4c8 +#define SOURCEMEM 0xc702 +#elif __SIM65C02__ +#define TARGETMEM 0xc4c8 +#define SOURCEMEM 0xc702 +#else +static unsigned char mem[0x10]; +#define TARGETMEM &mem[0] +#define SOURCEMEM &mem[8] +#endif + +/* do not put at pos. 1, and 1 byte apart - so we can eventually notice + off-by-one errors */ +static unsigned short u16w = 1; +static unsigned short u16r = 3; + +static unsigned char target[8] = { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7 }; +static unsigned char source[8] = { 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf }; +static unsigned char expect[8] = { 0x0, 0xb, 0xc, 0x3, 0x4, 0x5, 0x6, 0x7 }; + +static unsigned char i; +static unsigned char err = EXIT_SUCCESS; + +void test1(void) +{ + ((unsigned char*)TARGETMEM)[u16w++] = ((unsigned char*)SOURCEMEM)[u16r++]; +} + +void dotest(void) +{ + + memcpy(TARGETMEM, target, 8); + memcpy(SOURCEMEM, source, 8); + + test1(); + + memcpy(target, TARGETMEM, 8); + memcpy(source, SOURCEMEM, 8); +#ifdef __C64__ + clrscr(); +#endif + printf("source:"); + for(i = 0; i < 8; ++i) { + printf("%0x ", source[i]); + } + printf("\n\rtarget:"); + for(i = 0; i < 8; ++i) { + printf("%0x ", target[i]); + } + printf("\n\r"); + + printf("u16w: %d\n\r", u16w); + printf("u16r: %d\n\r", u16r); + +} + +int main(void) +{ + dotest(); + dotest(); + if (memcmp(target, expect, 8) != 0) { + printf("buffer data error\n\r"); + err = EXIT_FAILURE; + } + if (u16w != 3) { + err = EXIT_FAILURE; + } + if (u16r != 5) { + err = EXIT_FAILURE; + } + printf("return: %d\n\r", err); + return err; +} diff --git a/test/val/postinc-16-8.c b/test/val/postinc-16-8.c new file mode 100644 index 000000000..dd0a03d6c --- /dev/null +++ b/test/val/postinc-16-8.c @@ -0,0 +1,85 @@ + +#include +#include +#ifdef __C64__ +#include +#endif + +/* apparently we dont trigger the bug when not using absolute addresses? */ +#ifdef __C64__ +#define TARGETMEM 0x4c8 +#define SOURCEMEM 0x702 +#elif __SIM6502__ +#define TARGETMEM 0xc4c8 +#define SOURCEMEM 0xc702 +#elif __SIM65C02__ +#define TARGETMEM 0xc4c8 +#define SOURCEMEM 0xc702 +#else +static unsigned char mem[0x10]; +#define TARGETMEM &mem[0] +#define SOURCEMEM &mem[8] +#endif + +/* do not put at pos. 1, and 1 byte apart - so we can eventually notice + off-by-one errors */ +static unsigned short u16w = 1; +static unsigned char u8r = 3; + +static unsigned char target[8] = { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7 }; +static unsigned char source[8] = { 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf }; +static unsigned char expect[8] = { 0x0, 0xb, 0xc, 0x3, 0x4, 0x5, 0x6, 0x7 }; + +static unsigned char i; +static unsigned char err = 0; + +void test1(void) +{ + ((unsigned char*)TARGETMEM)[u16w++] = ((unsigned char*)SOURCEMEM)[u8r++]; +} + +void dotest(void) +{ + + memcpy(TARGETMEM, target, 8); + memcpy(SOURCEMEM, source, 8); + + test1(); + + memcpy(target, TARGETMEM, 8); + memcpy(source, SOURCEMEM, 8); +#ifdef __C64__ + clrscr(); +#endif + printf("source:"); + for(i = 0; i < 8; ++i) { + printf("%0x ", source[i]); + } + printf("\n\rtarget:"); + for(i = 0; i < 8; ++i) { + printf("%0x ", target[i]); + } + printf("\n\r"); + + printf("u16w: %d\n\r", u16w); + printf("u8r: %d\n\r", u8r); + +} + +int main(void) +{ + dotest(); + dotest(); + if (memcmp(target, expect, 8) != 0) { + printf("buffer data error\n\r"); + err = 1; + } + if (u16w != 3) { + err = 1; + } + if (u8r != 5) { + err = 1; + } + printf("return: %d\n\r", err); + return err; +} diff --git a/test/val/postinc-8-16.c b/test/val/postinc-8-16.c new file mode 100644 index 000000000..57e934ced --- /dev/null +++ b/test/val/postinc-8-16.c @@ -0,0 +1,86 @@ + +#include +#include +#include +#ifdef __C64__ +#include +#endif + +/* apparently we dont trigger the bug when not using absolute addresses? */ +#ifdef __C64__ +#define TARGETMEM 0x4c8 +#define SOURCEMEM 0x702 +#elif __SIM6502__ +#define TARGETMEM 0xc4c8 +#define SOURCEMEM 0xc702 +#elif __SIM65C02__ +#define TARGETMEM 0xc4c8 +#define SOURCEMEM 0xc702 +#else +static unsigned char mem[0x10]; +#define TARGETMEM &mem[0] +#define SOURCEMEM &mem[8] +#endif + +/* do not put at pos. 1, and 1 byte apart - so we can eventually notice + off-by-one errors */ +static unsigned char u8w = 1; +static unsigned short u16r = 3; + +static unsigned char target[8] = { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7 }; +static unsigned char source[8] = { 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf }; +static unsigned char expect[8] = { 0x0, 0xb, 0xc, 0x3, 0x4, 0x5, 0x6, 0x7 }; + +static unsigned char i; +static unsigned char err = EXIT_SUCCESS; + +void test1(void) +{ + ((unsigned char*)TARGETMEM)[u8w++] = ((unsigned char*)SOURCEMEM)[u16r++]; +} + +void dotest(void) +{ + + memcpy(TARGETMEM, target, 8); + memcpy(SOURCEMEM, source, 8); + + test1(); + + memcpy(target, TARGETMEM, 8); + memcpy(source, SOURCEMEM, 8); +#ifdef __C64__ + clrscr(); +#endif + printf("source:"); + for(i = 0; i < 8; ++i) { + printf("%0x ", source[i]); + } + printf("\n\rtarget:"); + for(i = 0; i < 8; ++i) { + printf("%0x ", target[i]); + } + printf("\n\r"); + + printf("u8w: %d\n\r", u8w); + printf("u16r: %d\n\r", u16r); + +} + +int main(void) +{ + dotest(); + dotest(); + if (memcmp(target, expect, 8) != 0) { + printf("buffer data error\n\r"); + err = EXIT_FAILURE; + } + if (u8w != 3) { + err = EXIT_FAILURE; + } + if (u16r != 5) { + err = EXIT_FAILURE; + } + printf("return: %d\n\r", err); + return err; +} diff --git a/test/val/postinc-8-8.c b/test/val/postinc-8-8.c new file mode 100644 index 000000000..b168af8df --- /dev/null +++ b/test/val/postinc-8-8.c @@ -0,0 +1,86 @@ + +#include +#include +#include +#ifdef __C64__ +#include +#endif + +/* apparently we dont trigger the bug when not using absolute addresses? */ +#ifdef __C64__ +#define TARGETMEM 0x4c8 +#define SOURCEMEM 0x702 +#elif __SIM6502__ +#define TARGETMEM 0xc4c8 +#define SOURCEMEM 0xc702 +#elif __SIM65C02__ +#define TARGETMEM 0xc4c8 +#define SOURCEMEM 0xc702 +#else +static unsigned char mem[0x10]; +#define TARGETMEM &mem[0] +#define SOURCEMEM &mem[8] +#endif + +/* do not put at pos. 1, and 1 byte apart - so we can eventually notice + off-by-one errors */ +static unsigned char u8w = 1; +static unsigned char u8r = 3; + +static unsigned char target[8] = { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7 }; +static unsigned char source[8] = { 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf }; +static unsigned char expect[8] = { 0x0, 0xb, 0xc, 0x3, 0x4, 0x5, 0x6, 0x7 }; + +static unsigned char i; +static unsigned char err = EXIT_SUCCESS; + +void test1(void) +{ + ((unsigned char*)TARGETMEM)[u8w++] = ((unsigned char*)SOURCEMEM)[u8r++]; +} + +void dotest(void) +{ + + memcpy(TARGETMEM, target, 8); + memcpy(SOURCEMEM, source, 8); + + test1(); + + memcpy(target, TARGETMEM, 8); + memcpy(source, SOURCEMEM, 8); +#ifdef __C64__ + clrscr(); +#endif + printf("source:"); + for(i = 0; i < 8; ++i) { + printf("%0x ", source[i]); + } + printf("\n\rtarget:"); + for(i = 0; i < 8; ++i) { + printf("%0x ", target[i]); + } + printf("\n\r"); + + printf("u8w: %d\n\r", u8w); + printf("u8r: %d\n\r", u8r); + +} + +int main(void) +{ + dotest(); + dotest(); + if (memcmp(target, expect, 8) != 0) { + printf("buffer data error\n\r"); + err = EXIT_FAILURE; + } + if (u8w != 3) { + err = EXIT_FAILURE; + } + if (u8r != 5) { + err = EXIT_FAILURE; + } + printf("return: %d\n\r", err); + return err; +} diff --git a/test/val/predec-16-16.c b/test/val/predec-16-16.c new file mode 100644 index 000000000..7d70b1208 --- /dev/null +++ b/test/val/predec-16-16.c @@ -0,0 +1,86 @@ + +#include +#include +#include +#ifdef __C64__ +#include +#endif + +/* apparently we dont trigger the bug when not using absolute addresses? */ +#ifdef __C64__ +#define TARGETMEM 0x4c8 +#define SOURCEMEM 0x702 +#elif __SIM6502__ +#define TARGETMEM 0xc4c8 +#define SOURCEMEM 0xc702 +#elif __SIM65C02__ +#define TARGETMEM 0xc4c8 +#define SOURCEMEM 0xc702 +#else +static unsigned char mem[0x10]; +#define TARGETMEM &mem[0] +#define SOURCEMEM &mem[8] +#endif + +/* do not put at pos. 1, and 1 byte apart - so we can eventually notice + off-by-one errors */ +static unsigned short u16w = 3; +static unsigned short u16r = 5; + +static unsigned char target[8] = { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7 }; +static unsigned char source[8] = { 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf }; +static unsigned char expect[8] = { 0x0, 0xb, 0xc, 0x3, 0x4, 0x5, 0x6, 0x7 }; + +static unsigned char i; +static unsigned char err = EXIT_SUCCESS; + +void test1(void) +{ + ((unsigned char*)TARGETMEM)[--u16w] = ((unsigned char*)SOURCEMEM)[--u16r]; +} + +void dotest(void) +{ + + memcpy(TARGETMEM, target, 8); + memcpy(SOURCEMEM, source, 8); + + test1(); + + memcpy(target, TARGETMEM, 8); + memcpy(source, SOURCEMEM, 8); +#ifdef __C64__ + clrscr(); +#endif + printf("source:"); + for(i = 0; i < 8; ++i) { + printf("%0x ", source[i]); + } + printf("\n\rtarget:"); + for(i = 0; i < 8; ++i) { + printf("%0x ", target[i]); + } + printf("\n\r"); + + printf("u16w: %d\n\r", u16w); + printf("u16r: %d\n\r", u16r); + +} + +int main(void) +{ + dotest(); + dotest(); + if (memcmp(target, expect, 8) != 0) { + printf("buffer data error\n\r"); + err = EXIT_FAILURE; + } + if (u16w != 1) { + err = EXIT_FAILURE; + } + if (u16r != 3) { + err = EXIT_FAILURE; + } + printf("return: %d\n\r", err); + return err; +} diff --git a/test/val/predec-16-8.c b/test/val/predec-16-8.c new file mode 100644 index 000000000..69a0a3e28 --- /dev/null +++ b/test/val/predec-16-8.c @@ -0,0 +1,86 @@ + +#include +#include +#include +#ifdef __C64__ +#include +#endif + +/* apparently we dont trigger the bug when not using absolute addresses? */ +#ifdef __C64__ +#define TARGETMEM 0x4c8 +#define SOURCEMEM 0x702 +#elif __SIM6502__ +#define TARGETMEM 0xc4c8 +#define SOURCEMEM 0xc702 +#elif __SIM65C02__ +#define TARGETMEM 0xc4c8 +#define SOURCEMEM 0xc702 +#else +static unsigned char mem[0x10]; +#define TARGETMEM &mem[0] +#define SOURCEMEM &mem[8] +#endif + +/* do not put at pos. 1, and 1 byte apart - so we can eventually notice + off-by-one errors */ +static unsigned short u16w = 3; +static unsigned char u8r = 5; + +static unsigned char target[8] = { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7 }; +static unsigned char source[8] = { 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf }; +static unsigned char expect[8] = { 0x0, 0xb, 0xc, 0x3, 0x4, 0x5, 0x6, 0x7 }; + +static unsigned char i; +static unsigned char err = EXIT_SUCCESS; + +void test1(void) +{ + ((unsigned char*)TARGETMEM)[--u16w] = ((unsigned char*)SOURCEMEM)[--u8r]; +} + +void dotest(void) +{ + + memcpy(TARGETMEM, target, 8); + memcpy(SOURCEMEM, source, 8); + + test1(); + + memcpy(target, TARGETMEM, 8); + memcpy(source, SOURCEMEM, 8); +#ifdef __C64__ + clrscr(); +#endif + printf("source:"); + for(i = 0; i < 8; ++i) { + printf("%0x ", source[i]); + } + printf("\n\rtarget:"); + for(i = 0; i < 8; ++i) { + printf("%0x ", target[i]); + } + printf("\n\r"); + + printf("u16w: %d\n\r", u16w); + printf("u8r: %d\n\r", u8r); + +} + +int main(void) +{ + dotest(); + dotest(); + if (memcmp(target, expect, 8) != 0) { + printf("buffer data error\n\r"); + err = EXIT_FAILURE; + } + if (u16w != 1) { + err = EXIT_FAILURE; + } + if (u8r != 3) { + err = EXIT_FAILURE; + } + printf("return: %d\n\r", err); + return err; +} diff --git a/test/val/predec-8-16.c b/test/val/predec-8-16.c new file mode 100644 index 000000000..750312215 --- /dev/null +++ b/test/val/predec-8-16.c @@ -0,0 +1,86 @@ + +#include +#include +#include +#ifdef __C64__ +#include +#endif + +/* apparently we dont trigger the bug when not using absolute addresses? */ +#ifdef __C64__ +#define TARGETMEM 0x4c8 +#define SOURCEMEM 0x702 +#elif __SIM6502__ +#define TARGETMEM 0xc4c8 +#define SOURCEMEM 0xc702 +#elif __SIM65C02__ +#define TARGETMEM 0xc4c8 +#define SOURCEMEM 0xc702 +#else +static unsigned char mem[0x10]; +#define TARGETMEM &mem[0] +#define SOURCEMEM &mem[8] +#endif + +/* do not put at pos. 1, and 1 byte apart - so we can eventually notice + off-by-one errors */ +static unsigned char u8w = 3; +static unsigned short u16r = 5; + +static unsigned char target[8] = { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7 }; +static unsigned char source[8] = { 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf }; +static unsigned char expect[8] = { 0x0, 0xb, 0xc, 0x3, 0x4, 0x5, 0x6, 0x7 }; + +static unsigned char i; +static unsigned char err = EXIT_SUCCESS; + +void test1(void) +{ + ((unsigned char*)TARGETMEM)[--u8w] = ((unsigned char*)SOURCEMEM)[--u16r]; +} + +void dotest(void) +{ + + memcpy(TARGETMEM, target, 8); + memcpy(SOURCEMEM, source, 8); + + test1(); + + memcpy(target, TARGETMEM, 8); + memcpy(source, SOURCEMEM, 8); +#ifdef __C64__ + clrscr(); +#endif + printf("source:"); + for(i = 0; i < 8; ++i) { + printf("%0x ", source[i]); + } + printf("\n\rtarget:"); + for(i = 0; i < 8; ++i) { + printf("%0x ", target[i]); + } + printf("\n\r"); + + printf("u8w: %d\n\r", u8w); + printf("u16r: %d\n\r", u16r); + +} + +int main(void) +{ + dotest(); + dotest(); + if (memcmp(target, expect, 8) != 0) { + printf("buffer data error\n\r"); + err = EXIT_FAILURE; + } + if (u8w != 1) { + err = EXIT_FAILURE; + } + if (u16r != 3) { + err = EXIT_FAILURE; + } + printf("return: %d\n\r", err); + return err; +} diff --git a/test/val/predec-8-8.c b/test/val/predec-8-8.c new file mode 100644 index 000000000..d1069b39e --- /dev/null +++ b/test/val/predec-8-8.c @@ -0,0 +1,86 @@ + +#include +#include +#include +#ifdef __C64__ +#include +#endif + +/* apparently we dont trigger the bug when not using absolute addresses? */ +#ifdef __C64__ +#define TARGETMEM 0x4c8 +#define SOURCEMEM 0x702 +#elif __SIM6502__ +#define TARGETMEM 0xc4c8 +#define SOURCEMEM 0xc702 +#elif __SIM65C02__ +#define TARGETMEM 0xc4c8 +#define SOURCEMEM 0xc702 +#else +static unsigned char mem[0x10]; +#define TARGETMEM &mem[0] +#define SOURCEMEM &mem[8] +#endif + +/* do not put at pos. 1, and 1 byte apart - so we can eventually notice + off-by-one errors */ +static unsigned char u8w = 3; +static unsigned char u8r = 5; + +static unsigned char target[8] = { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7 }; +static unsigned char source[8] = { 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf }; +static unsigned char expect[8] = { 0x0, 0xb, 0xc, 0x3, 0x4, 0x5, 0x6, 0x7 }; + +static unsigned char i; +static unsigned char err = EXIT_SUCCESS; + +void test1(void) +{ + ((unsigned char*)TARGETMEM)[--u8w] = ((unsigned char*)SOURCEMEM)[--u8r]; +} + +void dotest(void) +{ + + memcpy(TARGETMEM, target, 8); + memcpy(SOURCEMEM, source, 8); + + test1(); + + memcpy(target, TARGETMEM, 8); + memcpy(source, SOURCEMEM, 8); +#ifdef __C64__ + clrscr(); +#endif + printf("source:"); + for(i = 0; i < 8; ++i) { + printf("%0x ", source[i]); + } + printf("\n\rtarget:"); + for(i = 0; i < 8; ++i) { + printf("%0x ", target[i]); + } + printf("\n\r"); + + printf("u8w: %d\n\r", u8w); + printf("u8r: %d\n\r", u8r); + +} + +int main(void) +{ + dotest(); + dotest(); + if (memcmp(target, expect, 8) != 0) { + printf("buffer data error\n\r"); + err = EXIT_FAILURE; + } + if (u8w != 1) { + err = EXIT_FAILURE; + } + if (u8r != 3) { + err = EXIT_FAILURE; + } + printf("return: %d\n\r", err); + return err; +} diff --git a/test/val/preinc-16-16.c b/test/val/preinc-16-16.c new file mode 100644 index 000000000..d9c6dbf62 --- /dev/null +++ b/test/val/preinc-16-16.c @@ -0,0 +1,86 @@ + +#include +#include +#include +#ifdef __C64__ +#include +#endif + +/* apparently we dont trigger the bug when not using absolute addresses? */ +#ifdef __C64__ +#define TARGETMEM 0x4c8 +#define SOURCEMEM 0x702 +#elif __SIM6502__ +#define TARGETMEM 0xc4c8 +#define SOURCEMEM 0xc702 +#elif __SIM65C02__ +#define TARGETMEM 0xc4c8 +#define SOURCEMEM 0xc702 +#else +static unsigned char mem[0x10]; +#define TARGETMEM &mem[0] +#define SOURCEMEM &mem[8] +#endif + +/* do not put at pos. 1, and 1 byte apart - so we can eventually notice + off-by-one errors */ +static unsigned short u16w = 3; +static unsigned short u16r = 5; + +static unsigned char target[8] = { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7 }; +static unsigned char source[8] = { 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf }; +static unsigned char expect[8] = { 0x0, 0x1, 0x2, 0x3, 0xe, 0xf, 0x6, 0x7 }; + +static unsigned char i; +static unsigned char err = EXIT_SUCCESS; + +void test1(void) +{ + ((unsigned char*)TARGETMEM)[++u16w] = ((unsigned char*)SOURCEMEM)[++u16r]; +} + +void dotest(void) +{ + + memcpy(TARGETMEM, target, 8); + memcpy(SOURCEMEM, source, 8); + + test1(); + + memcpy(target, TARGETMEM, 8); + memcpy(source, SOURCEMEM, 8); +#ifdef __C64__ + clrscr(); +#endif + printf("source:"); + for(i = 0; i < 8; ++i) { + printf("%0x ", source[i]); + } + printf("\n\rtarget:"); + for(i = 0; i < 8; ++i) { + printf("%0x ", target[i]); + } + printf("\n\r"); + + printf("u16w: %d\n\r", u16w); + printf("u16r: %d\n\r", u16r); + +} + +int main(void) +{ + dotest(); + dotest(); + if (memcmp(target, expect, 8) != 0) { + printf("buffer data error\n\r"); + err = EXIT_FAILURE; + } + if (u16w != 5) { + err = EXIT_FAILURE; + } + if (u16r != 7) { + err = EXIT_FAILURE; + } + printf("return: %d\n\r", err); + return err; +} diff --git a/test/val/preinc-16-8.c b/test/val/preinc-16-8.c new file mode 100644 index 000000000..97a5dd306 --- /dev/null +++ b/test/val/preinc-16-8.c @@ -0,0 +1,86 @@ + +#include +#include +#include +#ifdef __C64__ +#include +#endif + +/* apparently we dont trigger the bug when not using absolute addresses? */ +#ifdef __C64__ +#define TARGETMEM 0x4c8 +#define SOURCEMEM 0x702 +#elif __SIM6502__ +#define TARGETMEM 0xc4c8 +#define SOURCEMEM 0xc702 +#elif __SIM65C02__ +#define TARGETMEM 0xc4c8 +#define SOURCEMEM 0xc702 +#else +static unsigned char mem[0x10]; +#define TARGETMEM &mem[0] +#define SOURCEMEM &mem[8] +#endif + +/* do not put at pos. 1, and 1 byte apart - so we can eventually notice + off-by-one errors */ +static unsigned short u16w = 3; +static unsigned char u8r = 5; + +static unsigned char target[8] = { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7 }; +static unsigned char source[8] = { 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf }; +static unsigned char expect[8] = { 0x0, 0x1, 0x2, 0x3, 0xe, 0xf, 0x6, 0x7 }; + +static unsigned char i; +static unsigned char err = EXIT_SUCCESS; + +void test1(void) +{ + ((unsigned char*)TARGETMEM)[++u16w] = ((unsigned char*)SOURCEMEM)[++u8r]; +} + +void dotest(void) +{ + + memcpy(TARGETMEM, target, 8); + memcpy(SOURCEMEM, source, 8); + + test1(); + + memcpy(target, TARGETMEM, 8); + memcpy(source, SOURCEMEM, 8); +#ifdef __C64__ + clrscr(); +#endif + printf("source:"); + for(i = 0; i < 8; ++i) { + printf("%0x ", source[i]); + } + printf("\n\rtarget:"); + for(i = 0; i < 8; ++i) { + printf("%0x ", target[i]); + } + printf("\n\r"); + + printf("u16w: %d\n\r", u16w); + printf("u8r: %d\n\r", u8r); + +} + +int main(void) +{ + dotest(); + dotest(); + if (memcmp(target, expect, 8) != 0) { + printf("buffer data error\n\r"); + err = EXIT_FAILURE; + } + if (u16w != 5) { + err = EXIT_FAILURE; + } + if (u8r != 7) { + err = EXIT_FAILURE; + } + printf("return: %d\n\r", err); + return err; +} diff --git a/test/val/preinc-8-16.c b/test/val/preinc-8-16.c new file mode 100644 index 000000000..3c3a9b479 --- /dev/null +++ b/test/val/preinc-8-16.c @@ -0,0 +1,86 @@ + +#include +#include +#include +#ifdef __C64__ +#include +#endif + +/* apparently we dont trigger the bug when not using absolute addresses? */ +#ifdef __C64__ +#define TARGETMEM 0x4c8 +#define SOURCEMEM 0x702 +#elif __SIM6502__ +#define TARGETMEM 0xc4c8 +#define SOURCEMEM 0xc702 +#elif __SIM65C02__ +#define TARGETMEM 0xc4c8 +#define SOURCEMEM 0xc702 +#else +static unsigned char mem[0x10]; +#define TARGETMEM &mem[0] +#define SOURCEMEM &mem[8] +#endif + +/* do not put at pos. 1, and 1 byte apart - so we can eventually notice + off-by-one errors */ +static unsigned char u8w = 3; +static unsigned short u16r = 5; + +static unsigned char target[8] = { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7 }; +static unsigned char source[8] = { 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf }; +static unsigned char expect[8] = { 0x0, 0x1, 0x2, 0x3, 0xe, 0xf, 0x6, 0x7 }; + +static unsigned char i; +static unsigned char err = EXIT_SUCCESS; + +void test1(void) +{ + ((unsigned char*)TARGETMEM)[++u8w] = ((unsigned char*)SOURCEMEM)[++u16r]; +} + +void dotest(void) +{ + + memcpy(TARGETMEM, target, 8); + memcpy(SOURCEMEM, source, 8); + + test1(); + + memcpy(target, TARGETMEM, 8); + memcpy(source, SOURCEMEM, 8); +#ifdef __C64__ + clrscr(); +#endif + printf("source:"); + for(i = 0; i < 8; ++i) { + printf("%0x ", source[i]); + } + printf("\n\rtarget:"); + for(i = 0; i < 8; ++i) { + printf("%0x ", target[i]); + } + printf("\n\r"); + + printf("u8w: %d\n\r", u8w); + printf("u16r: %d\n\r", u16r); + +} + +int main(void) +{ + dotest(); + dotest(); + if (memcmp(target, expect, 8) != 0) { + printf("buffer data error\n\r"); + err = EXIT_FAILURE; + } + if (u8w != 5) { + err = EXIT_FAILURE; + } + if (u16r != 7) { + err = EXIT_FAILURE; + } + printf("return: %d\n\r", err); + return err; +} diff --git a/test/val/preinc-8-8.c b/test/val/preinc-8-8.c new file mode 100644 index 000000000..a700bfc48 --- /dev/null +++ b/test/val/preinc-8-8.c @@ -0,0 +1,86 @@ + +#include +#include +#include +#ifdef __C64__ +#include +#endif + +/* apparently we dont trigger the bug when not using absolute addresses? */ +#ifdef __C64__ +#define TARGETMEM 0x4c8 +#define SOURCEMEM 0x702 +#elif __SIM6502__ +#define TARGETMEM 0xc4c8 +#define SOURCEMEM 0xc702 +#elif __SIM65C02__ +#define TARGETMEM 0xc4c8 +#define SOURCEMEM 0xc702 +#else +static unsigned char mem[0x10]; +#define TARGETMEM &mem[0] +#define SOURCEMEM &mem[8] +#endif + +/* do not put at pos. 1, and 1 byte apart - so we can eventually notice + off-by-one errors */ +static unsigned char u8w = 3; +static unsigned char u8r = 5; + +static unsigned char target[8] = { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7 }; +static unsigned char source[8] = { 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf }; +static unsigned char expect[8] = { 0x0, 0x1, 0x2, 0x3, 0xe, 0xf, 0x6, 0x7 }; + +static unsigned char i; +static unsigned char err = EXIT_SUCCESS; + +void test1(void) +{ + ((unsigned char*)TARGETMEM)[++u8w] = ((unsigned char*)SOURCEMEM)[++u8r]; +} + +void dotest(void) +{ + + memcpy(TARGETMEM, target, 8); + memcpy(SOURCEMEM, source, 8); + + test1(); + + memcpy(target, TARGETMEM, 8); + memcpy(source, SOURCEMEM, 8); +#ifdef __C64__ + clrscr(); +#endif + printf("source:"); + for(i = 0; i < 8; ++i) { + printf("%0x ", source[i]); + } + printf("\n\rtarget:"); + for(i = 0; i < 8; ++i) { + printf("%0x ", target[i]); + } + printf("\n\r"); + + printf("u8w: %d\n\r", u8w); + printf("u8r: %d\n\r", u8r); + +} + +int main(void) +{ + dotest(); + dotest(); + if (memcmp(target, expect, 8) != 0) { + printf("buffer data error\n\r"); + err = EXIT_FAILURE; + } + if (u8w != 5) { + err = EXIT_FAILURE; + } + if (u8r != 7) { + err = EXIT_FAILURE; + } + printf("return: %d\n\r", err); + return err; +}