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

Cannot use bbs or bbc instructions on the SPC700 platform. #146

Open undisbeliever opened 1 year ago

undisbeliever commented 1 year ago

While testing the SPC700 platform I was unable to write a test case for the bbs or bbc SPC700 instructions. I see them referenced in src/wiz/platform/spc700_platform.cpp, but I am unable to write wiz code that assembles to these instructions.

I did not include this failing test case to my spc700-fixes Pull Request as I am unsure if these wiz statements are correct or not.

// SYSTEM  spc700
//
// Disassembly manually created using a hex-editor and verified with Mesen-S's Trace Logger

bank zeropage @ 0x000 : [vardata;   0x100];
bank code     @ 0x200 : [constdata; 0x100];

in zeropage {
    var _padding1       : [u8; 0x08];

    var zp_u8_08        : u8;           // address = 0x08
}

// BLOCK 0000
in code {

func test() {

// BLOCK  0000  23 08 01   bbs $08.1,$0204
// BLOCK  0003  00         nop
    goto Label1 if zp_u8_08 $ 1 == true;
    nop();
Label1:

// BLOCK  0004  53 08 01   bbc $08.2,$0208
// BLOCK  0007  00         nop
    goto Label2 if zp_u8_08 $ 2 == false;
    nop();
Label2:

// BLOCK  0008  63 08 01   bbs $08.3,$020c
// BLOCK  000B  00         nop
    if (zp_u8_08 $ 3) == false {
        nop();
    }

// BLOCK  000C  93 08 01   bbc $08.4,$0210
// BLOCK  000F  00         nop
    if (zp_u8_08 $ 4) == true {
        nop();
    }

// BLOCK  0010  6F         rts
}

}

Wiz output:

* wiz: version 0.1.2 (alpha)
>> Parsing...
>> Compiling...
block/spc700_if_bit.wiz:23: error: branch instruction could not be generated
block/spc700_if_bit.wiz:29: error: branch instruction could not be generated
block/spc700_if_bit.wiz:35: error: could not generate branch instruction for `if` statement
block/spc700_if_bit.wiz:41: error: could not generate branch instruction for `if` statement
* wiz: failed with 4 error(s).