Code: Select all
Result = Var / 10
Remainder = Var % 10
RAX contains the Result and RDX contains the Remainder.
I tried a few combinations of arranging Result= Var / 10 and Remainder= Var % 10
But it results always 2 Division operations.
The C-Backend I guess optimize it to 1 division, as you can see at the timing Demo!
In Assembler for me it is no problem to do it, and I did it like that!
Code: Select all
Result =Var/10
!MOV [v_Remainder], RDX
My Question:
Is there any possiblity for force PB, with PB Code only, to get Result and Remainder wiht only 1 devision?
Timing Demo - try it in ASM and C-Backend to see the difference
Code: Select all
EnableExplicit
Define Result, Remainder
Define I, t1, sum
#Mio = 1000000
#Loops = 100 *#Mio
t1 = ElapsedMilliseconds()
For I = 0 To #Loops
Result =I/10
Remainder = I%10
sum = sum +Result +Remainder
Next
t1 = ElapsedMilliseconds() - t1
OpenConsole()
PrintN("Sum = " +Str(sum))
Print("")
PrintN("Time ms = " + Str(t1))
PrintN("")
PrintN("Press ENTER")
Input()



