GCC Inline Assembler??

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Wacky

GCC Inline Assembler??

Post 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
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:GCC Inline Assembler??

Post 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
Wacky

Re:GCC Inline Assembler??

Post 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
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:GCC Inline Assembler??

Post 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 ...
Post Reply