File: hello.ms

package info (click to toggle)
gdb-doc 16.3-1
  • links: PTS, VCS
  • area: non-free
  • in suites: forky, sid, trixie
  • size: 244,264 kB
  • sloc: ansic: 2,134,731; asm: 375,582; exp: 206,875; cpp: 73,639; makefile: 70,232; sh: 26,038; python: 13,697; yacc: 11,341; ada: 7,358; xml: 6,098; perl: 5,077; pascal: 3,389; tcl: 2,986; f90: 2,764; lisp: 1,984; cs: 879; lex: 738; sed: 228; awk: 181; objc: 137; fortran: 57
file content (91 lines) | stat: -rw-r--r-- 1,308 bytes parent folder | download | duplicates (40)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# output(): Hello, world.\n
# mach(): all

# Emit hello world while switching back and forth between arm/thumb.
# ??? Unfinished

	.macro invalid
# This is "undefined" but it's not properly decoded yet.
	.word 0x07ffffff
# This is stc which isn't recognized yet.
	stc 0,cr0,[r0]
	.endm

	.global _start
_start:
# Run some simple insns to confirm the engine is at least working.
	nop

# Skip over output text.

	bl skip_output

hello_text:
	.asciz "Hello, world.\n"

	.p2align 2
skip_output:

# Prime loop.

	mov r4, r14

output_next:

# Switch arm->thumb to output next chacter.
# At this point r4 must point to the next character to output.

	adr r0, into_thumb + 1
	bx r0

into_thumb:
	.thumb

# Output a character.

	mov r0,#3 @ writec angel call
	mov r1,r4
	swi 0xab @ ??? Confirm number.

# Switch thumb->arm.

	adr r5, back_to_arm
	bx r5

	.p2align 2
back_to_arm:
	.arm

# Load next character, see if done.

	add r4,r4,#1
	sub r3,r3,r3
	ldrb r5,[r4,r3]
	teq r5,#0
	beq done

# Output a character (in arm mode).

	mov r0,#3
	mov r1,r4
	swi #0x123456

# Load next character, see if done.

	add r4,r4,#1
	sub r3,r3,r3
	ldrb r5,[r4,r3]
	teq r5,#0
	bne output_next

done:
	mov r0,#0x18
	ldr r1,exit_code
	swi #0x123456

# If that fails, try to die with an invalid insn.

	invalid

exit_code:
	.word 0x20026