www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1995/09/25/14:36:07

Date: Mon, 25 Sep 1995 13:18:01 -0500 (CDT)
From: ALAN L HIGHTOWER <alh AT engr DOT engr DOT uark DOT edu>
To: Todd Muhlfelder <twm AT escape DOT com>
Cc: djgpp AT sun DOT soe DOT clarkson DOT edu
Subject: Re: ASM in DJGPP


On Mon, 25 Sep 1995, Todd Muhlfelder wrote:

> So, I tried to do this line in DJGPP (works fine in Turbo C++):
> 
> _AX = 0x0013 /* Gets into Mode 13H */

the equivalent would be:

     asm("  movw     $0x13, %ax  ");

gcc is a predominatly UNIX compiler and thus uses AT&T syntax assembler, 
completely backwards from Intel.  The most significant changes are 
dest,src opreands are src,dest.  Registers are prefixed with %, 
immediates are prefixed with $.  Addressing is usually done with () 
rather than [].  BYTE/WORD/DWORD PTRs don't exist, instead you suffix the 
op codes with b,w,l for 1,2,4 byte operations.  The 4 sign entending op 
codes have differnet names, and various other subtlties.  There is a sed 
script to do a lot of the conversion for existing code.  Email me if you 
want it and I'll send it privatly.

> and i got an error message.  How do I write this in DJGPP's ASM?  Please 
> help me out and tell me if there is a special way to do ASM in DJGPP.

> Plus, if anyone has time, please tell me how to do this DJGPP:
> 
> unsigned char *vga = (unsigned char *) MK_FP(0xA000, 0);

In DJGPP, you are running in 386 protected mode, which means several 
things.  Video memory typically isn't at offset 0xa0000, and never under 
DPMI at least under your default data selector.  Instead its in the low 
memory selector that can be obtained by reading the _go32_info_block.

Once you have the low memory selector number, you can use the macros in 
<sys/farptr.h> to access video memory at offset 0xa0000.  Last time I 
checked, I think the macros just loaded the selector entry into gs and 
referenced memory relative to gs:(offset).  Someone correct me if I'm 
wrong ;)

- Raw text -


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