System Call

from som v2.4 upward
more macros are defined in lib2.som

: print x = syscall {1 x}
: printc x = syscall {2 x}
: getc = syscall {3}
: gets buf = syscall {4 buf}

// mode 0-read, 1-write, 2-readwrite
: fopen fn mode = syscall {5 fn mode}
: fclose f = syscall {6 f}
: fprint f x = syscall {7 f x}
: fprintc f  x = syscall {8 f x}
: fgetc f = syscall {9 f}
: fgets f buf = syscall {10 f buf}

// for som-compiler

: eval a = syscall {12 a}
: exit = syscall {13}
: load fn = syscall {15 fn}
: syslex f = syscall {16 f}   // in som 4.2

Here is the list of system call for each version

v1, v1.5
1 print x
2 printc c
3 getchar
19 loadfile name

v1.7
1 print x
2 printc c
3 getchar
4 --
5 fopen name mode
6 fclose fp
7 fprint fp x
8 fprintc fp c
9 fgetc fp
10 alloc x
11 loadfile name

v1.8
1..11 as v17
12 eval x
13 end

v2
1 print x
2 printc c
3 getchar
4 gets
5 eval x
7 end

v2.4
1..9 as v17
10 fgets fp buf
11 --
12 eval x
13 end
14 alloc x
15 load name  ; exec from user

v3, v3.1, v4, v4.1
1 print x
2 printc c
3 getchar
4 gets
5 fopen name mode
6 fclose fp
7 fprint fp x
8 fprintc fp c
9 fgetc fp
10 fgets fp buf
11 --
12 eval x
13 end
14 alloc x
15 load name ; exec from user

v 4.2  (lex in vm)
1 .. 15 similar to v4
16 lex fc    ; return tok from the current file

v 5.0 similar to v4.2

last update 22 Nov 2009