2016-12-21 Vladimir Makarov <vmakarov@redhat.com>
[official-gcc.git] / gcc / testsuite / gcc.c-torture / compile / 20071114-1.c
blobddfbfefff4599759083e96f334d7bb7c80440b54
1 /* PR tree-optimization/34046 */
2 /* Origin: dcb <dcb314@hotmail.com> */
4 typedef unsigned char bool8;
5 typedef unsigned char uint8_t;
6 typedef unsigned short int uint16_t;
7 typedef unsigned int uint32_t;
8 typedef uint8_t uint8;
9 typedef uint16_t uint16;
10 typedef uint32_t uint32;
12 struct SIAPU
14 uint8 *PC;
15 uint8 *RAM;
16 uint8 Bit;
17 uint32 Address;
18 uint8 *WaitAddress1;
19 uint8 *WaitAddress2;
20 uint8 _Carry;
23 struct SAPU
25 bool8 ShowROM;
26 uint8 OutPorts [4];
27 uint8 ExtraRAM [64];
28 uint16 TimerTarget [3];
31 struct SAPU APU;
32 struct SIAPU IAPU;
34 void S9xSetAPUControl (uint8 byte);
35 void S9xSetAPUDSP (uint8 byte);
36 uint8 S9xGetAPUDSP ();
38 uint8 S9xAPUGetByte (uint32 Address)
40 Address &= 0xffff;
42 if (Address <= 0xff && Address >= 0xf0)
44 if (Address >= 0xf4 && Address <= 0xf7)
46 IAPU.WaitAddress2 = IAPU.WaitAddress1;
47 IAPU.WaitAddress1 = IAPU.PC;
48 return (IAPU.RAM [Address]);
50 else if (Address == 0xf3)
51 return (S9xGetAPUDSP ());
53 if (Address >= 0xfd)
55 IAPU.WaitAddress2 = IAPU.WaitAddress1;
56 IAPU.WaitAddress1 = IAPU.PC;
57 uint8 t = IAPU.RAM [Address];
58 IAPU.RAM [Address] = 0;
59 return (t);
62 return (IAPU.RAM [Address]);
64 else
65 return (IAPU.RAM [Address]);
68 void S9xAPUSetByte (uint8 byte, uint32 Address)
70 Address &= 0xffff;
72 if (Address <= 0xff && Address >= 0xf0)
74 if (Address == 0xf3)
75 S9xSetAPUDSP (byte);
76 else if (Address >= 0xf4 && Address <= 0xf7)
77 APU.OutPorts [Address - 0xf4] = byte;
78 else if (Address == 0xf1)
79 S9xSetAPUControl (byte);
80 else if (Address < 0xfd)
82 IAPU.RAM [Address] = byte;
83 if (Address >= 0xfa)
85 if (byte == 0)
86 APU.TimerTarget [Address - 0xfa] = 0x100;
87 else
88 APU.TimerTarget [Address - 0xfa] = byte;
92 else
94 if (Address < 0xffc0)
95 IAPU.RAM [Address] = byte;
96 else
98 APU.ExtraRAM [Address - 0xffc0] = byte;
99 if (!APU.ShowROM)
100 IAPU.RAM [Address] = byte;
105 void ApuCA ()
107 IAPU.Address = *(uint16 *) (IAPU.PC + 1);
108 IAPU.Bit = (uint8)(IAPU.Address >> 13);
109 if ((IAPU._Carry))
110 S9xAPUSetByte (S9xAPUGetByte (IAPU.Address) | (1 << IAPU.Bit), IAPU.Address);
111 else
112 S9xAPUSetByte (S9xAPUGetByte (IAPU.Address) & ~(1 << IAPU.Bit), IAPU.Address);