From 82684d98fbf8783cae5e08b8e681ca555df945cc Mon Sep 17 00:00:00 2001 From: cuz Date: Thu, 24 Oct 2002 19:23:24 +0000 Subject: [PATCH] Minor optimization suggested by Greg King git-svn-id: svn://svn.cc65.org/cc65/trunk@1468 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- libsrc/runtime/lmod.s | 9 ++++----- libsrc/runtime/mod.s | 7 +++---- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/libsrc/runtime/lmod.s b/libsrc/runtime/lmod.s index b3376b60f..ab3d8c0b7 100644 --- a/libsrc/runtime/lmod.s +++ b/libsrc/runtime/lmod.s @@ -15,8 +15,9 @@ tosmodeax: jsr poplsargs ; Get arguments from stack, adjust sign jsr udiv32 ; Do the division, remainder is in (ptr2:tmp3:tmp4) -; Load the result with the exception of the low byte +; Load the result + lda ptr2 ldx ptr2+1 ldy tmp3 sty sreg @@ -25,16 +26,14 @@ tosmodeax: ; Check the sign of the result. It is the sign of the left operand. - lda tmp1 ; Check sign of left operand + bit tmp1 ; Check sign of left operand bpl Pos ; Jump if result is positive ; Result is negative - lda ptr2 ; Load byte 0 of result jmp negeax ; Negate result ; Result is positive -Pos: lda ptr2 ; Load byte 0 of result - rts ; Done +Pos: rts ; Done diff --git a/libsrc/runtime/mod.s b/libsrc/runtime/mod.s index 1a97c6592..c5565a852 100644 --- a/libsrc/runtime/mod.s +++ b/libsrc/runtime/mod.s @@ -16,6 +16,7 @@ tosmoda0: tosmodax: jsr popsargs ; Get arguments from stack, adjust sign jsr udiv16 ; Do the division + lda ptr1 ; Load low byte of result ldx ptr1+1 ; Load high byte of result ; Adjust the sign of the result. tmp1 contains the high byte of the left @@ -23,16 +24,14 @@ tosmodax: ; the result of the modulo operation is the same as that of the left ; operand - lda tmp1 + bit tmp1 bpl Pos ; Jump if sign of result positive ; Result is negative - lda ptr1 ; Load low byte of result jmp negax ; Adjust the sign ; Result is positive -Pos: lda ptr1 - rts +Pos: rts