Post: PowerPC Tutorials: Lesson 1- Read/Write in memory
02-17-2014, 04:06 PM #1
(adsbygoogle = window.adsbygoogle || []).push({}); In this tutorial i will show you how Read and Write in the memory.

It's the same as 'PS3.GetMemory' and 'PS3.SetMemory' but it works a bit differently.


Reading memory

We can read memory with 4 instructions.
    
lbz (1 byte)
lhz (2 bytes)
lwz (4 bytes)
ld (8 bytes)


we use them like this:

    
lwz RESULT, ADDRESS, TEMP_VAL

Result = register containing the byte at the address
ADDRESS = register containing the address to read from
TEMP_VAL= we can use it as a temporary 'addic'


example:

    
lis r3, 0xff r3 = 00 ff 00 00 (0xff0000)
addic r3, r3, 0x1234 r3 = 00 ff 12 34 (0xff1234)
lwz r4, r3, 0 r4 = the first 4 bytes at 0xff1234


OR
    
lis r3, 0xff
lwz r4, r3, 0x1234 <- we use it as a temporary addic to save a line !!! but WARNING: on the next line r3 will be restored to 00 ff 00 00 while
using addic make it permanent !!!!


another example

reading the first 4 bytes at: 0x110d60c
    
lis r3, 0x0110
lwz r4, r3, 0xd60c


OR

    
lis r3, 0x0110
addic r3,r3, 0xd60c
lwz r4, r3, 0



Writing in the memory is as easy as reading it.

we will use:
    
stb (1 byte)
sth (2 bytes)
stw (4 bytes)
std (8 bytes)


we use them like this:
    
stw VALUE, ADDRESS, TEMP_VAL


example, i want to write 0x15 at: 0x2100000
    
lis r3, 0x210 (0x2100000) || 02 10 00 00
li r4, 0x15
stw r4, r3, 0


Another example would bwe to write 0x15 at: 0xFCA280

    
lis r3, 0xFC (r3 = 00 FC 00 00)
li r4. 0x15
stw r4, r3, 0xA280 (0xFCA280)

The following user thanked Bad Luck Brian for this useful post:

Notorious

Copyright © 2024, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo