1
0
mirror of https://github.com/cc65/cc65.git synced 2025-02-26 23:30:03 +00:00

Declare zero page variables before use. Otherwise they aren't used in zero

page addressing mode, if the assembler has a choice.


git-svn-id: svn://svn.cc65.org/cc65/trunk@3725 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz 2006-04-09 11:43:03 +00:00
parent c13f40a9f1
commit 06e00f9343

View File

@ -8,43 +8,57 @@
.import __rwsetup,__do_oserror,__inviocb,__oserror .import __rwsetup,__do_oserror,__inviocb,__oserror
.export _read .export _read
_read: jsr __rwsetup ; do common setup for read and write _read: jsr __rwsetup ; do common setup for read and write
beq done ; if size 0, it's a no-op beq done ; if size 0, it's a no-op
cpx #$FF ; invalid iocb? cpx #$FF ; invalid iocb?
beq _inviocb beq _inviocb
.ifdef LINEBUF .ifdef LINEBUF
; E: should be always at IOCB #0 ; E: should be always at IOCB #0
; fixme: what happens when user closes and reopens stdin? ; fixme: what happens when user closes and reopens stdin?
cpx #0 ; E: handler (line oriented keyboard input)? cpx #0 ; E: handler (line oriented keyboard input)?
beq do_line beq do_line
.endif .endif
lda #GETCHR ; iocb command code lda #GETCHR ; iocb command code
sta ICCOM,x sta ICCOM,x
jsr CIOV ; read it jsr CIOV ; read it
bpl done bpl done
cpy #EOFERR ; eof is treated specially cpy #EOFERR ; eof is treated specially
beq done beq done
jmp __do_oserror ; update errno jmp __do_oserror ; update errno
done: lda ICBLL,x ; buf len lo done: lda ICBLL,x ; buf len lo
pha ; save pha ; save
lda ICBLH,x ; get buf len hi lda ICBLH,x ; get buf len hi
tax ; to X tax ; to X
okdone: lda #0 okdone: lda #0
sta __oserror ; clear system dependend error code sta __oserror ; clear system dependend error code
pla ; get buf len lo pla ; get buf len lo
rts rts
_inviocb: _inviocb:
jmp __inviocb jmp __inviocb
.ifdef LINEBUF .ifdef LINEBUF
; line oriented input ; line oriented input
.segment "EXTZP" : zeropage
index: .res 1 ; index into line buffer
buflen: .res 1 ; length of used part of buffer
cbs: .res 1 ; current buffer size: buflen - index
dataptr:.res 2 ; temp pointer to user buffer
copylen:.res 1 ; temp counter
.bss
linebuf:.res LINEBUF ; the line buffer
.code
do_line: do_line:
lda buflen ; line buffer active? lda buflen ; line buffer active?
bne use_buf ; yes, get data from there bne use_buf ; yes, get data from there
@ -86,7 +100,7 @@ do_line:
newbuf: newbuf:
lda ICBLL,x ; get # of bytes read lda ICBLL,x ; get # of bytes read
sta buflen sta buflen
lda #0 lda #0
sta index ; fresh buffer sta index ; fresh buffer
; restore user buffer address & length ; restore user buffer address & length
@ -129,7 +143,7 @@ icbll_copy:
lda ICBAL,x ; buffer address lda ICBAL,x ; buffer address
sta dataptr sta dataptr
lda ICBAH,x ; buffer address lda ICBAH,x ; buffer address
sta dataptr+1 sta dataptr+1
lda ICBLL,x lda ICBLL,x
sta copylen sta copylen
@ -164,17 +178,5 @@ btsmall:
sta ICBLL,x sta ICBLL,x
bpl icbll_copy bpl icbll_copy
.segment "EXTZP" : zeropage
index: .res 1 ; index into line buffer
buflen: .res 1 ; length of used part of buffer
cbs: .res 1 ; current buffer size: buflen - index
dataptr:.res 2 ; temp pointer to user buffer
copylen:.res 1 ; temp counter
.bss
linebuf:.res LINEBUF ; the line buffer
.endif ; .ifdef LINEBUF .endif ; .ifdef LINEBUF