News:

The new Release 25.03 is out! You can download binaries for Windows and many major Linux distros here .

Main Menu

ASM & CodeBlock

Started by elvisdukaj, June 30, 2007, 07:39:13 PM

Previous topic - Next topic

elvisdukaj

How can I use asm inline in CodeBlock with GNU GCC Compiler? Why I can't do:

void SetGraphMode(char mode) {
   _asm {
      mov al, mode
      mov ah, 0x0
      int 0x10
   }
}

JGM

Quote from: elvisdukaj on June 30, 2007, 07:39:13 PM
How can I use asm inline in CodeBlock with GNU GCC Compiler? Why I can't do:

void SetGraphMode(char mode) {
   _asm {
      mov al, mode
      mov ah, 0x0
      int 0x10
   }
}

Well with the GCC compiler using c++ an example will be the following:

int function(){
  asm("movl $0, %eax\n\t");
}


The assembly syntax utilized on GCC is the AT&T asm. Here is a nice page with good info: http://www.ibiblio.org/gferg/ldp/GCC-Inline-Assembly-HOWTO.html

Good enough for getting started...

byo

Quote from: elvisdukaj on June 30, 2007, 07:39:13 PM
How can I use asm inline in CodeBlock with GNU GCC Compiler? Why I can't do:

void SetGraphMode(char mode) {
   _asm {
      mov al, mode
      mov ah, 0x0
      int 0x10
   }
}

One note: this code won't work when you use standard GCC or MinGW. It should change video mode but when it's called from DOS executable. When you create standard console application it's actually Win exe.

BYO