Ahh, but a compiler won't give you a more efficient program if you used a heap sort when a shell sort or a quicksort would have been better. If you scale that sort of optimization down to an assembly level, that's really what I'm looking to accomplish. Perhaps I'm going about it the wrong way?
I'm sure almost any psychologist would have a field day with me.
And it isn't supposed to. That wasn't my point, at all. The boring things about instructions are managed by the compiler, choosing the correct algorithm and/or data structure is what makes your code better, independent of the programming language.
Not sure about that. In my mind, I picture that once you have everything up in memory, however it gets processed won't matter, or if it does, it will be minimal using the same algorithm.
This kinda remind me of the gentoo crowd.
But more importantly, it reminds me of myself. I used to be the "DIY" kid. If I wanted a linked list, I would code it myself, to get a specialized list, that does what I want, and does it optimal for my solution.
But then again, the solution I built is "too specific", later I find myself wanting to have a more generic list, a list that can do other things, so I code them accordingly, and end up having a completely generic list.
On the process of having a generic list, I dumped everything that made the list specialized, therefore, I removed the single advantage I thought I would gain by making my own list.
And this is nothing wrong, abstractions exist for a reason, someone, somewhere, realized that a single problem was repeating way too much, so decided that he would do a generic solution trying to satisfy every possible scenario, therefore, providing a solution to the problem and creating a more abstract construct.
A set of abstract constructs that can speak to each other on the same level (for instance, not going lower, eg. Imagine that a java function suddenly wants a int *pointer, it would break the abstraction layer). Then the whole abstraction shifts to a higher one.
Your idea of moving algorithms to lower level languages is not wrong, but the whole point of Programming languages is that they build a layer on top of an older one, being the most basic one, the hardware. So pushing algorithms closest to hardware, implies a gain in speed, but a decrement in genericness, and losing touch with higher-level interfaces that would probably make a better use of said functions on the long run.
And how do I know this much about abstractions? Or where this theory comes? From the Systems Theory. I embraced the Hollistic viewpoint of things.
"Just in terms of allocation of time resources, religion is not very efficient. There's a lot more I could be doing on a Sunday morning."
-Bill Gates
GCC is basically a dude with a long UNIX beard. He has an expert knowledge of the internals of modern CPUs. He has been studying assembly optimization for years. And he lets you write code in C and he will put his expertise to work for you hand optimizing all that C code into very performant assembly code.
Proud GNU/Linux zealot and lover of penguins
"Value your freedom or you will lose it, teaches history." --Richard Stallman
Yes, the Intel compiler is more likely to spontaneously use SIMD instructions via auto-vectorization. GCC 4.4 has much improved in this regard.. I think if you will benchmark GCC against Intel's compiler suite you might be surprised.
Regardless I believe there are very few places where a programmer even one needing to do optimization will ever need to write assembly.
There exists libraries such as AMD's Math Library, or Intel's performance primitives, which are written with extremely optimized assembly routines and cover a wide scope of mathematical algorithmic primitives. Open source libraries like FFWT or the GNU Scientific Library are similar.
These numerical libraries or GNU/Intel compilers are written by experts who understand processor optimization very well. It's unlikely unless you too are an expert that you will outdo them.
As long as you write in C or Python improvements to the tooling will ensure your programs can continue to run faster. Can you say the same for assembly?
Look at PyPy or unladen-swallow: completely unmodified Python programs run faster. I believe that because you have richer metadata. In theory you have more to work with, for optimization. I believe in 10-20 years from now people might be rewriting their assembly routines in Python or Ruby for optimization purposes.
Last edited by phrostbyte; October 5th, 2009 at 07:46 AM.
Proud GNU/Linux zealot and lover of penguins
"Value your freedom or you will lose it, teaches history." --Richard Stallman
At first one little note: assembly is mainly useful in order to understand how computer works(which is a must if one wants to call himself/herself programmer), after that one can always use "asm" block in C/C++ if needed
About the stack, well it's FILO, but you can access everything with SP+value(assuming resulting address is valid), and one need to managed SP(and in general different architecture have a different understanding of it). Btw, biggest reason that Macs where platform of choice for every musician - it was simply faster and better, most notably PPC has a lot more registers
There's also something called compiler intrinsics which let programmer tell to "everything" knowing compiler that in some places...well, compilers just sucks and better left the job done by human(after all only person who write the program knows that algorithm need cache flush at specific time in order to be useful).
P.S. I'm amazed how thread about assembly start to not have anything to do with assembly, but more with other languages... come on! If you don't know something about the topic stop flooding and make another thread about abstractions and is it useful and when!
P({})
That's all I'm trying to do.
I may have seen that before, but I still laughed out loud this time.
Well put.
Assembly is intrinsic to a better understanding of other languages. It's only natural that almost any thread about assembly gets derailed. My initial question was answered already anyways.Originally Posted by grayrainbow
JWasm is is a MASM clone that runs in linux. Haven't tried it though...
Bookmarks