OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [gdb/] [testsuite/] [gdb.base/] [branches.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
/* Tests for single stepping through various branch conditions */
2
 
3
int noscramble(int a)
4
{
5
  return a ;
6
}
7
 
8
int echo(int a)
9
{ return noscramble(a) ; }
10
 
11
int equaltest(int a,int b)
12
{ int retval ;
13
  if (a == b)
14
    retval = noscramble(1) ;
15
  else retval = noscramble(0) ;
16
  return retval ;
17
}
18
 
19
int neqtest(int a , int b)
20
{ int retval ;
21
  if (a != b)
22
    retval = echo(1) ;
23
  else retval = echo(2) ;
24
  return retval ;
25
}
26
int zerotest(int a )
27
{ int retval ;
28
  a = echo(a) ;
29
  if (a ==0)
30
    retval = echo(1) ;
31
  else
32
    retval = echo(0) ;
33
  retval = echo(retval) ;
34
  return retval ;
35
}
36
 
37
int zerotest2(int a)
38
{
39
  return (a==0) ;
40
}
41
 
42
int nonzerotest(int a)
43
{
44
  int retval ;
45
  if (a != 0)
46
    retval = echo(0) ;
47
  else retval = echo(1) ;
48
  return retval ;
49
}
50
 
51
int whiletest(int a)
52
{
53
  while (a > 0)
54
    {
55
      a-- ;
56
    }
57
  return 0 ;
58
}
59
int whiletest2(int a)
60
{
61
  while (a > 0)
62
    {
63
      a = noscramble(a) ;
64
      a-- ;
65
    }
66
  return a ;
67
}
68
 
69
int decr(int x) { return x - 1  ; }
70
 
71
int while3(int a)
72
{
73
  int b = a ;
74
  while (a == b)
75
    {
76
      a = echo(a) ;
77
      b = decr(b) ;
78
    }
79
  return a ;
80
}
81
 
82
void done (int x) { }
83
 
84
int main()
85
{
86
  int a,b,c,d ;
87
  done(1) ;
88
  a = echo(123456) ;
89
  b = echo(123456) ;
90
  c = echo(56789) ;
91
  d = echo(0) ;
92
#if 1
93
  equaltest(a,b) ;
94
  done(7) ;
95
  equaltest(a,c) ;
96
  done(8) ;
97
  whiletest(3) ;  /* worked */
98
  done(3) ;
99
  while3(3) ;
100
  done(6) ;
101
#endif  
102
  neqtest(a,b) ;
103
  neqtest(a,b) ;
104
  neqtest(a,c) ;
105
  zerotest(d) ;
106
  zerotest(a) ;
107
  done(5) ;
108
  nonzerotest(d) ;
109
  done(4) ;
110
  nonzerotest(a) ;
111
  done(111) ;
112
  return 1 ;
113
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.