]> git.sur5r.net Git - cc65/commitdiff
lseek: Implement additional feedback from PR #723.
authorPatrick Pelletier <code@funwithsoftware.org>
Mon, 20 Aug 2018 07:56:01 +0000 (00:56 -0700)
committerOliver Schmidt <ol.sc@web.de>
Mon, 20 Aug 2018 20:24:48 +0000 (22:24 +0200)
* Check CPU_ISET_65SC02 rather than APPLE2ENH.
* Set sreg and sreg+1 to $FF on error, to return -1 as a long.

libsrc/apple2/lseek.s

index 6d5eba8a233b8eb19fdf74818e9745649a434bed..d1633c32cc833a7b03c7afe4b594c8847e9e7af2 100644 (file)
@@ -6,6 +6,7 @@
 
         .export         _lseek
         .import         popax, popptr1
+        .macpack        cpu
 
         .include        "zeropage.inc"
         .include        "errno.inc"
@@ -85,12 +86,12 @@ seek_common:
         bcs     oserr
 
         ; Need to return the position in EAX
-        .ifdef  __APPLE2ENH__
+.if (.cpu .bitand ::CPU_ISET_65SC02)
         stz     sreg+1
-        .else
-        lda     #0
+.else
+        lda     #$00
         sta     sreg+1
-        .endif
+.endif
         lda     mliparam + MLI::MARK::POSITION+2
         sta     sreg
         ldx     mliparam + MLI::MARK::POSITION+1
@@ -102,7 +103,13 @@ seek_common:
 einval: lda     #EINVAL
 
         ; Set __errno
-errno:  jmp     __directerrno
+errno:  ldx     #$FF
+        stx     sreg
+        stx     sreg+1
+        jmp     __directerrno
 
         ; Set __oserror
-oserr:  jmp     __mappederrno
+oserr:  ldx     #$FF
+        stx     sreg
+        stx     sreg+1
+        jmp     __mappederrno