* gas/cris/*: New tests for CRIS.
[external/binutils.git] / gas / testsuite / gas / cris / bwtest-err-1.s
1 ; File bwtest-err-1.s
2
3 ;  { dg-do assemble { target cris-*-* } }
4
5 ; A variant of exbwtest.s.  This is an example of invalid use of the broken-
6 ; dot-word function.  The nearest label occurs about 32 kbytes after the primary
7 ; jump table so the secondary jump table can't be reached by word displace-
8 ; ments and the broken words overflow.
9
10 ;  main()
11 ;  {
12 ;    byte i;
13 ;
14 ;    for (i=0; i <= 3; i++) {
15 ;      result[i] = funct(i);
16 ;    }
17 ;  }
18 ;
19 ;  Register use :  r1 - i
20 ;                  r2 - result address
21
22         .text
23         .word   0
24 main:   move.d  stack,sp
25         moveq   0,r1
26         move.d  result,r2
27 for1:   cmpq    3,r1
28         bgt     endfor1
29         move.d  r1,r0
30         jsr     funct
31         move.w  r0,[r2+r1.w]
32         ba      for1
33         addq    1,r1
34 endfor1:
35 end:    ba      end
36         nop
37
38
39 ;  uword funct(i)
40 ;    byte i;
41 ;  {
42 ;    switch (i) {
43 ;      case 0 :  return 0x1111;
44 ;      case 1 :  return 0x2222;
45 ;      case 2 :  return 0x3333;
46 ;      case 3 :  return 0x4444;
47 ;    }
48 ;  }
49 ;
50 ;  Parameters   :  r0 - i
51 ;
52 ;  Register use :  r1 - pjt address
53
54 funct:  push    r1
55         move.d  pjt,r1
56         adds.w  [r1+r0.w],pc
57 pjt:    .word   near1 - pjt
58         .word   near2 - pjt
59         .word   far1 - pjt
60         .word   far2 - pjt
61
62 ; Note that the line-number of the source-location of the error
63 ; seems slightly off from the user perspective, but it's the
64 ; best I could get without major changes in BW-handling.  Not
65 ; sure it it's worth fixing.  May need adjustments if
66 ; BW-handling changes.  Four errors from four .words are what's
67 ; expected.
68
69         .space  32760,0xFF; { dg-error "Adjusted signed \.word \(.*\) overflow.*" }
70
71 near1:  move.w  0x1111,r0
72         ba      ret1
73         nop
74
75 near2:  move.w  0x2222,r0
76         ba      ret1
77         nop
78
79 far1:   move.w  0x3333,r0
80         ba      ret1
81         nop
82
83 far2:   move.w  0x4444,r0
84 ret1:   pop     r1
85         ret
86
87
88 result: .space  4 * 2   ; static uword result[4];
89
90         .space  4
91 stack: