2014-11-04, 02:47 AM 
		
	
	
		Ouch! This bug gave me a headache! It took me some time to figure out the reason my game was crashing...
Take a look at this sample:
Try compiling this sample above using:
And it will produce the expected result:
However try compiling it again using:
Now the result won't make sense anymore:
The problem is, the optimizer is supposed to try to optimize its own generated code only, not someone else's assembly code that it doesn't have enough information to understand!
	
	
	
	
Take a look at this sample:
Code:
sub test()
    asm
        call    $fc12
        di
        ld      a, $fe
        ld      i, a
        im      2
        ei
    end asm
end sub
test()Try compiling this sample above using:
Code:
zxb.exe -A -O2 prog.basAnd it will produce the expected result:
Code:
_test:
    push ix
    ld ix, 0
    add ix, sp
#line 1
        call    $fc12
        di
        ld      a, $fe
        ld      i, a
        im      2
        ei
#line 7
_test__leave:
    ld sp, ix
    pop ix
    retHowever try compiling it again using:
Code:
zxb.exe -A -O3 prog.basNow the result won't make sense anymore:
Code:
_test:
    push ix
    ld ix, 0
    add ix, sp
#line 1
    call    $fc12
    di
    im      2
    ei
#line 7
_test__leave:
    ld sp, ix
    pop ix
    retThe problem is, the optimizer is supposed to try to optimize its own generated code only, not someone else's assembly code that it doesn't have enough information to understand!

