-
VC++ VS Borland C++
Hello All,
I have following snap of code. If I build the same in VC6++ I get following assembly output.
124: val = Count(x);
00401068 mov ecx,dword ptr [ebp-4]
0040106B shl ecx,4
0040106E mov eax,dword ptr [ebp-4]
00401071 xor edx,edx
00401073 mov esi,3
00401078 div eax,esi
0040107A sub ecx,eax
0040107C shr ecx,5
0040107F mov word ptr [ebp-8],cx
whereas when I build it in Borland C 4.02 version all operations like shl, div and shr are replaced by some function calls.
mov dx,word ptr DGROUP:_something+2
mov ax,word ptr DGROUP:_something
mov cl,4
call near ptr N_LXLSH@
push ax
push dx
push 0
push 3
push word ptr DGROUP:_something+2
push word ptr DGROUP:_something
call near ptr N_LUDIV@
mov bx,dx
pop dx
mov cx,ax
pop ax
sub ax,cx
sbb dx,bx
mov cl,5
call near ptr N_LXURSH@
mov word ptr DGROUP:_something+8,ax
Please let me know why is this happeneing?
So what compiler is better? Is there any compiler switch that will will replace function calls with directly with assembly instrction in Borland o/p?
Thanks,
Juganoo
-
What optimization levels are you using on your compilers? If you're using a different leve, this may be your problem. On a side note, IIRC, depending on your version of MSVC++, it doesn't use optimization (the 'standard' version). You should check your compiler's documentation and read up on the optimization flags.
Quzah.
-
Well duh!
One is a 32 bit compiler (see all those eax registers), and one is a 16 bit compiler (see all those ax registers)
-
Which one do you think is optimized?
Juganoo
-
Change your title, This one is a Flame-Bait.