Search
lxdream.org :: lxdream/test/sh4/add.s
lxdream 0.9.1
released Jun 29
Download Now
filename test/sh4/add.s
changeset 231:a9e61a96a885
prev226:0eeeb25447d3
author nkeynes
date Tue Sep 26 11:05:38 2006 +0000 (14 years ago)
permissions -rw-r--r--
last change Add BT, BT/S, CMP/EQ, CMP/GE, CMP/GT, CMP/HI, CMP/HS tests
Add general slot-illegal exception test
view annotate diff log raw
     1 .section .text
     2 .include "sh4/inc.s"
     4 .global _test_add
     5 _test_add:
     6 	start_test
     8 test_add_1:	! test adding 0+0 = 0
     9 	add #1, r12
    10 	xor r0,r0
    11 	xor r1,r1
    12 	xor r2,r2
    13 	add r0,r1
    14 	cmp/eq r1, r2
    15 	bt test_add_2
    16 	fail test_add_str_k
    18 test_add_2:	! test 0+ constant 1 = 1
    19 	add #1, r12
    20 	xor r0, r0
    21 	xor r1, r1
    22 	add #1, r1
    23 	mov.l test_add_2_result, r2
    24 	cmp/eq r1, r2
    25 	bt test_add_3
    26 	fail test_add_str_k
    27 	bra test_add_3
    28 	nop
    30 	.align 4
    31 test_add_2_result:
    32 	.long 0x00000001
    34 test_add_3:	! test 0 + constant -1 = -1
    35 	add #1, r12
    36 	xor r0, r0
    37 	xor r1, r1
    38 	add #-1, r1
    39 	mov.l test_add_3_result, r2
    40 	cmp/eq r1, r2
    41 	bt test_add_4
    42 	fail test_add_str_k
    43 	bra test_add_4
    44 	nop
    46 	.align 4
    47 test_add_3_result:
    48 	.long 0xFFFFFFFF
    50 test_add_4:	! test a+b = c w/ overflow
    51 	add #1, r12
    52 	mov.l test_add_4_op1, r4
    53 	mov.l test_add_4_op2, r5
    54 	mov.l test_add_4_result, r0
    55 	add r4, r5
    56 	cmp/eq r5, r0
    57 	bt test_add_5
    58 	fail test_add_str_k
    59 	bra test_add_5
    60 	nop
    62 	.align 4
    63 test_add_4_op1:
    64 	.long 0x98765432
    65 test_add_4_op2:
    66 	.long 0xA1234567
    67 test_add_4_result:
    68 	.long 0x39999999
    70 test_add_5:	! test carry neither used nor set (ala ADDC)
    71 	add #1, r12
    72 	mov.l test_add_5_op1, r4
    73 	mov.l test_add_5_op2, r5
    74 	stc sr, r6
    75 	xor r0,r0
    76 	add #1, r0
    77 	stc sr, r1
    78 	or r0,r6
    79 	ldc r6, sr
    80 	add r5,r4
    81 	mov.l test_add_5_result, r7
    82 	cmp/eq r7, r4
    83 	bt test_add_5_b
    84 	fail test_add_str_k
    85 	bra test_add_6
    86 	nop
    87 test_add_5_b:
    88 	and r0, r1
    89 	cmp/eq r0, r1
    90 	bt test_add_6
    91 	fail test_add_str_k
    92 	bra test_add_6
    93 	nop
    95 test_add_5_op1:
    96 	.long 0x11111111
    97 test_add_5_op2:	
    98 	.long 0x1000FFFF
    99 test_add_5_result:	
   100 	.long 0x21121110
   102 test_add_6:	! test maximum negative immediate
   103 	add #1, r12
   104 	xor r0,r0
   105 	add #128, r0
   106 	mov.l test_add_6_result, r1
   107 	cmp/eq r0, r1
   108 	bt test_add_7
   109 	fail test_add_str_k
   110 	bra test_add_7
   111 	nop
   112 test_add_6_result:
   113 	.long 0xFFFFFF80
   115 test_add_7:	! test maximum positive immediate
   116 	add #1, r12
   117 	xor r0,r0
   118 	add #127, r0
   119 	mov.l test_add_7_result, r1
   120 	cmp/eq r0, r1
   121 	bt test_add_8
   122 	fail test_add_str_k
   123 	bra test_add_8
   124 	nop
   125 test_add_7_result:
   126 	.long 0x0000007F
   128 test_add_8:	! Test example from manual
   129 	add #1, r12
   130 	mov.l test_add_8_op1, r3
   131 	add #-2, R3
   132 	mov.l test_add_8_result, r1
   133 	cmp/eq r3,r1
   134 	bt test_add_end
   135 	fail test_add_str_k
   136 	bra test_add_end
   137 	nop
   138 test_add_8_op1:
   139 	.long 0x00000001
   140 test_add_8_result:
   141 	.long 0xFFFFFFFF
   143 test_add_end:
   144 	end_test test_add_str_k
   146 test_add_str:
   147 	.string "ADD"
   149 .align 4	
   150 test_add_str_k:	
   151 	.long test_add_str
.