mirror of
https://github.com/cc65/cc65.git
synced 2024-06-23 09:29:34 +00:00
Serial: Optimize SER_PUT
We don't need to reload SendFreeCnt if we don't jsr TryToSend.
This commit is contained in:
parent
89af42e5cb
commit
e8f5ad2471
|
@ -328,20 +328,21 @@ SER_PUT:
|
||||||
|
|
||||||
; Try to send
|
; Try to send
|
||||||
ldy SendFreeCnt
|
ldy SendFreeCnt
|
||||||
iny ; Y = $FF?
|
cpy #$FF ; Nothing to flush
|
||||||
beq :+
|
beq :+
|
||||||
pha
|
pha
|
||||||
lda #$00 ; TryHard = false
|
lda #$00 ; TryHard = false
|
||||||
jsr TryToSend
|
jsr TryToSend
|
||||||
pla
|
pla
|
||||||
|
|
||||||
; Put byte into send buffer & send
|
; Reload SendFreeCnt after TryToSend
|
||||||
: ldy SendFreeCnt
|
ldy SendFreeCnt
|
||||||
bne :+
|
bne :+
|
||||||
lda #SER_ERR_OVERFLOW
|
lda #SER_ERR_OVERFLOW
|
||||||
ldx #0 ; return value is char
|
ldx #0 ; return value is char
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
; Put byte into send buffer & send
|
||||||
: ldy SendTail
|
: ldy SendTail
|
||||||
sta SendBuf,y
|
sta SendBuf,y
|
||||||
inc SendTail
|
inc SendTail
|
||||||
|
|
|
@ -269,20 +269,21 @@ SER_GET:
|
||||||
SER_PUT:
|
SER_PUT:
|
||||||
; Try to send
|
; Try to send
|
||||||
ldy SendFreeCnt
|
ldy SendFreeCnt
|
||||||
iny ; Y = $FF?
|
cpy #$FF ; Nothing to flush
|
||||||
beq :+
|
beq :+
|
||||||
pha
|
pha
|
||||||
lda #$00 ; TryHard = false
|
lda #$00 ; TryHard = false
|
||||||
jsr TryToSend
|
jsr TryToSend
|
||||||
pla
|
pla
|
||||||
|
|
||||||
; Put byte into send buffer & send
|
; Reload SendFreeCnt after TryToSend
|
||||||
: ldy SendFreeCnt
|
ldy SendFreeCnt
|
||||||
bne :+
|
bne :+
|
||||||
lda #SER_ERR_OVERFLOW
|
lda #SER_ERR_OVERFLOW
|
||||||
ldx #0 ; return value is char
|
ldx #0 ; return value is char
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
; Put byte into send buffer & send
|
||||||
: ldy SendTail
|
: ldy SendTail
|
||||||
sta SendBuf,y
|
sta SendBuf,y
|
||||||
inc SendTail
|
inc SendTail
|
||||||
|
|
|
@ -362,21 +362,23 @@ SER_PUT:
|
||||||
; Try to send
|
; Try to send
|
||||||
|
|
||||||
ldx SendFreeCnt
|
ldx SendFreeCnt
|
||||||
inx ; X = $ff?
|
cpx #$FF ; Nothing to flush
|
||||||
beq @L2
|
beq @L2
|
||||||
pha
|
pha
|
||||||
lda #$00
|
lda #$00
|
||||||
jsr TryToSend
|
jsr TryToSend
|
||||||
pla
|
pla
|
||||||
|
|
||||||
; Put byte into send buffer & send
|
; Reload SendFreeCnt after TryToSend
|
||||||
|
|
||||||
@L2: ldx SendFreeCnt
|
ldx SendFreeCnt
|
||||||
bne @L3
|
bne @L2
|
||||||
lda #SER_ERR_OVERFLOW ; X is already zero
|
lda #SER_ERR_OVERFLOW ; X is already zero
|
||||||
rts
|
rts
|
||||||
|
|
||||||
@L3: ldx SendTail
|
; Put byte into send buffer & send
|
||||||
|
|
||||||
|
@L2: ldx SendTail
|
||||||
sta SendBuf,x
|
sta SendBuf,x
|
||||||
inc SendTail
|
inc SendTail
|
||||||
dec SendFreeCnt
|
dec SendFreeCnt
|
||||||
|
|
|
@ -336,21 +336,23 @@ SER_PUT:
|
||||||
; Try to send
|
; Try to send
|
||||||
|
|
||||||
ldx SendFreeCnt
|
ldx SendFreeCnt
|
||||||
inx ; X = $ff?
|
cpx #$FF ; Nothing to flush
|
||||||
beq @L2
|
beq @L2
|
||||||
pha
|
pha
|
||||||
lda #$00
|
lda #$00
|
||||||
jsr TryToSend
|
jsr TryToSend
|
||||||
pla
|
pla
|
||||||
|
|
||||||
; Put byte into send buffer & send
|
; Reload SendFreeCnt after TryToSend
|
||||||
|
|
||||||
@L2: ldx SendFreeCnt
|
ldx SendFreeCnt
|
||||||
bne @L3
|
bne @L2
|
||||||
lda #SER_ERR_OVERFLOW ; X is already zero
|
lda #SER_ERR_OVERFLOW ; X is already zero
|
||||||
rts
|
rts
|
||||||
|
|
||||||
@L3: ldx SendTail
|
; Put byte into send buffer & send
|
||||||
|
|
||||||
|
@L2: ldx SendTail
|
||||||
sta SendBuf,x
|
sta SendBuf,x
|
||||||
inc SendTail
|
inc SendTail
|
||||||
dec SendFreeCnt
|
dec SendFreeCnt
|
||||||
|
|
|
@ -292,21 +292,23 @@ SER_PUT:
|
||||||
; Try to send
|
; Try to send
|
||||||
|
|
||||||
ldx SendFreeCnt
|
ldx SendFreeCnt
|
||||||
inx ; X = $ff?
|
cpx #$FF ; Nothing to flush
|
||||||
beq @L2
|
beq @L2
|
||||||
pha
|
pha
|
||||||
lda #$00
|
lda #$00
|
||||||
jsr TryToSend
|
jsr TryToSend
|
||||||
pla
|
pla
|
||||||
|
|
||||||
; Put byte into send buffer & send
|
; Reload SendFreeCnt after TryToSend
|
||||||
|
|
||||||
@L2: ldx SendFreeCnt
|
ldx SendFreeCnt
|
||||||
bne @L3
|
bne @L2
|
||||||
lda #SER_ERR_OVERFLOW ; X is already zero
|
lda #SER_ERR_OVERFLOW ; X is already zero
|
||||||
rts
|
rts
|
||||||
|
|
||||||
@L3: ldx SendTail
|
; Put byte into send buffer & send
|
||||||
|
|
||||||
|
@L2: ldx SendTail
|
||||||
sta SendBuf,x
|
sta SendBuf,x
|
||||||
inc SendTail
|
inc SendTail
|
||||||
dec SendFreeCnt
|
dec SendFreeCnt
|
||||||
|
|
|
@ -293,21 +293,23 @@ SER_PUT:
|
||||||
; Try to send
|
; Try to send
|
||||||
|
|
||||||
ldx SendFreeCnt
|
ldx SendFreeCnt
|
||||||
inx ; X = $ff?
|
cpx #$ff ; Nothing to flush
|
||||||
beq @L2
|
beq @L2
|
||||||
pha
|
pha
|
||||||
lda #$00
|
lda #$00
|
||||||
jsr TryToSend
|
jsr TryToSend
|
||||||
pla
|
pla
|
||||||
|
|
||||||
; Put byte into send buffer & send
|
; Reload SendFreeCnt after TryToSend
|
||||||
|
|
||||||
@L2: ldx SendFreeCnt
|
ldx SendFreeCnt
|
||||||
bne @L3
|
bne @L2
|
||||||
lda #SER_ERR_OVERFLOW ; X is already zero
|
lda #SER_ERR_OVERFLOW ; X is already zero
|
||||||
rts
|
rts
|
||||||
|
|
||||||
@L3: ldx SendTail
|
; Put byte into send buffer & send
|
||||||
|
|
||||||
|
@L2: ldx SendTail
|
||||||
sta SendBuf,x
|
sta SendBuf,x
|
||||||
inc SendTail
|
inc SendTail
|
||||||
dec SendFreeCnt
|
dec SendFreeCnt
|
||||||
|
|
|
@ -300,21 +300,23 @@ SER_PUT:
|
||||||
; Try to send
|
; Try to send
|
||||||
|
|
||||||
ldx SendFreeCnt
|
ldx SendFreeCnt
|
||||||
inx ; X = $ff?
|
cpx #$ff ; Nothing to flush
|
||||||
beq @L2
|
beq @L2
|
||||||
pha
|
pha
|
||||||
lda #$00
|
lda #$00
|
||||||
jsr TryToSend
|
jsr TryToSend
|
||||||
pla
|
pla
|
||||||
|
|
||||||
; Put byte into send buffer & send
|
; Reload SendFreeCnt after TryToSend
|
||||||
|
|
||||||
@L2: ldx SendFreeCnt
|
ldx SendFreeCnt
|
||||||
bne @L3
|
bne @L2
|
||||||
lda #SER_ERR_OVERFLOW ; X is already zero
|
lda #SER_ERR_OVERFLOW ; X is already zero
|
||||||
rts
|
rts
|
||||||
|
|
||||||
@L3: ldx SendTail
|
; Put byte into send buffer & send
|
||||||
|
|
||||||
|
@L2: ldx SendTail
|
||||||
sta SendBuf,x
|
sta SendBuf,x
|
||||||
inc SendTail
|
inc SendTail
|
||||||
dec SendFreeCnt
|
dec SendFreeCnt
|
||||||
|
|
Loading…
Reference in New Issue
Block a user