File: bool1.c

package info (click to toggle)
cc65 2.19-2
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 20,268 kB
  • sloc: ansic: 117,151; asm: 66,339; pascal: 4,248; makefile: 1,009; perl: 607
file content (130 lines) | stat: -rw-r--r-- 1,613 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/*
  !!DESCRIPTION!!
  !!ORIGIN!!      SDCC regression tests
  !!LICENCE!!     GPL, read COPYING.GPL
*/

#include <stdio.h>
#include <limits.h>

unsigned char success=0;
unsigned char failures=0;
unsigned char dummy=0;

#ifdef SUPPORT_BIT_TYPES
bit bit0 = 0;
#endif
unsigned int aint0 = 0;
unsigned int aint1 = 0;
unsigned char achar0 = 0;
unsigned char achar1 = 0;

void done()
{
  dummy++;
}

void bool_or1(void)
{
  if( (achar0 >0) || (achar1 >0 ))
    failures++;
}

void bool_or2(void)
{
  if( achar0 || achar1)
    failures++;
}

void bool_test1(void)
{
  if( (achar0==0) || achar1)
    failures++;
}

void bool_test2(void)
{
  if( (achar0==0) || aint0)
    failures++;
}

void bool_and1(void)
{
  if( achar0 && achar1)
    failures++;
}

void bin_or1(void)
{
  char t;

  t = achar0 | achar1;
  if(t)
    failures++;
}

void bin_xor1(void)
{
  if(achar0 ^ achar1)
    failures++;
}

void bool_test3(void)
{
  if((achar0 == 0x42) || (achar1 == 42))
    failures++;
}

void bool_or_lit1(void)
{
  achar0 |= 0x0f;

  if(achar0 > 0x10)
    failures++;

  if( (achar0 | 0x10) > 0xf0)
    failures++;
}

void bool_and_lit1(void)
{
  achar0 &= 0xf0;

  if(achar0 > 0x10)
    failures++;

  if( (achar0 & 0x10) > 0xf0)
    failures++;

  achar0 &= 0xef;
}

int  main(void)
{
  bool_or1();
  bool_or2();
  bool_and1();
  bin_or1();
  bin_xor1();

  achar0++;
  bool_and1();
  bool_test1();
  bool_test2();
  bool_test3();

  achar0--; achar1++;
  bool_and1();

  achar0=0;
  achar1=0;

  bool_or_lit1();
  bool_and_lit1();

  success = failures;
  done();
  printf("failures: %d\n",failures);

  return failures;
}