Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
undisbeliever opened this issue Jan 27, 2023 · 0 comments
Open

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

undisbeliever opened this issue Jan 27, 2023 · 0 comments

Comments

@undisbeliever
Copy link
Contributor

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);
}

}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant