File: open.s

package info (click to toggle)
cc65 2.19-2
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 20,268 kB
  • sloc: ansic: 117,151; asm: 66,339; pascal: 4,248; makefile: 1,009; perl: 607
file content (33 lines) | stat: -rw-r--r-- 995 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
    .export    _open

    .import    addysp,popax

    .importzp  sp,tmp2,tmp3,tmp1


    .include   "telestrat.inc"
    .include   "errno.inc"
    .include   "fcntl.inc"

; int open (const char* name, int flags, ...);    /* May take a mode argument */
.proc _open
; Throw away any additional parameters passed through the ellipsis

    dey                     ; Parm count < 4 shouldn't be needed to be...
    dey                     ; ...checked (it generates a c compiler warning)
    dey
    dey
    beq         parmok      ; Branch if parameter count ok
    jsr         addysp      ; Fix stack, throw away unused parameters

; Parameters ok. Pop the flags and save them into tmp3

parmok:
    jsr         popax       ; Get flagss
    sta         tmp3        ; save flags
; Get the filename from stack and parse it. Bail out if is not ok
    jsr         popax       ; Get name
    ldy         tmp3        ; Get flags again
    BRK_TELEMON XOPEN       ; launch primitive ROM
    rts
.endproc