mirror of
https://github.com/cc65/cc65.git
synced 2024-12-25 02:29:52 +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 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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user