Date: Mon, 20 Oct 1997 09:50:15 +1100 From: Bill Currie Subject: Re: flip routine in asm In-reply-to: <01bcdcc7$98621a60$296df482@scavvis> To: Anders Clerwall , 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 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Comments: Authenticated sender is Precedence: bulk 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.