cvs.gedasymbols.org/archives/browse.cgi   search  
Mail Archives: djgpp/1999/08/01/22:00:36

From: DavMac AT iname DOT com (Davin McCall)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Intel - AT&T inline with DJGPP
Date: Mon, 02 Aug 1999 01:59:08 GMT
Organization: Monash Uni
Lines: 96
Distribution: world
Message-ID: <37a4f693.7358190@newsserver.cc.monash.edu.au>
References: <7o1psl$d46$1 AT news DOT iinet DOT net DOT au>
NNTP-Posting-Host: damcc5.halls.monash.edu.au
X-Trace: towncrier.cc.monash.edu.au 933559096 26710 130.194.198.138 (2 Aug 1999 01:58:16 GMT)
X-Complaints-To: abuse AT monash DOT edu DOT au
NNTP-Posting-Date: 2 Aug 1999 01:58:16 GMT
X-Newsreader: Forte Free Agent 1.1/32.230
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Oh dear.

The biggest problem you have is that the code you posted is written
for real mode programs. DJGPP executables run in 32-bit protected mode
using a DPMI host environment, which really screws around with the way
memory is accessed.

not having used inline assembly under DJGPP very often, I have done
some work with 32-bit assembly (AT&T syntax) and can offer the
following modifications as a minimum (I also suggest you thoroughly
read all the relevant sections of the DJGPP FAQ):

>void putpixel(int x, int y, char col)
>{
>  asm(
>   "mov $0xA000,%ax \r
>    mov %ax,%es \r

OxA000 is the real-mode segment address of the VGA video buffer. Under
protected mode, the buffer can no-longer be accessed at this address.
You several options, see section 10.2 of the FAQ.

>    mov y,%bx \r
>    mov %bx,%di \r
>    xchg %bl,%bh \r
>    shl $6,%di \r
>    add %bx,%di \r
>    add x,%di \r
>    mov col,%al \r
>    mov %al,%es[%di]"'''
>  );
>}

You're using 16-bit registers a lot. The difference between ax, bx, cx
etc and eax, ebx, ecx etc is the width in bits. The 'e' probably
stands for 'extended' and the 'e' registers are all 32-bits in width,
the regular registers of the same name forming the lower 16 bits. For
eg, eax is a 32-bit register (ax is its least significant half).

Under a 32-bit protected mode environment, it is generally faster to
use 32-bit instructions (ie, using 32-bit registers) than to use
16-bit instructions.


As further advice, I would recommend not jumping in so quickly. Using
a "putpixel" routine such as this, even though it is written in
assembly, is not going to be particularly fast - you need to optimize
the higher level routines such as the line-drawing etc.

If you *must* learn assembly and use it, start with 16-bit real mode
programs (using the tutorials you've got, if need be), get some
graphics routines going, then *thoroughly* read the FAQ and any other
info you can find about 32-bit instructions and protected mode
programming before trying to do any conversion. You can also take a
look at the source code for one of my own games, it is available from
my page:

http://yoyo.cc.monash.edu.au/~davmac/

(it includes some assembly routines, though they are not inline, to
perform graphics operations).

As an alternative, why not just use one of the graphics libraries
already available for DJGPP - Allegro is quite popular for games
programming, I believe there is a link from DJs site
(http://www.delorie.com).

Davin.



On Sun, 1 Aug 1999 23:41:45 +0800, "Centrozity"
<centrozity AT SPAMMENOT DOT tekkenking DOT com> wrote:

>My problem is simple, I currently have a set of mode 13h routines in C that
>I use with all the programs( mostly poor quality and extremely small games )
>that I write.  One of my more recent projects had a rather choppy framerate,
>so I optimised all my C code, including my 13h routines, but it didn't do
>much good, I have never gotten into assembly too well but now it is looking
>like my only way around this bottleneck.
>
>The asm tutorials I found were all Intel format, and so with the help of an
>additional Intel - AT&T FAQ I attempted to convert the asm routines into
>inline(is that the correct term for when the asm is in the c file?) AT&T
>ones that would compile with DJGPP.
>
>Since I really have no idea what I'm doing to these functions, I decided
>it's time to ask for help.  The error I'm getting is 'Base/Index register
>must be 32bit".

[snipped rest]


__________________________________________________________
       *** davmac - sharkin'!! davmac AT iname DOT com ***
my programming page: http://yoyo.cc.monash.edu.au/~davmac/

- Raw text -


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