WiiRd forum

Wii & Gamecube Hacking => Wii Game hacking help => Topic started by: live2play on September 19, 2010, 06:17:18 PM

Title: addi of large decimal in ASMWiiRD
Post by: live2play on September 19, 2010, 06:17:18 PM
For some reason, the following instruction won't convert to WiiRD code.  Is there a way to get this to work?

addi r10,r10,1070400

Would the following be the equivalent?

lis r9,0x0010
ori r9,r9,0x5540
add r10,r10,r9
Title: Re: addi of large decimal in ASMWiiRD
Post by: Deathwolf on September 19, 2010, 06:40:54 PM
I think the value is too big.
[addi] [r10],r10, 1[07][04] [00]

one line = 32 bit = 8 bytes.

with addi you only can use 16 bit values = 2 bytes
Title: Re: addi of large decimal in ASMWiiRD
Post by: Romaap on September 19, 2010, 07:24:58 PM
Quote from: live2play on September 19, 2010, 06:17:18 PM
Would the following be the equivalent?

lis r9,0x0010
ori r9,r9,0x5540
add r10,r10,r9
Yes, this would be a good solution.
Title: Re: addi of large decimal in ASMWiiRD
Post by: live2play on September 19, 2010, 07:36:30 PM
Thanks for the confirmation.  I do appreciate it.
Title: Re: addi of large decimal in ASMWiiRD
Post by: dcx2 on September 19, 2010, 08:08:28 PM
The "i" in "addi" stands for "immediate".  An immediate is a number that is provided as part of the instruction itself (notice that if you say "addi r0,r3,1", the last 16 bits of the instruction are "0001", which is the immediate).  Since instructions are 32 bits, if you were to specify a 32-bit immediate, there would be no room left for the op code, source registers, destination register, etc.  This is why you must load the 32-bit value into a register and then use the add instruction.