jueves, 21 de marzo de 2019

MIPS common used instructions

Load
In this example, I will use the first registers that NO$PSX uses.
General-purpose registers
The registers are like memory to store values, in this case MIPS 32 can store a 32bit value up to 0xFFFFFFFF

LOAD:
Load instructions are used to load (duh) data into registers, it can be from RAM, other register or immediate values.
- Immediate values -

# LUI (load unsigned immediate)
This is a pseudo instruction, will load a value up to 0xFFFF0000
lui at, 0x8008
The register at will end up with the value 0x80080000

# ORI (or immediate)
This performs a logical or in the desired register (Operation form: Z = X + Y)
This instruction is very handy on load values up to 0x0000FFFF and can be used in conjunction with LUI to load offsets like this:
lui at, 0x8008
ori at, at, 0x2030
And it looks like this: at = 0x8008 | 0x2030 at will end with the value 0x80082030

- Useful logical instruccions -
SLTI (Set on lower than immadiate)
It sets a boolean value (1 or 0) when the value in the register is lower than immediate
at = 0x20
slti v0 at, 0x0030
v0 will end up with 0x00000001

XORI (Exclusive OR immendiate)
This is very use for when you want to "add" if the values does not exist or "rest" if the value exist at bit level.
Example "add":
at = 0x20
xori at, at,0x0F
The register at will end with the value 0x2F
at = 0x2F
xori at, at,0x10
The register at will end with the value 0x3F since the value 0x10 does not exist in 0x2F(bit level value)

Example 2 "rest":
at = 0x3F
xori at, at,0x10
The register at will end with the value 0x2F since the value 0x10 does exist in 0x3F(bit level value)
at = 0x2F
xori at, at, 0x2F
The register at will end with the value 0x00 since is the same value as the immediate(bit level value)


ANDI (And immadite)
This is very useful to check if a value exists in a register special for jokers :)
at = 0x2F
andi at, at, 0x20
The register at will end with the value 0x20 since 0x2F contains 0x20(bit level value)
at = 0x20
andi at, at, 0x10
The register at will end with the value 0x00 since 0x20 does not contain 0x10 (bit level value)

Load values from RAM:
Useful when you have the offset and want to retrieve a value [Operation form: Z = Offset(Pointer)]

# LB (load byte, can load unsigned value)
Load a byte from RAM up to 0xFF
lb v0, 0x0000(at)

# LH (load halfword, can load unsigned value)
Load a byte from RAM up to 0xFFFF
lh v0, 0x0000(at)

# LW (load word)
Load a byte from RAM up to 0xFFFFFFFF
lw v0, 0x0000(at)

Note: all load instructions from RAM have a delay, that means you need an extra cycle until the desired value becomes available.

Store
Store values to RAM:
Useful when you need to write something to RAM [Operation form: RAM = Offset (Pointer)]

# SB (store byte)
Store a byte to RAM up to 0xFF
sb v0, 0x0000(at)

# SH (store halfword)
Store a byte to RAM up to 0xFFFF
sh v0, 0x0000(at)

# LW (store word)
Store a byte to RAM up to 0xFFFFFFFF
sw v0, 0x0000(at)

- Branch instructions -
TODO


Best emulator to start learning MIPS

Download:
NO$PSX

How to configure for MIPS:
First screen when you open NO$PSX
Go to options
Go to debug tab
Final screen

jueves, 29 de marzo de 2018

PSP Playstation EBOOT

PSX 2 PSP: Here

Parasite Eve 2 files used in the tutorial:Here

Tutorial



sábado, 17 de marzo de 2018

Hacking Tools and Referience Books

Tools:


-MIPS Assamber:
This tool can help you to convert N64, PSX and PS2 opcode to their hex representation.
MIPS Assambler

-Hex Convert:
With this you can convert decimal to hex base, also you can convert hex to float and vice-versa.
Hex Convert

-CD Mage:
A must have if you are into graphics modding, translations, allow to extract and reinsert files easily and automatically fixes TOC.
CDmage

-HxD:
Very powerful tool to Hex edit files, browse CDImages by sectors, comparing files, search for strings and much more good stuff.

Reference guides

-MIPS for PSX and N64 (English only)
This guide can help you to understand how MIPS works, also what are some of the opcodes the PSX uses. 
MIPS

-MIPS for PS2 (English only)

This guide can help you to understand how MIPS IV works and the new instruction set for the coprocessor unit in the PS2.
MIPS IV