-
Notifications
You must be signed in to change notification settings - Fork 93
Description
Is this a BUG REPORT, FEATURE REQUEST or QUESTION?:
- Bug Report
- Feature Request
- Question
What happened:
I have a few ideas for the __emit operator, but before implementing them and making a PR I guess it would be better to discuss them here first.
- Add
__emit dump <identifier>.
This would allow the compiler to retrieve addresses of functions, variables etc. as constant values, which could be useful for initialization of constants and immutable arrays.
Example:
static const functions[] =
{
__emit dump func1,
__emit dump func2,
__emit dump func3
};Though I'm not sure if dump would be a proper pseudo-instruction name because in compiler assembly output dump means "put value(s) into the data section", not "retrieve symbol value/address".
- Allow jumps to naked functions.
Since the next release is going to have naked functions without prologue and epilogue code, maybe we should allow such functions as arguments for jump instructions?
#pragma naked
NakedFunction() { /* ... */ }
// ...
__emit jzer NakedFunction;- Issue an error/warning if data/stack offset is not a multiple of cell size.
__emit load.s.pri 5; // The offset is not a multiple of 4, so this is clearly an error.This would require addition of new error in sc5.c though (would "not a multiple of cell size" be a good description for it?)
- Add a new error for invalid IDs in
lctrl,sctrland other instructions.
__emit lctrl -1;Currently this would make the compiler issue an "invalid range" error, which clearly isn't the right description. But again, I'm not sure how to phrase that error properly.
What you expected to happen:
How to reproduce it (as minimally and precisely as possible):
Anything else we need to know?:
Special thanks to @VVWVV for giving me the idea about the "not a multiple of cell size" error.
Environment:
- Operating System
- Compiler version
- How are you invoking the compiler? Pawno, Sublime, vscode, sampctl or command-line?
- If using sampctl, the version number