comparison 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
comparison
equal deleted inserted replaced
-1:000000000000 0:bfdcc3820b32
1 (* Spill result of function call *)
2
3 proc f(x: integer): integer;
4 begin
5 return x
6 end;
7
8 begin
9 print_num(f(3)+f(4)); newline()
10 end.
11
12 (*<<
13 7
14 >>*)
15
16 (*[[
17 @ picoPascal compiler output
18 .include "fixup.s"
19 .global pmain
20
21 @ proc f(x: integer): integer;
22 .text
23 _f:
24 mov ip, sp
25 stmfd sp!, {r0-r1}
26 stmfd sp!, {r4-r10, fp, ip, lr}
27 mov fp, sp
28 @ return x
29 ldr r0, [fp, #40]
30 ldmfd fp, {r4-r10, fp, sp, pc}
31 .ltorg
32
33 pmain:
34 mov ip, sp
35 stmfd sp!, {r4-r10, fp, ip, lr}
36 mov fp, sp
37 @ print_num(f(3)+f(4)); newline()
38 mov r0, #3
39 bl _f
40 mov r4, r0
41 mov r0, #4
42 bl _f
43 mov r5, r0
44 add r0, r4, r5
45 bl print_num
46 bl newline
47 ldmfd fp, {r4-r10, fp, sp, pc}
48 .ltorg
49
50 @ End
51 ]]*)