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