lynn/chibicc

Support `asm()`

Closed this issue · 1 comments

lynn commented

It would be nice to support inline Uxntal, something like:

int max(int x, int y) {
    return asm(x, y, "LTH2k JMP SWP2 NIP2");
}

The syntax I'm picturing is: n values to push, followed by a literal string of Uxntal that leaves an int result on the stack.

Or maybe something top-level like this is even easier to implement, and more flexible in a way:

int max(int x, int y);
asm("@max_ LTH2k JMP SWP2 NIP2 JMP2r");

That's a good idea, I would make use of this! I think the nested version is a bit more clear.