Coding Questions and other Quandaries
#46
Code:
mfctr r0
andi. r0, r0, 0xF
cmpwi r0, 4
bne- default_instruction
ori r4, r4, 0x0000
default_instrction:
ori r4, r4, 0x0001

The branching is wrong on this. Regardless of which branch route is taken, bit 31 of r4 will always end up high. Label names by themselves aren't 'barriers' in your source.

I would write it like this~

Code:
ori r4, r4, 0x0001 #Default Instruction, bit 31 is set high
mfctr r0 #Grab address from CTR
andi. r0, r0, 0xF #Check last digit
cmpwi r0, 4 #Check last digit against value of 4
bne- end_code #If not equal, end code, we want bit 31 kept high
rlwinm r4, r4, 0, 0, 30 #Flip bit 31 low
end_code: #The end

You can end a source with a label name destination for a branch if required.

Regarding your question on '600000000 00000000'~

It's a nop then the null word for the Code Handler to know to put a branch forward instruction to jump back where you left off. Nops will be added to your source by the compiler for compiled code alignment whenever necessary.
Reply


Messages In This Thread
RE: Coding Questions and other Quandaries - by Vega - 12-16-2021, 03:56 PM

Forum Jump:


Users browsing this thread: 2 Guest(s)