Pick three bugfixes from next branch to trunk for inclusion in 4.5.0 RC2, as discusse...
[sdcc.git] / sdcc / support / regression / tests / sfr16.c
blob5b97eebe78d142dc882e3a2f8c87ebb2072e950a
1 /*
2 sfr16.c
3 */
5 #include <testfwk.h>
7 #if defined (__SDCC_mcs51)
8 __sfr __at 0x8A SFR_LSB; //timer 0 low byte
9 __sfr __at 0x8C SFR_MSB; //timer 0 high byte
10 __sfr16 __at 0x8C8A SFR_16; //timer 0
11 __sfr32 __at 0x8C8ACDCC SFR_32; //timer 0 & 2
12 #elif defined (__SDCC_ds390)
13 __sfr __at 0x8B SFR_LSB; //timer 1 low byte
14 __sfr __at 0x8D SFR_MSB; //timer 1 high byte
15 __sfr16 __at 0x8D8B SFR_16; //timer 1
16 __sfr32 __at 0x8D8B8090 SFR_32; //timer 1 & P4 & P1
17 #endif
19 void
20 test_sfr (void)
22 #if defined (__SDCC_mcs51) || defined (__SDCC_ds390)
23 SFR_16 = 0x00FE;
24 ASSERT (SFR_MSB == 0x00);
25 ASSERT (SFR_LSB == 0xFE);
27 SFR_16++;
28 ASSERT (SFR_MSB == 0x00);
29 ASSERT (SFR_LSB == 0xFF);
31 SFR_16++;
32 ASSERT (SFR_MSB == 0x01);
33 ASSERT (SFR_LSB == 0x00);
35 SFR_LSB++;
36 ASSERT (SFR_16 == 0x0101);
38 SFR_32 = 0x12345678;
39 SFR_32 -= 0x02040608;
40 ASSERT (SFR_32 == 0x10305070);
41 #endif