customasm icon indicating copy to clipboard operation
customasm copied to clipboard

Labels and `$` inside `asm` blocks

Open gnutterts opened this issue 4 years ago • 3 comments

This is not an issue I expect to be resolved at the moment, but certainly a reminder that it is a valid use-case. It seems customasm is not designed to support single instruction architectures by lack of a true macro mnemonic. The two main issues:

  1. You can't define a relative label inside a asm{}
  2. $ will always reference the first asm{} IP even when referencing other asm{}

gnutterts avatar Oct 08 '21 23:10 gnutterts

As we've discussed on Discord, there's the problem of asm blocks being available in any kind of expression context, even if the address isn't aligned. For example:

#ruledef {
    jmp {addr: u8} => 0xaa @ addr
}

#d4 0xf
#d4 asm { jmp $ }

So labels wouldn't work either. But if the address is indeed aligned, then I think the idea is workable. We'll just have to continue erroring out on misaligned addresses.

hlorenzi avatar Oct 11 '21 15:10 hlorenzi

When it comes to $ I understand the problem. But your example should be equivalent to the one below in a way. Both fail with that error. So yes, it should keep failing like that by design.

#ruledef {
    jmp {addr: u8} => 0xaa @ addr
}

#d4 0xf
jmp $

gnutterts avatar Oct 11 '21 23:10 gnutterts

I'm sorry, I'm an idiot. Tried to find out how to syntax highlight assembly and clicked the wrong button closing the issue. :) Yeah, I might not be the sharpest tool in the shed. lol

gnutterts avatar Oct 11 '21 23:10 gnutterts