The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: houyunqing on December 28, 2009, 06:47:50 PM

Title: is there some assembler for IA32?
Post by: houyunqing on December 28, 2009, 06:47:50 PM
I tried to determine which one was faster... and I tested with MASM/C++/Fortran/C#.NET, basically just through some repetitive arithmetic operations. It turned out that Fortran wasn't nearly as fast as some boasted, and MASM lost to C#.NET. So I was amazed. Shouldn't assembly be the fastest? There was no optimization in the C# compiler, but it did ran faster than MASM. And I guess it might be related to the IA32 framework? Aafter all MASM is such an old thing now... Is there an assembler for IA32 somewhere? or just some recently made assemblers for me to give some try?
Title: Re: is there some assembler for IA32?
Post by: jj2007 on December 28, 2009, 07:43:37 PM
Quote from: houyunqing on December 28, 2009, 06:47:50 PM
Shouldn't assembly be the fastest?

Very bad assembly can actually be slower than C. Post your code if you want answers.
Title: Re: is there some assembler for IA32?
Post by: dedndave on December 28, 2009, 07:46:28 PM
well - any compiler eventually cranks out machine code, which can be written with assembler
some compilers may use advanced optimization techniques
but, there shouldn't be anything that can't be understood, learned, and applied in assembler
as JJ says - post the code
if the assembler code was slower, there is a reason for it
Title: Re: is there some assembler for IA32?
Post by: brethren on December 28, 2009, 09:47:32 PM
Quote from: houyunqing on December 28, 2009, 06:47:50 PM
I tried to determine which one was faster... and I tested with MASM/C++/Fortran/C#.NET, basically just through some repetitive arithmetic operations. It turned out that Fortran wasn't nearly as fast as some boasted, and MASM lost to C#.NET. So I was amazed. Shouldn't assembly be the fastest? There was no optimization in the C# compiler, but it did ran faster than MASM. And I guess it might be related to the IA32 framework? Aafter all MASM is such an old thing now... Is there an assembler for IA32 somewhere? or just some recently made assemblers for me to give some try?

c# compiles into bytecode that runs on a virtual machine, there is no way it could be faster than handcrafted asm
Title: Re: is there some assembler for IA32?
Post by: dedndave on December 28, 2009, 10:58:05 PM
Quotec# compiles into bytecode that runs on a virtual machine, there is no way it could be faster than handcrafted asm

huh ?   :eek
Title: Re: is there some assembler for IA32?
Post by: Farabi on December 29, 2009, 01:53:39 AM
Quote from: houyunqing on December 28, 2009, 06:47:50 PM
I tried to determine which one was faster... and I tested with MASM/C++/Fortran/C#.NET, basically just through some repetitive arithmetic operations. It turned out that Fortran wasn't nearly as fast as some boasted, and MASM lost to C#.NET. So I was amazed. Shouldn't assembly be the fastest? There was no optimization in the C# compiler, but it did ran faster than MASM. And I guess it might be related to the IA32 framework? Aafter all MASM is such an old thing now... Is there an assembler for IA32 somewhere? or just some recently made assemblers for me to give some try?

Well, C# might use the optimized function one and your ASM code might use only FPU.
I bet this code is faster on any C compiler.


C:
main ()
{ float x ;
x=2/2 ;
}

ASM:

Main:
mov eax,2
shr eax,1
ret



:green Okay, we are cheating.
Title: Re: is there some assembler for IA32?
Post by: houyunqing on December 29, 2009, 05:53:37 AM
C# is supposed to be slow? I don't think so... from my own test C# was a hell lot faster than C++ and according to another test done by some guy using fourier transform, unoptimized C# was faster than even optimized C++ code. It's here: http://www.grimes.demon.co.uk/dotnet/man_unman.htm. As for the code I used... the test was done actually quite a few months ago... I can't find it now... i will test again and post the code here...
update:I've found my Fortran, C++ and C# code... now looking for my ASM code...
Title: Re: is there some assembler for IA32?
Post by: MichaelW on December 29, 2009, 08:41:09 AM
In your  previous thread (http://www.masm32.com/board/index.php?topic=10132.0) you were testing code where the calculations and the loop could be replaced with a single compile-time calculation, without affecting the result. If a Microsoft C/C++ compiler can recognize and remove useless code, why not a C# compiler? AFAIK Sun worked very hard to get the performance of Java up to a reasonable level. Why wouldn't Microsoft do the same? Try testing something where all of the code is essential to producing the desired result.
Title: Re: is there some assembler for IA32?
Post by: Ficko on December 29, 2009, 09:21:22 AM
Quote
I tried to determine which one was faster... and I tested with MASM/C++/Fortran/C#.NET, basically just through some repetitive arithmetic operations. It turned out that Fortran wasn't nearly as fast as some boasted, and MASM lost to C#.NET. So I was amazed. Shouldn't assembly be the fastest? There was no optimization in the C# compiler, but it did ran faster than MASM. And I guess it might be related to the IA32 framework? Aafter all MASM is such an old thing now... Is there an assembler for IA32 somewhere? or just some recently made assemblers for me to give some try?
Reading your "logic" I think you have some big holes in your basic education about computer science. :bg
Look up such things as "machine code", "native code", "bytecode", "assembler", "CPU", "JIT".
Quote
"Aafter all MASM is such an old thing now..."
It doesn't matter how old an assembler is.
You can take an assembler from the 80'es running it on a computer from the 80's and if you are a smart programmer you can beat C# easily by comparing average run time.
C# is a front end for a "JIT".
This means it has to compile your code before it can run it.
Lot of people call "JIT" being an interpreter because it is actually more close to an interpreter as to a compiler and a lot of things that applies for an interpreter which makes them slow applies to a "JIT" as well.
Even if your precompiled assembly cash is huge it has to go through a lot of dependency adjustment etc.

Quote
"Is there an assembler for IA32 somewhere?"
I do not know what you mean by that but if you are being a masochist you can try "ILasm". :toothy
Title: Re: is there some assembler for IA32?
Post by: rags on December 29, 2009, 10:37:37 AM
Ficko I think he's a bit confused about the names and thinks IA32 is something different
from x86.
Title: Re: is there some assembler for IA32?
Post by: houyunqing on December 29, 2009, 02:12:51 PM
ah... thanks guys i found my ASM code and realized i was just wasting your time... ASM is indeed the fastest... sorry... haven't been dealing with those stuffs and forgot quite a lot. 
Title: Re: is there some assembler for IA32?
Post by: brethren on December 29, 2009, 04:00:23 PM
Quote from: dedndave on December 28, 2009, 10:58:05 PM
Quotec# compiles into bytecode that runs on a virtual machine, there is no way it could be faster than handcrafted asm

huh ?   :eek

http://en.wikipedia.org/wiki/Common_Intermediate_Language
Title: Re: is there some assembler for IA32?
Post by: dedndave on December 29, 2009, 04:43:02 PM
that applies to .NET
Title: Re: is there some assembler for IA32?
Post by: GregL on December 29, 2009, 06:37:50 PM
Dave,

C# is a .NET compiler.

Title: Re: is there some assembler for IA32?
Post by: redskull on December 30, 2009, 02:28:15 AM
Quote from: dedndave on December 29, 2009, 04:43:02 PM
that applies to .NET

C#, VB.NET, and J# are all essentially the same language (.NET); each is a different syntax that produces the same intermediate code (CLI), which executes in a VM similar to Java.  They are, in every respect, all the same language

http://en.wikipedia.org/wiki/File:Overview_of_the_Common_Language_Infrastructure.svg

-r