comparison lab4/test/infwhile.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 proc foo(): integer;
2 var i: integer;
3 begin
4 i := 3;
5 while true do
6 i := i + 2;
7 if i > 10 then return i end;
8 end
9 end;
10
11 begin
12 print_num(foo()); newline()
13 end.
14
15 (*<<
16 11
17 >>*)
18
19 (*[[
20 @ picoPascal compiler output
21 .include "fixup.s"
22 .global pmain
23
24 @ proc foo(): integer;
25 .text
26 _foo:
27 mov ip, sp
28 stmfd sp!, {r4-r10, fp, ip, lr}
29 mov fp, sp
30 @ i := 3;
31 mov r4, #3
32 .L2:
33 @ i := i + 2;
34 add r4, r4, #2
35 @ if i > 10 then return i end;
36 cmp r4, #10
37 ble .L2
38 mov r0, r4
39 ldmfd fp, {r4-r10, fp, sp, pc}
40 .ltorg
41
42 pmain:
43 mov ip, sp
44 stmfd sp!, {r4-r10, fp, ip, lr}
45 mov fp, sp
46 @ print_num(foo()); newline()
47 bl _foo
48 bl print_num
49 bl newline
50 ldmfd fp, {r4-r10, fp, sp, pc}
51 .ltorg
52
53 @ End
54 ]]*)