]> git.sur5r.net Git - cc65/blob - libsrc/common/creat.s
Allow "mode" argument to open() to be passed from 6502 code.
[cc65] / libsrc / common / creat.s
1 ;
2 ; Ullrich von Bassewitz, 2003-06-12
3 ;
4 ; int __fastcall__ creat (const char* name, unsigned mode);
5 ;
6
7         .export         _creat
8         .import         _open
9         .import         pushax
10
11         .include        "fcntl.inc"
12
13
14 ; The call
15 ;
16 ;       creat (name, mode);
17 ;
18 ; is equivalent to
19 ;
20 ;       open (name, O_CREAT | O_WRONLY | O_TRUNC, mode);
21 ;
22
23
24 .proc   _creat
25
26         pha
27         txa
28         pha                             ; Save mode
29
30         lda     #<(O_CREAT | O_WRONLY | O_TRUNC)
31         ldx     #>(O_CREAT | O_WRONLY | O_TRUNC)
32         jsr     pushax
33
34         pla
35         tax
36         pla
37         jsr     pushax                  ; Push mode on argument stack
38
39         ldy     #6                      ; Number of argument bytes
40         jmp     _open
41
42 .endproc
43
44
45