raz / conform / run / SystemImport.raz

25 lines · 704 B · raw · history · last change e33d4214

1(* import SYSTEM (report section 3): SYSTEM.ADR, SYSTEM.PTR,
2 SYSTEM.SYSCALL and SYSTEM.ARGV are the built-ins of section 6.8,
3 written by that name, and a local given to SYSTEM.ADR is that
4 variable, however busy. *)
5module SystemImport;
6import Out, SYSTEM;
7
8proc main*;
9var k, i: INT; p: ^INT; a: [4]U8; s: []U8; q: ^U8;
10begin
11 for i := 1 to 10 do INC(k); end;
12 p := SYSTEM.ADR(k);
13 p^ := p^ + 100;
14 for i := 1 to 10 do INC(k); end;
15 Out.int(k);
16 a := "abcd";
17 s := a;
18 q := SYSTEM.PTR(s);
19 Out.char(q^);
20 if SYSTEM.ARGV() # nil then Out.char('v'); end;
21 if SYSTEM.SYSCALL(39) > 0 then Out.char('p'); end; (* getpid *)
22 Out.char(10);
23end;
24
25end SystemImport.