Page 1 of 1

GCC Inline Assembler??

Posted: Wed May 21, 2003 5:01 am
by Wacky
Hi, i want to write the following code in the Inline Assembler of GCC (It's from a borland-code)

Code: Select all

int getch(void)
{
   int puffer;

   asm   {
         mov ah, 00h
         int 16h
         mov puffer, al
      }

   return puffer;
}
But i don't understand the Inline function for inline-assembler in GCC :'( !

Is any application out there, with that i can convert an assembler code from Borland into inline-assembler for GCC??

i can't follow the GCC-Manual in this part, maybe one of yours can!...

thx and greets Wacky

Re:GCC Inline Assembler??

Posted: Wed May 21, 2003 6:55 am
by Pype.Clicker
try info gcc (C-extension -> extend asm) for a generic description of GCC inline assembly. you also have
http://www.delorie.com/djgpp/v2faq/faq17_2.html
and http://www-2.cs.cmu.edu/afs/cs/academic ... -notes.txt that are very valuable information sources ... (both came from a google search on "AT&T" "Intel" and "conversion" keywords

it should look like

Code: Select all

asm volatile("mov $0,%ax ; int $0x16; mov %al,%1":"=g"(puffer));
however, remember GCC is a 32-bits compiler and thus you're unlikely to be able to call BIOS to get a character if you can run GCC code ... except if you have a magic environment helping you :p

Re:GCC Inline Assembler??

Posted: Wed May 21, 2003 7:27 am
by Wacky
Right, i toyed a little bit with this function in my kernel (i used a nice app to convert my old asm-code to gcc code!!) and on every interrupt --> restard.

I think i should use another method for the getch() funktion.. hmmm :-\

thanks anyway.. Wacky

Re:GCC Inline Assembler??

Posted: Wed May 21, 2003 8:21 am
by Pype.Clicker
there's nothing like bios calls once your in pmode. calling INT 16 will result in nothing good and will reset your CPU until you load a proper Interrupt Descriptor Table with a custom descriptor for INT16 or a good handler for GPF (as missing interrupts raise a GPF, iirc)

You can read the keyboard events through port 0x60 every time IRQ1 is raised. See for an example of how it could be done

There may be valuable tutorialz in http://osdev.neopages.net/docs.php aswell ...