Free Look [JoshuaMK]
#6
(09-22-2019, 11:39 PM)salmon01 Wrote: Maybe your code could benefit from some simplification. I find that a code is a lot easier to debug when it’s optimized.

Recommendation 1: instead of having multiple branches, take the absolute value of your number you want to check and then just check if it’s greater/less than some bound, in one branch. Here’s the relevant function (parameter r3, return r6) from the PPC CWG:
srawi R4,R3,31
xor R5,R4,R3
subf R6,R4,R5

Recommendation 2: I noticed you have a lot of repeated code for the checks with different registers. There are two ways to fix this: either make your repeated code into a function or implement self-modifying ASM, in which you use the BL trick to get the address of the ASM address you want, then use rlwimi to change the register bits of the opcode. The catch with this is that you have to flush the instruction cache in order to fully “reset” your ASM; since it’s a little overkill so I would probably just use a function.

I know little to nothing about cache on Broadway. Would this correct to do the part in bold?

r4 = Location to write in new instruction
r3 = contains new instruction
r0 = 0

stw r3, 0 (r4) #Store modified instruction to static memory

dcbst r0, r4 #Update memory
sync 0 #wait for update, hard sync

icbi r0, r4 #Invalidate block w/ old instruction
sync 0 #wait for update, hard sync

isync #remove copy in own instruction buffer

--

Is this close to what needs to be done? Or is this overkill?
Reply


Messages In This Thread
Free Look [JoshuaMK] - by JoshuaMK - 09-21-2019, 10:09 PM
RE: Free Look [JoshuaMK] - by Vega - 09-22-2019, 01:48 PM
RE: Free Look [JoshuaMK] - by JoshuaMK - 09-22-2019, 06:40 PM
RE: Free Look [JoshuaMK] - by salmon01 - 09-22-2019, 11:39 PM
RE: Free Look [JoshuaMK] - by JoshuaMK - 09-23-2019, 12:50 AM
RE: Free Look [JoshuaMK] - by Vega - 10-09-2019, 10:47 PM
RE: Free Look [JoshuaMK] - by salmon01 - 10-09-2019, 11:51 PM
RE: Free Look [JoshuaMK] - by JoshuaMK - 10-10-2019, 03:11 AM

Forum Jump:


Users browsing this thread: 2 Guest(s)