www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/11/22/18:53:18

To: djgpp AT delorie DOT com
Subject: converting Watcom-style inline asm to DJGPP-style
Message-ID: <19961122.184307.8439.1.aclemmer@juno.com>
From: aclemmer AT juno DOT com (Aaron M Clemmer)
Date: Fri, 22 Nov 1996 18:41:55 EST

	I'm trying to convert a macro that does a fixed-point divide.  It
was originally written in watcom's inline asm syntax, and all my attempts
to get the code to work properly under djgpp have failed.

This was the original routine:

typedef long fp14

fp14 fpDiv(fp14 d1, fp14 d2);
#pragma aux fpDiv = \
    "cdq" \
    "shld   edx, eax, 14" \
    "sal    eax,14" \
    "idiv   ebx" \
    parm [eax] [ebx]\
    modify [edx] \
    value [eax];


And this was how I tried to convert it:

extern __inline__ fp14 fpDiv(fp14 d1, fp14 d2)
{
  long retval=0;
  __asm__ __volatile__("cdq \n"      <- djgpp says this isn't a valid 386
opcode
 		       "shl $14, %%eax \n"   <- same for shld; and I
couldn't get
		       "shl $14, %%edx \n"        both on the same line
  		       "sal $14, %%eax \n"
 	                          "idiv %%ebx \n"
	                     : "=a" (retval)
	                     : "a" (d1), "b" (d2)
	                     : "dx");
 return retval;
}

- Raw text -


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