mirror of
https://github.com/cc65/cc65.git
synced 2024-11-18 15:05:14 +00:00
8f7b91eea6
git-svn-id: svn://svn.cc65.org/cc65/trunk@3032 b7a2c559-68d2-44c3-8de9-860c34a00d81
50 lines
958 B
ArmAsm
50 lines
958 B
ArmAsm
;
|
|
; Ullrich von Bassewitz, 22.11.2002
|
|
;
|
|
; FILE* __fastcall__ fopen (const char* name, const char* mode)
|
|
; /* Open a file */
|
|
;
|
|
|
|
.export _fopen
|
|
|
|
.import __fopen, __fdesc
|
|
.import pushax, return0
|
|
|
|
.include "errno.inc"
|
|
|
|
|
|
; ------------------------------------------------------------------------
|
|
; Code
|
|
|
|
.proc _fopen
|
|
|
|
; Bring the mode parameter on the stack
|
|
|
|
jsr pushax
|
|
|
|
; Allocate a new file stream
|
|
|
|
jsr __fdesc
|
|
|
|
; Check if we have a stream
|
|
|
|
cmp #$00
|
|
bne @L1
|
|
cpx #$00
|
|
bne @L1
|
|
|
|
; Failed to allocate a file stream
|
|
|
|
lda #EMFILE
|
|
jsr __seterrno ; Set __errno, will return 0 in A
|
|
tax
|
|
rts ; Return zero
|
|
|
|
; Open the file and return the file descriptor. All arguments are already
|
|
; in place: name and mode on the stack, and f in a/x
|
|
|
|
@L1: jmp __fopen
|
|
|
|
.endproc
|
|
|