Error: unrecognized opcode `lv'

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
anmabagima
Posts: 87
Joined: Thu Oct 01, 2009 8:43 pm

Error: unrecognized opcode `lv'

Post by anmabagima »

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 »

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 »

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 »

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 »

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 »

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 »

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 »

use heimdal's pspsdk.
Criptych
Posts: 64
Joined: Sat Sep 12, 2009 5:18 am

Post by Criptych »

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 »

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 »

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 »

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 »

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 »

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 »

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 »

Hi,

thanks a lot. This really solved the last issue as well. Great.

You've one free ;)

Regards,
AnMaBaGiMa
Post Reply