Results 1 to 40 of 91

Thread: Nibbles, bit operations and C dll's [RESOLVED]

Hybrid View

  1. #1
    PowerPoster Dave Sell's Avatar
    Join Date
    Mar 2004
    Location
    /dev/null
    Posts
    2,961

    Re: Why is C faster than VB

    Quote Originally Posted by krtxmrtz
    I find this quite surprising not to say hard to believe. If c is so efficient at string parsing you'd only have to take the compiled c code and convert it to assembler, on the basis that each machine instruction corresponds to an actual assembler instruction...
    If you take a string parsing routine written in C, say a for loop using integer offsets to the base address of the string (array of bytes), and then decompile it to assembler, you will get about a 1-1 ratio of C code to assembler code. In other words, you may not get 1-line to 1-line correspondence, but you would not be able to reduce the assembler any further. C can be extremely close to assembler in terms of efficiency.
    Nobody knows what software they want until after you've delivered what they originally asked for.

    Don't solve problems which don't exist.

    "If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)

    2 idiots don't make a genius.

  2. #2

    Thread Starter
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    Re: Why is C faster than VB

    Quote Originally Posted by Dave Sell
    If you take a string parsing routine written in C, say a for loop using integer offsets to the base address of the string (array of bytes), and then decompile it to assembler, you will get about a 1-1 ratio of C code to assembler code. In other words, you may not get 1-line to 1-line correspondence, but you would not be able to reduce the assembler any further. C can be extremely close to assembler in terms of efficiency.
    Oh I see what you mean, C is as efficient as assembler. I thought you meant assembler was less efficient than C, silly me !!!
    Lottery is a tax on people who are bad at maths
    If only mosquitoes sucked fat instead of blood...
    To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)

  3. #3
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Nibbles!

    In many cases a C compiler will produce faster code than you will produce writing in assembly language yourself. This is beacuse the compiler knows a lot of tricks that you don't. I've actually tested it.

  4. #4
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246

    Re: Nibbles!

    Quote Originally Posted by moeur
    In many cases a C compiler will produce faster code than you will produce writing in assembly language yourself. This is beacuse the compiler knows a lot of tricks that you don't. I've actually tested it.
    Can you post some code form both for me to test? Something no doubt memory heavy?

    I've written a few things in C/C++ that are about 100-200ms quicker in ASM (32-bit: both).

    Please, post something I can test..

    Phreak

    Visual Studio 6, Visual Studio.NET 2005, MASM

  5. #5
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Nibbles: still need help

    Can you post some code form both for me to test? Something no doubt memory heavy?

    I've written a few things in C/C++ that are about 100-200ms quicker in ASM (32-bit: both).
    I don't have any asm code anymore.
    Make sure that when you compile the C code, you are otimizing for maximum speed and that you are not compiling the Debug code.

    Of course if you know all the tricks too (like memory alignment issues) then you can produce asm code that is faster than C code since the C compiler is not 100% optimized, but I only know the obvious ones like Dave mentioned and hence produce slower code. That's why I don't use ASM anymore.

  6. #6
    PowerPoster Dave Sell's Avatar
    Join Date
    Mar 2004
    Location
    /dev/null
    Posts
    2,961

    Re: Nibbles!

    Quote Originally Posted by «°°phReAk°°»
    Remember that a Megabyte, a Meg, an MB are 1048576 bytes. Most of the time though, manufacturers give specifications showing a Mebabyte is 1000000 bytes in size to let their products look 4.8576% more impressive.
    Actually, this is an incorrect statement. A Megabyte is not 1048576 bytes.

    See http://helios.augustana.edu/~dr/kibibytes.html.

    A Megabyte is 10^6, or 1,000,000 (a million) bytes.
    A Mebibyte is 2^20, or 1,048,576 bytes.
    Nobody knows what software they want until after you've delivered what they originally asked for.

    Don't solve problems which don't exist.

    "If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)

    2 idiots don't make a genius.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width