-
Notifications
You must be signed in to change notification settings - Fork 2
/
file.S
46 lines (42 loc) · 979 Bytes
/
file.S
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
34
35
36
37
38
39
40
41
42
43
44
45
46
# file.S - words used to work with files and shared libraries
# ( path flags -- filedes )
# open a file
# path - address of path string null terminated
# option flags
#Forthword_ OPENF, 0, "open"
# rpush_ # flags
# rpushd0_ # path
# call open
# rnip2_
# nip_
# ret
# ( filedes -- )
# open a file
# filedes - file descriptor
#Forthword_ CLOSEF, 0, "close"
# rpush_ # filedes
# call close
# rnip_
# ret
# ( filedes buffer length -- bytesread )
# fetch bytes from an open file using filedes
# number of bytes read left in WR
#Forthword_ READF, 0, "read"
# rpush_ # length
# rpushd0_ # buffer
# rpushd1_ # filedes
# call read
# rnip3_
# nip2_
# ret
# ( filedes buffer length -- bytesread )
# write bytes to an open file using filedes
# number of bytes written left in WR
#Forthword_ WRITEF, 0, "write"
# rpush_ # length
# rpushd0_ # buffer
# rpushd1_ # filedes
# call write
# rnip3_
# nip2_
# ret