 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
Kojima
Joined: 26 Jun 2006 Posts: 275
|
Posted: Sat Jul 08, 2006 5:20 am Post subject: From ps2 asm to psp asm. |
|
|
Can anyone spot why this doesn't work?
It's a simple multply test that works perfectly on the ps2, but on the psp (using the c++ compiler not c) it fails, saying mult $5,$5,$3 is an illegal operand.
| Code: |
void AddTest()
{
int num1=5;
int num2=10;
int out=0;
asm __volatile__ ("\n\
mult %0,%1,%2\n\ // <<<<
":"=r"(out):"r"(num1),"r"(num2));
printf("Result:%d \n",out);
}
|
Are there major differences between ps2/psp asm in inline usage or do I just need to modify it a little? |
|
| Back to top |
|
 |
TyRaNiD
Joined: 18 Jan 2004 Posts: 918
|
Posted: Sat Jul 08, 2006 6:04 am Post subject: |
|
|
| Probably because on the allegrex it only supports the mult s, t form with the result going to the HI and LO regs I would expect. |
|
| Back to top |
|
 |
Kojima
Joined: 26 Jun 2006 Posts: 275
|
Posted: Sat Jul 08, 2006 6:12 am Post subject: |
|
|
| ah ok, thanks. |
|
| Back to top |
|
 |
Kojima
Joined: 26 Jun 2006 Posts: 275
|
Posted: Sat Jul 08, 2006 6:34 pm Post subject: |
|
|
Anyone know why this doesn't work on psp?
ori $15,$0,%1\n\
I'm just trying to set register 15 with the value of operand 1 but it says "Error:Register value used as an expression"
Has ori changed from ps2 too? |
|
| Back to top |
|
 |
TyRaNiD
Joined: 18 Jan 2004 Posts: 918
|
Posted: Sat Jul 08, 2006 7:33 pm Post subject: |
|
|
| no ori is the same as it ever was, the third parameter is an immediate value not the a register, if you use a register then use normal or. |
|
| Back to top |
|
 |
Kojima
Joined: 26 Jun 2006 Posts: 275
|
Posted: Sat Jul 08, 2006 7:54 pm Post subject: |
|
|
| Whoops, ok thanks. Still learning as I go. |
|
| Back to top |
|
 |
Kojima
Joined: 26 Jun 2006 Posts: 275
|
Posted: Sat Jul 08, 2006 9:22 pm Post subject: |
|
|
Can anyone see why this pice of asm hangs?
| Code: |
num1 =5;
num2 = 10;
out = 0;
to = 5;
asm __volatile__ ("\n\
ori $5,$0,0\n\
ori $17,$0,0\n\
loop:\n\
mul %1,%2\n\
mflo $16\n\
addu $19,$16,$17\n\
move $17,$19\n\
addu $5,$5,1\n\
bne $5,%3,loop\n\
nop\n\
move %0,$17\n\
":"=r"(out):"r"(num1),"r"(num2),"r"(to));
|
in c++ terms it's only doing this,
| Code: |
int num1=5;
int num2=10;
int out=0;
int to = 5;
float r17,r16;
r16=0;
r17=0;
for(int i=0;i<to;i++)
{
float res = num1*num2;
r16 = res;
r17 = r16+r17;
}
|
|
|
| Back to top |
|
 |
Saotome

Joined: 03 Apr 2004 Posts: 182
|
Posted: Sat Jul 08, 2006 10:56 pm Post subject: |
|
|
I think it's because of this one:
the third parameter is an immediate but you're using addu instead of addiu. I believe in this case it's as if you're using addu $5,$5,$1 and if $1 != 1 then it doesn't work like it should ;) _________________ infj |
|
| Back to top |
|
 |
Kojima
Joined: 26 Jun 2006 Posts: 275
|
Posted: Sun Jul 09, 2006 12:54 am Post subject: |
|
|
Thanks, still hangs though :)
Here's my new attempt at it,
| Code: |
void AddTest()
{
int num1=5;
int num2=10;
int out=0;
int to = 5;
float r17,r16;
r16=0;
r17=0;
for(int i=0;i<to;i++)
{
float res = num1*num2;
r16 = res;
r17 = r16+r17;
}
printf("C Res:%f",r17);
num1 =5;
num2 = 10;
out = 0;
to = 5;
asm __volatile__ ("\n\
ori $5,$0,0\n\
ori $17,$0,0\n\
loop:\n\
mul %1,%2\n\
mflo $16\n\
addu $19,$16,$17\n\
move $17,$19\n\
addiu $5,$5,1\n\
bne $5,%3,loop\n\
nop\n\
move %0,$17\n\
":"=r"(out):"r"(num1),"r"(num2),"r"(to));
printf("Asm Result:%d \n",out);
}
|
It doesn't just hang, the psp resets, and the power light blinks on/off, I guess indicating there was a fatal error, then i have to hard reset. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|