News: 11 March 2016 - Forum Rules
Current Moderators - DarkSol, KingMike, MathOnNapkins, Azkadellia, Danke

Author Topic: [PSP]ASM function that multiplies and stores the value in one line ?  (Read 1006 times)

omarrrio

  • Jr. Member
  • **
  • Posts: 47
    • View Profile
Hi, i am trying to find a a function that does multiplication and stores inside a register in the same line, because my game crashes if i use jumps and write the three multiplication instructions(see bellow) on either 0x0880100Y or 0x0880200Y, so i only have limited space, what i am trying to do, is modify a jump to go to 0x08801000, do whatever the multiplication requires, jump back to where it would've jumped originally.

Code: [Select]
0x08F008D8  jal  0x08801000
0x08801000  li   t2,0x4
0x08801004  mult a0,t2
0x08801008  mflo a0
0x0880100C  jal  0x08834D7C

The code above does run, but the game crashes, i have made sure the instruction i changed does NOT get used anyway in the game by any other function, i've been playing for an hour now, and the BP only reports at a specific moment, excatly where it is expected to report.

Thank you.
« Last Edit: July 28, 2017, 01:16:52 pm by omarrrio »

Gemini

  • Hero Member
  • *****
  • Posts: 2007
  • 時を越えよう、そして彼女の元に戻ろう
    • View Profile
    • Apple of Eden
Re: [PSP]ASM function that multiplies and stores the value in one line ?
« Reply #1 on: July 28, 2017, 01:36:51 pm »
Check on MIPS documents what lazy jumps are to understand why that isn't working. Also, to make a simple *4 operation use SLL reg, 2 instead.
I am the lord, you all know my name, now. I got it all: cash, money, and fame.

omarrrio

  • Jr. Member
  • **
  • Posts: 47
    • View Profile
Re: [PSP]ASM function that multiplies and stores the value in one line ?
« Reply #2 on: July 28, 2017, 02:07:34 pm »
Check on MIPS documents what lazy jumps are to understand why that isn't working. Also, to make a simple *4 operation use SLL reg, 2 instead.

Thank you ! SLL is what i was looking for, and for lazy jumps, now i get it, JAL actually does change RA and PC registers aswell as jumps, so when the game was trying to get back to the main thread, the RA and PC were badly wrong.