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