Using ASM (x86) with Qt on MacOS with CMake. How?
-
Hello all!
Trying to find any examples of how to setup using ASM (x86) in Qt project with CMake. Is there any manuals or examples?
For now trying to run this examples https://firexfly.com/clang-inline-assembly/
Have this kind of errors:
error: unknown register name '%eax' in asm
or
error: unrecognized instruction mnemonic, did you mean: fmov, mov, movi, movk, movn, movz, smov, umov?
What is missing by me?
-
Hello all!
Trying to find any examples of how to setup using ASM (x86) in Qt project with CMake. Is there any manuals or examples?
For now trying to run this examples https://firexfly.com/clang-inline-assembly/
Have this kind of errors:
error: unknown register name '%eax' in asm
or
error: unrecognized instruction mnemonic, did you mean: fmov, mov, movi, movk, movn, movz, smov, umov?
What is missing by me?
@bogong said in Using ASM (x86) with Qt on MacOS with CMake. How?:
What is missing by me?
That the error messages imply that you try to use x86 assembly but your compilation is targeting arm64 (hence the assembler's complaints about the
eax
register not existing; and you getting offered ARM mnemonics likemovz
, probably in response to you trying to use themovl
mnemonic which is x86 only).- Make sure you target only x86_64 in your build (in CMake, you have
CMAKE_OSX_ARCHITECTURES
). - Or if you want to target ARM, you need to use ARM assembly code which is completely different to x86 assembly.
- If you are building universal binaries, then you need to write a different version of the inline assembly block for each architecture, and direct to the correct one with preprocessor macros.
May I ask why you think you need inline assembly? There is quite possibly an easier approach.
- Make sure you target only x86_64 in your build (in CMake, you have
-
@bogong said in Using ASM (x86) with Qt on MacOS with CMake. How?:
What is missing by me?
That the error messages imply that you try to use x86 assembly but your compilation is targeting arm64 (hence the assembler's complaints about the
eax
register not existing; and you getting offered ARM mnemonics likemovz
, probably in response to you trying to use themovl
mnemonic which is x86 only).- Make sure you target only x86_64 in your build (in CMake, you have
CMAKE_OSX_ARCHITECTURES
). - Or if you want to target ARM, you need to use ARM assembly code which is completely different to x86 assembly.
- If you are building universal binaries, then you need to write a different version of the inline assembly block for each architecture, and direct to the correct one with preprocessor macros.
May I ask why you think you need inline assembly? There is quite possibly an easier approach.
@IgKh Just trying to learn it for myself. Need to know and understand how it works on low-level. My life-path is moving me to the low-level applications development from developing 'just-UI'. Always trying to learn something. Need to know how-it-works on the level of electricity.
- Make sure you target only x86_64 in your build (in CMake, you have
-
@IgKh Just trying to learn it for myself. Need to know and understand how it works on low-level. My life-path is moving me to the low-level applications development from developing 'just-UI'. Always trying to learn something. Need to know how-it-works on the level of electricity.
@bogong That's a very commendable goal. If your purpose is just to learn low-level programming principles, I'd suggest you to actually not start with x86 assembly. The CISC micro-architecture of Intel and AMD processors is hugely complex after decades of evolution while remaining backwards compatible all the way to the original 8086. It leads to the assembly language having all kinds of strange and arbitrary limitation, which you probably don't want to lose sanity on for just learning the principles.
ARM assembly may be smoother, or actually - you can play around with assembly for one of the PDP-derived architectures (VAX, m68k, ...) with an emulator. They are straightforward to program for (my university's computing fundamentals course was taught with PDP-11 assembly language... and I'm not that old).
Also, in case you don't know about the NAND-to-Tetris course, I warmly recommend taking it to learn about computing down to the logic gate level.