annotate lab4/test/memkill.p @ 0:bfdcc3820b32

Basis
author Mike Spivey <mike@cs.ox.ac.uk>
date Thu, 05 Oct 2017 08:04:15 +0100
parents
children
rev   line source
0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
1 (* All loads are killed by a procedure call *)
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
2
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
3 proc f(): integer;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
4 var x, y: integer;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
5 begin
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
6 x := 3;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
7 y := x + 1;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
8 g();
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
9 return x + 1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
10 end;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
11
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
12 proc g(); begin end;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
13
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
14 begin
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
15 print_num(f()); newline()
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
16 end.
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
17
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
18 (*<<
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
19 4
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
20 >>*)
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
21
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
22 (*[[
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
23 @ picoPascal compiler output
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
24 .include "fixup.s"
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
25 .global pmain
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
26
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
27 @ proc f(): integer;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
28 .text
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
29 _f:
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
30 mov ip, sp
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
31 stmfd sp!, {r4-r10, fp, ip, lr}
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
32 mov fp, sp
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
33 @ x := 3;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
34 mov r4, #3
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
35 @ y := x + 1;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
36 add r5, r4, #1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
37 @ g();
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
38 bl _g
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
39 @ return x + 1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
40 add r0, r4, #1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
41 ldmfd fp, {r4-r10, fp, sp, pc}
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
42 .ltorg
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
43
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
44 @ proc g(); begin end;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
45 _g:
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
46 mov ip, sp
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
47 stmfd sp!, {r4-r10, fp, ip, lr}
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
48 mov fp, sp
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
49 ldmfd fp, {r4-r10, fp, sp, pc}
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
50 .ltorg
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
51
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
52 pmain:
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
53 mov ip, sp
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
54 stmfd sp!, {r4-r10, fp, ip, lr}
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
55 mov fp, sp
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
56 @ print_num(f()); newline()
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
57 bl _f
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
58 bl print_num
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
59 bl newline
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
60 ldmfd fp, {r4-r10, fp, sp, pc}
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
61 .ltorg
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
62
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
63 @ End
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
64 ]]*)