-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Secondary return registers #62
Comments
Is it completely essential that the function(s) in question have two return values, rather than returning a pascal-style string? Say we encoded "Hello!" as a p-string, we would get (Assuming little endian, each table column is a word):
Unless I'm missing something, I feel this would be the better solution for the library. |
@kk-: My initial version did use p-string, but someone objected to the idea. There is ongoing debate between p-string and c-string anyway, so I redesigned the interface to avoid the compatibility issue. Wrapping getline to return p-string or c-string should be easy though. |
@lifthrasiir everyone seems to be more partial to p-strings as of current, however if you are thinking of abstracting upon this function then perhaps you could just hide this function away and expose the p-string and c-string interfaces. Internalising the function will effectively allow you to do as you please for as long as it's hidden. |
Ahh, I am getting back to this really late. My instinct is to say that anything longer than 16 bit should just return a pointer but maybe that is not acceptable. Guess I need to get out some other ABIs and see how they return 64-bit ints on a 32-bit platform and do what they do. |
Under the current ABI draft it's perfectly safe to return additional values in B and C. Since the caller must preserve the values of B and C if it cares about them, at worst, the caller will ignore the additional returned values. For anything larger you'll need to explore another calling convention or a heap/freestore implementation. Returning these values on the stack can be tricky if you also expect the caller to clean up any parameters that were passed on the stack. I'd suggest returning by pointer for any value larger than two words. |
I suggest just returning a pointer to any value larger than three words - we have A B and C as possible return registers. |
The current ABI draft 2 specifies that "The CALLEE MUST return it's result, if any, in register A", but it does not specify anything about the return value which size exceeds 16 bits. I suggest to use register B for this use, as used by (for example) 0x10c-dev stdlib.
The text was updated successfully, but these errors were encountered: