www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1995/08/16/16:11:33

Date: Wed, 16 Aug 95 13:35 MDT
From: mat AT ardi DOT com (Mat Hostetter)
To: kore AT eurpd DOT csg DOT mot DOT com
Cc: djgpp AT sun DOT soe DOT clarkson DOT edu
Subject: Re: Quick inline assembly code problems/questions...
Newsgroups: comp.os.msdos.djgpp
References: <1995Aug16 DOT 133905 DOT 1844 AT schbbs DOT mot DOT com>

>>>>> "Ken" == Ken Ore <kore AT kali-e DOT eurpd DOT csg DOT mot DOT com> writes:

    Ken>    asm("
    Ken>	push %ds
    Ken>	les  (_video_buffer), %edi
    Ken>	ldsw (_double_buffer), %esi
    Ken>	movw 320*200/2, %cx
    Ken>	rep; movsw
    Ken>	pop  %ds
    Ken>  	");	

    Ken> The Borland45 inline works(with Borland 4.5 obviously).  The
    Ken> DJ version compiles, links, and runs and stuff but coughs
    Ken> when it hits the inline and pukes out the registers and
    Ken> stuff.  Anyone have a clue?  Please post or
    Ken> email(kore AT eurpd DOT csg DOT mot DOT com), email preferred.  Thanks!

There are a few problems I see here:

The repeat count needs to be in "%ecx", not "%cx".  And use "movsl",
not "movsw"; djgpp uses a 32-bit code segment so it will be *much*
faster to do it that way.

In gas syntax you need to use a $ sign before your constant
being moved to %ecx; otherwise you're loading from that address.

You can't clobber %es, since gcc assumes that %ds == %es when it
generates inline memcpy's and stuff.

Your asm fails to note that %esi, %edi, and %ecx are all being
clobbered, which will confuse gcc's optimizer and possibly cause
serious problems.

You should probably just use djgpp V2's movedata or dosmemput.  Those
have a simple C interface and do 32-bit moves, and since you're moving
so many bytes anyway, the minor extra overhead is irrelevant.

-Mat

- Raw text -


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