pubby/nesfab

Stack overflow on hardware access in nested loop

spazzylemons opened this issue · 2 comments

This code produces a stack overflow in build_incoming in asm_graph.cpp.

vars
    U[16] level_tiles

fn foo()
    {PPUADDR}($20)
    {PPUADDR}($00)
    U index = 0
    for U y = 0; y < 15; y += 1
        for U x = 0; x < 16; x += 1
            U tile = level_tiles[index]
            index += 1
            {PPUDATA}(tile)
            {PPUDATA}(tile)
        index -= 16
        for U x = 0; x < 16; x += 1
            U tile = level_tiles[index]
            index += 1
            {PPUDATA}(tile)
            {PPUDATA}(tile)
        index -= 16
    {PPUSCROLL}(0)
    {PPUSCROLL}(0)

mode main()
    while true
        foo()
        nmi
pubby commented

Thanks. Looks like the code wasn't handling loops correctly.

I think this is fixed on branch b0.7 now, but lemme know if it still doesn't work.

This appears to fix this issue, thanks!