assembly with clion

Answered

Hello,

I'm new with assembly x86_64 (in combination with c / c++) and would like to learn it.

I can not find how to setup assembly with clion for linux. Or should I use an other tool for it?

Is there any documentation how to setup clion for to assembly?

regards

Franz

0
10 comments

Hello!

We don't have any CLion documentation about that, unfortunately. On the Internet I found https://www.eagle44.io/blog/how-to-configure-an-ide-for-x86-nasm-on-linux/, maybe it will help.

0

would be very good, especially for schools.

we do teach asm. 

and asm inline would be a comptetive advange upon MS Visual studio

 

0

Gian Enrico Conti, what asm-related features would you like to see in CLion? 

For example, CLion provides syntax highlighting for AT&T assembly code - https://www.jetbrains.com/help/clion/disassembly-view.html#highlight-asm. Also, it's possible to debug the assembly code in CLion.

0

we corrently teach ASM for intel, in intel format.

my collegues uses msvc so the can write;

 

 
int main()
{
    _asm{

        mov eax,22

   }
}

 

2 notes:

1) this is msvc, woudl be nice to have in CLION ;)

2) I wouidl like to write also mov rax, 2222, MSVC cant! clion wll have a comptetive advantge!

0

I dint know If You know about 64 bits assembly, but i think so! ;)

 

0

super absurd: on XCode (after setting intel x64 target..) I can write and RUN:

 

 

#include <stdio.h>

 

int main(int argc, const char * argv[]) {

    int a = 0;

    size_t l = sizeof(a);

    asm{

        mov rax,3

        mov a,rax

    }

    printf("%d\n", a);

    return 0;

}


 

0

my collegues uses msvc so the can write;

int main()
{
    _asm{

        mov eax,22

   }
}

Gian Enrico Conti , could you please clarify if you face any issues with __asm{} code in CLion?

Here is the same code sample in CLion 2025.2.2 on Windows with the MSVC toolchain:

0

writing asm is not supported.

using:  __asm{…

 

 

====================[ Build | untitled1 | Debug ]===============================
"C:\Users\g.conti\AppData\Local\Programs\CLion 2025.2.1\bin\cmake\win\x64\bin\cmake.exe" --build C:\Users\g.conti\CLionProjects\untitled1\cmake-build-debug --target untitled1 -j 10
[1/2] Building C object CMakeFiles\untitled1.dir\main.c.obj
FAILED: CMakeFiles/untitled1.dir/main.c.obj 
C:\PROGRA~1\MICROS~2\2022\ENTERP~1\VC\Tools\MSVC\1441~1.341\bin\Hostx64\x64\cl.exe  /nologo   /DWIN32 /D_WINDOWS /Ob0 /Od -std:c11 -MDd -RTC1 -Zi /showIncludes /FoCMakeFiles\untitled1.dir\main.c.obj /FdCMakeFiles\untitled1.dir\ /FS -c C:\Users\g.conti\CLionProjects\untitled1\main.c
C:\Users\g.conti\CLionProjects\untitled1\main.c(4): error C4235: nonstandard extension used: '__asm' keyword not supported on this architecture
C:\Users\g.conti\CLionProjects\untitled1\main.c(5): error C2065: 'mov': undeclared identifier
C:\Users\g.conti\CLionProjects\untitled1\main.c(5): error C2146: syntax error: missing ';' before identifier 'eax'
C:\Users\g.conti\CLionProjects\untitled1\main.c(5): error C2065: 'eax': undeclared identifier
C:\Users\g.conti\CLionProjects\untitled1\main.c(6): error C2143: syntax error: missing ';' before '}'
ninja: build stopped: subcommand failed.
 

 

0

you are using 32 bit arch.

0

Gian Enrico Conti, yes, I set the architecture of my MSVC toolchain to x86 because the MSVC compiler doesn't support __asm{} for x64 - https://learn.microsoft.com/en-us/cpp/assembler/inline/inline-assembler:

Inline assembly is not supported on the ARM and x64 processors

The '__asm' keyword not supported on this architecture compiler message that you got illustrates the same point. 

However, this is a limitation of the MSVC compiler; CLion can't do anything about it. CLion delegates the building process to the selected build tool and compilers. So, the outcome of the building process is the same as if you were building the project outside CLion (with the same build tool and compilers).

As another example, here is the code that compiles with the bundled MinGW toolchain:

0

Please sign in to leave a comment.