www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/05/13/00:03:43

From: qballlives AT aol DOT com (QBallLives)
Newsgroups: comp.os.msdos.djgpp
Subject: RE:INLINE ASM IN DJGPP
Lines: 53
Message-ID: <1998051223031100.TAA20195@ladder03.news.aol.com>
NNTP-Posting-Host: ladder03.news.aol.com
Date: 12 May 1998 23:03:10 GMT
Organization: AOL http://www.aol.com
References: <199805121725 DOT NAA15818 AT acmez DOT gatech DOT edu>
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

>DJGPP uses AT&T syntax. For more info on assembly programming go to the
>DJGPP main page(www.delorie.com). There is also another option of using
>NASM assembler with DJGPP.
><

You can also generate interrupts with c callable functions, and you can do OUTS
with outportb (I think outportw too...)

I don't know quite that much about converting inline asm to djgpp's syntax...
but I do know some things.... the order of operands is reversed...

..also, "immediate" operands have a $ in front of them...

you precede register operands with a % symbol... and the letter after the
instruction tells the SIZE of the move or assignment....

I was just looking for a good example but... well here goes....

mov ax, 0x03

is something like

movw $0x03, %ax

Here's some code that does nothing in particular.... it's inline assembly
though.... the __volatile__ keyword, I believe, tells GAS (djgpps assembler)
not to mess with the code and change things around...

notice the \n\t after each line of code.... I've seen code without it... but
this is the way I do it....


     __asm__ __volatile__(

     "movl $99,%ebx\n\t"
     "shll $8,%ebx\n\t"
     "movl %ebx,%eax\n\t"
     "shrl $2,%ebx\n\t"

        );

There are many faqs out there... but one you may want to look at is the one in
the DJGPP section of the game programming megasite:

http://www.perplexed.com/GPMega/

Good luck!


Jim the loiterer
aloiterer AT juno DOT com
http://members.xoom.com/JimMcCue/index.htm
(Jim the loiterer's PC games, programming, & stuff...)

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019