Menu

Assembly code error

2008-02-11
2012-09-26
  • keyvan eslami

    keyvan eslami - 2008-02-11

    Hi everyone,

    I have this line of code in a header file:

    define OS_TASK_SW() asm(TRAP #14)

    and whenever I try to include this header file into my main I get this error:

    82:42 C:\Keyvan\Project2\MyRTOS\RTOS\Sources\os_cpu.h '#' is not followed by a macro parameter

    the compiler output is:

    Compiler: Default compiler
    Building Makefile: "C:\Keyvan\Project2\MyRTOS\Makefile.win"
    Executing make...
    make.exe -f "C:\Keyvan\Project2\MyRTOS\Makefile.win" all
    gcc.exe -c RTOS/Sources/os_core.c -o RTOS/Sources/os_core.o -I"C:/Dev-Cpp/include" -I"C:/Keyvan/Project2/MyRTOS/RTOS/Sources" -fexpensive-optimizations -O3

    In file included from C:/Keyvan/Project2/MyRTOS/RTOS/Sources/ucos_ii.h:46,
    from RTOS/Sources/os_core.c:26:
    C:/Keyvan/Project2/MyRTOS/RTOS/Sources/os_cpu.h:82:42: '#' is not followed by a macro parameter

    make.exe: *** [RTOS/Sources/os_core.o] Error 1

    Execution terminated

    Now, I found that way to get rid of the problem is to remove '#' but it will have further problems with OS_TASK_SW() function.

    Can anyone please help me out with this problem?

    Thank you,

     
    • cpns

      cpns - 2008-02-13

      A Windows hosted GCC toolchain to Coldfire is available at http://www.ronetix.at/software.html I have not used it, so I don't know if it is a true Windows native compiler like MinGW to if it relies on Cygwin (which makes it more complex and much larger). Either way, it can be integrated with Dev-C++ if you choose by defining an alternative tool chain in Tools->Compiler options. The Ronetix site includes a guide on how to use it for do cross-development within Eclipse rather than Dev-C++ which you may prefer. http://download.ronetix.info/toolchain/m68k_cross_development_guide.pdf

      I have used WinARM (a Windows hosted GCC cross-compiler toolchain for ARM) with Dev-C++. It requires a little tweaking, and possibly a custom build step to create a linked object file in the appropriate format. The default settings will produce an exe file which will of course be an invalid executable on Windows.

      Clifford

       
    • Anonymous

      Anonymous - 2008-02-11

      The stringification # need some parameter in both sides. Some like

      define OS_TASK_SW(param) asm(TRAP #param)

      or even

      define OS_TASK_SW() asm(TRAP param)

       
    • keyvan eslami

      keyvan eslami - 2008-02-11

      Thanks ajmillan! but like I said, if I remove # it will have problems with using OS_TASK_SW(). here's the compiler output for that result:

      Compiler: Default compiler
      Building Makefile: "C:\Keyvan\Project2\MyRTOS\Makefile.win"
      Executing make...
      make.exe -f "C:\Keyvan\Project2\MyRTOS\Makefile.win" all
      gcc.exe -c RTOS/Sources/os_core.c -o RTOS/Sources/os_core.o -I"C:/Dev-Cpp/include" -I"C:/Keyvan/Project2/MyRTOS/RTOS/Sources" -fexpensive-optimizations -O3

      RTOS/Sources/os_core.c: In function OS_Sched': RTOS/Sources/os_core.c:1624: error:TRAP' undeclared (first use in this function)
      RTOS/Sources/os_core.c:1624: error: (Each undeclared identifier is reported only once
      RTOS/Sources/os_core.c:1624: error: for each function it appears in.)
      RTOS/Sources/os_core.c:1624: error: syntax error before numeric constant

      make.exe: *** [RTOS/Sources/os_core.o] Error 1

      Execution terminated

      and using param in both sides requires a change in entire code wherever I used OS_TASK_SW(). I would try that and see what would happen.

       
    • BiT

      BiT - 2008-02-11

      define OS_TASK_SW() asm(TRAP ##14)

      Should work.

       
    • keyvan eslami

      keyvan eslami - 2008-02-11

      the compile log with #define OS_TRACK_SW() asm(TRAP ##14) is:

      Compiler: Default compiler
      Building Makefile: "C:\Keyvan\Project2\MyRTOS\Makefile.win"
      Executing make...
      make.exe -f "C:\Keyvan\Project2\MyRTOS\Makefile.win" all
      gcc.exe -c RTOS/Sources/os_core.c -o RTOS/Sources/os_core.o -I"C:/Dev-Cpp/include" -I"C:/Keyvan/Project2/MyRTOS/RTOS/Sources" -fexpensive-optimizations -O3

      RTOS/Sources/os_core.c: In function OS_Sched': RTOS/Sources/os_core.c:1624: error:TRAP14' undeclared (first use in this function)
      RTOS/Sources/os_core.c:1624: error: (Each undeclared identifier is reported only once
      RTOS/Sources/os_core.c:1624: error: for each function it appears in.)

      RTOS/Sources/os_core.c:1624: error: argument of `asm' is not a constant string

      make.exe: *** [RTOS/Sources/os_core.o] Error 1

      Execution terminated

      Now, I'm wondering in several things:
      1- I think the right syntax for asm() is #define OS_TASK_SW() asm("TRAP ##14"), which is explained in gcc reference manual but I used several different formats like: asm("TRAP ##14;"), asm(TRAP ##14), asm(TRAP ##14;), etc and yet no success.
      2- I hope the error that says "RTOS/Sources/os_core.c:1624: error: `TRAP14' undeclared (first use in this function)" does not mean that I have to manually define traps, because I have not. I assumed that trap is an assembly keyword and it should be run automatically. please let me know if I'm mistaken.

       
    • BiT

      BiT - 2008-02-11
       
    • cpns

      cpns - 2008-02-11

      A number of points:

      1) # has special meaning to the preprocessor, so you cannot have a literal # in the macro definition. You can of course use one within a string.

      2) Neither C nor C++ define a standard syntax for inline assembler, and that is certainly not the correct syntax for GCC in any case (see http://www.ibiblio.org/gferg/ldp/GCC-Inline-Assembly-HOWTO.html )

      3) What is the intended target? TRAP is not an x86 mnemonic as far as I am aware (correct me if I am wrong). Unless you have configured Dev-C++ to use a cross-compiler, this instruction would not build in any case. Moreover the default MinGW compiler requires Windows runtime support whereas an RTOS would need to run without another OS already running - unless you do something 'nasty' like build it as a 16bit DOS app, but it will be 'virtualised' and not truely real-time. MinGW only supports 32bit protected mode compilation, so you would not be able to do the low level processor access required to implement an RTOS scheduler.

      Basically, there is something wrong with this picture. Let us know what you are trying to do perhaps?

      Clifford

       
    • keyvan eslami

      keyvan eslami - 2008-02-11

      Clifford,

      I think your third point is what my problem is.
      Like you said, I need another compiler to run RTOS directly to the device under test.

      Thank you all for very interesting inputs on this problem.

      Cheers

       
      • cpns

        cpns - 2008-02-12

        What is the target, and what is the the RTOS (link)? I may be able to help since it is my field of expertise.

        Clifford

         
    • keyvan eslami

      keyvan eslami - 2008-02-12

      The RTOS is uC/OS-II, the free version for research. the target is coldfire mcf51qe128 on DEMOQE.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.