Giter Club home page Giter Club logo

Comments (4)

aralbrec avatar aralbrec commented on May 13, 2024

Another point of difference is in how char parameters are push onto the stack. sdcc will push one byte for each char whereas sccz80 will push a word.

from z88dk.

pauloscustodio avatar pauloscustodio commented on May 13, 2024

Just thinking out loud: could we add attributes to function entry points and change the linker to search a matching function name and function attributes? This would require changes in the compilers and assembler, to pass the attributes to the object file, and in the linker to search for a matching function.

from z88dk.

aralbrec avatar aralbrec commented on May 13, 2024

A simpler variation on that is to get the preprocessor to substitute different names for function entry points depending on which compiler is running:

#ifdef __SDCC
#define strcpy sdcc_strcpy
#endif

#ifdef __SCCZ80
#define strcpy sccz80_strcpy
#endif

Then have C entry points for each that collect parameters and then jump into the common asm implementation.

So the compiler and attributes get encoded in the name rather than having to modify any of the toolchain.

from z88dk.

aralbrec avatar aralbrec commented on May 13, 2024

A note regarding function renaming for zsdcc. sdcc will inline a handful of string functions:

#ifndef __SDCC_DISABLE_BUILTIN

#undef memcpy
#undef strcpy
#undef strncpy
#undef strchr
#undef memset

#define memcpy(dst, src, n) __builtin_memcpy(dst, src, n)
#define strcpy(dst, src) __builtin_strcpy(dst, src)
#define strncpy(dst, src, n) __builtin_strncpy(dst, src, n)
#define strchr(s, c) __builtin_strchr(s, c)
#define memset(dst, c, n) __builtin_memset(dst, c, n)

#endif

This replaces the macro magic we use for fastcall/callee linkage in favour of selecting sdcc's built-ins for these functions. In practice, sdcc's inlining of these functions are a big win in terms of speed.

Sometimes sdcc is unable to inline these functions and instead the compiler will insert a call to the c library's implementation. However, this insertion happens after the preprocessor has already run so we do not get callee/fastcall linkage selected as we would want.

Instead, this case is caught by copt in post-processing along with the other calls that sdcc makes to its support functions.

If we adopt naming as suggested in the last post, the case of built-ins must be kept in mind.

from z88dk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.