hi everyone i create a simple program on dev++ but always a message error exist
ps: im a debutante :/ plz help !

#include<stdio.h>
#include <iostream>

int main ()
{int a,b;
    __asm__ __volatile__
("load a \n\t"
"cmp b \n\t"
"jb etq1 \n\t"
"jmp etq2 \n\t"
"etq1 load b \n\t"
"etq2 store res \n\t"
);
    printf(" %d %d",a,b);
    return 0;
}

The errors are due to the fact that this assembly code is not real assembly code. This is just a simplified syntax to teach the logic of it. The actual syntax is quite a bit more complicated.

Here is the AT&T syntax that is equivalent to your program ("AT&T" syntax is preferred in GCC (used by Dev-CPP), the "Intel" syntax is the alternative often used by other compilers):

int main ()
{
    int a = 10, b = 50, res;
    asm(
      "movl %1, %%eax; \
       cmp %2, %%eax; \
       jb etq1; \
       jmp etq2; \
       etq1: \
       movl %2, %%eax; \
       etq2: \
       movl %%eax, %0"
      : "=r"(res)
      : "r"(a), "r"(b)
    );
    printf(" %d %d %d\n",a,b,res);
    return 0;
}

If you want to do assembly, you should read this tutorial, you will find the explanations of the code I just posted on that page.

I tested the above code (I use Linux), and it works and behaves as expected, so I guess you should be able to compile and run it too.

BTW, here is a shorter version that does the same thing:

asm(
  "cmp %%ebx, %%eax; \
   ja etq1; \
   movl %%ebx, %%eax; \
   etq1:"
  : "=a"(res)
  : "a"(a), "b"(b)
);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.