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

Sometimes subruledef's aren't evaluated in asm{...} blocks #170

Open
chrisgbk opened this issue Jul 3, 2023 · 0 comments
Open

Sometimes subruledef's aren't evaluated in asm{...} blocks #170

chrisgbk opened this issue Jul 3, 2023 · 0 comments

Comments

@chrisgbk
Copy link

chrisgbk commented Jul 3, 2023

In 12.0, following is valid:

#subruledef reg
{
	x{val: u4} => val`4
}
#ruledef test
{
	test {imm: u8} => imm
	testasm {R1: reg}, {R2: reg} => asm{test (R1 @ R2)}
}

	testasm x0, x1 ;succeeds
 outp | addr | data

  0:0 |    0 | 01 ; testasm x0, x1

which obviously fails in 13.x with the requirement of enclosing parameters in {}; however enclosing in {} also fails:

#subruledef reg
{
	x{val: u4} => val`4
}
#ruledef test
{
	test {imm: u8} => imm
	testasm {R1: reg}, {R2: reg} => asm{test ({R1} @ {R2})}
}

	testasm x0, x1 ;fails
error: failed to resolve instruction
  --> test.asm:11:2:
 9 | }
10 |
11 |   testasm x0, x1
   |   ^^^^^^^^^^^^^^
   + note: within `test`, rule 1
   --> test.asm:8:2:
  8 |   testasm {R1: reg}, {R2: reg} => asm{test ({R1} @ {R2})}
    |   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    + error: failed to resolve instruction
     --> test.asm:8:38:
    6 | {
    7 |   test {imm: u8} => imm
    8 |   testasm {R1: reg}, {R2: reg} => asm{test ({R1} @ {R2})}
      |                                       ^^^^^^^^^^^^^^^^^^
    9 | }
   10 |
      + note: within `test`, rule 0
      --> test.asm:7:2:
     7 |   test {imm: u8} => imm
       |   ^^^^^^^^^^^^^^
       + error: unknown symbol `x0`
        --> test.asm:8:45:
       6 | {
       7 |   test {imm: u8} => imm
       8 |   testasm {R1: reg}, {R2: reg} => asm{test ({R1} @ {R2})}
         |                                              ^^
       9 | }
      10 |

it seems the parameters can end up out of scope.

However, as a workaround, the following does work:

	testasm2 {R1: reg}, {R2: reg} => 
	{
		temp = (R1 @ R2)
		asm{test {temp}}
	}

So I'm not sure if this is best handled as a known/documented incompatibility between 12.0 and 13,x and the workaround is best practice for this situation, or if there is actually an issue to address. A note that conversions/calculations required in asm{...} blocks should be performed with temporary values in the wiki could suffice.

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

No branches or pull requests

2 participants