Ceedling icon indicating copy to clipboard operation
Ceedling copied to clipboard

Assembler messages: Error: no such instruction

Open abergerSRS opened this issue 7 years ago • 19 comments

I am trying to run Ceedling tests for a module and am receiving the somewhat cryptic compilation output:

Test 'test_motorDrive.c'
------------------------
Compiling motorDrive.c...

C:\Users\[userName]\AppData\Local\Temp\cc2DmMto.s: Assembler messages:
C:\Users\[userName]\AppData\Local\Temp\cc2DmMto.s:48: Error: no such instruction: `ldrsh %eax,[%r8]'
C:\Users\[userName]\AppData\Local\Temp\cc2DmMto.s:49: Error: no such instruction: `ldrsh %ecx,[%r8,'
C:\Users\[userName]\AppData\Local\Temp\cc2DmMto.s:50: Error: expecting operand after ','; got nothing
C:\Users\[userName]\AppData\Local\Temp\cc2DmMto.s:51: Error: number of operands mismatch for `mul'
C:\Users\[userName]\AppData\Local\Temp\cc2DmMto.s:52: Error: invalid char '[' beginning operand 2 `[%r9]'
C:\Users\[userName]\AppData\Local\Temp\cc2DmMto.s:53: Error: no such instruction: `asr %ecx,%ecx,'
C:\Users\[userName]\AppData\Local\Temp\cc2DmMto.s:54: Error: number of operands mismatch for `add'
C:\Users\[userName]\AppData\Local\Temp\cc2DmMto.s:55: Error: number of operands mismatch for `sub'
C:\Users\[userName]\AppData\Local\Temp\cc2DmMto.s:56: Error: no such instruction: `rsb %edx,%edx,'
C:\Users\[userName]\AppData\Local\Temp\cc2DmMto.s:57: Error: no such instruction: `ssat %ecx,'
C:\Users\[userName]\AppData\Local\Temp\cc2DmMto.s:58: Error: no such instruction: `ssat %edx,'
C:\Users\[userName]\AppData\Local\Temp\cc2DmMto.s:59: Error: no such instruction: `strh %ecx,[%r9,'
C:\Users\[userName]\AppData\Local\Temp\cc2DmMto.s:60: Error: no such instruction: `strh %edx,[%r9,'
C:\Users\[userName]\AppData\Local\Temp\cc2DmMto.s:128: Error: no such instruction: `ldrsh %r9d,[%rdx]'
C:\Users\[userName]\AppData\Local\Temp\cc2DmMto.s:129: Error: no such instruction: `ldrsh %r8d,[%rdx,'
C:\Users\[userName]\AppData\Local\Temp\cc2DmMto.s:130: Error: no such instruction: `ldrsh %ecx,[%rax]'
C:\Users\[userName]\AppData\Local\Temp\cc2DmMto.s:131: Error: no such instruction: `ldrsh %rdx,[%rax,'
C:\Users\[userName]\AppData\Local\Temp\cc2DmMto.s:132: Error: number of operands mismatch for `mul'
C:\Users\[userName]\AppData\Local\Temp\cc2DmMto.s:133: Error: no such instruction: `mls %rax,%r8d,%ecx,%rax'
C:\Users\[userName]\AppData\Local\Temp\cc2DmMto.s:134: Error: no such instruction: `ssat %rax,'
C:\Users\[userName]\AppData\Local\Temp\cc2DmMto.s:135: Error: number of operands mismatch for `mul'
C:\Users\[userName]\AppData\Local\Temp\cc2DmMto.s:136: Error: no such instruction: `mla %r8d,%r9d,%ecx,%r8d'
C:\Users\[userName]\AppData\Local\Temp\cc2DmMto.s:137: Error: no such instruction: `ssat %r8d,'
C:\Users\[userName]\AppData\Local\Temp\cc2DmMto.s:138: Error: no such instruction: `strh %rax,[%r10]'
C:\Users\[userName]\AppData\Local\Temp\cc2DmMto.s:139: Error: no such instruction: `strh %r8d,[%r10,'
ERROR: Shell command failed.
> Shell executed command:
'gcc.exe -I"test" -I"test/source" -I"test/source/utilities" -I"test/utilities" -I"test/support" -I"source" -I"source/utilities" -I"drivers" -I"board" -I"CMSIS" -I"C:/nxp/RTCESL/CM4F_RTCESL_4.5_MCUX/GMCLIB/Include" -I"C:/nxp/RTCESL/CM4F_RTCESL_4.5_MCUX/MLIB/Include" -I"C:/nxp/RTCESL/CM4F_RTCESL_4.5_MCUX/GFLIB/Include" -I"D:/Documents/MCUXpressoIDE_10.1.0_589/workspace/SR544/vendor/ceedling/vendor/unity/src" -I"D:/Documents/MCUXpressoIDE_10.1.0_589/workspace/SR544/vendor/ceedling/vendor/cmock/src" -I"build/test/mocks" -DTEST -DCPU_MK64FN1M0VMD12 -DGNU_COMPILER -g -c "source/utilities/motorDrive.c" -o "build/test/out/motorDrive.o"'
> And exited with status: [1].

rake aborted!
ShellExecutionException: ShellExecutionException
D:/Documents/MCUXpressoIDE_10.1.0_589/workspace/SR544/vendor/ceedling/lib/ceedling/tool_executor.rb:78:in `exec'
D:/Documents/MCUXpressoIDE_10.1.0_589/workspace/SR544/vendor/ceedling/lib/ceedling/generator.rb:95:in `generate_object_file'
D:/Documents/MCUXpressoIDE_10.1.0_589/workspace/SR544/vendor/ceedling/lib/ceedling/rules_tests.rake:17:in `block in <top (required)>'
D:/Documents/MCUXpressoIDE_10.1.0_589/workspace/SR544/vendor/ceedling/lib/ceedling/task_invoker.rb:74:in `invoke_test_results'
D:/Documents/MCUXpressoIDE_10.1.0_589/workspace/SR544/vendor/ceedling/lib/ceedling/test_invoker.rb:104:in `block in setup_and_invoke'
D:/Documents/MCUXpressoIDE_10.1.0_589/workspace/SR544/vendor/ceedling/lib/ceedling/test_invoker.rb:63:in `setup_and_invoke'
D:/Documents/MCUXpressoIDE_10.1.0_589/workspace/SR544/vendor/ceedling/lib/ceedling/tasks_tests.rake:11:in `block (2 levels) in <top (required)>'
C:/Ruby21/bin/ceedling:23:in `load'
C:/Ruby21/bin/ceedling:23:in `<main>'
Tasks: TOP => build/test/results/test_motorDrive.pass => build/test/out/test_motorDrive.out => build/test/out/motorDrive.o
(See full trace by running task with --trace)
ERROR: Ceedling Failed

Any suggestions for how to locate and fix the issue here would be appreciated.

abergerSRS avatar Jul 06 '18 00:07 abergerSRS

If you rerun the test with verbosity turned up, it should show the call you're making to the assembler. Does it look correct? It seems like it's trying to call the wrong tool when you are passing it an assembly file?

mvandervoord avatar Jul 06 '18 02:07 mvandervoord

The verbosity doesn't shed any more light on it for me, but it's attached here for your perusal. Ceedling_VerboseOutput.txt

There are some warnings before the Assembler errors, but those don't appear to be the main issue. (All of the warnings are generated by the third party drivers).

The shell command that causes the exit (on line 218) looks ok.

abergerSRS avatar Jul 06 '18 16:07 abergerSRS

It appears from that snippet that motorDrive.c includes peripherals.h which includes ccjubmUE.s (or does motorDrive.c directly include it?) I'm just trying to see how you get to the point where you are attempting to compile this assembly file... it LOOKS like it's being pulled in as C code, which is why it is failing.

mvandervoord avatar Jul 06 '18 16:07 mvandervoord

motorDrive.c does include peripherals.h. But peripherals.h doesn't include any .s files. In fact, I can't even find those .s files (they are in a \Temp\ directory that I am not explicitly making use of for my project). Does Ceedling or gcc write intermediate files to \Temp?

abergerSRS avatar Jul 06 '18 16:07 abergerSRS

Nope. All of Ceedling's output goes into the build directory and subdirectory. This is one of the other tools. I'm not really sure what is going on here. If you copy the compile command that Ceedling is generating and execute it by itself at the command prompt, does it run properly or still have the same issue?

mvandervoord avatar Jul 06 '18 16:07 mvandervoord

If I run the gcc command from line 219 of the above .txt file, it has the same issue (although the .s files are named differently each time).

If I run the very first line, I get:

gcc.exe: error: build/temp/_test_motorDrive.c: No such file or directory
gcc.exe: fatal error: no input files
compilation terminated.

abergerSRS avatar Jul 06 '18 17:07 abergerSRS

I have a hunch with what's going on here. The project I am testing is for a Cortex M4 CPU, and in order to compile, I need to define the CPU. I've therefore included "CPU_MK64FN1M0VMD12" in the list of :defines: in the project.yml settings. (Without this #define, the compilation throws the error "No valid CPU defined!"). But since Ceedling is trying to compile the code for execution on a host PC, this is not the correct CPU, and so I get the "Error: no such instruction" messages from the assembler.

If this is the right interpretation of this error, how can I properly break the source code dependency on the CPU?

abergerSRS avatar Aug 08 '18 18:08 abergerSRS

You will need to "mock" the functions in that header files or manually assign variables. I do this trick very often where I redifne absolute addresses to some variable. For example:

#define ADC0_BASE         (0x40002000UL) /**< ADC0 base address  */

is then changed to in file procfamilyprocnummock.h:

volatile ADC_TypeDef	  adc0_base;
#define ADC0_BASE         (&adc0_base) /**< ADC0 base address  */

Then in the file where CPU is defined I just add another ifdef and then actually define PROCFAMILYPROCNUMMOCK, so that MOCK gets chosen in Ceedling, while all else works normally.

Your invalid instructions is mostly because of some hardcoded asm magic. That I usually replace with some ifdef by valid C implementation, which keeps everybody happy. When you upgrade the library I usually put the new version on separate branch, and then merge it in with "master".

I hope that makes some sense.

Letme avatar Aug 08 '18 18:08 Letme

i am using #define DATA_MEMORY_BARRIER() asm volatile("dmb sy": : :"memory") in my one of source.cpp file and calling DATA_MEMORY_BARRIER() in many places.

while compiling for my gtest sourceFile_test.cpp [source.cpp is added in Makefile.am for compilation dependency] it is giving an error as, Error: no such instruction: `dmb sy'. [got this error ubuntu 16.04 x86-64 amchine]

How can i resolved it or what Assembler option I can use to make compilation successful for source.cpp file?

Ajay107246 avatar Sep 26 '19 09:09 Ajay107246

@Ajay107246 -- I think you may be on the wrong forum? You're talking about C++ code and gTest. This is a forum for Ceedling and C testing. (If I had to guess, though, I would suspect that you are going to need to define DATA_MEMORY_BARRIER as nothing during a test. With Ceedling, TEST is defined during a test so you can use an #ifdef to decide which definition to use. There is likely something similar in gTest).

mvandervoord avatar Sep 26 '19 10:09 mvandervoord

Have you been able to solve this @abergerSRS ? we are having the exact same issue...

tomh4 avatar Mar 22 '21 08:03 tomh4

Hello. Any updates ? I am having same issue. @tomh4 @abergerSRS

AleksaStojkovic avatar Jan 13 '22 09:01 AleksaStojkovic

I don't think this has anything to do with Ceedling. You are compiling ARM assembly while you are running test cases on x86_64 machine. So you either define/remove the assembly with ifdef TEST or you use simulator to run your tests (along with arm compiler).

Letme avatar Jan 13 '22 10:01 Letme

It seems no one solve this problem until now.

Jamishon avatar Aug 25 '22 11:08 Jamishon

Can you explain a bit what is not solved?

Letme avatar Aug 25 '22 14:08 Letme

Can you explain a bit what is not solved?

I face the same issue.. While compiling source file i get the same errors Compiling dfu_mode.c with coverage... C:\Users\x\AppData\Local\Temp\cc3Lvn1N.s: Assembler messages: C:\Users\x\AppData\Local\Temp\cc3Lvn1N.s:28: Error: number of operands mismatch for ds' C:\Users\x\AppData\Local\Temp\cc3Lvn1N.s:57: Error: number of operands mismatch for ds' C:\Users\x\AppData\Local\Temp\cc3Lvn1N.s:474: Error: no such instruction: mrs %eax,primask' C:\Users\x\AppData\Local\Temp\cc3Lvn1N.s:504: Error: no such instruction: cpsid i' C:\Users\x\AppData\Local\Temp\cc3Lvn1N.s:577: Error: no such instruction: `msr primask,%eax'

but I could not find "mrs %eax, primask" or "msr primask, %eax" instructions in my source code. It worth noting that this error appeares when i move test project files to a folder one level deeper.

wasder1234 avatar Aug 27 '22 12:08 wasder1234

I still think you guys are compiling the ARM code (or whatever target) with x86_64 compiler and running it on your PC? That is why it is logical that it does not recognize the instructions. You include a source file which uses some assembly file which is target specific and not x86_64.

Letme avatar Aug 28 '22 11:08 Letme

Here is the way I found how to deal with this error in my case

in .yml file add __asm definition

:defines: in order to add common defines: 1) remove the trailing [] from the :common: section 2) add entries to the :common: section (e.g. :test: has TEST defined) :commmon: &common_defines #[] - __asm

And it will show files with assembly related errors. Then I just substitute this files with __asm (bla bla bla...) lines removed.

wasder1234 avatar Aug 28 '22 12:08 wasder1234

So you are basically omitting the assembly code (designed to do something)? Does it work? It is a potential hack, but I would rather follow the suggested path of amending library code or running on a simulator (if possible).

Letme avatar Aug 28 '22 13:08 Letme