WORDS_BIGENDIAN

2003-08-21
2003-08-24
  • Jeff Wittrock

    Jeff Wittrock - 2003-08-21

    Hello,

    I am using SDCC with the cygnal line of 8051 microcontrollers.  The one problem that I run into is that the Cygnal IDE expects multi-byte variables to be big-ended, while SDCC stores multi-byte variables as little-ended.

    I noticed the define WORDS_BIGENDIAN  in "sdccconf_in.h".  How is this actually used?  Is it possible to build SDCC so that it will create code which treats multi-byte values as big-endian.

    Thank You  for any help

     
    • Frieder Ferlemann

      Hi Jeff,

      while 8 bit CPUs normally don't care about
      endianness, the 8051 has a preferred byte order (at least for variables in xdata)
      As the dptr can only be incremented it is more
      effective to store the least significant word
      at lower addresses.

      Look at adding a literal to an int:

      mov a,@dptr
      add a,#0xbe
      mov @dptr,a
      inc dptr                ; <--
      mov a,@dptr
      adc a,#0xaf
      mov @dptr,a

      you'll find clever but still lengthy code
      needed to decrement the dptr f.e. in:
        sdcc/device/lib/_decdptr.c

      So Cygnal's IDE should have an option to
      change endianness because
      a) it is much easier to implement at a few
         display routines than within a compiler
         and its libraries
      b) it is the technically better endianness
         for the 8051
      c) sdcc is probably not the only compiler
         which is aware of b;)

      Frieder

       
      • Jeff Wittrock

        Jeff Wittrock - 2003-08-22

        Hello Frieder,

        Thanks for the info.
        I wish that the Cygnal IDE did allow for support of little-endian WORDS.  Unfortunately they don't.  Cygnal has kind of tied their IDE to the Keil tools, (even though they do support integration of some others), and these use big-endian words.

        Can you tell me what the WORDS_BIGENDIAN define in "sdccconf_in.h" does?

        Thanks,
        Jeff Wittrock

         
        • Bernhard Held

          Bernhard Held - 2003-08-24

          WORDS_BIGENDIAN is used to define the endianess of the host, on which SDCC runs.