Assembler messages: Error: no such instruction
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.
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?
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.
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.
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?
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?
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.
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?
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.
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 -- 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).
Have you been able to solve this @abergerSRS ? we are having the exact same issue...
Hello. Any updates ? I am having same issue. @tomh4 @abergerSRS
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).
It seems no one solve this problem until now.
Can you explain a bit what is not solved?
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.
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.
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.
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).