annotate lab4/test/spill.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 (* Spill result of function 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(x: integer): integer;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
4 begin
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
5 return x
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
6 end;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
7
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
8 begin
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
9 print_num(f(3)+f(4)); newline()
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 (*<<
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
13 7
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
14 >>*)
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
15
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
16 (*[[
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
17 @ picoPascal compiler output
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
18 .include "fixup.s"
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
19 .global pmain
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
20
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
21 @ proc f(x: integer): integer;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
22 .text
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
23 _f:
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
24 mov ip, sp
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
25 stmfd sp!, {r0-r1}
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
26 stmfd sp!, {r4-r10, fp, ip, lr}
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
27 mov fp, sp
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
28 @ return x
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
29 ldr r0, [fp, #40]
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
30 ldmfd fp, {r4-r10, fp, sp, pc}
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
31 .ltorg
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
32
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
33 pmain:
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
34 mov ip, sp
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
35 stmfd sp!, {r4-r10, fp, ip, lr}
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
36 mov fp, sp
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
37 @ print_num(f(3)+f(4)); newline()
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
38 mov r0, #3
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
39 bl _f
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
40 mov r4, r0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
41 mov r0, #4
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
42 bl _f
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
43 mov r5, r0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
44 add r0, r4, r5
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
45 bl print_num
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
46 bl newline
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
47 ldmfd fp, {r4-r10, fp, sp, pc}
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
48 .ltorg
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
49
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
50 @ End
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
51 ]]*)