[Icc-mot] GNU to ICC
Edward Karpicz
ekarpicz at freemail.lt
Thu Sep 20 10:35:39 PDT 2007
Your GCC inline asm snippet doesn't look rocket science after scannig this:
http://www.ibiblio.org/gferg/ldp/GCC-Inline-Assembly-HOWTO.html
int a=10, b;
asm ("movl %1, %%eax;
movl %%eax, %0;"
:"=r"(b) /* output */
:"r"(a) /* input */
:"%eax" /* clobbered register */
);
Reformatting your code to have ':' in the right position makes it readable
__asm__ __volatile__ ("emul\n"
"ldx #100\n"
"ediv\n"
:"=y" (utmp1)
:"y" (flash4.ReqFuel),"d" (utmp1)
:"x");
output in Y is utmp1
inputs: flash4.ReqFuel in Y reg, utmp1 in D reg
clobbered: X reg
You are almost right, you just missed emul prior to LDX #100.
In C your snippet should be something like this:
////start
unsigned short utmp1;
unsigned short flash4.ReqFuel; // I don't know anything about flash4 struct
utmp1 = ((unsigned long)utmp1 * flash4.ReqFuel) / 100u;
////end
Regards
Edward
----- Original Message -----
From: "Oskar Atkinson" <oskar at atk-it.com>
To: "Discussion List for ICC08/11/12/16 users. You do NOT need to subscribe
toicc-announce if you are a member of this." <icc-mot at imagecraft.com>
Sent: Thursday, September 20, 2007 6:58 PM
Subject: RE: [Icc-mot] GNU to ICC
still learning and well, now I am stuck with some inline assembler ...
in GCC it is:
__asm__ __volatile__ ("emul\n"
"ldx #100\n"
"ediv\n":
"=y" (utmp1):
"y" (flash4.ReqFuel),
"d" (utmp1):
"x");
the GCC syntax is asm( asm instuctions : output : input : clobbered
registers );
I read above in terms of parameters as:
load the content of C variable flash4.ReqFuel into register y
load the content of C variable utmp1 into register edx
ldx #100
ediv
store the content of register y to the C variable utmp1
reg x content is not valid anymore
Thanks for any hints
Oskar
--------------------------------------------------------------------------------
> _______________________________________________
> Icc-mot mailing list
> Icc-mot at imagecraft.com
> http://dragonsgate.net/mailman/listinfo/icc-mot
>
More information about the Icc-mot
mailing list