VC++ VS Borland C++

This is a discussion on VC++ VS Borland C++ within the C Programming forums, part of the General Programming Boards category; Hello All, I have following snap of code. If I build the same in VC6++ I get following assembly output. ...

  1. #1
    Registered User
    Join Date
    Nov 2002
    Posts
    38

    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

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    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.
    Hope is the first step on the road to disappointment.

  3. #3
    jhgvmhv
    Guest
    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)

  4. #4
    Registered User
    Join Date
    Nov 2002
    Posts
    38
    Which one do you think is optimized?

    Juganoo

  5. #5
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    Change your title, This one is a Flame-Bait.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to show line no in VC ++
    By mpushkar in forum Tech Board
    Replies: 1
    Last Post: 12-17-2006, 08:33 AM
  2. makefile exported by vc 6.0 doesn't work
    By wow in forum Windows Programming
    Replies: 7
    Last Post: 03-24-2006, 03:20 PM
  3. Can't compile this with VC 6.0
    By uriel2013 in forum C++ Programming
    Replies: 4
    Last Post: 05-31-2003, 07:43 PM
  4. VC 7.0 and templates
    By Mongush in forum C++ Programming
    Replies: 12
    Last Post: 03-11-2003, 09:32 AM
  5. Why VC?
    By Unregistered in forum Windows Programming
    Replies: 1
    Last Post: 04-15-2002, 05:24 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21