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