hlorenzi / customasm

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

Global labels do not seem to resolve out-of-order (inside asm{} block) #111

Closed Emmett81 closed 3 years ago

Emmett81 commented 3 years ago

Hi, when I try to run the code below I get an "instruction size did not converge after iterations" error.

Placing the T and Z parts above the #ruledef makes it work. I tried working around it by renaming Z & T to ZZ & TT and placing Z=ZZ & T=TT above the #ruledef block. But then it'll throw a "unknown variable" error. That also happens without the #ruledef block.

Am I doing something wrong?

#ruledef 
{
    sub.neg {a: u32} {b: u32} {r: u32} {j: u32} => a`32 @ b`32 @ r`32 @ j`32

    jmp {j: u32} => asm { sub.neg Z Z+1 T j }
}

jmp main

T: 
#d32 0

Z:
#d32 0 
#d32 1

main: