mirror of
https://github.com/cc65/cc65.git
synced 2024-12-22 12:30:41 +00:00
Minor optimization suggested by Greg King
git-svn-id: svn://svn.cc65.org/cc65/trunk@1468 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
89fe03a728
commit
82684d98fb
@ -15,8 +15,9 @@ tosmodeax:
|
|||||||
jsr poplsargs ; Get arguments from stack, adjust sign
|
jsr poplsargs ; Get arguments from stack, adjust sign
|
||||||
jsr udiv32 ; Do the division, remainder is in (ptr2:tmp3:tmp4)
|
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
|
ldx ptr2+1
|
||||||
ldy tmp3
|
ldy tmp3
|
||||||
sty sreg
|
sty sreg
|
||||||
@ -25,16 +26,14 @@ tosmodeax:
|
|||||||
|
|
||||||
; Check the sign of the result. It is the sign of the left operand.
|
; 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
|
bpl Pos ; Jump if result is positive
|
||||||
|
|
||||||
; Result is negative
|
; Result is negative
|
||||||
|
|
||||||
lda ptr2 ; Load byte 0 of result
|
|
||||||
jmp negeax ; Negate result
|
jmp negeax ; Negate result
|
||||||
|
|
||||||
; Result is positive
|
; Result is positive
|
||||||
|
|
||||||
Pos: lda ptr2 ; Load byte 0 of result
|
Pos: rts ; Done
|
||||||
rts ; Done
|
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@ tosmoda0:
|
|||||||
tosmodax:
|
tosmodax:
|
||||||
jsr popsargs ; Get arguments from stack, adjust sign
|
jsr popsargs ; Get arguments from stack, adjust sign
|
||||||
jsr udiv16 ; Do the division
|
jsr udiv16 ; Do the division
|
||||||
|
lda ptr1 ; Load low byte of result
|
||||||
ldx ptr1+1 ; Load high 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
|
; 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
|
; the result of the modulo operation is the same as that of the left
|
||||||
; operand
|
; operand
|
||||||
|
|
||||||
lda tmp1
|
bit tmp1
|
||||||
bpl Pos ; Jump if sign of result positive
|
bpl Pos ; Jump if sign of result positive
|
||||||
|
|
||||||
; Result is negative
|
; Result is negative
|
||||||
|
|
||||||
lda ptr1 ; Load low byte of result
|
|
||||||
jmp negax ; Adjust the sign
|
jmp negax ; Adjust the sign
|
||||||
|
|
||||||
; Result is positive
|
; Result is positive
|
||||||
|
|
||||||
Pos: lda ptr1
|
Pos: rts
|
||||||
rts
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user