-;
-; Ullrich von Bassewitz, 10.12.1998
-;
-; Integer compare function - used by the compare operators
-;
-
- .export tosicmp
- .importzp sp, sreg
-
-
-tosicmp:
- sta sreg
- stx sreg+1 ; Save ax
-
- ldy #$01
- lda (sp),y ; Get high byte
- tax
- dey
- lda (sp),y ; Get low byte
-
-; Inline incsp2 for better performance
-
- inc sp ; 5
- bne @L1 ; 3
- inc sp+1 ; (5)
-@L1: inc sp ; 5
- bne @L2 ; 3
- inc sp+1 ; (5)
-
-; Do the compare.
-
-@L2: cpx sreg+1 ; Compare high byte
- bne @L3
- cmp sreg ; Compare low byte
- beq @L3
- bcs @L4
- lda #$FF ; Set the N flag
-@L3: rts
-
-@L4: lda #$01 ; Clear the N flag
- rts
-
-
+;\r
+; Piotr Fusik, 15.04.2002\r
+; originally by Ullrich von Bassewitz\r
+;\r
+; Integer compare function - used by the compare operators\r
+;\r
+\r
+ .export tosicmp\r
+ .importzp sp, sreg\r
+\r
+\r
+tosicmp:\r
+ sta sreg\r
+ stx sreg+1 ; Save ax\r
+\r
+ ldy #$00\r
+ lda (sp),y ; Get low byte\r
+ tax\r
+ inc sp ; 5\r
+ bne @L1 ; 3\r
+ inc sp+1 ; (5)\r
+@L1:\r
+ lda (sp),y ; Get high byte\r
+ inc sp ; 5\r
+ bne @L2 ; 3\r
+ inc sp+1 ; (5)\r
+\r
+; Do the compare.\r
+\r
+@L2: sec\r
+ sbc sreg+1 ; Compare high byte\r
+ bne @L4\r
+ cpx sreg ; Compare low byte\r
+ beq @L3\r
+ adc #$FF ; If the C flag is set then clear the N flag\r
+ ora #$01 ; else set the N flag\r
+@L3: rts\r
+\r
+@L4: bvc @L3\r
+ eor #$FF ; Fix the N flag if overflow\r
+ ora #$01 ; Clear the Z flag\r
+ rts\r
+\r
+\r
-;
-; Ullrich von Bassewitz, 10.12.1998
-;
-; Long int compare function - used by the compare operators
-;
-
- .export toslcmp
- .import incsp4
- .importzp sp, sreg, ptr1
-
-
-toslcmp:
- sta ptr1
- stx ptr1+1 ; EAX now in sreg:ptr1
-
- ldy #$03
- lda (sp),y
- cmp sreg+1
- bne L4
-
- dey
- lda (sp),y
- cmp sreg
- bne L1
-
- dey
- lda (sp),y
- cmp ptr1+1
- bne L1
-
- dey
- lda (sp),y
- cmp ptr1
-
-L1: php ; Save flags
- jsr incsp4 ; Drop TOS
- plp ; Restore the flags
- beq L2
- bcs L3
- lda #$FF ; Set the N flag
-L2: rts
-
-L3: lda #$01 ; Clear the N flag
- rts
-
-L4: php ; Save flags
- jsr incsp4 ; Drop TOS
- plp ; Restore flags
- rts
-
-
+;\r
+; Piotr Fusik, 15.04.2002\r
+; originally by Ullrich von Bassewitz\r
+;\r
+; Long int compare function - used by the compare operators\r
+;\r
+\r
+ .export toslcmp\r
+ .import incsp4\r
+ .importzp sp, sreg, ptr1\r
+\r
+\r
+toslcmp:\r
+ sta ptr1\r
+ stx ptr1+1 ; EAX now in sreg:ptr1\r
+\r
+ ldy #$03\r
+ lda (sp),y\r
+ sec\r
+ sbc sreg+1\r
+ bne L4\r
+\r
+ dey\r
+ lda (sp),y\r
+ cmp sreg\r
+ bne L1\r
+\r
+ dey\r
+ lda (sp),y\r
+ cmp ptr1+1\r
+ bne L1\r
+\r
+ dey\r
+ lda (sp),y\r
+ cmp ptr1\r
+\r
+L1: php ; Save flags\r
+ jsr incsp4 ; Drop TOS\r
+ plp ; Restore the flags\r
+ beq L2\r
+ bcs L3\r
+ lda #$FF ; Set the N flag\r
+L2: rts\r
+\r
+L3: lda #$01 ; Clear the N flag\r
+ rts\r
+\r
+L4: bvc L5\r
+ eor #$FF ; Fix the N flag if overflow\r
+ ora #$01 ; Clear the Z flag\r
+L5: php ; Save flags\r
+ jsr incsp4 ; Drop TOS\r
+ plp ; Restore flags\r
+ rts\r
+\r
+\r