Serial: Optimize SER_PUT

We don't need to reload SendFreeCnt if we don't jsr TryToSend.
This commit is contained in:
Colin Leroy-Mira
2023-08-30 21:02:47 +02:00
parent 89af42e5cb
commit e8f5ad2471
7 changed files with 43 additions and 31 deletions

View File

@@ -300,21 +300,23 @@ SER_PUT:
; Try to send
ldx SendFreeCnt
inx ; X = $ff?
cpx #$ff ; Nothing to flush
beq @L2
pha
lda #$00
jsr TryToSend
pla
; Put byte into send buffer & send
; Reload SendFreeCnt after TryToSend
@L2: ldx SendFreeCnt
bne @L3
ldx SendFreeCnt
bne @L2
lda #SER_ERR_OVERFLOW ; X is already zero
rts
@L3: ldx SendTail
; Put byte into send buffer & send
@L2: ldx SendTail
sta SendBuf,x
inc SendTail
dec SendFreeCnt