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