Menu

#3112 [pdk] Memory managment / reusability issue

open
nobody
None
PDK
5
2020-09-12
2020-09-12
kaweksl
No

Don't know what the reason is but I have a memory reusability issue.

    uint8_t i;
    for (i = 0; i < 8; i++)
    {
        test++;
        var++;
    }
    for (i = 0; i < 8; i++)
    {
        test++;
        var++;
    }

    for (i = 0; i < 8; i++)
    {
        test++;
        var++;
    }

in code above each for loop allocates memory for 'i' variable and it's not reused in next one, so you can get out of memory by just having loops.  Code below will also allocate memory for i variable

i = 0;
while(1) {
    var++;
    test++;

    i++;
    if(i > 8) break;
}

Attached code will not compile due exeteding RAM addressing for pdk13 by one byte, remove any loop and code will compile.

checked on
sdcc 4.0.3 #11850 (Linux)
and #11722

1 Attachments

Discussion


Log in to post a comment.

Auth0 Logo