1

**PSX FFT Hacking / Re: ASM Help**

« **on:**March 22, 2015, 09:43:06 PM »

That is... some strange code...

Pretty sure instead of:

lui r3,0xcccc

lhu r2,0x002e(r16)

ori r3,r3,0xcccd

multu r2,r3

mfhi r3

srl r3,r3,0x03

This would achieve the same thing:

lhu r2,0x002e(r16)

ori r3, r0, 0x000A

divu r2, r3

mflo 3

You could also add this if there was enough space (I doubt there is, since this would take 1 extra line) to round up if the number is uneven:

lhu r2,0x002e(r16)

ori r3, r0, 0x000A

divu r2, r3

mfhi r2

beq r2, r0, 0x0008

mflo r3

addiu r3, r3, 0x0001

Of course, there are many ways to go at it.

Multiplying a value by 0xCCCCCCCD means only 80% of the original value makes it into the hi register.

It's basically the same way as doing Value * 4 / 5. Which could be translated as:

lhu r2,0x002e(r16)

ori r3, 0x0005

sll r2, r2, 0x0002

divu r2, r3

mflo r3

(which then gets divided by 8 with srl to get 10%)

Which isn't more or less effective AFAIK.

If you just want to change 10% to 5%...

Change srl r3,r3,0x03 to srl r3,r3,0x04

So your 80% / 8 = 10% becomes 80% / 16 = 5%

Pretty sure instead of:

lui r3,0xcccc

lhu r2,0x002e(r16)

ori r3,r3,0xcccd

multu r2,r3

mfhi r3

srl r3,r3,0x03

This would achieve the same thing:

lhu r2,0x002e(r16)

ori r3, r0, 0x000A

divu r2, r3

mflo 3

You could also add this if there was enough space (I doubt there is, since this would take 1 extra line) to round up if the number is uneven:

lhu r2,0x002e(r16)

ori r3, r0, 0x000A

divu r2, r3

mfhi r2

beq r2, r0, 0x0008

mflo r3

addiu r3, r3, 0x0001

Of course, there are many ways to go at it.

Multiplying a value by 0xCCCCCCCD means only 80% of the original value makes it into the hi register.

It's basically the same way as doing Value * 4 / 5. Which could be translated as:

lhu r2,0x002e(r16)

ori r3, 0x0005

sll r2, r2, 0x0002

divu r2, r3

mflo r3

(which then gets divided by 8 with srl to get 10%)

Which isn't more or less effective AFAIK.

If you just want to change 10% to 5%...

Change srl r3,r3,0x03 to srl r3,r3,0x04

So your 80% / 8 = 10% becomes 80% / 16 = 5%