biggestsonicfan / i960-CTOOLS-with-NINDY

A repo in which i960 CTOOLS and NINDY are mirrored and a work in progress for binaries will be.
4 stars 2 forks source link

ERRORS - ic960 and flash.c #1

Closed biggestsonicfan closed 4 years ago

biggestsonicfan commented 4 years ago

Compiling flash.c in qt960 with the following I960BASE=~/i960-CTOOLS-with-NINDY/i386-nbsd1-ctools/ ../../i386-nbsd1-ctools/bin/ic960 -c -R -AKB -I../include flash.c results in the following errors:

In file included from flash.c:25:

                                + sizeof(sectbuf[0].p_addr) \
                                ^                             
ic960 ERROR: "../include/globals.h", line 55 -- parse error before `+'
ic960 ERROR: "../include/globals.h", line 55 -- stray '\' in program
ic960 ERROR: "../include/globals.h", line 56 -- stray '\' in program
ic960 ERROR: "../include/globals.h", line 57 -- stray '\' in program
ic960 ERROR: "../include/globals.h", line 58 -- stray '\' in program
ic960 ERROR: "../include/globals.h", line 59 -- stray '\' in program
ic960 ERROR: "../include/globals.h", line 60 -- stray '\' in program
ic960 ERROR: "../include/globals.h", line 61 -- stray '\' in program
ic960 ERROR: "../include/globals.h", line 62 -- stray '\' in program
ic960 ERROR: "../include/globals.h", line 63 -- stray '\' in program
ic960 ERROR: "../include/globals.h", line 64 -- stray '\' in program
ic960 ERROR: "../include/globals.h", line 67 -- stray '\' in program
ic960 ERROR: "../include/globals.h", line 68 -- stray '\' in program
ic960 ERROR: "../include/globals.h", line 69 -- stray '\' in program
ic960 ERROR: "../include/globals.h", line 70 -- stray '\' in program
ic960 ERROR: "../include/globals.h", line 71 -- stray '\' in program
ic960 ERROR: "../include/globals.h", line 72 -- stray '\' in program
../include/qtcommon.h: In function `time':
In file included from flash.c:26:

To fix the "stray '\' in program" errors, an underscore ( _ ) is used instead. This clears those errors. The "parse error before +" still remains . A fix at the expense of readability was to delete all indents and " \ " characters to form #define SHDR_UNPADDED_SIZE and #define AOUT_UNPADDED_SIZE on single lines.

        {
        ^ 
ic960 ERROR: "../include/qtcommon.h", line 252 -- asm function definition must have a function prototype
flash.c: At top level:

The code in question from qtcommon.h is as follows:

/* ASSEMBLY INLINE */
#ifdef __GNUC__
#   define GASM __asm__ __volatile__
    __inline__ static void
    time( loops )
    {
        int cnt;
        GASM( "mov %1,%0" : "=d"(cnt) : "d"(loops) );
        GASM( "0: cmpdeco 0,%1,%0; bl 0b" : "=d"(cnt) : "0"(cnt) );
    }
#else
    asm
    time(loops)
    {
        %reglit loops; tmpreg cnt; label loop;
        mov     loops, cnt
      loop: cmpdeco 0, cnt, cnt
        bl  loop
        %error;
    }
#endif

line 252 is just after time(loops)

EDIT1: From i_asm_func.c:

int
check_asm_parms()
{
  /* We have seen the asm declarator and parameter list.
     Check out the funtion for basic suitability as an
     asm function.  The stuff reported here is stuff
     we want reported exactly once per function def, as
     opposed to once per asm leaf.
  */

  tree t,p;
  int b,x;

  reinit_parse_for_function ();
  store_parm_decls ();

  t = TREE_TYPE(current_function_decl);

  if (TYPE_ARG_TYPES(t) == 0)
    error("asm function definition must have a function prototype");

  if (TYPE_ARG_TYPES(t) != 0
  && TREE_VALUE(tree_last(TYPE_ARG_TYPES(t))) != void_type_node)
    error("asm function definition cannot have a variable number of arguments");

  t  = DECL_RESULT(current_function_decl);

  if (TYPE_MODE(TREE_TYPE(t)) != VOIDmode)
  { b = int_size_in_bytes (TREE_TYPE(t));
    if (b > 16)
    { error ("asm function return value must be 16 bytes or smaller");
      assert (TYPE_MODE(TREE_TYPE(t)) == BLKmode);
    }
  }

  t = DECL_ARGUMENTS(current_function_decl);

  if (t && (p=tree_last(t)) && DECL_NAME (p) && 
            !strcmp (IDENTIFIER_POINTER(DECL_NAME (p)), "__builtin_va_alist"))
    error("asm function definition cannot have a variable number of arguments");

  while (t)
  { int b;

    if (TREE_CODE(t) == PARM_DECL)
    { b = int_size_in_bytes (TREE_TYPE(t));
      if (b > 16)
      { error ("asm function parameter '%s' must be 16 bytes or smaller",
               IDENTIFIER_POINTER(DECL_NAME(t)));
        assert (TYPE_MODE(TREE_TYPE(t)) == BLKmode);
      }
    }

    t = TREE_CHAIN(t);
  }
}

EDIT2: 7-54 of the i960® Processor Compiler User’s Manual explains Inline Assembly Language. Perhaps this could be of use?

biggestsonicfan commented 4 years ago

Fixed in commit f30af473308a38611078be729c5117eb5312dc63