-
-
Notifications
You must be signed in to change notification settings - Fork 56
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
"Unknown Variable" error on Instruction names which are not meant to be variables #9
Comments
Could you show me what your This issue could have many causes, and the first thing that comes to mind is that you should usually define the register variants before the address variants -- it seems like you're already doing this, though? I'll try to reproduce this later, too. It should be perfectly possible to do as you intended, but I'm not sure how you are implementing this register combination syntax. So your exact definitions should come in handy to sorting this out! |
my CPUDEF looks like this: https://pastebin.com/WtCsTrmv i also tried to change the order so that the instructions in question come first but that didn't seem to change anything so i changed it back here is also the program i tried it in. in case that helps understanding my mess: |
So, this problem appears to be caused by an ambiguity between lines 101 and 143 from your pastebin, as seen in this minimal example: #cpudef
{
; line 101
LD ({dest}), ({src}) -> 0b101 @ 0b101 @ 0b01 @ src[15:0] @ dest[15:0]
; line 143
LD {dest}, (CDB) -> 0b101 @ 0b111 @ 0b01 @ dest[15:0]
}
LD (0xffff), (CDB) While ambiguities are usually solved by the order in which instructions are defined, in this case the current implementation will always choose Line 101 no matter the order. The decision tree looks like the following, in a simplified version: "LD" # step 1
/ \
"(" {dest} # step 2
| |
{dest} ","
| |
"),(" "(CDB)"
|
{src}
|
")" The branches are always considered left to right. Right now, you cannot reverse the order of the branches in this case by switching the order of the definitions. This is due to plaintext tokens always being considered before parameter slots (as in step 2 above), which is an artifact of the optimization structure used for matching. Since it doesn't appear Other approaches would include using a different plaintext token before the unparenthesized parameter, like I'll have to look into ways to make the decision tree respect the definition order in this case. I'll let you know when I get around to doing it! |
actually now that i see it. i made a mistake. all Instructions that use addresses should have parentheses around them, so
is supposed to be
this means the order is queal on both sides until it reaches CDB. i will fix this and see if it works. maybe this was just casued by that typo EDIT: it was, the program compiled. well now i feel stupid. |
well i think it's time to close this one, seeing as it has been solved byfixing a typo. |
Oh, sorry! I was actually waiting to close this after a fix to the unbalanced token decision tree I talked about in the previous comment. But I'm glad you were able to work around your issue! |
no problem.
example:
would turn into:
would this work to give me the relative address from the instruction's location to the address/label it should jump to? (and also stay within the bounds of a specific bit width) |
I got a few instructions which use 3 Registers as a sort of index with offset. Registers C and D being combined into CD to form the base index, and Register B being added as the offset.
so my instruction to load from and address pointed by CD + B to some other address is:
LD (addr), (CDB)
and i also got some instructions that load from one address to another directly, which would be:
LD (addr), (addr)
and this must be why the assembler thinks that CDB is a variable, because it sees the second instruction as the correct one instead of checking if there is one with a more correct/relevant name.
and i cannot think of an elegant way to get rid of this.
i tried removing the brackets, i tried using different brackets, i tried adding characters inside CDB to make it not count as a variable, but nothing worked to tell the assembler "this is not a variable, it's text, search an instruction with exactly this text"
The text was updated successfully, but these errors were encountered: