Author Topic: ASM & CodeBlock  (Read 16232 times)

elvisdukaj

  • Guest
ASM & CodeBlock
« 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
   }
}

Offline JGM

  • Lives here!
  • ****
  • Posts: 518
  • Got to practice :)
Re: ASM & CodeBlock
« Reply #1 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

Good enough for getting started...

Offline byo

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 837
Re: ASM & CodeBlock
« Reply #2 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