comparison lab4/test/nest.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 (* Nested calls *)
2
3 proc f(x: integer): integer; begin return 2*x end;
4 begin print_num(f(f(3))); newline() end.
5
6 (*<<
7 12
8 >>*)
9
10 (*[[
11 @ picoPascal compiler output
12 .include "fixup.s"
13 .global pmain
14
15 @ proc f(x: integer): integer; begin return 2*x end;
16 .text
17 _f:
18 mov ip, sp
19 stmfd sp!, {r0-r1}
20 stmfd sp!, {r4-r10, fp, ip, lr}
21 mov fp, sp
22 @ proc f(x: integer): integer; begin return 2*x end;
23 ldr r0, [fp, #40]
24 lsl r0, r0, #1
25 ldmfd fp, {r4-r10, fp, sp, pc}
26 .ltorg
27
28 pmain:
29 mov ip, sp
30 stmfd sp!, {r4-r10, fp, ip, lr}
31 mov fp, sp
32 @ begin print_num(f(f(3))); newline() end.
33 mov r0, #3
34 bl _f
35 bl _f
36 bl print_num
37 bl newline
38 ldmfd fp, {r4-r10, fp, sp, pc}
39 .ltorg
40
41 @ End
42 ]]*)