From: cuz Date: Wed, 20 Nov 2002 18:14:35 +0000 (+0000) Subject: Move more common code into rwcommon.s. X-Git-Tag: V2.12.0~2081 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=cd552515fb8d7fec6a6af5075c28faa86f702918;p=cc65 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 --- diff --git a/libsrc/cbm/close.s b/libsrc/cbm/close.s index cb71224f9..989d8953b 100644 --- a/libsrc/cbm/close.s +++ b/libsrc/cbm/close.s @@ -8,7 +8,7 @@ .import CLOSE .import readdiskerror, closecmdchannel - .import __errno, __oserror + .import __oserror .importzp tmp2 .include "errno.inc" diff --git a/libsrc/cbm/open.s b/libsrc/cbm/open.s index bb6c6188c..e27f475f2 100644 --- a/libsrc/cbm/open.s +++ b/libsrc/cbm/open.s @@ -10,7 +10,7 @@ .import addysp, popax .import scratch, fnparse, fncomplete, fnset .import opencmdchannel, closecmdchannel, readdiskerror - .import __errno, __oserror + .import __oserror .import fnunit .importzp sp, tmp2, tmp3 diff --git a/libsrc/cbm/read.s b/libsrc/cbm/read.s index 0183946b5..1e9fdbd5c 100644 --- a/libsrc/cbm/read.s +++ b/libsrc/cbm/read.s @@ -10,10 +10,9 @@ .import SETLFS, OPEN, CHKIN, BASIN, CLRCH, READST .import rwcommon .import popax - .import __errno, __oserror + .import __oserror .importzp ptr1, ptr2, ptr3, tmp1, tmp2, tmp3 - .include "errno.inc" .include "fcntl.inc" .include "cbm.inc" .include "filedes.inc" @@ -42,7 +41,7 @@ .proc _read 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 @@ -122,15 +121,6 @@ eof: lda ptr3 ldx ptr3+1 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 notopen: @@ -149,4 +139,3 @@ errout: lda #$FF - diff --git a/libsrc/cbm/rwcommon.s b/libsrc/cbm/rwcommon.s index 2e124c7b0..2b6a33257 100644 --- a/libsrc/cbm/rwcommon.s +++ b/libsrc/cbm/rwcommon.s @@ -9,6 +9,7 @@ .import popax .importzp ptr1, ptr2, ptr3, tmp2 + .include "errno.inc" .include "filedes.inc" @@ -36,11 +37,19 @@ sta ptr3+1 ; Clear ptr3 jsr popax ; Get the handle - sta tmp2 cpx #$01 - bcs inv + bcs invhandle 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 diff --git a/libsrc/cbm/write.s b/libsrc/cbm/write.s index 64b3c580e..dbdc7d8d9 100644 --- a/libsrc/cbm/write.s +++ b/libsrc/cbm/write.s @@ -9,10 +9,9 @@ .import SETLFS, OPEN, CKOUT, BSOUT, CLRCH .import rwcommon - .import __errno, __oserror + .import __oserror .importzp sp, ptr1, ptr2, ptr3 - .include "errno.inc" .include "fcntl.inc" .include "cbm.inc" .include "filedes.inc" @@ -46,7 +45,7 @@ .proc _write 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 @@ -95,15 +94,6 @@ ldx ptr3+1 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 notopen: