Skip to content

Conversation

ZERICO2005
Copy link
Contributor

@ZERICO2005 ZERICO2005 commented Sep 13, 2025

Moved the following functions from src/crt to src/libc since these functions use the C calling convention:

labs.src
ldiv.src
i48abs.src
i48div.src
llabs.src
lldiv.src

abs.src and div.src were already inside of src/libc.

I also cleaned up the code of and added timings to ineg, inot, ineg_fast, and inot_fast.

@ZERICO2005 ZERICO2005 changed the title Moved (l/i48/ll)abs into LIBC, and added libcall absolute value functions Moved (l/i48/ll)abs into LIBC Sep 16, 2025
@ZERICO2005
Copy link
Contributor Author

I undid the libcall absolute value functions commit to keep this PR simple. They can be added later in a different PR

@ZERICO2005 ZERICO2005 marked this pull request as ready for review September 16, 2025 01:49
@ZERICO2005 ZERICO2005 marked this pull request as draft September 16, 2025 04:29
@ZERICO2005 ZERICO2005 changed the title Moved (l/i48/ll)abs into LIBC Moved (l/i48/ll)abs/div into LIBC Sep 16, 2025
@ZERICO2005 ZERICO2005 marked this pull request as ready for review September 16, 2025 15:50
@mateoconlechuga
Copy link
Member

what no these are not libc functions.

@ZERICO2005
Copy link
Contributor Author

ZERICO2005 commented Sep 16, 2025

They are the only functions in src/crt that follow the C calling convention to my knowledge. These functions are defined in <stdlib.h>.
ldivs.src and lrems.src use the LIBCALL convention, but ldiv.src does not

@mateoconlechuga
Copy link
Member

Fine, why is there still a bunch of #if 1 in there

@ZERICO2005
Copy link
Contributor Author

ineg.src and inot.src have two possible implementations (size versus speed optimized), which is why I have an if 1 there.

Although the size optimized implementation mostly just adds a push/pop de to ineg_fast.src and inot_fast.src, so no knowledge would be lost if they are removed.

@mateoconlechuga
Copy link
Member

Then it should be a define to choose size vs speed not some unknown modifier

@mateoconlechuga
Copy link
Member

Why did you remove it????

@ZERICO2005
Copy link
Contributor Author

I removed the size optimized versions of __ineg and __inot. Since a better way to size optimize those routines would be to link to Ti's routines with the PREFER_OS_CRT define

@mateoconlechuga
Copy link
Member

Unless the user doesn't have a CE OS

@ZERICO2005
Copy link
Contributor Author

ZERICO2005 commented Sep 16, 2025

I also figure that __inot and __ineg are likely the most commonly called routines, and that saving 2 bytes is not really worth it. Having a size optimized version would be better suited towards large and uncommon routines, where something on the order of 20 bytes could be saved for example

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

Successfully merging this pull request may close these issues.

2 participants