-.proc _open
-
- dey ; parm count < 4 shouldn't be needed to be checked
- dey ; (it generates a c compiler warning)
- dey
- dey
- beq parmok ; parameter count ok
- jsr addysp ; fix stack, throw away unused parameters
-
-parmok: jsr findfreeiocb
- beq iocbok ; we found one
-
- lda #<EMFILE ; "too many open files"
-seterr: jsr __directerrno
- jsr incsp4 ; clean up stack
- lda #$FF
- tax
- rts ; return -1
-
- ; process the mode argument
-
-iocbok: stx tmp4
- jsr clriocb ; init with zero
- ldy #1
- jsr ldaxysp ; get mode
- ldx tmp4
- pha
- and #O_APPEND
- beq no_app
- pla
- and #15
- cmp #O_RDONLY ; DOS supports append with write-only only
- beq invret
- cmp #O_RDWR
- beq invret
- lda #OPNOT|APPEND
- bne set
-
-.ifndef UCASE_FILENAME
-invret: lda #<EINVAL ; file name is too long
- jmp seterr
+.proc _open
+
+ dey ; parm count < 4 shouldn't be needed to be checked
+ dey ; (it generates a c compiler warning)
+ dey
+ dey
+ beq parmok ; parameter count ok
+ jsr addysp ; fix stack, throw away unused parameters
+
+parmok: jsr findfreeiocb
+ beq iocbok ; we found one
+
+ lda #<EMFILE ; "too many open files"
+seterr: jsr __directerrno
+ jsr incsp4 ; clean up stack
+ lda #$FF
+ tax
+ rts ; return -1
+
+ ; process the mode argument
+
+iocbok: stx tmp4
+ jsr clriocb ; init with zero
+ ldy #1
+ jsr ldaxysp ; get mode
+ ldx tmp4
+ pha
+ and #O_APPEND
+ beq no_app
+ pla
+ and #15
+ cmp #O_RDONLY ; DOS supports append with write-only only
+ beq invret
+ cmp #O_RDWR
+ beq invret
+ lda #OPNOT|APPEND
+ bne set
+
+.ifndef UCASE_FILENAME
+invret: lda #<EINVAL ; file name is too long
+ jmp seterr