allegrex full instruction set

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

Moderators: cheriff, TyRaNiD

Post Reply
serige
Posts: 34
Joined: Mon Nov 26, 2007 8:41 am

allegrex full instruction set

Post by serige »

hi,
I am looking at some psp assembly code, and I come across some unfamiliar instructions:

ins $s0, $zr, 0, 4
bnezl $s1, loc_00133D0C <--- a branch obviously, but not exactly sure what it does

can anyone tell me what are they? it would be nice if someone can give me the full instruction set (with explanations) so that i can look them up myself.
hlide
Posts: 739
Joined: Sun Sep 10, 2006 2:31 am

Re: allegrex full instruction set

Post by hlide »

serige wrote: ins $s0, $zr, 0, 4
bnezl $s1, loc_00133D0C <--- a branch obviously, but not exactly sure what it does
you can find those instructions in MIPS32 R2 documentation

ins $s0, $zr, 0, 4 ===> s0.bits[0..3] = 0;

branch has a delay slot (that is an instruction which follows the branch instruction) which is executed before jumping to target address

usually the instruction in the delay slot is always executed regardless whether the branch is taken (conditionnal branching).

But if a conditional branch has a 'l' suffix (which means 'likely') the instruction in the delay slot is executed if the branch is taken or skipped if not taken.

so if you have this :

bnezl $s1, loc
move $v0, $s1
===>
if (s1 != 0) { v0 = s1; goto loc; }

bnez $s1, loc
move $s1, $v0
===>
tmp = s1; s1 = v0; if (tmp != 0) { goto loc; }

beq r1, r2, loc : (r1 == r2)
bne r1, r2, loc : (r1 != r2)
beqz r1, loc : (r1 == 0)
bnez r1, loc : (r1 != 0)
bltz r1, loc : (r1 < 0)
bgez r1, loc : (r1 >= 0)
etc.
serige
Posts: 34
Joined: Mon Nov 26, 2007 8:41 am

Post by serige »

i am not sure if i got the ins instruction right

ins $1 $2 x y
so what it does it to clobber the the bits from index x to y-1 of the first register with that of the second register?

it doesn't seem I was able to find any info on this instruction from my google searches about the MIPS32 R2 documentation.

Thanks
serige
Posts: 34
Joined: Mon Nov 26, 2007 8:41 am

Post by serige »

found it, thanks a lot!
moonlight
Posts: 567
Joined: Wed Oct 26, 2005 7:46 pm

Post by moonlight »

serige wrote:i am not sure if i got the ins instruction right

ins $1 $2 x y
so what it does it to clobber the the bits from index x to y-1 of the first register with that of the second register?

it doesn't seem I was able to find any info on this instruction from my google searches about the MIPS32 R2 documentation.

Thanks
Almost. It inserts y bits of $2 at the position x of $1.
Examples:

ins v0, v1, 0, 4 -> is equivalent to v0 = v0 | (v1 & 0xF)
ins v0, v1, 3, 9 -> equvialent to v0 = (v0 & 0xFFFFF007) | ((v1 & 0x1FF) << 3)

Too bad the psp sdk doesn't have a bulitin func for it.

Anyways I uploaded to you the mips doc i had somewhere:
http://rapidshare.com/files/72446657/Mi ... e.pdf.html

It may miss some psp instruction like max and min, but ins, ext, seh, seb, etc should be there.
serige
Posts: 34
Joined: Mon Nov 26, 2007 8:41 am

Post by serige »

can you use something like 'asm{ins v0, v1, 0, 4};' to execute this instruction?
i dont have the sdk installed in my computer anymore i can't verify this...
serige
Posts: 34
Joined: Mon Nov 26, 2007 8:41 am

Post by serige »

moonlight wrote:
serige wrote:i am not sure if i got the ins instruction right

ins $1 $2 x y
so what it does it to clobber the the bits from index x to y-1 of the first register with that of the second register?

it doesn't seem I was able to find any info on this instruction from my google searches about the MIPS32 R2 documentation.

Thanks
Almost. It inserts y bits of $2 at the position x of $1.
Examples:

ins v0, v1, 0, 4 -> is equivalent to v0 = v0 | (v1 & 0xF)
ins v0, v1, 3, 9 -> equvialent to v0 = (v0 & 0xFFFFF007) | ((v1 & 0x1FF) << 3)

Too bad the psp sdk doesn't have a bulitin func for it.

Anyways I uploaded to you the mips doc i had somewhere:
http://rapidshare.com/files/72446657/Mi ... e.pdf.html

It may miss some psp instruction like max and min, but ins, ext, seh, seb, etc should be there.
Thanks a lot for your pdf!
User avatar
Raphael
Posts: 646
Joined: Tue Jan 17, 2006 4:54 pm
Location: Germany
Contact:

Post by Raphael »

serige wrote:can you use something like 'asm{ins v0, v1, 0, 4};' to execute this instruction?
i dont have the sdk installed in my computer anymore i can't verify this...
http://www.ibiblio.org/gferg/ldp/GCC-In ... HOWTO.html
<Don't push the river, it flows.>
http://wordpress.fx-world.org - my devblog
http://wiki.fx-world.org - VFPU documentation wiki

Alexander Berl
moonlight
Posts: 567
Joined: Wed Oct 26, 2005 7:46 pm

Post by moonlight »

It's a pity that instructions such as ins and ext don't have a builtin in the pspsdk, while other less useful like seb and seh have them.
hlide
Posts: 739
Joined: Sun Sep 10, 2006 2:31 am

Post by hlide »

Raphael wrote:
serige wrote:can you use something like 'asm{ins v0, v1, 0, 4};' to execute this instruction?
i dont have the sdk installed in my computer anymore i can't verify this...
http://www.ibiblio.org/gferg/ldp/GCC-In ... HOWTO.html

Code: Select all

#define __asm_ins&#40;rt, rs, lsb, len&#41; \
  &#40;&#123; \
    int res = rt; \
    __asm__ __volatile__ &#40; \
      "ins %0, %1, %2, %3" \
      &#58; "+r"&#40;res&#41; /* output */ \
      &#58; "r"&#40;rs&#41;, "i"&#40;lsb&#41;, "i"&#40;len&#41; /* input */ \
    &#41;; \
    res; /* returns res */  \
  &#125;&#41;

can be used this way :

int z = __asm_ins(x, y, 0, 4);

note that y can be a constant like __builtin_ins(x, 0, 0, 4);

and x and y can also be a complex expression like :

Code: Select all

  rgb565 = __asm_ins&#40;
             __asm_ins&#40;&#40;r8>>3&#41;, &#40;g8>>2&#41;, 5, 6&#41;,
               &#40;b8>>3&#41;, 5+6, 5
           &#41;;
fungos
Posts: 41
Joined: Wed Oct 31, 2007 10:43 am
Location: cwb br
Contact:

Post by fungos »

J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

fungos wrote:Just for comparission:

http://forums.amd.com/devblog/blogpost. ... &catid=271
Or the 68020 from 20 years ago:

http://68k.hax.com/BFINS
http://68k.hax.com/BFEXTU
Post Reply