Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Using ASM (x86) with Qt on MacOS with CMake. How?
Forum Updated to NodeBB v4.3 + New Features

Using ASM (x86) with Qt on MacOS with CMake. How?

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 140 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    bogong
    wrote last edited by bogong
    #1

    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?

    I 1 Reply Last reply
    0
    • B bogong

      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?

      I Offline
      I Offline
      IgKh
      wrote last edited by
      #2

      @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 like movz, probably in response to you trying to use the movl 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.

      B 1 Reply Last reply
      3
      • I IgKh

        @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 like movz, probably in response to you trying to use the movl 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.

        B Offline
        B Offline
        bogong
        wrote last edited by
        #3

        @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.

        I 1 Reply Last reply
        0
        • B bogong

          @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.

          I Offline
          I Offline
          IgKh
          wrote last edited by
          #4

          @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.

          1 Reply Last reply
          0
          • JonBJ Online
            JonBJ Online
            JonB
            wrote last edited by JonB
            #5

            6502 assembly, simple, elegant :) Bit limited on memory though...

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved