Code::Blocks Forums

User forums => General (but related to Code::Blocks) => Topic started by: elvisdukaj on June 30, 2007, 07:39:13 pm

Title: ASM & CodeBlock
Post by: 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
   }
}
Title: Re: ASM & CodeBlock
Post by: JGM on June 30, 2007, 08:04:34 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:
Code
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 (http://www.ibiblio.org/gferg/ldp/GCC-Inline-Assembly-HOWTO.html)

Good enough for getting started...
Title: Re: ASM & CodeBlock
Post by: byo on June 30, 2007, 10:45:15 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