1
0
mirror of https://github.com/cc65/cc65.git synced 2024-09-29 17:56:21 +00:00

Move more common code into rwcommon.s.

Move declaration of __errno into errno.inc.


git-svn-id: svn://svn.cc65.org/cc65/trunk@1552 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz 2002-11-20 18:14:35 +00:00
parent cfbe5ec5b4
commit cd552515fb
5 changed files with 18 additions and 30 deletions

View File

@ -8,7 +8,7 @@
.import CLOSE .import CLOSE
.import readdiskerror, closecmdchannel .import readdiskerror, closecmdchannel
.import __errno, __oserror .import __oserror
.importzp tmp2 .importzp tmp2
.include "errno.inc" .include "errno.inc"

View File

@ -10,7 +10,7 @@
.import addysp, popax .import addysp, popax
.import scratch, fnparse, fncomplete, fnset .import scratch, fnparse, fncomplete, fnset
.import opencmdchannel, closecmdchannel, readdiskerror .import opencmdchannel, closecmdchannel, readdiskerror
.import __errno, __oserror .import __oserror
.import fnunit .import fnunit
.importzp sp, tmp2, tmp3 .importzp sp, tmp2, tmp3

View File

@ -10,10 +10,9 @@
.import SETLFS, OPEN, CHKIN, BASIN, CLRCH, READST .import SETLFS, OPEN, CHKIN, BASIN, CLRCH, READST
.import rwcommon .import rwcommon
.import popax .import popax
.import __errno, __oserror .import __oserror
.importzp ptr1, ptr2, ptr3, tmp1, tmp2, tmp3 .importzp ptr1, ptr2, ptr3, tmp1, tmp2, tmp3
.include "errno.inc"
.include "fcntl.inc" .include "fcntl.inc"
.include "cbm.inc" .include "cbm.inc"
.include "filedes.inc" .include "filedes.inc"
@ -42,7 +41,7 @@
.proc _read .proc _read
jsr rwcommon ; Pop params, check handle jsr rwcommon ; Pop params, check handle
bcs invalidfd ; Branch if handle not ok bcs errout ; Invalid handle, errno already set
; Check if the LFN is valid and the file is open for writing ; Check if the LFN is valid and the file is open for writing
@ -122,15 +121,6 @@ eof: lda ptr3
ldx ptr3+1 ldx ptr3+1
rts rts
; Error entry, file descriptor is invalid
invalidfd:
lda #EINVAL
sta __errno
lda #0
sta __errno+1
beq errout
; Error entry, file is not open ; Error entry, file is not open
notopen: notopen:
@ -149,4 +139,3 @@ errout: lda #$FF

View File

@ -9,6 +9,7 @@
.import popax .import popax
.importzp ptr1, ptr2, ptr3, tmp2 .importzp ptr1, ptr2, ptr3, tmp2
.include "errno.inc"
.include "filedes.inc" .include "filedes.inc"
@ -36,11 +37,19 @@
sta ptr3+1 ; Clear ptr3 sta ptr3+1 ; Clear ptr3
jsr popax ; Get the handle jsr popax ; Get the handle
sta tmp2
cpx #$01 cpx #$01
bcs inv bcs invhandle
cmp #MAX_FDS cmp #MAX_FDS
inv: rts bcs invhandle
sta tmp2
rts ; Return with carry clear
invhandle:
lda #EINVAL
sta __errno
lda #0
sta __errno+1
rts ; Return with carry set
.endproc .endproc

View File

@ -9,10 +9,9 @@
.import SETLFS, OPEN, CKOUT, BSOUT, CLRCH .import SETLFS, OPEN, CKOUT, BSOUT, CLRCH
.import rwcommon .import rwcommon
.import __errno, __oserror .import __oserror
.importzp sp, ptr1, ptr2, ptr3 .importzp sp, ptr1, ptr2, ptr3
.include "errno.inc"
.include "fcntl.inc" .include "fcntl.inc"
.include "cbm.inc" .include "cbm.inc"
.include "filedes.inc" .include "filedes.inc"
@ -46,7 +45,7 @@
.proc _write .proc _write
jsr rwcommon ; Pop params, check handle jsr rwcommon ; Pop params, check handle
bcs invalidfd ; Branch if handle not ok bcs errout ; Invalid handle, errno already set
; Check if the LFN is valid and the file is open for writing ; Check if the LFN is valid and the file is open for writing
@ -95,15 +94,6 @@
ldx ptr3+1 ldx ptr3+1
rts rts
; Error entry, file descriptor is invalid
invalidfd:
lda #EINVAL
sta __errno
lda #0
sta __errno+1
beq errout
; Error entry, file is not open ; Error entry, file is not open
notopen: notopen: