git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@4676 4a8a32a2...
[fw/sdcc] / support / regression / tests / absolute.c
1 /** Absolute addressing tests.
2
3     mem: code, xdata
4 */
5 #include <testfwk.h>
6
7 {mem} at(0xCAB7) char u;
8 {mem} at(0xCAB7) char x = 'x';
9 {mem} at(0xCAB9) char y = 'y';
10 {mem} at(0xCAB0) int  k = 0x1234;
11
12 char z = 'z';
13
14 void
15 testAbsolute(void)
16 {
17 #if defined(SDCC_mcs51) || defined(SDCC_ds390) || defined(SDCC_hc08)
18   char {mem} *pC = (char {mem} *)(0xCAB0);
19   int  {mem} *pI = (int  {mem} *)(0xCAB0);
20
21   ASSERT(u == 'x');
22   ASSERT(pC[7] == 'x');
23   ASSERT(pC[9] == 'y');
24   ASSERT(pI[0] == 0x1234);
25 #endif
26 }
27
28 #if defined(SDCC_mcs51) || defined(SDCC_ds390)
29 volatile data at(0x20) unsigned char Byte0 = 0x00;
30 volatile data at(0x22) unsigned char Byte1 = 0x00;
31 volatile bit Bit0, Bit1, Bit2, Bit3, Bit4, Bit5, Bit6, Bit7, Bit8;
32 #endif
33
34 void
35 testAbsBdata(void)
36 {
37 #if defined(SDCC_mcs51) || defined(SDCC_ds390)
38   Bit0 = 1;
39   ASSERT(Byte0 == 0x00);
40   Byte0 = 0xFF;
41   Bit0 = 0;
42   ASSERT(Byte0 == 0xFF);
43 #endif
44 }