Skip to content
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

No autocast result to function definition #2264

Closed
Dark-Schneider-666 opened this issue May 16, 2023 · 4 comments
Closed

No autocast result to function definition #2264

Dark-Schneider-666 opened this issue May 16, 2023 · 4 comments

Comments

@Dark-Schneider-666
Copy link

Dark-Schneider-666 commented May 16, 2023

I have this definitions:
typedef uint8_t bool;
extern bool collide_check_u16(uint16_t x, uint16_t y, Rectangle_u16 *collision) __smallc __z88dk_callee;
The returning values is like:

collide_return_false:
    ld l, 0
    ret
collide_return_true:
    ld l, 1
    ret

When doing something like:
collide_draw_set(collide_check_u16(100, 90, &rect2) ? 8 : 7);
It uses also the value at register H, so getting incorrect behavior, if instead I do:
collide_draw_set((bool)collide_check_u16(100, 90, &rect2) ? 8 : 7);
Works normally, using only register L.

If I set returning values like:

collide_return_false:
    ld hl, 0
    ret
collide_return_true:
    ld hl, 1
    ret

Then works with the 1st calling method, but is supposed to be an 8-bit returning value.

@suborb
Copy link
Member

suborb commented May 22, 2023

I think this is another manifestation of #2216

@Dark-Schneider-666
Copy link
Author

I am using SmallC, should have indicated at title.

@suborb
Copy link
Member

suborb commented May 23, 2023

Ah, in that case it's working as expected: https://github.com/z88dk/z88dk/wiki/CallingConventions - return values with __smallc are in hl, or dehl

@Dark-Schneider-666
Copy link
Author

Then I have to revise some of my asm code.

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants