From 30abd7a2bf47710e91faa7618c923678efffa38d Mon Sep 17 00:00:00 2001 From: Stevan Freeborn Date: Sat, 18 Jul 2026 15:15:46 -0500 Subject: [PATCH] fix(cpu): correct borrow flag comparison in subtraction opcodes --- main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index 2885f10..6b66b59 100644 --- a/main.c +++ b/main.c @@ -354,14 +354,14 @@ int main(int argc, char *argv[]) { chip->V[15] = (r > 255) ? 1 : 0; chip->V[x] = r & 255; } else if (n == 5) { - chip->V[15] = (chip->V[x] > chip->V[y]) ? 1 : 0; + chip->V[15] = (chip->V[x] >= chip->V[y]) ? 1 : 0; chip->V[x] = chip->V[x] - chip->V[y]; } else if (n == 6) { uint8_t flag = chip->V[x] & 1; chip->V[15] = flag; chip->V[x] /= 2; } else if (n == 7) { - chip->V[15] = (chip->V[y] > chip->V[x]) ? 1 : 0; + chip->V[15] = (chip->V[y] >= chip->V[x]) ? 1 : 0; chip->V[x] = chip->V[y] - chip->V[x]; } else if (n == 14) { uint8_t flag = (chip->V[x] & 128) >> 7;