(1) I’m getting CMake assembler errors such as:
(2) Question: What can I do within the CMake file to correct these errors? My assembly code (in file testing.s) looks something like the following code. I’ve removed a lot of it and am trying to be concise.
#define _ASMLANGUAGE
#include “vxWorks.h”
#include <ash.h>
FUNC_EXPORT(testing)
.text
.align 2
.long 0
.long 1
.globl testing
FUNC_BEGIN(testing)
li r3, 1
ori r4, r4, 0x6789
srw r4, r4, r5
FUNC_END(testing)
(3) My CMakeLists.txt looks something like:
cmake_minimum_required (VERSION 2.6)
project(testing LANGUAGES CXX ASM)
set(CMAKE_CXX_FLAGS “${CMAKE_CXX_FLAGS} -Wall -g -std=c++0x -Wextra -Wpedantic”)
set(dir3 …/…/…/util/dir3)
add_executable(testing
${dir3}/one.cpp
${dir3}/testing.s
)
(4) File one.cpp looks something like —
extern “C” int testing(void); //… testing(); //…
Mike001 said:What can I do within the CMake file to correct these errors?
Surely, those are errors from the assembler - nothing to do with CMAKE ?
...
Should I change the assembler being used? How do I do this with CMake? Where can I get the assembler? How do I install it? What do I do to use the new assembler?
(1)If I test with inline assembly code, I get assembler errors such as: Assembler messages: Error: unrecognized opcode: `movl' Error: unrecognized opcode: `movl' Error: unrecognized opcode: `addl' Error: unsupported relocation against r3 (2) Question: What can I do about these errors by using a different assembler with CMake? My inline assembly code is the following. __asm__ ( "movl $10, %eax;" "movl $20, %ebx;" "addl %ebx, %eax;" "li r3, 1" ); (4) If I put this assembly code in a separate file with a suffix "s" (testing.s) and add: extern "C" int testingt(void); to that same C++ file instead of using the inline assembly code, I get the same error messages plus "func_export", "func_begin" and "func_end" are also flagged as unrecognized opcodes. #define _ASMLANGUAGE func_export(testing) .text .align 2 .long 0 .long 1 .globl testing func_begin(testing) movl $10, %eax; movl $20, %ebx; addl %ebx, %eax; li r3, 1 func_end(testing)
Mike001 said:Should I change the assembler being used?
As we have no idea what assembler you are currently using, there's no way to tell if changing it would help!
Of course, you have to use the correct assembler for the source files you are using - but you have checked that, right?
I'm on Linux and using GNU C++11 (version 8.2.0) and GNU assembler version 2.31.1. I obtained this information using the "-v" compiler option.
So are your assembly source files written for that assembler?
That's the question that needs to be answered.
I inherited the code. The code should most likely work. If it's a compiler problem then I can address that. But, no one on my end will immediately want to accept the fact that it's a compiler problem. They will insist that the code worked in the past and should work now.
You've got the code - so you need to establish what is the correct assembler for it.
Mike001 said:They will insist that the code worked in the past
This has nothing to do with whether the code works or not - this is about having the correct tools to build it with!
Can they not tell you how it was built in the past?
It's all going to work out.
Thanks,
Hi Mike,
That's x86 assembly not Arm or AArch64 so GCC for any Arm tooling won't accept it.
You will need to get yourself an x86 toolchain.
Thank you for the information, you are correct.
Someone else gave me useful information.
I was given the following two links:
https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html
https://stackoverflow.com/questions/199966/how-do-you-use-gcc-to-generate-assembly-code-in-intel-syntax
So, I have to convert nonsense code similar to the following code from the "intel" dialect to the "att" dialect.
add r4, r4, r3
subi r3, r3, 2
cmplw r4, r5
bne GOIT
GOIT:
Question: Do you see any problems in converting these instructions to the "att" dialect?
Tamar Christina said:That's x86 assembly not Arm
Mike001 said:you are correct
So if it's not ARM, and you know it, why are you posting in the ARM forum?