delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/10/19/16:50:51

Date: Mon, 20 Oct 1997 09:50:15 +1100
From: Bill Currie <billc AT blackmagic DOT tait DOT co DOT nz>
Subject: Re: flip routine in asm
In-reply-to: <01bcdcc7$98621a60$296df482@scavvis>
To: Anders Clerwall <anders DOT clerwall AT swipnet DOT se>, djgpp AT delorie DOT com
Message-id: <199710192047.JAA05876@teleng1.tait.co.nz gatekeeper.tait.co.nz>
Organization: Tait Electronics Limited
MIME-version: 1.0
Comments: Authenticated sender is <billc AT blackmagic DOT tait DOT co DOT nz>

On 19 Oct 97 at 18:51, Anders Clerwall wrote:

> Hi!.. I have made a flip routine in inline asm, why doesn't it
> work!!.. Can anyone help? Here it is: 
> void flip(short source, short dest) {
>  asm(	"movw	%0, %%ds\n\t"
>   "movw	%1, %%es\n\t"
>   "rep\n\t"
>           "movsl"
>                 : : "r" (source), "r" (dest), "S" (0), "D" (0), "c"
>                 (16000) : "memory", "%esi", "%edi", "%ecx");
> }

You must preserve %es and %ds accross the call.

void flip(short source, short dest) {
 asm(	"movw	%0, %%ds\n\t"
  "pushl %%es\n\t"
  "pushl %%ds\n\t"
  "movw	%1, %%es\n\t"
  "rep\n\t"
  "movsl\n\t"
  "popl %%ds\n\t"
  "popl %%es\n\t"
  : : "r" (source), "r" (dest), "S" (0), "D" (0), "c"
                (16000) : "memory", "%esi", "%edi", "%ecx");
}
Bill
--
Leave others their otherness.

- Raw text -


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