Home | History | Annotate | Line # | Download | only in arm
      1  1.1  christos # Test LDR instructions with offsets misaligned by 2 bytes. 
      2  1.1  christos # mach(): all
      3  1.1  christos 
      4  1.1  christos 	.macro invalid
      5  1.1  christos # This is "undefined" but it's not properly decoded yet.
      6  1.1  christos 	.word 0x07ffffff
      7  1.1  christos # This is stc which isn't recognized yet.
      8  1.1  christos 	stc 0,cr0,[r0]
      9  1.1  christos 	.endm
     10  1.1  christos 
     11  1.1  christos 	.global _start
     12  1.1  christos _start:
     13  1.1  christos # Run some simple insns to confirm the engine is at least working.
     14  1.1  christos 	nop
     15  1.1  christos 
     16  1.1  christos # Skip over output text.
     17  1.1  christos 	bl do_test
     18  1.1  christos 
     19  1.1  christos pass:
     20  1.1  christos 	.asciz "pass\n"
     21  1.1  christos 	.p2align 2
     22  1.1  christos 
     23  1.1  christos do_test:
     24  1.1  christos 	mov r4, r14
     25  1.1  christos 	bl continue
     26  1.1  christos word1:
     27  1.1  christos 	.word 0x5555
     28  1.1  christos continue:
     29  1.1  christos 	ldr r6, [r14, #2]
     30  1.1  christos 	ldr r7, word2
     31  1.1  christos 	cmp r6, r7
     32  1.1  christos 	# Failed.
     33  1.1  christos 	bne done
     34  1.1  christos 
     35  1.1  christos output_next:
     36  1.1  christos # Output a character (in arm mode).
     37  1.1  christos 	mov r0,#3
     38  1.1  christos 	mov r1,r4
     39  1.1  christos 	swi #0x123456
     40  1.1  christos 
     41  1.1  christos # Load next character, see if done.
     42  1.1  christos 	add r4,r4,#1
     43  1.1  christos 	sub r3,r3,r3
     44  1.1  christos 	ldrb r5,[r4,r3]
     45  1.1  christos 	teq r5,#0
     46  1.1  christos 	bne output_next
     47  1.1  christos 
     48  1.1  christos done:
     49  1.1  christos 	mov r0,#0x18
     50  1.1  christos 	ldr r1,exit_code
     51  1.1  christos 	swi #0x123456
     52  1.1  christos 
     53  1.1  christos # If that fails, try to die with an invalid insn.
     54  1.1  christos 	invalid
     55  1.1  christos 
     56  1.1  christos exit_code:
     57  1.1  christos 	.word 0x20026
     58  1.1  christos 
     59  1.1  christos word2:
     60  1.1  christos 	.word 0x55550000
     61