Skip to content

Conversation

@ZERICO2005
Copy link
Contributor

@ZERICO2005 ZERICO2005 commented Sep 23, 2025

Changes:

  • Implemented atoi, atol, strtol, strtoul, strtoll, strtoull in assembly.
  • Optimized llmulu_b
CC per decimal digit
atoi    :  21F +  4R +  3W +  1
atol    :  32F +  4R +  3W +  1
strtol  :  79F + 13R + 12W + 21
strtoll : 103F + 10R +  9W + 33

atoi, and atol, now have their own dedicated routines which offer a good performance boost compared to wrapping strtol. This is because they don't need to track endptr or overflow, and they only work with base 10.

A dedicated routine for atoll wouldn't be much faster than strtoll since the main bottle neck is multiplication.

I also added __strtoi and __strtoui, which behave exactly like strtol and strtoul, but will raise ERANGE and return INT_MIN/INT_MAX and UINT_MAX respectively when the result is out of range. This is mostly useful for implementing std::string.stoi(), which is supposed to throw an exception if the result is out of range for int. We can't throw exceptions on the eZ80, but using __strtoi allows for ERANGE to be raised instead.

@ZERICO2005 ZERICO2005 marked this pull request as ready for review September 27, 2025 03:55
@ZERICO2005 ZERICO2005 changed the title implemented atoi, atol, and atoll in assembly implemented atoi, atol, and strto(u)l(l) in assembly Sep 30, 2025
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.

1 participant