_heapmemavail.o \
_oserror.o \
_printf.o \
+ _seterrno.o \
_swap.o \
_sys.o \
abs.o \
invmode:
lda #EINVAL
- sta __errno
- lda #0
- sta __errno+1
- tax
+ jsr __seterrno ; Set __errno, returns zero in A
+ tax ; a/x = 0
jmp incsp4
; Mode string successfully parsed. Store the binary mode onto the stack in
--- /dev/null
+;
+; Ullrich von Bassewitz, 2004-05-13
+;
+; __seterrno: Will set __errno to the value in A and return zero in A. Other
+; registers aren't changed. The function is C callable, but
+; currently only called from asm code.
+;
+
+ .include "errno.inc"
+
+.code
+
+.proc __seterrno
+
+ sta __errno
+ lda #0
+ sta __errno+1
+ rts
+
+.endproc
+
+
; Error, no space left
@Error: lda #ENOSPC ; No space left
- sta __errno
- ldx #$00
- stx __errno+1
- dex ; Make return value -1
+ jsr __seterrno
+ ldx #$FF ; Return -1
txa
rts
; File is not open
lda #EINVAL
- sta __errno
- ldx #0
- stx __errno+1
- dex
- txa
+ jsr __seterrno
+ lda #$FF ; Return -1
+ tax
rts
; File is open. Reset the flags and close the file.
; Failed to allocate a file stream
lda #EMFILE
- sta __errno
- lda #0
- sta __errno+1
+ jsr __seterrno ; Set __errno, will return 0 in A
tax
rts ; Return zero
; File not open
- lda #EINVAL
- sta __errno
- lda #0
- sta __errno+1
+ lda #EINVAL
+ jsr __seterrno
@L1: jsr incsp6
jmp return0
; File not open
lda #EINVAL
- sta __errno
- lda #0
- sta __errno+1
+ jsr __seterrno
@L1: jsr incsp6
jmp return0
@L1: ldy sreg+1
bpl @L2
-
- lda #$00
- sta __errno+1
+
lda #ENOSYS ; Function not implemented
- sta __errno
+ jsr __seterrno ; Set __errno
; Reload the low byte of the result and return