Skip to content

Cannot compile ya = y * a; on the SPC700 platform #145

@undisbeliever

Description

@undisbeliever

While coding a SNES audio driver in wiz I noticed I was unable to compile a multiplication statement.

I made an attempt at fixing this bug, but I'm unsure how to fix it without adding a spc700 multiplication exception to Compiler::simplifyBinaryArithmeticExpression() or Compiler::reduceExpression().


// SYSTEM  spc700

bank code     @ 0x200 : [constdata; 0x100];

in code {

func test() {
    ya = y * a;
    ya = a * y;
}

}

Wiz output:

* wiz: version 0.1.2 (alpha)
>> Parsing...
>> Compiling...
mul_test.wiz:8: error: left-hand side of type `u16` cannot be assigned `u8` expression
mul_test.wiz:9: error: left-hand side of type `u16` cannot be assigned `u8` expression
* wiz: failed with 2 error(s).

I did discover a workaround, wrapping the multiplication in an inline func compiles successfully.

// SYSTEM  spc700

bank code     @ 0x200 : [constdata; 0x100];

in code {

inline func mul(u8a : u8 in a, u8y : u8 in y) : u16 in ya {
    return a * y;
}

func test() {
    ya = mul(a, y);
}

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions