1 1.1 christos # output(): Hello, world.\n 2 1.1 christos # mach(): all 3 1.1 christos 4 1.1 christos # This is a test for movw & movt instructions. 5 1.1 christos # It emits hello world if movw & movt works appropriately. 6 1.1 christos 7 1.1 christos .macro invalid 8 1.1 christos # This is "undefined" but it's not properly decoded yet. 9 1.1 christos .word 0x07ffffff 10 1.1 christos # This is stc which isn't recognized yet. 11 1.1 christos stc 0,cr0,[r0] 12 1.1 christos .endm 13 1.1 christos 14 1.1 christos .global _start 15 1.1 christos _start: 16 1.1 christos # Run some simple insns to confirm the engine is at least working. 17 1.1 christos nop 18 1.1 christos 19 1.1 christos # Skip over output text. 20 1.1 christos 21 1.1 christos bl skip_output 22 1.1 christos 23 1.1 christos hello_text: 24 1.1 christos .asciz "Hello, world.\n" 25 1.1 christos 26 1.1 christos .p2align 2 27 1.1 christos skip_output: 28 1.1 christos movw r4, #:lower16:hello_text 29 1.1 christos movt r4, #:upper16:hello_text 30 1.1 christos 31 1.1 christos output_next: 32 1.1 christos # Output a character 33 1.1 christos mov r0,#3 34 1.1 christos mov r1,r4 35 1.1 christos swi #0x123456 36 1.1 christos 37 1.1 christos # Load next character, see if done. 38 1.1 christos add r4,r4,#1 39 1.1 christos sub r3,r3,r3 40 1.1 christos ldrb r5,[r4,r3] 41 1.1 christos teq r5,#0 42 1.1 christos bne output_next 43 1.1 christos 44 1.1 christos done: 45 1.1 christos mov r0,#0x18 46 1.1 christos ldr r1,exit_code 47 1.1 christos swi #0x123456 48 1.1 christos 49 1.1 christos # If that fails, try to die with an invalid insn. 50 1.1 christos invalid 51 1.1 christos 52 1.1 christos exit_code: 53 1.1 christos .word 0x20026 54