]> git.sur5r.net Git - cc65/blob - test/val/assign-use1.c
Separate header and trailers of Atari system_check chunk.
[cc65] / test / val / assign-use1.c
1 /*
2   !!DESCRIPTION!! Assign an int; then, do an operation that depends directly on that assignment.
3   !!ORIGIN!!      cc65 regression tests
4   !!LICENCE!!     Public Domain
5   !!AUTHOR!!      Greg King
6 */
7
8 #include <stdio.h>
9
10 static unsigned char failures = 0;
11
12 static unsigned int result;
13 static const unsigned int buffer = 0xABCD;
14
15 int main(void)
16 {
17     result = buffer;
18
19     /* Shift doesn't use high byte (X register); previous assignment should be optimized. */
20     result <<= 8;
21     if (result != 0xCD00) {
22         ++failures;
23         printf("assign-use1: left shift is $%X, not $CD00.\n", result);
24     }
25
26     result = buffer;
27
28     /* Shift does use high byte; previous assignment shouldn't be optimized by OptStore5(). */
29     result >>= 8;
30     if (result != 0x00AB) {
31         ++failures;
32         printf("assign-use1: right shift is $%X, not $00AB.\n", result);
33     }
34
35     return failures;
36 }