From 20d3a67db8ef0976e9d5f036fb8f51aef9b43e5d Mon Sep 17 00:00:00 2001 From: Aaron Culliney Date: Mon, 16 Feb 2015 12:18:59 -0800 Subject: [PATCH] Increase testing of CPU branch logic, include 16bit underflow and overflow - Unlikely that the original Apple //e ever saw this happen in reality? - TODO : test with valgrind for invalid code access ... --- src/test/testcpu.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/test/testcpu.c b/src/test/testcpu.c index be83c9a9..1736834b 100644 --- a/src/test/testcpu.c +++ b/src/test/testcpu.c @@ -7354,7 +7354,7 @@ GREATEST_SUITE(test_suite_cpu) { HASH_ITER(hh, test_funcs, func, tmp) { fprintf(GREATEST_STDOUT, "\n%s (SILENCED OUTPUT) :\n", func->name); - for (uint16_t addrs = 0x1f02; addrs < 0x2000; addrs+=0x80) { + for (uint16_t addrs = 0x1f02; addrs < 0x2000; addrs++) { for (uint8_t flag = 0x00; flag < 0x02; flag++) { uint8_t off=0x00; do { @@ -7363,6 +7363,26 @@ GREATEST_SUITE(test_suite_cpu) { } } + // 16bit branch overflow tests + for (uint16_t addrs = 0xff00; addrs >= 0xff00 || addrs < 0x00fe; addrs++) { + for (uint8_t flag = 0x00; flag < 0x02; flag++) { + uint8_t off=0x00; + do { + A2_RUN_TESTp(func->func, off, flag, addrs); + } while (++off); + } + } + + // 16bit branch underflow tests + for (uint16_t addrs = 0x00fe; addrs <= 0x00fe || addrs > 0xff00; addrs--) { + for (uint8_t flag = 0x00; flag < 0x02; flag++) { + uint8_t off=0x00; + do { + A2_RUN_TESTp(func->func, off, flag, addrs); + } while (++off); + } + } + fprintf(GREATEST_STDOUT, "...OK\n"); A2_REMOVE_TEST(func); }