Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 89baa208 authored by Jack Palevich's avatar Jack Palevich
Browse files

Fix the ARM postdecrement operator.

Add a test for ++ and -- so this bug won't happen again.
parent c1e49f96
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1628,7 +1628,7 @@ class Compiler : public ErrorSink {
                 o4((0xE3A00000 + t) | rN); // mov    rN, #0
            } else if (t >= -256 && t < 0) {
                // mvn means move constant ^ ~0
                o4((0xE3E00001 - t) | rN); // mvn    rN, #0
                o4((0xE3E00000 - (t+1)) | rN); // mvn    rN, #0
            } else {
                  o4(0xE51F0000 | rN); //         ldr    rN, .L3
                  o4(0xEA000000); //         b .L99
+23 −0
Original line number Diff line number Diff line
// Check integer operations

void loops() {
    int y;
    printf("++\n");
    for(y = 0; y < 10; y++) {
        printf("%d\n", y);
    }
    printf("--\n");
    for(y = 10; y >= 0; y--) {
        printf("%d\n", y);
    }
}

void checkLiterals() {
    printf("Literals: %d %d\n", 1, -1);
}

int main() {
    checkLiterals();
    loops();
    return 0;
}
+34 −7
Original line number Diff line number Diff line
@@ -287,6 +287,33 @@ result: 10""", """""")
        self.compileCheck(["-R", "data/floatdouble.c"], """Executing compiled code:
result: 0""", """0.002 0.1 10""")

    def testIops(self):
        self.compileCheck(["-R", "data/iops.c"], """Executing compiled code:
result: 0""", """Literals: 1 -1
++
0
1
2
3
4
5
6
7
8
9
--
10
9
8
7
6
5
4
3
2
1
0
""")

if __name__ == '__main__':
    if not outputCanRun():