hlorenzi / customasm

💻 An assembler for custom, user-defined instruction sets! https://hlorenzi.github.io/customasm/web/
Apache License 2.0
704 stars 55 forks source link

no match for instruction found #165

Closed OfficialPixelBrush closed 1 year ago

OfficialPixelBrush commented 1 year ago

I define register as follows.

#ruledef register
{
    a => 0b1000
    b => 0b0100
    pc => 0b0010
    sp => 0b0001
}

Followed by defining my instruction.

#ruledef
{
    [other instructions]

    ld {r: register}, {value} =>
    {
        assert(r >= 0b0100)
        assert(r <= 0b1000)
        0x6 @ r @ value `4
    }

    ld {r: register}, {value} =>
    {
        assert(r >= 0b0001)
        assert(r <= 0b0010)
        0x6 @ r @ value `12
    }

    [other instructions]
}

Lastly, I use it as such. LD A,0xA or LD SP,0xFFF

This results in the error: error: no match for instruction found I'm absolutely certain this code worked in the past.

hlorenzi commented 1 year ago

That looks like it's because of the missing space after the comma! v0.12 now respects whitespace in rule patterns to fix some other issues, and is quite strict about it. I might be able to relax this requirement in the future, but for now, you can add a space after the comma to your instructions, or remove the space after the comma from your rule definitions.

OfficialPixelBrush commented 1 year ago

Awesome! That fixed it! Thanks!