wiz-lang / wiz

A high-level assembly language for writing homebrew software and games on retro console platforms.
http://wiz-lang.org/
Other
409 stars 40 forks source link

Wiz does not save the value of a func call if return register is missing or incorrect #66

Closed undisbeliever closed 5 years ago

undisbeliever commented 5 years ago

The following wiz code (taken from 6502_func_ignore_return_bug.wiz)

func return_a() : u8 in a {
    return 5;
}

func test() {
    x = return_a();

    ram_u8_201 = return_a();
}

Produces a binary that does not transfer a to x or store a into ram_u8_201.

`--> r2 -a6502 -m0x8000 test.bin               
WARNING: using oba to load the syminfo from different mapaddress.
TODO: Must use the API instead of running commands to speedup loading times.
 -- In Soviet Russia, radare2 has documentation.
[0x00008000]> 
[0x00008000]> e asm.bytespace=true
[0x00008000]> pd
            0x00008000      a9 05                 lda #0x05
            0x00008002      60                    rts
            0x00008003      20 00 80              jsr 0x8000
            0x00008006      20 00 80              jsr 0x8000
            0x00008009      60                    rts

Wiz should either produce an error (preferred), or emit the tax/sta instructions.