It seems like CONSTANT words compile a reference to themselves, so the value isn't looked up til run-time.
I guess this allows the value to change before the word executes which is perhaps a benefit in some cases.
I want to make a CONST word which just inlines itself at compile-time, so the value is guaranteed and it runs a bit faster.
What threading model are you interested in doing this in? The way I do it in my ITC Forth is almost the same for CONSTANT as for VARIABLE, both putting a number on the stack, but for a variable the number is expected to be an address. It was many years ago that I wrote it, but it looks like if I were to really get into the details now I would find not more than a cycle or two difference in execution speed in my '816 Forth. That's for when the target computer is running. When I'm forming the kernel in another computer, whether assembling or compiling, for a ROM-based system where the variable's data cannot be right there with the variable's header, they truly are the same, and VARIABLE just returns the (constant) number which is the address of the variable's data in RAM. The runtime is const for both VARIABLE and CONSTANT. No difference.
In your example though, if you have an assembler onboard and it's super easy to write primitives, why not just do that. In the simplest example, 1+ in the '816 with accumulator width set to 16-bit becomes just INC 0,X, rather that putting 1 on the stack as a constant and then running the add routine. If there's a number you need to add frequently and quickly, make it a primitive, for example 42+ becomes (for 65816 with accumulator width option set to 16-bit):
If you want speed instead of size, you can forgo using LITERAL and just put the assembly to get the value on the stack (looks like Garth beat me to it):
yes, i like Garth's idea of adding a couple of primitives too. I think I can speed up the 65c02-on-65c02 emulator a lot with inlined const and some well-chosen bit-twiddling words for all the flag updates. needs a bit of thought about exactly what words tho.