From 4793f79e79ea1c09f6dd51718126a9c97487ca2c Mon Sep 17 00:00:00 2001 From: Sijmen Schoon Date: Mon, 7 Dec 2020 14:08:03 +0100 Subject: [PATCH] Fix a few dumbs in udivmod32 --- c64/math.asm | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/c64/math.asm b/c64/math.asm index f8bb0c7..5eb93e1 100644 --- a/c64/math.asm +++ b/c64/math.asm @@ -296,18 +296,18 @@ generate_multiplication_tables: udivmod32: // if (divisor == 0) { lda udivmod32_divisor + 0 - bne !+ + bne !if_end+ lda udivmod32_divisor + 1 - bne !+ + bne !if_end+ lda udivmod32_divisor + 2 - bne !+ + bne !if_end+ lda udivmod32_divisor + 3 - bne !+ + bne !if_end+ // return 0; rts -!: // } +!if_end: // uint32_t scaled_divisor = divisor; lda udivmod32_divisor + 0 @@ -339,23 +339,23 @@ udivmod32: sta multiple + 3 // uint32_t result = 0; - sta result + 0 - sta result + 1 - sta result + 2 - sta result + 3 + sta udivmod32_result + 0 + sta udivmod32_result + 1 + sta udivmod32_result + 2 + sta udivmod32_result + 3 // while (scaled_divisor < dividend) { !while_start: sec lda scaled_divisor + 0 - sbc dividend + 0 + sbc udivmod32_dividend + 0 lda scaled_divisor + 1 - sbc dividend + 1 + sbc udivmod32_dividend + 1 lda scaled_divisor + 2 - sbc dividend + 2 + sbc udivmod32_dividend + 2 lda scaled_divisor + 3 - sbc dividend + 3 + sbc udivmod32_dividend + 3 bcs !while_end+ // scaled_divisor <<= 1 @@ -404,7 +404,7 @@ udivmod32: sta udivmod32_remainder + 3 // } -!if_end +!if_end: // scaled_divisor >>= 1; lsr scaled_divisor + 3 @@ -418,15 +418,15 @@ udivmod32: ror multiple + 1 ror multiple + 0 - lda multiple + 0 - bne !do_start - lda multiple + 1 - bne !do_start - lda multiple + 2 - bne !do_start - lda multiple + 3 - bne !do_start // } while (multiple != 0); + lda multiple + 0 + bne !do_start- + lda multiple + 1 + bne !do_start- + lda multiple + 2 + bne !do_start- + lda multiple + 3 + bne !do_start- rts