Page 1 of 1

Better ASM optimization

Posted: Wed Apr 15, 2009 5:12 pm
by cxAlex
I'd like a litte bit better ASM optimization for the PB compiler. The current optimization is not bad, but not very good.

For exmple:
PB Source wrote:x = 50
y = x/10
z = x%10
PB ASM Output wrote:mov dword [0x438ce4], 0x32
mov ebx, [0x438ce4]
mov eax, ebx
mov ebx, 0xa
cdq
idiv ebx
mov ebx, eax
mov [0x438ce8], ebx
mov ebx, [0x438ce4]
mov eax, ebx
mov ebx, 0xa
cdq
idiv ebx
mov ebx, edx
mov [0x438cec], ebx
Optimized Output wrote:mov dword [0x438ce4], 0x32
mov eax, [0x438ce4]
mov ebx, 0xa
cdq
idiv ebx
mov [0x438ce8], eax
mov [0x438cec], edx
>mov ebx, [0x438ce4]
>mov eax, ebx
>mov ebx, 0xa


>mov ebx, eax
>mov [0x438ce8], ebx
>mov ebx, [0x438ce4]


>mov ebx, [0x438ce4]
>mov eax, ebx
>mov ebx, 0xa

>mov ebx, edx
>mov [0x438cec], ebx

Why always use ebx as buffer? I don't think that can be good for the performance.