Discuss the development of new homebrew software, tools and libraries.
Moderators: cheriff , TyRaNiD
anmabagima
Posts: 87 Joined: Thu Oct 01, 2009 8:43 pm
Post
by anmabagima » Sun Nov 15, 2009 6:29 am
Hi there,
I'm using MinPSPW SDK with eclipse and getting the error:
Error: unrecognized opcode `lv' when I try to compile:
Code: Select all
float clVfpuTool::distanceVector3(ScePspFVector3 *v1, ScePspFVector3 *v2)
{
float result;
__asm__ volatile (
"lv.t C000, %1\n"
"lv.t C100, %2\n"
"vsub.t C000, C000, C100\n"
"vdot.t S010, C000, C000\n"
"vsqrt.s S010, S010\n"
"sv.s S010, %0\n"
: "=r"(result):"r"(v1),"r"(v2));
return result;
Has anyone any Idea ? I've already tried to re-install the pspsdk.
However,
the following code compiles without error:
Code: Select all
float clVfpuTool::sinf(float rad)
{
float result;
__asm__ volatile (
"mtv %1, S000\n" //load input to single register
"vcst.s S001, VFPU_2_PI\n" //load constant 2/PI
"vmul.s S000, S000, S001\n" //S000 = S000 * S001
"vsin.s S000, S000\n" //S000 = SIN(S000)
"mfv %0, S000\n" //store register back
: "=r"(result):"r"(rad)
);
return result;
}
Criptych
Posts: 64 Joined: Sat Sep 12, 2009 5:18 am
Post
by Criptych » Sun Nov 15, 2009 11:27 pm
The problem is the ".t" suffix - lv can only take .s or .q. I did this myself a couple times. :) You have to either load the components individually with .s, or load an extra (possibly garbage) value with .q.
"You hungry? I haven't eaten since later this afternoon."
hlide
Posts: 739 Joined: Sun Sep 10, 2006 2:31 am
Post
by hlide » Mon Nov 16, 2009 3:41 am
if you don't care about compatibility with PSP1K (fat/phat/tank), you can use "ulv.q" to load your vectors and just compute with .t. Normally the fourth component of a vector is not changed by the computation so you can store it through "usv.q". But in your example, a "sv.s" is perfect :).
if you care about compatibility with PSP1K, you have no choice else to use three "lv.s" and three "sv.s".
anmabagima
Posts: 87 Joined: Thu Oct 01, 2009 8:43 pm
Post
by anmabagima » Mon Nov 16, 2009 4:33 am
Hi,
using "lv.q" results in:
"Macro lv.q not implemented yet"
Therefore I need to use lv.s 3 times.....I've change the code to:
Code: Select all
__asm__ volatile (
"lv.s R000, 0 + %1\n"
"lv.s R001, 16 + %1\n"
"lv.s R002, 32 + %1\n"
"lv.s R100, 0 + %2\n"
"lv.s R101, 16 + %2\n"
"lv.s R102, 32 + %2\n"
"vsub.t C000, C000, C100\n"
"vdot.t S010, C000, C000\n"
"vsqrt.s S010, S010\n"
"sv.s S010, %0\n"
: "=r"(result):"r"(v1),"r"(v2));
unfortunately I got the following errors:
"Error: Improper VFPU register prefix 'r'"
"Error: expression too complex"
Any further idea ?
Criptych
Posts: 64 Joined: Sat Sep 12, 2009 5:18 am
Post
by Criptych » Mon Nov 16, 2009 1:34 pm
anmabagima wrote: using "lv.q" results in:
"Macro lv.q not implemented yet"
I've never gotten that error before. :( Are you using an older SDK build?
"r" can be used with mtv and mfv, but for lv/sv you should use "m":
Code: Select all
: "=m"(result):"m"(v1),"m"(v2));
or
Code: Select all
"mfv %0, S010\n"
: "=r"(result):"m"(v1),"m"(v2));
"You hungry? I haven't eaten since later this afternoon."
hlide
Posts: 739 Joined: Sun Sep 10, 2006 2:31 am
Post
by hlide » Tue Nov 17, 2009 4:37 am
Code: Select all
__asm__ volatile (
"lv.q C000, %1\n"
"lv.q C100, %2\n"
"vsub.t C000, C000, C100\n"
"vdot.t S010, C000, C000\n"
"vsqrt.s S010, S010\n"
"sv.s S010, %0\n"
: "=r"(result):"m"(v1[0]),"m"(v2[0]):"memory"));
or
Code: Select all
__asm__ volatile (
"lv.s S000, %1\n"
"lv.s S100, %2\n"
"lv.s S001, %3\n"
"lv.s S101, %4\n"
"lv.s S002, %5\n"
"lv.s S102, %6\n"
"vsub.t C000, C000, C100\n"
"vdot.t S010, C000, C000\n"
"vsqrt.s S010, S010\n"
"sv.s S010, %0\n"
: "=r"(result):"m"(v1[0]),"m"(v2[0]),"m"(v1[1]),"m"(v2[1]),"m"(v1[2]),"m"(v2[2]):"memory"));
or
Code: Select all
__asm__ volatile (
"lv.s S000, 0(%1)\n"
"lv.s S100, 0(%2\n"
"lv.s S001, 4(%1)\n"
"lv.s S101, 4(%2)\n"
"lv.s S002, 8(%1)\n"
"lv.s S102, 8(%2)\n"
"vsub.t C000, C000, C100\n"
"vdot.t S010, C000, C000\n"
"vsqrt.s S010, S010\n"
"sv.s S010, %0\n"
: "=r"(result):"r"(v1),"r"(v2):"memory");
anmabagima
Posts: 87 Joined: Thu Oct 01, 2009 8:43 pm
Post
by anmabagima » Tue Nov 17, 2009 6:24 am
Hi,
thanks for thi hints. I'm using the MinPSPW in it's latest release. I'm pretty sure its not the latest SDK version as of SVN.
However, only the following code will pass the compiler without error:
Code: Select all
__asm__ volatile (
"mtv %1, S000\n"
"mtv %4, S100\n"
"mtv %2, S001\n"
"mtv %5, S101\n"
"mtv %3, S002\n"
"mtv %6, S102\n"
"vsub.t C000, C000, C100\n"
"vdot.t S010, C000, C000\n"
"vsqrt.s S010, S010\n"
"mfv %0, S010\n"
: "=r"(result):"r"(v1->x), "r"(v1->y), "r"(v1->z),"r"(v2->x), "r"(v2->y), "r"(v2->z):"memory");
Meanwhile:
Is there a possability to update my MinPSPW with the updates available via SVN ?
Thanks.
hlide
Posts: 739 Joined: Sun Sep 10, 2006 2:31 am
Post
by hlide » Wed Nov 18, 2009 6:11 am
use heimdal's pspsdk.
Criptych
Posts: 64 Joined: Sat Sep 12, 2009 5:18 am
Post
by Criptych » Wed Nov 18, 2009 1:57 pm
anmabagima wrote: I'm using the MinPSPW in it's latest release.
Are you sure? "MinPSPW" has since lost the W, so maybe you're using the last release which still kept it, and not the
actual latest release. I was using MinPSP(W) until recently and was able to use lv.q without error.
anmabagima wrote: Is there a possability to update my MinPSPW with the updates available via SVN ?
Yes, if you have Cygwin installed... which kind of defeats the purpose. :)
"You hungry? I haven't eaten since later this afternoon."
anmabagima
Posts: 87 Joined: Thu Oct 01, 2009 8:43 pm
Post
by anmabagima » Wed Nov 18, 2009 5:48 pm
Hi there,
I'm using MinPsP(w) version 0.9.5 I guess this is the latest one. However, I would try to lokate heimdall's and give him a try.
EDIT: After research in the net I come to the conclusion that MinPSP(w) is the one from heimdall ;o) any other Ideas ? Re-Installing havn't solved the issue..
Additional thought: I'm using VFPU within CPP class . May be this isthe root cause? Should VFPU callings only being placed within C code ?
Regards,
AnMaBaGiMa
hlide
Posts: 739 Joined: Sun Sep 10, 2006 2:31 am
Post
by hlide » Wed Nov 18, 2009 9:18 pm
your case is weird. C++ or C isn't the issue.
I use Heimdal' pspsdk and never fail with lv.q.
I'm not sure you're using them in gcc correctly
anmabagima
Posts: 87 Joined: Thu Oct 01, 2009 8:43 pm
Post
by anmabagima » Thu Nov 19, 2009 6:18 am
I'm not sure you're using them in gcc correctly
what do you mean by this ?
hlide
Posts: 739 Joined: Sun Sep 10, 2006 2:31 am
Post
by hlide » Fri Nov 20, 2009 2:51 am
I mean you must post the exact code of your function using "lv.q" which are not working. I'm not sure you are using __asm constraints correctly.
anmabagima
Posts: 87 Joined: Thu Oct 01, 2009 8:43 pm
Post
by anmabagima » Sun Nov 22, 2009 6:40 am
Hi there,
I've no clue what happens, but trying again today the following code works now fine:
Code: Select all
__asm__ volatile (
"lv.q C000, %1\n"
"lv.q C100, %2\n"
"vsub.t C000, C000, C100\n"
"vdot.t S010, C000, C000\n"
"vsqrt.s S010, S010\n"
"mfv %0, S010\n"
: "=r"(result):"m"(*v1),"m"(*v2):"memory");
Only issue I've seen that sv.s does not work with a single register like S010.
Using at the end "sv.s S010, %0\n" results in "Error: expression too complex". However, the initial error seem to be fixed. May be I've a selfhealing dev-environment ;o)
Thanks to all for your support
Regards,
AnMaBaGiMa
hlide
Posts: 739 Joined: Sun Sep 10, 2006 2:31 am
Post
by hlide » Mon Nov 23, 2009 5:09 am
Code: Select all
__asm__ volatile (
"lv.q C000, %0\n"
"lv.q C100, %1\n"
"vsub.t C000, C000, C100\n"
"vdot.t S010, C000, C000\n"
"vsqrt.s S010, S010\n"
"sv.s S010, %2\n"
: "m"(*v1),"m"(*v2), "m"(result):"memory");
where
result is declared as
float result;
constraint "r" is only for GPR register, so using "=r" for a base register in sv.s is an error. Maybe using "=m"(result) is possible.
anmabagima
Posts: 87 Joined: Thu Oct 01, 2009 8:43 pm
Post
by anmabagima » Tue Nov 24, 2009 5:31 am
Hi,
thanks a lot. This really solved the last issue as well. Great.
You've one free ;)
Regards,
AnMaBaGiMa