summaryrefslogtreecommitdiff
path: root/src/regression/pcodeopt.c
blob: 8be5a2ae5d4abec97123fb22e92938d226422c04 (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
#include "gpsim_assert.h"

/*
 * Test for buggy pCode optimization on
 *    CLRF reg	; pc1
 *    ...
 *    MOVF reg,W	; pc2
 *
 * Originally, both instructions were removed and pc2 replaced with
 *    CLRF reg          iff reg was used afterwards, but Z and W were not, or
 *    MOVLW 0           iff reg and Z were not used afterwards, but W was.
 * Detection of W being used used to be buggy, though...
 */
signed int x=0;
unsigned char y=1;

void main() {
    x += y;
    x += y;
    if (x != 2) { FAILED(); }
    if (y != 1) { FAILED(); }
    //ASSERT(MANGLE(x) == 2);
    //ASSERT(MANGLE(y) == 1);
    PASSED();
}