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. Assembly from DOS to QT
Forum Updated to NodeBB v4.3 + New Features

Assembly from DOS to QT

Scheduled Pinned Locked Moved General and Desktop
22 Posts 7 Posters 14.3k Views 1 Watching
  • 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.
  • T Offline
    T Offline
    Taamalus
    wrote on last edited by
    #1

    I have some old code, for a game utility written in Assembly. The code compiles in Watcom 11. I'm out of luck compiling it in QT Creator. I looked through tutorials, books and what not. How does one approach to convert the below to something Creator can process?

    @#pragma aux scale =
    "imul ebx",
    "idiv ecx",
    parm [eax][ebx][ecx]
    modify [eax edx]\

    #pragma aux mulscale =
    "imul ebx",
    "shrd eax, edx, cl",
    parm [eax][ebx][ecx]
    modify [edx]@

    I forgot - the above is WASM - used to be the best way to program in 1994 :)

    ... time waits for no one. - Henry

    1 Reply Last reply
    0
    • V Offline
      V Offline
      vcsala
      wrote on last edited by
      #2

      Please remember it's Qt and not QT (QuickTime).

      1 Reply Last reply
      0
      • X Offline
        X Offline
        xsacha
        wrote on last edited by
        #3

        This has nothing to do with Qt\QtCreator as far as I can tell.

        Qt is just C++. Your compiler handles the C++ and assembly.
        If your compiler handles WASM, it'll work. Most likely it'll need to be converted to AT&T or Intel style assembly depending on compiler.

        Which compiler are you using in QtCreator?
        In MSVC you just use:
        @__asm {
        ...
        }@

        • Sacha
        1 Reply Last reply
        0
        • G Offline
          G Offline
          giesbert
          wrote on last edited by
          #4

          If you have the "default" Qt SDK for windows, you are using gcc. One of many description how to do inline assembler in gcc can be found "here":http://www.ibiblio.org/gferg/ldp/GCC-Inline-Assembly-HOWTO.html

          Nokia Certified Qt Specialist.
          Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

          1 Reply Last reply
          0
          • T Offline
            T Offline
            Taamalus
            wrote on last edited by
            #5

            Thanks for all your responses. :D

            to Vcsala – It's QT Creator not QT SDK nor Quicktime.

            to xsacha – that's the first thing I tried before I posted. Creator seems to want something more.

            to Gerolf Reinwardt - The compiler that ships with QT-Creator is MingW. WASM is part of the (Intell) x86 – Windows, DOS family, and MingW/GCC expects Unix? Would you know of hand a web site or book that defines the core differences? The link is helpful, but it assumes I know the differences, right now I do not. :(

            ... time waits for no one. - Henry

            1 Reply Last reply
            0
            • V Offline
              V Offline
              vcsala
              wrote on last edited by
              #6

              Actually it is Qt Creator...

              1 Reply Last reply
              0
              • T Offline
                T Offline
                Taamalus
                wrote on last edited by
                #7

                Thank you Vcsala :)

                For all others: The topic has how now drastically changed. I need to figure out how to implement WASM, an Intel's x86 assembly language, into Qt Creator.

                ... time waits for no one. - Henry

                1 Reply Last reply
                0
                • F Offline
                  F Offline
                  Franzk
                  wrote on last edited by
                  #8

                  [quote author="Taamalus" date="1292694059"]to Vcsala – It's QT Creator not QT SDK nor Quicktime.[/quote]Vcsala was referring to the fact that Qt is spelled with capital Q and small t. That goes for both creator and the sdk. QuickTime is spelled with capital QT. But hey, it's off-topic.

                  On-topic: Inline assembly is always dependent on environment, target processor and compiler. Chances are that if you're porting 15 year old code, there is no good reason to stick to the assembly implementation and just use C++ code instead. It's much more portable and the difference in performance will pass by unnoticed -- both because the systems are much faster now, and because your average compiler has become much more effective at optimization.

                  "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

                  http://www.catb.org/~esr/faqs/smart-questions.html

                  1 Reply Last reply
                  0
                  • G Offline
                    G Offline
                    giesbert
                    wrote on last edited by
                    #9

                    bq. Taamalus wrote
                    The compiler that ships with QT-Creator is MingW. WASM is part of the (Intell) x86 – Windows, DOS family, and MingW/GCC expects Unix? Would you know of hand a web site or book that defines the core differences? The link is helpful, but it assumes I know the differences, right now I do not. :(

                    The compiler is not platform dependant. How inline assembler works always depends on the compiler.

                    • So MinGW/gcc which is default on linux, "uses this definition":http://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html.
                    • WASM is used for Watcom compilers.
                    • MSVC "uses this syntax":http://msdn.microsoft.com/en-us/library/5f7adz6y(v=vs.80).aspx

                    So you see, inline assembler is not standardised. What is standard is the commands, that exist, but the order of the parameters, how you inle the assembler, how you access the parameters, you put from C/C++ to assembler and vice versa is totally different. I already did inline assembler on a multi platform project that uses MSVC for windows and gcc for linux embedded. It was really challenging as you had to write the assembler totally twice and different.

                    Nokia Certified Qt Specialist.
                    Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                    1 Reply Last reply
                    0
                    • G Offline
                      G Offline
                      giesbert
                      wrote on last edited by
                      #10

                      By the way. the command you can use in the assebler code depend on the processor platform you use (X86, x386, sparc, ...). So the assebmler commands depend on that. But mostly on common linux and windows machines, you wil find x386 architecture.

                      Nokia Certified Qt Specialist.
                      Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                      1 Reply Last reply
                      0
                      • G Offline
                        G Offline
                        goetz
                        wrote on last edited by
                        #11

                        [quote author="Taamalus" date="1292697516"]For all others: The topic has how now drastically changed. I need to figure out how to implement WASM, an Intel's x86 assembly language, into Qt Creator.[/quote]

                        That's not a matter of Qt Creator, as it is only an IDE that integrates an editor, compiler, linker, debugger and some other tools into a nice graphical user interface.

                        Assembler code is highly dependend on your platform (i386, x86_64, ppc, ppc64, etc.) and the compiler/tool chain (gcc, MS Visual Studio toolchain, intel, etc.).

                        You should search on the web for the details of your specific combination of the above. Maybe there are some hints on how to port from one tool chain to another.

                        http://www.catb.org/~esr/faqs/smart-questions.html

                        1 Reply Last reply
                        0
                        • T Offline
                          T Offline
                          Taamalus
                          wrote on last edited by
                          #12

                          To Gerolf Reinwardt – Those links were an eye opener. This is anything but simple to use.

                          To Volker – Great. :( Since Qt Creator is cross-platform it can't adapt an Assembly Version.

                          To Franzk – You are now the second person to suggest to look seriously into rewriting the code into straight C++. You would not know a good book to read? I have three about Assembly (ancient), none of which even mention C or C++. - Yes, we are off topic. PM me if this is more appropriate.

                          ... time waits for no one. - Henry

                          1 Reply Last reply
                          0
                          • V Offline
                            V Offline
                            vsorokin
                            wrote on last edited by
                            #13

                            Taamalus, see books about C++ and Qt on "this wiki page":http://developer.qt.nokia.com/wiki/Books_and_Links_for_learning_C_and_advanced_topics.

                            --
                            Vasiliy

                            1 Reply Last reply
                            0
                            • X Offline
                              X Offline
                              xsacha
                              wrote on last edited by
                              #14

                              [quote author="Taamalus" date="1292716462"]To Volker – Great. :( Since Qt Creator is cross-platform it can't adapt an Assembly Version.
                              [/quote]

                              Look, this has nothing to do with Qt or Qt Creator.

                              If you want to target a single platform, continue using your Assembly code in the compiler that supports it. If the compiler supports C++, you can use Qt too.
                              Just because Qt is cross-platform doesn't mean you need to use cross-platform code.

                              It works the same as if you were using plain C++.

                              WASM isn't supported by any mainstream compiler so if you want to continue using it and don't care about being cross-platform, just convert it to what your compiler uses.
                              The default is MingW/GCC with QtCreator.

                              Any assembly code you can do within C++ in any other mainstream IDE, you can do in Qt with QtCreator.

                              • Sacha
                              1 Reply Last reply
                              0
                              • G Offline
                                G Offline
                                goetz
                                wrote on last edited by
                                #15

                                [quote author="Taamalus" date="1292716462"]To Volker – Great. :( Since Qt Creator is cross-platform it can't adapt an Assembly Version.[/quote]
                                Qt Creator is neither the compiler nor an assembler. It works on what the underlying tool chain provides. This is gcc/g++/ld in the gnu/linux/mac world, it's the Visual Studio tool chain its the Microsoft compiler, with MinGW on Windows it's again gcc. Each of them may have another syntax for assembly language. Each of them works on different platforms (read: processor families like Intel x86 and siblings, PowerPC, ARM, and so on). You would have the very same problems with the native development environments. Qt libs and Qt creator cannot help you in this domain, which is logical programming a CPU by assembly language is by its nature very platform dependent.

                                [quote author="Taamalus" date="1292716462"]To Franzk – You are now the second person to suggest to look seriously into rewriting the code into straight C++. You would not know a good book to read? I have three about Assembly (ancient), none of which even mention C or C++. - Yes, we are off topic. PM me if this is more appropriate.[/quote]

                                You must understand the old code. What does it do? What's the flow of control, the data structures? etc. Then you should be able to reimplement this in plain C or C++. I don't know of any special book about this topic. We do have a wiki page on C++ books "here":http://developer.qt.nokia.com/wiki/Books_and_Links_for_learning_C_and_advanced_topics. Books about assembly language do seldom cover the links to "higher" programming languages.

                                http://www.catb.org/~esr/faqs/smart-questions.html

                                1 Reply Last reply
                                0
                                • T Offline
                                  T Offline
                                  Taamalus
                                  wrote on last edited by
                                  #16

                                  [quote author="Volker" date="1292717715"][quote author="Taamalus" date="1292716462"]To Volker – Great. :( Since Qt Creator is cross-platform it can't adapt an Assembly Version.[/quote] Qt Creator is neither the compiler nor an assembler. It works on what the underlying tool chain provides. This is gcc/g++/ld in the gnu/linux/mac world, it's the Visual Studio tool chain its the Microsoft compiler, with MinGW on Windows it's again gcc. Each of them may have another syntax for assembly language. Each of them works on different platforms (read: processor families like Intel x86 and siblings, PowerPC, ARM, and so on). You would have the very same problems with the native development environments. Qt libs and Qt creator cannot help you in this domain, which is logical programming a CPU by assembly language is by its nature very platform dependent.

                                  You must understand the old code. What does it do? What's the flow of control, the data structures? etc. Then you should be able to reimplement this in plain C or C++. I don't know of any special book about this topic. We do have a wiki page on C++ books "here":http://developer.qt.nokia.com/wiki/Books_and_Links_for_learning_C_and_advanced_topics. Books about assembly language do seldom cover the links to "higher" programming languages.[/quote]
                                  That was not an complained about Qt Creator but one about Assembly. Until I posted my question and received the forum's feed back I never realized how diverse Assembly is. I assumed a low level language would come more standard.

                                  That also cancels my second question for a book. Unless someone converted WASM code into C++ and wrote a book about it, there wont be any books available for me to use. - Therefore I'll do as you suggest! This is anything but simple. :D

                                  ... time waits for no one. - Henry

                                  1 Reply Last reply
                                  0
                                  • X Offline
                                    X Offline
                                    xsacha
                                    wrote on last edited by
                                    #17

                                    Well it's actually the opposite. The lower level the language is, the less platforms and architectures it generally covers.

                                    Higher-level interpreted languages like scripts and interpreted languages run on pretty much anything (think javascript, html, python).

                                    Qt is sort of special because it is C++ which isn't as high-level (it's closer to assembly) and yet, it is cross-platform (many operating systems and architectures are supported).

                                    Assembly is pretty much machine code (1:1 map) for individual architectures and compilers (which generally differ dependent on platform) generally choose different syntax.

                                    It works this way because, as you add layers of syntax and language the idea is to make it simpler to program in. In doing so, you usually add a type of method that performs several lower level types and methods in a way that is consistent through many platforms and architectures.

                                    • Sacha
                                    1 Reply Last reply
                                    0
                                    • V Offline
                                      V Offline
                                      vcsala
                                      wrote on last edited by
                                      #18

                                      [quote author="Taamalus" date="1292725209"]Unless someone converted WASM code into C++[/quote]

                                      More than 15 years ago I remember there was a tool doing this kind of reverse engineering (at least for C), but as I remember the resulting code was rather unreadable.

                                      1 Reply Last reply
                                      0
                                      • G Offline
                                        G Offline
                                        goetz
                                        wrote on last edited by
                                        #19

                                        [quote author="Taamalus" date="1292725209"]That was not an complained about Qt Creator but one about Assembly. Until I posted my question and received the forum's feed back I never realized how diverse Assembly is. I assumed a low level language would come more standard.[/quote]

                                        Ah, sorry. I misunderstood this. I cannot imagine anything other that is more platform dependend than assembly code :-) It is the lowest end of programming, since you directly manipulate the processor, i.e. load/save registers, ask the processor to do some math, etc. All that depends on the processor itself: how many registers are there, is it a "RISC":http://en.wikipedia.org/wiki/Reduced_instruction_set_computing or "CISC":http://en.wikipedia.org/wiki/Complex_instruction_set_computer architecture, and so on. Regarding this nature of assembly language, it's clear, that it's quite impossible to standardize this :-)

                                        [quote author="Taamalus" date="1292725209"]That also cancels my second question for a book. Unless someone converted WASM code into C++ and wrote a book about it, there wont be any books available for me to use. - Therefore I'll do as you suggest! This is anything but simple. :D[/quote]

                                        This task (writing a book) would be quit impossible. Assembler code mostly used to do some time critical tasks and is often hand optimized. One has to reverse-engineer the code and understand what it does, to back-translate it into a higher level language like C or C++.

                                        http://www.catb.org/~esr/faqs/smart-questions.html

                                        1 Reply Last reply
                                        0
                                        • F Offline
                                          F Offline
                                          Franzk
                                          wrote on last edited by
                                          #20

                                          [quote author="Taamalus" date="1292716462"]You are now the second person to suggest to look seriously into rewriting the code into straight C++.[/quote]It only makes sense. It will improve maintainability and readability. It'll just cost you the extra time of translating (I understand it's fully written in assembly?).

                                          [quote author="Taamalus" date="1292716462"]You would not know a good book to read? I have three about Assembly (ancient), none of which even mention C or C++.[/quote] A book about converting asm to c/c++? I wouldn't know of any. Besides, I don't think I'd want one. You have to actually reverse engineer the thing. Find out what the assembly does and rewrite it. It'll be worth the effort in the end if you're going to maintain that project.

                                          "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

                                          http://www.catb.org/~esr/faqs/smart-questions.html

                                          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