OSDN Git Service

* public snapshot of sid simulator
[pf3gnuchains/pf3gnuchains3x.git] / sid / component / testsuite / sidcomp.cgen-cpu / armhello.ms
1 # output(): Hello, world.\n
2 # mach(): all
3
4 # Emit hello world while switching back and forth between arm/thumb.
5
6         .macro invalid
7 # This is "undefined" but it's not properly decoded yet.
8         .word 0x07ffffff
9 # This is stc which isn't recognized yet.
10         stc 0,cr0,[r0]
11         .endm
12
13         .global _start
14 _start:
15 # Run some simple insns to confirm the engine is at least working.
16         nop
17
18 # Skip over output text.
19
20         bl skip_output
21
22 hello_text:
23         .asciz "Hello, world.\n"
24
25         .p2align 2
26 skip_output:
27
28 # Prime loop.
29
30         mov r4, r14
31
32 output_next:
33
34 # Switch arm->thumb to output next chacter.
35 # At this point r4 must point to the next character to output.
36
37         adr r0, into_thumb + 1
38         bx r0
39
40 into_thumb:
41         .thumb
42
43 # Output a character.
44
45         mov r0,#3 @ writec angel call
46         mov r1,r4
47         swi 0xab @ ??? Confirm number.
48
49 # Switch thumb->arm.
50
51         adr r5, back_to_arm
52         bx r5
53
54         .p2align 2
55 back_to_arm:
56         .arm
57
58 # Load next character, see if done.
59
60         add r4,r4,#1
61         sub r3,r3,r3
62         ldrb r5,[r4,r3]
63         teq r5,#0
64         beq done
65
66 # Output a character (in arm mode).
67
68         mov r0,#3
69         mov r1,r4
70         swi #0x123456
71
72 # Load next character, see if done.
73
74         add r4,r4,#1
75         sub r3,r3,r3
76         ldrb r5,[r4,r3]
77         teq r5,#0
78         bne output_next
79
80 done:
81         mov r0,#0x18
82         ldr r1,exit_code
83         swi #0x123456
84
85 # If that fails, try to die with an invalid insn.
86
87         invalid
88
89 exit_code:
90         .word 0x20026