On Sun, 3 Oct 2021 09:57:28 +0200 Philipp Klaus Krause <p...@spth.de> wrote:
> Dear SDCC users, > > would you consider it useful to have more functionality for bit > manipulation exposed as functions in the stadnard library. If yes, any > of the following (and if yes, with which interface?)? Anything else? > > * Endiannnes conversion for individual integers (e.g. big-endian to > native, native to little-endian, etc) via functions that convert from a > cahr array to the inetger or vice versa Right now Fuzix uses a bunch of longwinded defines with SDCC and they often generate poor code as SDCC doesn't appear to spot the opportunities to do things like load a long into four memory addresses in reverse order. Having the gcc __builtin_bswap16/32/.. functions wopuld be nice - and they seem to be turning into a sort of defacto standard. From those you can then generically produce the Linux like cpu_to/from_ and the BSD htons and friends given an endianness defines. If they are not builtins that resolve to constants at compile time then they are a lot less useful for me at least as I put them in initializations. > * Population count (i.e. the number of bits that are 1) of an integer I don't currently use __builtin_popcount*() or population counts. > * Rotation of integer types > * Count leading / trailing zeroes / ones __builtin_ffs/fls __builtin_ffz/flz are applicable to a pile of OS functionality, although for speed reasons very little Fuzix code uses them on 8bit systems. > * Single bit chek (i.e. check if an integer is a power of two, and if > yes, which one) Currently doing this with the usual algorithm explicity. > * Generic byte reverse for a block of memory Yes. Fuzix uses the existing 2 byte one from Posix (swab) in several places but having the __builtin_bswap*() from gcc would be useful for 4 byte swaps in a couple of spots. Alan _______________________________________________ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user