Coding Questions and other Quandaries
#27
In regards to your Assembly writes within your F6 Codes, I see a few problems. Here's the ASM source of your 3rd F6 code, I placed a comment next to any mistakes I found.

Code:
lwz r12, 0x0014 (r29)
cmpwi r12, 0xC8
beq- celia_health #You are branching literally to the next instruction, this is a useless branch

celia_health:
li r12, 0 #r12's value is going to be overwritten by the andi. instruction. So this li instruction has zero effect
andi. r12, r29, 0xF
cmpwi r12, 0
bne- default_instruction
li r3, 0xC8

default_instruction:
stw r3, 0x0014 (r29)

Here's a better way~

Code:
#First check the last digit of the Health Address
addi r12, r29, 0x0014 #increment r29's mem address by value of 0x0014
andi. r12, r12, 0xF
cmpwi r12, 0x4
bne- default_instruction

#Check if Health Value 0xC8 is initially present
lwz r12, 0x0014 (r29)
cmpwi r12, 0xC8
bne- default_instruction

#Keep Celia's health at 0xC8
mr r3, r12

#Default Instruction, update the Health
default_instruction:
stw r3, 0x0014 (r29)

Use that in your F6 code and see if it works. If not, try the F6 Code with using the following ASM source instead just in case....

Code:
addi r12, r29, 0x0014 #increment r29's mem address by value of 0x0014
andi. r12, r12, 0xF
cmpwi r12, 0x4
bne- default_instruction
li r3, 0xC8
default_instruction:
stw r3, 0x0014 (r29)

The + and - symbols are conditional branch hints. They give Broadway a hint of what the higher probability outcome of the conditional branch is. We're talking about saving nanoseconds here. It's pretty much useless for Wii Codes, I just do it out of habit and imo it makes the Assembly look much more clean.

+ = The branch is most likely to be taken
- = The branch is less likely to be taken

If no hint is supplied, the ASM compiler will default to - when compiling your Code
If you are unsure about the probabilities, use a -

Putting incorrect branch hints won't botch a code, but it will slow down the execution of said code by a super super small amount of time (measurement in nanoseconds lol). And, yes you can have multiple branches land/jump at the same spot/destination.

In regards to how I write out the branch commands:
Branches are basic jumps, that's it. Don't overthink it at all. A simple jump to your label name. There should never be any type of branch that jumps down to the very next instruction below. You could handwrite your ASM on a piece of paper and draw arrows of the branch jumps to help you out more visually.

Don't worry about the IABR thing, I'm just glad we have that as a backup and I personally just wanted to see if that nifty trick would even work.

You seem close to solving this. All that is needed is finding a reliable discrepancy.
Reply


Messages In This Thread
RE: Coding Questions and other Quandaries - by Vega - 12-10-2021, 02:29 PM

Forum Jump:


Users browsing this thread: 2 Guest(s)