PowerPC For Dummies: Guides And Examples Page
#1
This is a separate "Guides And Examples" page that I made as part of the PowerPC For Dummies Guide

I've initially been posting examples under the list of instructions but due to the way the instruction comments push the instructions to various edges of the screen, sometimes way out of alignment from others, everything is all over the place. I have a feeling that people trying to read it will get a headache.

So I've made an entire different page for it called "Guides And Examples". 
It's in the style of the documentation page from the late GeckoCodes.org

I thought about posting it to the original guide thread but I had a feeling it would get lost in the existing sea of replies there already.
So I decided to make this separate thread, just so that anybody who browses this category of the site will have the chance to see it.

I'll still be updating the original guide and posting instruction specific code examples to it, but all of the general "examples" and guides will be posted to this new page.

Here is the page!
PowerPC For Dummies: The Guides and Examples Page

Let me know if anything on the page is incorrect.
Also, please let me know if there is an easier way I can explain a certain thing on it, trying to explain the logic instructions was..... not fun.
Reply
#2
Stop using r1 for non-stack examples. It will confuse the user. You use the term 'r1' in non stack examples but then proceed to use the term 'sp' in your stack guide which is the alternate name for r1.

Stop using r2 in other examples.




"Create a Stack Frame
To put it simply, if you don't make one of these, the game you're making a code for will crash if you try and replace a value in Registers 0 - 4."


This is incorrect, there's many different factors when it comes to the topic of Register Safety. The registers that are safe to use all depends on what kind of stack frame you are allocating and/or depends what registers are being used on or around your default instruction of your code's insertion/execution address. Your stack example frees up r3 thru r31 only, but doesn't effect r0's safety at all.

You could write something like this...
"To put simply, you can make one of these to ensure a high probability of the game not crashing due to Registers being backed up and restored safely"



The Logical Operations stuff has good overall descriptions, but at some point, if you can add a mini guide on bits/binary, it will help any user understand Logical Operations quicker. Since Logical Operations are done at the binary level.



A section needs to be added explaining how some instructions use Signed values while others use Logical values and explain the 16-bit rules/ranges for Signed and Logical.



I hope I don't sound harsh, just getting straight to the point. Everything else looks good and the Gecko-style format of the page is a nice touch!
Reply
#3
Code:
Stop using r1 for non-stack examples. It will confuse the user. You use the term 'r1' in non stack examples but then proceed to use the term 'sp' in your stack guide which is the alternate name for r1.

tbh I just copy-pasted the entire stack frame example from what I was told when I asked about how it works. I'm looking more into how it works in game so I can simplify it myself.

Why shouldn't I use r2 though?


Code:
The Logical Operations stuff has good overall descriptions, but at some point, if you can add a mini guide on bits/binary, it will help any user understand Logical Operations quicker. Since Logical Operations are done at the binary level.

Wait so what I put was actually correct? I thought it was completely wrong lol. I wanted to add xnor and others but they made the resulting values negative/flipped and I didn't know how to explain it properly.

And one more thing
Code:
The registers that are safe to use all depends on what kind of stack frame you are allocating

There are different "types" of stack frames?
Reply
#4
Sometimes over simplification is bad for ASM as ASM is a lower level language thus naturally the user needs to learn some of the finer details.

r2 is the rtoc. Like r1 and r13, it is not for general use. Has specific usages.

Regarding the Logic stuff, the very first sentence for each category is correct but everything after that is fundamentally wrong. ORs, ANDs, and XORs can used as tools for a variety of objectives and thus should be taught with the finer details involved. Or else the user will never truly understand how logical operations work.

For instance go to the C0 code type tutorial thread. There is a snippet of code using AND to make controller activation work in the C0 codes. In order to understand how that snippet of code actually gets the job done you need to learn Logical Operations the 'correct' way.

-

A user can basically make any size of stack frame they desire and store whatever registers they want on said stack. It's not complicated at all. Basic math and some alignment rules. View the About Stack Frames tut.
Reply
#5
Code:
r2 is the rtoc. Like r1 and r13, it is not for general use. Has specific usages.

Sorry man, but I just feel that using the first few registers makes for an easier example, If it bothers you that much, I'll add a big warning on the page that's impossible to miss saying not to use any of the registers in the examples. 

For me, It actually takes a bit longer if an example is laid out like "r14, r2, r8" for me to understand it, It's just all over the place. I just feel that using the first 3 is a better way to go about it, It's hard for me to explain, but I'm sure a least 1 other person feels the same way. I just think it would just make for easier learning. I can't explain it in detail but you probably get what I'm trying to say.

Code:
Sometimes over simplification is bad for ASM as ASM is a lower level language thus naturally the user needs to learn some of the finer details.

