]> git.sur5r.net Git - cc65/blobdiff - libsrc/cbm/open.s
Removed .import for std kernal entries. Added .include "cbm.inc"
[cc65] / libsrc / cbm / open.s
index 678dd04412f331f385b92f30e5c94d4173d263d1..f23e97383cff68918ef262ad39b227c85751abe7 100644 (file)
@@ -1,17 +1,12 @@
 ;
 ; Ullrich von Bassewitz, 16.11.2002
 ;
-; int open (const char* name, int flags, ...); /* May take a mode argument */
-;
-; Be sure to keep the value priority of closeallfiles lower than that of
-; closeallstreams (which is the high level C file I/O counterpart and must be
-; called before closeallfiles).
+; int open (const char* name, int flags, ...);  /* May take a mode argument */
 
 
         .export         _open
         .destructor     closeallfiles, 5
 
-        .import         SETLFS, OPEN, CLOSE
         .import         addysp, popax
         .import         scratch, fnparse, fnaddmode, fncomplete, fnset
         .import         opencmdchannel, closecmdchannel, readdiskerror
@@ -22,6 +17,7 @@
         .include        "errno.inc"
         .include        "fcntl.inc"
         .include        "filedes.inc"
+        .include        "cbm.inc"
 
 
 ;--------------------------------------------------------------------------
@@ -58,12 +54,12 @@ next:   dex
 
 ; Throw away any additional parameters passed through the ellipsis
 
-               dey                     ; Parm count < 4 shouldn't be needed to be...
-               dey                     ; ...checked (it generates a c compiler warning)
+        dey                     ; Parm count < 4 shouldn't be needed to be...
+        dey                     ; ...checked (it generates a c compiler warning)
+        dey
         dey
-               dey
-               beq     parmok          ; Branch if parameter count ok
-               jsr     addysp          ; Fix stack, throw away unused parameters
+        beq     parmok          ; Branch if parameter count ok
+        jsr     addysp          ; Fix stack, throw away unused parameters
 
 ; Parameters ok. Pop the flags and save them into tmp3
 
@@ -96,7 +92,7 @@ parmok: jsr     popax           ; Get flags
 
 ; Invalid open mode
 
-einval: lda     #EINVAL
+        lda     #EINVAL
 
 ; Error entry. Sets _errno, clears _oserror, returns -1
 
@@ -119,14 +115,11 @@ closeandexit:
 
 oserror:jmp     __mappederrno
 
-
 ; Read bit is set. Add an 'r' to the name
 
-doread: ldy     fnisfile        ; File or directory?
-        beq     isdir           ; Don't add ,R for directory
-        lda     #'r'
+doread: lda     #'r'
         jsr     fnaddmode       ; Add the mode to the name
-isdir:  lda     #LFN_READ
+        lda     #LFN_READ
         bne     common          ; Branch always
 
 ; If O_TRUNC is set, scratch the file, but ignore any errors
@@ -202,4 +195,4 @@ nofile:                         ; ... else use SA=0 (read)
 .endproc
 
 
-
+