mirror of
https://github.com/cc65/cc65.git
synced 2024-06-15 17:30:06 +00:00
Conio: 65c02 optimisations
cputc: -2 cycles per char, -2 cycles per carriage return cputs: -5 cycles per char, -3 cycles on cputsxy vcprintf: -6 cycles per char
This commit is contained in:
parent
d70c902a02
commit
8a140e6503
|
@ -14,6 +14,8 @@
|
||||||
|
|
||||||
.include "apple2.inc"
|
.include "apple2.inc"
|
||||||
|
|
||||||
|
.macpack cpu
|
||||||
|
|
||||||
.segment "ONCE"
|
.segment "ONCE"
|
||||||
|
|
||||||
.ifdef __APPLE2ENH__
|
.ifdef __APPLE2ENH__
|
||||||
|
@ -51,8 +53,13 @@ cputdirect:
|
||||||
cmp WNDWDTH
|
cmp WNDWDTH
|
||||||
bcc :+
|
bcc :+
|
||||||
jsr newline
|
jsr newline
|
||||||
left: lda #$00 ; Goto left edge of screen
|
left:
|
||||||
|
.if (.cpu .bitand CPU_ISET_65SC02)
|
||||||
|
stz CH ; Goto left edge of screen
|
||||||
|
.else
|
||||||
|
lda #$00 ; Goto left edge of screen
|
||||||
sta CH
|
sta CH
|
||||||
|
.endif
|
||||||
: rts
|
: rts
|
||||||
|
|
||||||
newline:
|
newline:
|
||||||
|
@ -78,17 +85,18 @@ mask: and INVFLG ; Apply normal, inverse, flash
|
||||||
|
|
||||||
putchardirect:
|
putchardirect:
|
||||||
pha
|
pha
|
||||||
ldy CH
|
|
||||||
.ifdef __APPLE2ENH__
|
.ifdef __APPLE2ENH__
|
||||||
|
lda CH
|
||||||
bit RD80VID ; In 80 column mode?
|
bit RD80VID ; In 80 column mode?
|
||||||
bpl put ; No, just go ahead
|
bpl put ; No, just go ahead
|
||||||
tya
|
|
||||||
lsr ; Div by 2
|
lsr ; Div by 2
|
||||||
tay
|
|
||||||
bcs put ; Odd cols go in main memory
|
bcs put ; Odd cols go in main memory
|
||||||
bit HISCR ; Assume SET80COL
|
bit HISCR ; Assume SET80COL
|
||||||
|
put: tay
|
||||||
|
.else
|
||||||
|
ldy CH
|
||||||
.endif
|
.endif
|
||||||
put: lda (BASL),Y ; Get current character
|
lda (BASL),Y ; Get current character
|
||||||
tax ; Return old character for _cgetc
|
tax ; Return old character for _cgetc
|
||||||
pla
|
pla
|
||||||
sta (BASL),Y
|
sta (BASL),Y
|
||||||
|
|
|
@ -8,28 +8,46 @@
|
||||||
.export _cputsxy, _cputs
|
.export _cputsxy, _cputs
|
||||||
.import gotoxy, _cputc
|
.import gotoxy, _cputc
|
||||||
.importzp ptr1, tmp1
|
.importzp ptr1, tmp1
|
||||||
|
.macpack cpu
|
||||||
|
|
||||||
_cputsxy:
|
_cputsxy:
|
||||||
sta ptr1 ; Save s for later
|
sta ptr1 ; Save s for later
|
||||||
stx ptr1+1
|
stx ptr1+1
|
||||||
jsr gotoxy ; Set cursor, pop x and y
|
jsr gotoxy ; Set cursor, pop x and y
|
||||||
|
.if (.cpu .bitand CPU_ISET_65SC02)
|
||||||
|
bra L0 ; Same as cputs...
|
||||||
|
.else
|
||||||
jmp L0 ; Same as cputs...
|
jmp L0 ; Same as cputs...
|
||||||
|
.endif
|
||||||
|
|
||||||
_cputs: sta ptr1 ; Save s
|
_cputs: sta ptr1 ; Save s
|
||||||
stx ptr1+1
|
stx ptr1+1
|
||||||
L0: ldy #0
|
|
||||||
L1: lda (ptr1),y
|
.if (.cpu .bitand CPU_ISET_65SC02)
|
||||||
beq L9 ; Jump if done
|
|
||||||
|
L0: lda (ptr1) ; (5)
|
||||||
|
beq L9 ; (7) Jump if done
|
||||||
|
jsr _cputc ; (13) Output char, advance cursor
|
||||||
|
inc ptr1 ; (18) Bump low byte
|
||||||
|
bne L0 ; (20) Next char
|
||||||
|
inc ptr1+1 ; (25) Bump high byte
|
||||||
|
bne L0
|
||||||
|
|
||||||
|
.else
|
||||||
|
|
||||||
|
L0: ldy #0 ; (2)
|
||||||
|
L1: lda (ptr1),y ; (7)
|
||||||
|
beq L9 ; (9) Jump if done
|
||||||
iny
|
iny
|
||||||
sty tmp1 ; Save offset
|
sty tmp1 ; (14) Save offset
|
||||||
jsr _cputc ; Output char, advance cursor
|
jsr _cputc ; (20) Output char, advance cursor
|
||||||
ldy tmp1 ; Get offset
|
ldy tmp1 ; (23) Get offset
|
||||||
bne L1 ; Next char
|
bne L1 ; (25) Next char
|
||||||
inc ptr1+1 ; Bump high byte
|
inc ptr1+1 ; (30) Bump high byte
|
||||||
bne L1
|
bne L1
|
||||||
|
|
||||||
|
.endif
|
||||||
|
|
||||||
; Done
|
; Done
|
||||||
|
|
||||||
L9: rts
|
L9: rts
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
.importzp sp, ptr1, ptr2, ptr3, tmp1
|
.importzp sp, ptr1, ptr2, ptr3, tmp1
|
||||||
|
|
||||||
.macpack generic
|
.macpack generic
|
||||||
|
.macpack cpu
|
||||||
|
|
||||||
.data
|
.data
|
||||||
|
|
||||||
|
@ -74,21 +74,40 @@ out: jsr popax ; count
|
||||||
|
|
||||||
; Loop outputting characters
|
; Loop outputting characters
|
||||||
|
|
||||||
|
.if (.cpu .bitand CPU_ISET_65SC02)
|
||||||
|
|
||||||
@L1: dec outdesc+6
|
@L1: dec outdesc+6
|
||||||
beq @L4
|
beq @L4
|
||||||
@L2: ldy tmp1
|
@L2: lda (ptr1) ; (5)
|
||||||
lda (ptr1),y
|
inc ptr1 ; (10)
|
||||||
iny
|
bne @L3 ; (12)
|
||||||
bne @L3
|
inc ptr1+1 ; (17)
|
||||||
inc ptr1+1
|
@L3: jsr _cputc ; (23)
|
||||||
@L3: sty tmp1
|
bra @L1 ; (26)
|
||||||
jsr _cputc
|
|
||||||
jmp @L1
|
|
||||||
|
|
||||||
@L4: dec outdesc+7
|
@L4: dec outdesc+7
|
||||||
bne @L2
|
bne @L2
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
.else
|
||||||
|
|
||||||
|
@L1: dec outdesc+6
|
||||||
|
beq @L4
|
||||||
|
@L2: ldy tmp1 ; (3)
|
||||||
|
lda (ptr1),y ; (8)
|
||||||
|
iny ; (10)
|
||||||
|
bne @L3 ; (12)
|
||||||
|
inc ptr1+1 ; (17)
|
||||||
|
@L3: sty tmp1 ; (20)
|
||||||
|
jsr _cputc ; (26)
|
||||||
|
jmp @L1 ; (32)
|
||||||
|
|
||||||
|
@L4: dec outdesc+7
|
||||||
|
bne @L2
|
||||||
|
rts
|
||||||
|
|
||||||
|
.endif
|
||||||
|
|
||||||
; ----------------------------------------------------------------------------
|
; ----------------------------------------------------------------------------
|
||||||
; vcprintf - formatted console i/o
|
; vcprintf - formatted console i/o
|
||||||
;
|
;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user