1
0
mirror of https://github.com/cc65/cc65.git synced 2025-01-11 11:30:13 +00:00

Serial: Optimize TryToSend

We don't need to reload SendFreeCnt each time we loop to wait
for the ACIA to be ready.
This commit is contained in:
Colin Leroy-Mira 2023-08-30 21:28:09 +02:00
parent c674b7ced4
commit 3f3b6123b9
7 changed files with 43 additions and 41 deletions

View File

@ -427,12 +427,13 @@ Done: rts
TryToSend: TryToSend:
sta tmp1 ; Remember tryHard flag sta tmp1 ; Remember tryHard flag
Again: lda SendFreeCnt NextByte:
lda SendFreeCnt
cmp #$FF cmp #$FF
beq Quit ; Bail out beq Quit ; Bail out
; Check for flow stopped ; Check for flow stopped
lda Stopped Again: lda Stopped
bne Quit ; Bail out bne Quit ; Bail out
; Check that ACIA is ready to send ; Check that ACIA is ready to send
@ -449,4 +450,4 @@ Send: ldy SendHead
sta ACIA_DATA,x sta ACIA_DATA,x
inc SendHead inc SendHead
inc SendFreeCnt inc SendFreeCnt
jmp Again jmp NextByte

View File

@ -352,12 +352,13 @@ Done: rts
TryToSend: TryToSend:
sta tmp1 ; Remember tryHard flag sta tmp1 ; Remember tryHard flag
Again: lda SendFreeCnt NextByte:
lda SendFreeCnt
cmp #$FF cmp #$FF
beq Quit ; Bail out beq Quit ; Bail out
; Check for flow stopped ; Check for flow stopped
lda Stopped Again: lda Stopped
bne Quit ; Bail out bne Quit ; Bail out
; Check that ACIA is ready to send ; Check that ACIA is ready to send
@ -374,4 +375,4 @@ Send: ldy SendHead
sta ACIA::DATA sta ACIA::DATA
inc SendHead inc SendHead
inc SendFreeCnt inc SendFreeCnt
jmp Again jmp NextByte

View File

@ -466,25 +466,25 @@ NmiHandler:
sta tmp1 ; Remember tryHard flag sta tmp1 ; Remember tryHard flag
@L0: lda SendFreeCnt @L0: lda SendFreeCnt
cmp #$ff cmp #$ff
beq @L3 ; Bail out beq @L2 ; Bail out
; Check for flow stopped ; Check for flow stopped
@L1: lda Stopped @L1: lda Stopped
bne @L3 ; Bail out bne @L2 ; Bail out
; Check that swiftlink is ready to send ; Check that swiftlink is ready to send
@L2: lda ACIA_STATUS lda ACIA_STATUS
and #$10 and #$10
bne @L4 bne @L3
bit tmp1 ;keep trying if must try hard bit tmp1 ;keep trying if must try hard
bmi @L0 bmi @L1
@L3: rts @L2: rts
; Send byte and try again ; Send byte and try again
@L4: ldx SendHead @L3: ldx SendHead
lda SendBuf,x lda SendBuf,x
sta ACIA_DATA sta ACIA_DATA
inc SendHead inc SendHead

View File

@ -443,25 +443,25 @@ NmiHandler:
sta tmp1 ; Remember tryHard flag sta tmp1 ; Remember tryHard flag
@L0: lda SendFreeCnt @L0: lda SendFreeCnt
cmp #$ff cmp #$ff
beq @L3 ; Bail out beq @L2 ; Bail out
; Check for flow stopped ; Check for flow stopped
@L1: lda Stopped @L1: lda Stopped
bne @L3 ; Bail out bne @L2 ; Bail out
; Check that swiftlink is ready to send ; Check that swiftlink is ready to send
@L2: lda ACIA_STATUS lda ACIA_STATUS
and #$10 and #$10
bne @L4 bne @L3
bit tmp1 ;keep trying if must try hard bit tmp1 ;keep trying if must try hard
bmi @L0 bmi @L1
@L3: rts @L2: rts
; Send byte and try again ; Send byte and try again
@L4: ldx SendHead @L3: ldx SendHead
lda SendBuf,x lda SendBuf,x
sta ACIA_DATA sta ACIA_DATA
inc SendHead inc SendHead