Please don't take any type of offense to this. But a lot of the time some of the tutorials posted have very v.a.g.u.e and technical wording, I know it makes perfect sense to you, but I barely even know what any of it means. Stack frames seem like one of those things that have to be explained using very specific details, but I'm learning how they work first.

Your simplified instructions tutorial on this site was really useful, and I used some of the information on it for my guide, but there are things like ''Instruction X OR's/AND's Register A's value" until recently (from your guides), I didn't know what "ORing or ANDing" was, All of the PowerPC guides pretty much just assume that you know exactly how it works. But most people don't. There are a lot of things like this.

I don't know, maybe it's just me, I can't really learn anything complicated unless it's explained in full detail to me, or if I'm able to test things with it, If it weren't for me being able to test instructions in dolphin, I most likely would have never been able to figure how and/or/xor worked. It's not your fault for wording the guide the way you did, it's my fault for my brain working the way it does causing me to be a very slow learner. but I know that at least one other person has the same issue, which is mostly why I made the guide.

Code:
ORs, ANDs, and XORs can used as tools for a variety of objectives and thus should be taught with the finer details involved.

What are the other uses it has though? Are you talking about the extended mnemonics like ori, andi, etc.?
Reply
#6
(06-30-2021, 07:15 PM)JimmyKazakhstan Wrote: Sorry man, but I just feel that using the first few registers makes for an easier example, If it bothers you that much, I'll add a big warning on the page that's impossible to miss saying not to use any of the registers in the examples. 

For me, It actually takes a bit longer if an example is laid out like "r14, r2, r8" for me to understand it, It's just all over the place. I just feel that using the first 3 is a better way to go about it, It's hard for me to explain, but I'm sure a least 1 other person feels the same way. I just think it would just make for easier learning. I can't explain it in detail but you probably get what I'm trying to say.

No worries at all and there's no need to apologize. At the end of the day, it's your guide.

(06-30-2021, 07:15 PM)JimmyKazakhstan Wrote: Please don't take any type of offense to this. But a lot of the time some of the tutorials posted have very v.a.g.u.e and technical wording, I know it makes perfect sense to you, but I barely even know what any of it means. Stack frames seem like one of those things that have to be explained using very specific details, but I'm learning how they work first.

No offense taken. Regarding the stack frame stuff, you can just utilize the version that backs up r14 thru 31, and you can let your readers know to use that specific stack example for their codes.

(06-30-2021, 07:15 PM)JimmyKazakhstan Wrote: I don't know, maybe it's just me, I can't really learn anything complicated unless it's explained in full detail to me, but I know that at least one other person has the same issue, which is mostly why I made the guide.

I believe my tutorials have enough details, in fact I think I baby step them a little too much. However my tutorials lack screenshots and visual documentation. If I get time, I can add a bunch of pics, diagrams, screenshots, etc. I just worry that new comers will skim the threads go right to the pics and try to 'copy paste' instructions/sources into addresses randomly instead of actually reading and digesting the info as ASM is not an 'exact science' and every situation with every code is different.

(06-30-2021, 07:15 PM)JimmyKazakhstan Wrote: What are the other uses it has though? Are you talking about the extended mnemonics like ori, andi, etc.?

Yes.

Check out one of Seeky's first codes - https://mkwii.com/showthread.php?tid=1389

View the source on that and you can see he does an ori instruction to flip a hit high and a rlwinm instruction to flip a bit low (rlwinm can 'mimic' ANDing'). Some values in games won't be in bytes, halfwords, or words, but they will be represented by bits. Thus the only way you can modify these bits correctly is by Logical Operations.



Also, I saw this on your guide~

(06-30-2021, 07:15 PM)JimmyKazakhstan Wrote: This will load address 0x8000FFFF into register 0

You might be thinking "why not just use li for the bottom half of the register?"

"li" can only load values up to 0x7FFF into a register, whereas "ori" can load values up to 0xFFFF

Anytime li (load immediate) is executed, the upper 16 bits of a register is set to 0x0000, unless you are placing in a negative value (.i.e li r4, 0xFFFFFFFC which can also be written as li r4, -4)

Ori is used to complete the lower 16 bits as it's easier than using addi, cause addi uses signed values, and you can't use addi to write a word value from scratch to a register if it's register 0 cause of the literal 0 rule.

Examples:
lis r4, 0x8000
addi r4, r4, 0x1500 #Sets r4 to 0x80001500 just like how ori will

--

Fill r4 as 0x8000A000 w/o using ori
lis r4, 0x8001 #Increase lis value by 1
addi r4, r4, 0xFFFFA000 #Do the sign extend trick

--

lis r0, 0x8000
addi r0, r0, 0x1500 #Won't work as r0 will end up just being 0x00001500; fyi this addi instruction is the same thing as li r0, 0x1500
Reply
#7
Thanks! This whole time I thought you meant that the OR/AND Instructions specifically had different uses lol.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)