2017-02-01 23:11:11 +00:00
|
|
|
.export _open
|
|
|
|
|
|
|
|
.import addysp,popax
|
|
|
|
|
|
|
|
.importzp sp,tmp2,tmp3,tmp1
|
2017-01-04 19:03:19 +00:00
|
|
|
|
2017-01-31 21:09:14 +00:00
|
|
|
|
2017-01-31 21:33:19 +00:00
|
|
|
.include "telestrat.inc"
|
|
|
|
.include "errno.inc"
|
|
|
|
.include "fcntl.inc"
|
2017-01-31 21:09:14 +00:00
|
|
|
|
|
|
|
; int open (const char* name, int flags, ...); /* May take a mode argument */
|
2016-12-14 20:22:10 +00:00
|
|
|
.proc _open
|
|
|
|
; Throw away any additional parameters passed through the ellipsis
|
|
|
|
|
2017-01-31 21:33:19 +00:00
|
|
|
dey ; Parm count < 4 shouldn't be needed to be...
|
|
|
|
dey ; ...checked (it generates a c compiler warning)
|
|
|
|
dey
|
|
|
|
dey
|
2017-02-01 23:11:11 +00:00
|
|
|
beq parmok ; Branch if parameter count ok
|
|
|
|
jsr addysp ; Fix stack, throw away unused parameters
|
2016-12-14 20:22:10 +00:00
|
|
|
|
|
|
|
; Parameters ok. Pop the flags and save them into tmp3
|
|
|
|
|
2017-02-01 23:11:11 +00:00
|
|
|
parmok:
|
|
|
|
jsr popax ; Get flagss
|
|
|
|
sta tmp3 ; save flags
|
2016-12-14 20:22:10 +00:00
|
|
|
; Get the filename from stack and parse it. Bail out if is not ok
|
2017-02-01 23:11:11 +00:00
|
|
|
jsr popax ; Get name
|
2017-02-02 21:53:28 +00:00
|
|
|
ldy tmp3 ; Get flags again
|
2017-02-01 23:11:11 +00:00
|
|
|
BRK_TELEMON XOPEN ; launch primitive ROM
|
2017-01-31 21:33:19 +00:00
|
|
|
rts
|
2016-12-14 20:22:10 +00:00
|
|
|
.endproc
|