comparison lab4/test/immed.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 (* Representation of immediate constants *)
2
3 var k: integer;
4 begin
5 k := 100;
6 print_num(516); newline();
7 print_num(517); newline();
8 print_num(k + -50); newline();
9 print_num(k + -1023); newline();
10 print_num(k + -1024); newline()
11 end.
12
13 (*<<
14 516
15 517
16 50
17 -923
18 -924
19 >>*)
20
21 (*[[
22 @ picoPascal compiler output
23 .include "fixup.s"
24 .global pmain
25
26 .text
27 pmain:
28 mov ip, sp
29 stmfd sp!, {r4-r10, fp, ip, lr}
30 mov fp, sp
31 @ k := 100;
32 mov r0, #100
33 set r1, _k
34 str r0, [r1]
35 @ print_num(516); newline();
36 mov r0, #516
37 bl print_num
38 bl newline
39 @ print_num(517); newline();
40 set r0, #517
41 bl print_num
42 bl newline
43 @ print_num(k + -50); newline();
44 set r0, _k
45 ldr r0, [r0]
46 sub r0, r0, #50
47 bl print_num
48 bl newline
49 @ print_num(k + -1023); newline();
50 set r0, _k
51 ldr r0, [r0]
52 set r1, #1023
53 sub r0, r0, r1
54 bl print_num
55 bl newline
56 @ print_num(k + -1024); newline()
57 set r0, _k
58 ldr r0, [r0]
59 sub r0, r0, #1024
60 bl print_num
61 bl newline
62 ldmfd fp, {r4-r10, fp, sp, pc}
63 .ltorg
64
65 .comm _k, 4, 4
66 @ End
67 ]]*)