Search
lxdream.org :: lxdream/test/sh4/add.s
lxdream 0.9.1
released Jun 29
Download Now
filename test/sh4/add.s
changeset 225:e5cea6125580
next226:0eeeb25447d3
author nkeynes
date Wed Sep 20 09:52:32 2006 +0000 (17 years ago)
permissions -rw-r--r--
last change Commit start of SH4 test cases
view annotate diff log raw
     1 	.section .text
     2 .global _test_add
     3 _test_add:
     4 	mov.l r14, @-r15
     5 	sts.l pr, @-r15
     6 	mov.l r12, @-r15
     7 	mov.l r13, @-r15
     8 	mov r15, r14
     9 	xor r12,r12
    10 	xor r13,r13
    11 # r12 is the test counter
    12 # r13 is the failed-test counter
    14 test_add_1:	# test adding 0+0 = 0
    15 	add #1, r12
    16 	xor r0,r0
    17 	xor r1,r1
    18 	xor r2,r2
    19 	add r0,r1
    20 	cmp/eq r1, r2
    21 	bt test_add_2
    22 	add #1, r13
    24 test_add_2:	# test 0+ constant 1 = 1
    25 	add #1, r12
    26 	xor r0, r0
    27 	xor r1, r1
    28 	add #1, r1
    29 	mov.l test_add_2_result, r2
    30 	cmp/eq r1, r2
    31 	bt test_add_3
    32 	add #1, r13
    33 	bra test_add_3
    34 	nop
    36 	.align 4
    37 test_add_2_result:
    38 	.long 0x00000001
    40 test_add_3:  # test 0 + constant -1 = -1
    41 	add #1, r12
    42 	xor r0, r0
    43 	xor r1, r1
    44 	add #-1, r1
    45 	mov.l test_add_3_result, r2
    46 	cmp/eq r1, r2
    47 	bt test_add_4
    48 	add #1, r13
    49 	bra test_add_4
    50 	nop
    52 	.align 4
    53 test_add_3_result:
    54 	.long 0xFFFFFFFF
    56 test_add_4:  # test a+b = c w/ overflow
    57 	add #1, r12
    58 	mov.l test_add_4_op1, r4
    59 	mov.l test_add_4_op2, r5
    60 	mov.l test_add_4_result, r0
    61 	add r4, r5
    62 	cmp/eq r5, r0
    63 	bt test_add_5
    64 	add #1, r13
    65 	bra test_add_5
    66 	nop
    68 	.align 4
    69 test_add_4_op1:
    70 	.long 0x98765432
    71 test_add_4_op2:
    72 	.long 0xA1234567
    73 test_add_4_result:
    74 	.long 0x39999999
    76 test_add_5:	# test carry neither used nor set (ala ADDC)
    77 	add #1, r12
    78 	mov.l test_add_5_op1, r8
    79 	mov.l test_add_5_op2, r9
    80 	stc sr, r10
    81 	xor r0,r0
    82 	add #1, r0
    83 	or r0,r10
    84 	ldc r10, sr
    85 	add r9,r8
    86 	mov.l test_add_5_result, r11
    87 	cmp/eq r11, r8
    88 	bt test_add_5_b
    89 	add #1, r13
    90 	mov.l test_print_failure_k, r3
    91 	mov r12, r5
    92 	mov.l test_add_str_k, r4
    93 	jsr @r3
    94 	nop
    95 	bra test_add_6
    96 	nop
    97 test_add_5_b:
    98 	stc sr, r1
    99 	and r0, r1
   100 	cmp/eq r0, r1
   101 	bt test_add_6
   102 	add #1, r13
   103 	mov.l test_print_failure_k, r3
   104 	mov r12, r5
   105 	mov.l test_add_str_k, r4
   106 	jsr @r3
   107 	nop
   108 	bra test_add_6
   109 	nop
   111 test_add_5_op1:
   112 	.long 0x11111111
   113 test_add_5_op2:	
   114 	.long 0x1000FFFF
   115 test_add_5_result:	
   116 	.long 0x21121110
   118 test_add_6:	
   120 test_add_end:
   121 	mov.l test_add_str_k, r4
   122 	mov r13, r5
   123 	mov r12, r6
   124 	mov.l test_print_result_k, r1
   125 	jsr @r1
   126 	mov r14, r15
   127 	mov.l @r15+, r13
   128 	mov.l @r15+, r12
   129 	lds.l @r15+, pr
   130 	mov.l @r15+, r14
   131 	rts
   132 	nop
   134 	.align 2
   135 test_add_str:
   136 	.string "ADD"
   137 	.align 2
   139 test_add_str_k:	
   140 	.long test_add_str
   141 test_print_result_k:
   142 	.long _test_print_result
   143 test_print_failure_k:
   144 	.long _test_print_failure
.