Advertisement
ScriptzMoDz

[PowerPC] Reading/Writing Memory

Aug 29th, 2014
446
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. //Tutorial by BadLuckBrian
  2.  
  3. In this tutorial i will show you how Read and Write in the memory.
  4.  
  5. It's the same as 'PS3.GetMemory' and 'PS3.SetMemory' but it works a bit differently. Not really but its for the sake of understanding how it works !
  6.  
  7.  
  8. Reading memory
  9.  
  10. We can read memory with 4 instructions.
  11. Code:
  12. lbz (1 byte)
  13. lhz (2 bytes)
  14. lwz (4 bytes)
  15. ld (8 bytes)
  16. we use them like this:
  17.  
  18. Code:
  19. lwz RESULT, ADDRESS, TEMP_VAL
  20.  
  21. Result = register containing the byte at the address
  22. ADDRESS = register containing the address to read from
  23. TEMP_VAL= we can use it as a temporary 'addic'
  24. example:
  25.  
  26. Code:
  27. lis r3, 0xff r3 = 00 ff 00 00 (0xff0000)
  28. addic r3, r3, 0x1234 r3 = 00 ff 12 34 (0xff1234)
  29. lwz r4, r3, 0 r4 = the first 4 bytes at 0xff1234
  30. OR
  31. Code:
  32. lis r3, 0xff
  33. 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
  34. using addic make it permanent !!!!
  35. another example
  36.  
  37. reading the first 4 bytes at: 0x110d60c
  38. Code:
  39. lis r3, 0x0110
  40. lwz r4, r3, 0xd60c
  41. OR
  42.  
  43. Code:
  44. lis r3, 0x0110
  45. addic r3,r3, 0xd60c
  46. lwz r4, r3, 0
  47.  
  48. Writing in the memory is as easy as reading it.
  49.  
  50. we will use:
  51. Code:
  52. stb (1 byte)
  53. sth (2 bytes)
  54. stw (4 bytes)
  55. std (8 bytes)
  56. we use them like this:
  57. Code:
  58. stw VALUE, ADDRESS, TEMP_VAL
  59. example, i want to write 0x15 at: 0x2100000
  60. Code:
  61. lis r3, 0x210 (0x2100000) || 02 10 00 00
  62. li r4, 0x15
  63. stw r4, r3, 0
  64. Another example would bwe to write 0x15 at: 0xFCA280
  65.  
  66. Code:
  67. lis r3, 0xFC (r3 = 00 FC 00 00)
  68. li r4. 0x15
  69. stw r4, r3, 0xA280 (0xFCA280)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement