User Activity

  • Posted a comment on discussion Open Discussion on Small Device C Compiler (SDCC)

    That is correct, changing to unsigned fixed it, and it makes sense for the compiler not to make assumptions. My doubt originated because, in a project I'm hired to work on, those optimizations weren't being applied in some code, but it already uses unsigned values. So I guess it must be due to the complexity of the statement (as it's closed source I can't copy it here, but it access a multidimensional array, calls another function...).

  • Posted a comment on discussion Open Discussion on Small Device C Compiler (SDCC)

    I was asking, because I had my doubts. I put together this (totally useless) sample code: int array[10] = {45, 78, 15, 39, 57, 93, 3, 63, 12, 77}; void work(int position) { array[position / 2] = array[position % 8]; } void main(void) { work(13); } When I replaced the assignment line with array[position >> 1] = array[position & 7]; I thought it would compile to exactly the same code, but it didn't. Looking at the output ASM it seems no optimization is being done in the first case. Sorry if this is...

  • Posted a comment on discussion Open Discussion on Small Device C Compiler (SDCC)

    Hello, I'd like to know if SDCC will optimize things like division and modulo with powers of 2 when the values are known at compile time, like: int a = 116; a = a / 16; // This should equal "a >> 4" int b = 73; b = b % 64; // This should equal "b & 63" And if true, will this too happen with complex expressions involving other variables and operands? Not just those simple assignments. Are these optimizations (like constant folding) only performed if --opt-code-speed is enabled, or always? Thanks.

  • Posted a comment on discussion Open Discussion on Small Device C Compiler (SDCC)

    Thanks!

  • Posted a comment on discussion Open Discussion on Small Device C Compiler (SDCC)

    According to the manual, section 3.1.8.8: SDCC will inline functions if and only if they are declared using inline and do not have variable arguments. Can SDCC make functions inline automatically according to some criteria, or will it only do that if the coder uses the inline keyword?

  • Posted a comment on discussion Help on Small Device C Compiler (SDCC)

    Well, it's no big deal, I can always change the file names, or add an empty line, and in any case this only happens when compiling in debug mode, so... Just wanted to know if SDCC han an option to use different symbol naming. It's not that important to me that I'd patch the compiler myself just to compile this project. Thank you.

  • Posted a comment on discussion Help on Small Device C Compiler (SDCC)

    Thank you both for the comments. @janko-5, I agree that it's the developer's duty to make sure there are no linking conflicts. In my project I've made sure of that by making all symbol names unique (at least the public ones), as there are no two functions, variables or constants with the same name. I've also configured my build system to place the output using the same relative path, so source/subfolder1/interface.c would go to bin/subfolder1/interface.rel or whatever. Actually it all works okay...

  • Posted a comment on discussion Help on Small Device C Compiler (SDCC)

    Forgot to add! I'm using SDCC 4.5.0.

View All

Personal Data

Username:
savidan
Joined:
2025-05-16 10:04:45.067000

Projects

  • No projects to display.

Personal Tools