From 89af42e5cbcb98f43fc2269fc5ca5bb0e43f6bf1 Mon Sep 17 00:00:00 2001 From: Colin Leroy-Mira Date: Wed, 30 Aug 2023 21:14:07 +0200 Subject: [PATCH] Serial: Optimize SER_IRQ Apple2 and Atmos have Index in X, but can still use it for the best-case path as long as we reload it in the worst-case part (when we assert flow control). Also, standardize the free space to trigger flow control to 32 characters left (compare with RecvFreeCnt before decrement) --- libsrc/apple2/ser/a2.ssc.s | 8 ++++---- libsrc/atmos/ser/atmos-acia.s | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/libsrc/apple2/ser/a2.ssc.s b/libsrc/apple2/ser/a2.ssc.s index c2b0bf321..1dbf5f3a4 100644 --- a/libsrc/apple2/ser/a2.ssc.s +++ b/libsrc/apple2/ser/a2.ssc.s @@ -404,19 +404,19 @@ SER_IRQ: and #$08 beq Done ; Jump if no ACIA interrupt lda ACIA_DATA,x ; Get byte from ACIA - ldy RecvFreeCnt ; Check if we have free space left + ldx RecvFreeCnt ; Check if we have free space left beq Flow ; Jump if no space in receive buffer ldy RecvTail ; Load buffer pointer sta RecvBuf,y ; Store received byte in buffer inc RecvTail ; Increment buffer pointer dec RecvFreeCnt ; Decrement free space counter - ldy RecvFreeCnt ; Check for buffer space low - cpy #33 + cpx #33 ; Check for buffer space low bcc Flow ; Assert flow control if buffer space low rts ; Interrupt handled (carry already set) ; Assert flow control if buffer space too low -Flow: lda RtsOff +Flow: ldx Index +lda RtsOff sta ACIA_CMD,x sta Stopped sec ; Interrupt handled diff --git a/libsrc/atmos/ser/atmos-acia.s b/libsrc/atmos/ser/atmos-acia.s index ed5386471..774a337bd 100644 --- a/libsrc/atmos/ser/atmos-acia.s +++ b/libsrc/atmos/ser/atmos-acia.s @@ -329,19 +329,19 @@ SER_IRQ: and #$08 beq Done ; Jump if no ACIA interrupt lda ACIA::DATA,x ; Get byte from ACIA - ldy RecvFreeCnt ; Check if we have free space left + ldx RecvFreeCnt ; Check if we have free space left beq Flow ; Jump if no space in receive buffer ldy RecvTail ; Load buffer pointer sta RecvBuf,y ; Store received byte in buffer inc RecvTail ; Increment buffer pointer dec RecvFreeCnt ; Decrement free space counter - ldy RecvFreeCnt ; Check for buffer space low - cpy #33 + cpx #33 bcc Flow ; Assert flow control if buffer space low rts ; Interrupt handled (carry already set) ; Assert flow control if buffer space too low -Flow: lda RtsOff +Flow: ldx Index ; Reload port + lda RtsOff sta ACIA::CMD,x sta Stopped sec ; Interrupt handled