summaryrefslogtreecommitdiff
path: root/support/regression/tests/smallc.c
blob: 1a0eeb754c24c119c7b8800c4d7841aec07523c4 (plain) (blame)
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
/*
	smallc.c

	Test support for __smallc for Small-C-compatible calling convention
*/
#include <testfwk.h>
#include <stdlib.h>

#if !(defined __SDCC_z80 || defined __SDCC_z180 || defined __SDCC_gbz80 || defined __SDCC_r2k || defined __SDCC_r3ka || defined __SDCC_tlcs90)
#define __smallc
#endif

unsigned char f1(unsigned char c) __smallc
{
	return c + 1;
}

unsigned int f2(unsigned int c) __smallc
{
	return c + 1;
}

unsigned char s1(unsigned char c, unsigned char d) __smallc
{
	return c - d;
}

unsigned int s2(unsigned int c, unsigned int d) __smallc
{
	return c - d;
}

void
testSmallC(void)
{
  ASSERT (f1 (23) == 24);
  ASSERT (f2 (23) == 24);

  ASSERT (s1 (42, 23) == 19);
  ASSERT (s2 (42, 23) == 19);
}