@kas1e
Thanks a lot, your help was useful to let me look at right way..
I have just rewrote my function in a GCC compatible way wihout need to allocate and free aby stack space or sare any particular register,
I just used only voatile registers and optimized scheduling to get some instructions cycles for free.
So I paste my results here, in case it can be useful as example to some other guy.
There were some differncies between old StormAsm and GCC (AS) assembler, ie. in constant declarations and absence of proper automatic prolog and epilog routines, among other stuff too.
It was also not simple to declare the 4.0 float constant due IEEE rapresentation..
The loop was expanded two times to gain speed and has been applied some code reorg to match best speed without nreak compatibility with all powerpc cpus.
If domeone has some suggestion to offer is welcome.
Next step is to make a Tabor specific version of FlashMandel based on SPE mah.. meanwhile I'll go with a little update.
Now it's mostly compatible with MorphOS too via OS4EMU
####################################################################
# Written by Dino Papararo 15-Jan-2020
#
# FUNCTION
#
# MandelPPC -- perform Z = Z^n + C iteration.
#
# SYNOPSIS
#
# unsigned int MandelnPPC (long Iterations,double Cre,double Cim)
#
#
# This function tests if a point belongs or not at Mandelbrot's set
# Handmade optimized for PowerPC processors.#
#
# r3:Iterations r4:Power r5:Temp
# f1:Cre f2:Cim f3:Zr f4:Zi f5:Zr2 f6:Zi2 f7:Dist f8:MaxDist
####################################################################
.file "mandelnppc.s"
.section ".text"
.align 2
.globl MandelnPPC
.type MandelnPPC, @function
MandelnPPC:
lis %r5,.Radius@ha #set high 16bits R5 as Radius and crealr lower 16bits
lfd %f8,.Radius@l(%r5) #load dword from Radius into F8
fmr %f4,%f2 #Zi = Cim
fmr %f3,%f1 #Zr = Cre
.MainLoop:
mtctr %r4 #Load Power into counter
.PowerLoop1:
fmul %f6,%f4,%f4 #Zi2 = Zi * Zi
fmul %f4,%f4,%f3 #Zi *= Zr
fmul %f5,%f3,%f3 #Zr2 = Zr * Zr
fsub %f3,%f5,%f6 #Zr = Zr2 - Zi2
fadd %f4,%f4,%f4 #Zi += Zi
bdnz .PowerLoop1 #if Power > 0 goto .PowerLoop1
fadd %f7,%f5,%f6 #Dist = Zr2 + Zi2
fcmpu cr7,%f7,%f8 #compare dist with Radius
fadd %f4,%f4,%f2 #Zi += Cim
bgt cr7,.Exit #if dist > radius goto .Exit
cmpwi cr6,%r3,0 #compare Iterations with 0
fadd %f3,%f3,%f1 #Zr += Cre
beq cr6,.Exit #if Iterations == 0 goto .Exit
addi %r3,%r3,-1 #Iterations--
mtctr %r4 #Load Power into counter
.PowerLoop2:
fmul %f6,%f4,%f4 #Zi2 = Zi * Zi
fmul %f4,%f4,%f3 #Zi *= Zr
fmul %f5,%f3,%f3 #Zr2 = Zr * Zr
fsub %f3,%f5,%f6 #Zr = Zr2 - Zi2
fadd %f4,%f4,%f4 #Zi += Zi
bdnz .PowerLoop2 #if Power > 0 goto .PowerLoop2
fadd %f7,%f5,%f6 #Dist = Zr2 + Zi2
fcmpu cr7,%f7,%f8 #compare dist with Radius
fadd %f4,%f4,%f2 #Zi += Cim
bgt cr7,.Exit #if dist > radius goto .Exit
cmpwi cr6,%r3,0 #compare Iterations with 0
fadd %f3,%f3,%f1 #Zr += Cre
beq cr6,.Exit #if Iterations == 0 goto .Exit
addi %r3,%r3,-1 #Iterations--
b .MainLoop #goto .MainLoop
.Exit:
blr #return
.size MandelnPPC,.-MandelnPPC
.section .rodata
.align 3
.Radius:
.long 1074790400
.long 0