]> git.sur5r.net Git - cc65/blob - libsrc/telestrat/open.s
9455855dace392fc5123e4bca6fb80417a1857b0
[cc65] / libsrc / telestrat / open.s
1         .export         _open
2         .import                 addysp,popax
3         .importzp           sp,tmp2,tmp3,tmp1
4         
5         
6         .include        "telestrat.inc"
7         .include                "errno.inc"
8         .include        "fcntl.inc"     
9
10 ; int open (const char* name, int flags, ...);    /* May take a mode argument */
11 .proc _open
12 ; Throw away any additional parameters passed through the ellipsis
13
14         dey                     ; Parm count < 4 shouldn't be needed to be...
15         dey                     ; ...checked (it generates a c compiler warning)
16         dey
17         dey
18         beq             parmok          ; Branch if parameter count ok
19         jsr             addysp          ; Fix stack, throw away unused parameters
20
21 ; Parameters ok. Pop the flags and save them into tmp3
22
23 parmok: jsr             popax           ; Get flagss
24                 sta                     tmp3 ; save flags
25 ; Get the filename from stack and parse it. Bail out if is not ok
26
27         jsr             popax   ; Get name
28         ldy             tmp3    ; Get flags again
29         BRK_TELEMON XOPEN       ; launch primitive ROM
30         rts
31 .endproc
32                 
33