Search code examples
c++gccinline-assembly

How to convert inline assembly in msbuild to gcc


My code which uses inline assembly is executes complatly in visual studio 2019.

I want to execute this code in GCC enviroment. But, I don`t have any idea to do

How can I do that?

this is my code

int a, b;
cin >> a >> b;
__asm {
    cmp b, 30;
    jl bunder30;
    jge bup30;

bunder30 :
    add a, - 1;
    add b, 60;
bup30 :
    add b, - 30;
    
    cmp a, 0;
    jge endPtr;
    add a, 24;

    endPtr :
}

Solution

  • Inline assembler is standardized in C++, so try to follow the C++ standard (see this) instead of using non-standard extensions. That is, use this syntax:

    asm ( string_literal ) ;

    GCC-Inline-Assembly-HOWTO for details and alternative (non-standard) ways.