View File

@ -395,31 +395,31 @@ SER_IRQ:
sta IndReg ; Switch to the system bank sta IndReg ; Switch to the system bank
@L0: lda SendFreeCnt @L0: lda SendFreeCnt
cmp #$ff cmp #$ff
beq @L3 ; Bail out beq @L2 ; Bail out
; Check for flow stopped ; Check for flow stopped
@L1: lda Stopped @L1: lda Stopped
bne @L3 ; Bail out bne @L2 ; Bail out
; Check that swiftlink is ready to send ; Check that swiftlink is ready to send
@L2: ldy #ACIA::STATUS ldy #ACIA::STATUS
lda (acia),y lda (acia),y
and #$10 and #$10
bne @L4 bne @L3
bit tmp1 ; Keep trying if must try hard bit tmp1 ; Keep trying if must try hard
bmi @L0 bmi @L1
; Switch back the bank and return ; Switch back the bank and return
@L3: lda ExecReg @L2: lda ExecReg
sta IndReg sta IndReg
rts rts
; Send byte and try again ; Send byte and try again
@L4: ldx SendHead @L3: ldx SendHead
lda SendBuf,x lda SendBuf,x
ldy #ACIA::DATA ldy #ACIA::DATA
sta (acia),y sta (acia),y

View File

@ -395,31 +395,31 @@ SER_IRQ:
sta IndReg ; Switch to the system bank sta IndReg ; Switch to the system bank
@L0: lda SendFreeCnt @L0: lda SendFreeCnt
cmp #$ff cmp #$ff
beq @L3 ; Bail out beq @L2 ; Bail out
; Check for flow stopped ; Check for flow stopped
@L1: lda Stopped @L1: lda Stopped
bne @L3 ; Bail out bne @L2 ; Bail out
; Check that swiftlink is ready to send ; Check that swiftlink is ready to send
@L2: ldy #ACIA::STATUS ldy #ACIA::STATUS
lda (acia),y lda (acia),y
and #$10 and #$10
bne @L4 bne @L3
bit tmp1 ; Keep trying if must try hard bit tmp1 ; Keep trying if must try hard
bmi @L0 bmi @L1
; Switch back the bank and return ; Switch back the bank and return
@L3: lda ExecReg @L2: lda ExecReg
sta IndReg sta IndReg
rts rts
; Send byte and try again ; Send byte and try again
@L4: ldx SendHead @L3: ldx SendHead
lda SendBuf,x lda SendBuf,x
ldy #ACIA::DATA ldy #ACIA::DATA
sta (acia),y sta (acia),y

View File

@ -387,25 +387,25 @@ SER_IRQ:
sta tmp1 ; Remember tryHard flag sta tmp1 ; Remember tryHard flag
@L0: lda SendFreeCnt @L0: lda SendFreeCnt
cmp #$ff cmp #$ff
beq @L3 ; Bail out beq @L2 ; Bail out
; Check for flow stopped ; Check for flow stopped
@L1: lda Stopped @L1: lda Stopped
bne @L3 ; Bail out bne @L2 ; Bail out
; Check that swiftlink is ready to send ; Check that swiftlink is ready to send
@L2: lda ACIA_STATUS lda ACIA_STATUS
and #$10 and #$10
bne @L4 bne @L3
bit tmp1 ;keep trying if must try hard bit tmp1 ;keep trying if must try hard
bmi @L0 bmi @L1
@L3: rts @L2: rts
; Send byte and try again ; Send byte and try again
@L4: ldx SendHead @L3: ldx SendHead
lda SendBuf,x lda SendBuf,x
sta ACIA_DATA sta ACIA_DATA
inc SendHead inc SendHead