Page 1 of 1
OPTIMIZATION !
Posted: Thu Oct 14, 2004 9:36 am
by Progs
I wish to see better assembler output....
I suppose that now ther is no optimization at all... only Line by line translation to asm.
Here PureBasic generated code
Code: Select all
; *mae_selectedlinkedlist\count = *mae_selectedlinkedlist\count - 1
MOV ebp,dword [p_mae_selectedlinkedlist]
MOV ebx,dword [ebp+20]
ADD ebx,-1
PUSH ebx
MOV ebp,dword [p_mae_selectedlinkedlist]
POP eax
MOV dword [ebp+20],eax
i think this code is bad....
it should be like
Code: Select all
MOV ebp,dword [p_mae_selectedlinkedlist]
MOV eax,dword [ebp + 20]
DEC eax
MOV dword [ebp + 20], eax
or even like
Code: Select all
MOV ebp,dword [p_mae_selectedlinkedlist]
DEC dword [ebp + 20]
sorry if im wrong...
Posted: Thu Oct 14, 2004 12:56 pm
by Blade
I wonder if a thirty party asm-optimized can be added to the compiling pipeline...
Or can already be done manually?
Posted: Thu Oct 14, 2004 1:14 pm
by Progs
You can write directly in asm
Example... pure function
Code: Select all
Procedure.l mae_linkedlist_next()
If *mae_selectedlinkedlist\nxt = 0
*mae_selectedlinkedlist\pointer = 0
ProcedureReturn 0
EndIf
*mae_selectedlinkedlist\pointer = *mae_selectedlinkedlist\nxt
*mae_selectedlinkedlist\nxt = *mae_selectedlinkedlist\pointer\nxt
ProcedureReturn (*mae_selectedlinkedlist\pointer-*mae_selectedlinkedlist\datasize)
EndProcedure
My asm version
Code: Select all
Procedure.l mae_linkedlist_next()
!MOV ebp,dword [p_mae_selectedlinkedlist]
!MOV ebx,dword [ebp+12]
!CMP ebx, 0
!JNE _my_ok
!MOV dword [ebp+8],0
!XOR eax,eax
!JMP _my_end
!_my_ok:
;*mae_selectedlinkedlist\pointer = *mae_selectedlinkedlist\nxt
!MOV eax,dword [ebp+12]
!MOV dword [ebp+8],eax
;*mae_selectedlinkedlist\nxt = *mae_selectedlinkedlist\pointer\nxt
!MOV ebp,dword [ebp+8]
!MOV eax,dword [ebp] ;eax = *nxt
!MOV ebp,dword [p_mae_selectedlinkedlist];ebx
!MOV dword [ebp+12], eax
;return
!MOV eax,dword [ebp+8]
!NOP
!SUB eax,dword [ebp+16]
ProcedureReturn
!_my_end:
EndProcedure
ASM version is about 50% faster !
Posted: Thu Oct 14, 2004 5:16 pm
by fsw
Well, PureBasic's website states:
- The key features of PureBasic are portability (Windows, AmigaOS and Linux are currently fully supported), the production of very fast and highly optimized executables and, of course, the very simple BASIC syntax.
I'm not a asm pro (so are most of pb users...), so I can't say if this is true with every bit of code pb produces.
But if you find some stuff just post it... it's appreciated.
Good hunting

Posted: Fri Oct 15, 2004 9:42 am
by Num3
On Amiga there was a small program that would optimize assembler source code.
You would just select the source, and it would parse it and compare it against a built in optimization database, and would replace has much code has possible.
Posted: Fri Oct 15, 2004 11:01 am
by Moonshine
Is there anything that wll do the same for x86 on a PC though?
Posted: Fri Oct 15, 2004 12:58 pm
by freedimension
Moonshine wrote:Is there anything that wll do the same for x86 on a PC though?

Posted: Fri Oct 15, 2004 1:42 pm
by Num3
Oh, that is an evil one!
Posted: Fri Oct 15, 2004 1:45 pm
by Dare2
lol. Cruel.
There is always a downside to a post like that - your own questions could end up get links back to that post!

Posted: Fri Oct 15, 2004 1:55 pm
by freedimension
Dare2 wrote:lol. Cruel.
There is always a downside to a post like that - your own questions could end up get links back to that post!

I never ask questions, do I????

Posted: Fri Oct 15, 2004 3:30 pm
by benny
@freedimension:
At least from now on, you've laid a lot of pressure on yourself before you
can ask a question
