- 19,371
- 15,580
I don't think assemblers HAVE optimization. The assumption is that you mean exactly what you write.FactChecker said:I assume that modern assemblers have the same optimization options that higher level language compilers have.
I don't think assemblers HAVE optimization. The assumption is that you mean exactly what you write.FactChecker said:I assume that modern assemblers have the same optimization options that higher level language compilers have.
A wizard is never buggy. He writes precisely what he means to.phinds said:I don't think assemblers HAVE optimization. The assumption is that you mean exactly what you write.
That is correct. Assemblers don't optimize.phinds said:I don't think assemblers HAVE optimization. The assumption is that you mean exactly what you write.
Ok. I'll buy that.phinds said:I don't think assemblers HAVE optimization. The assumption is that you mean exactly what you write.
The case I cited above was an mass-produced embedded system with heat limitations. The issue isn't "as fast as possible" but simply "fast enough to keep up with a real time data stream". Moving to a faster processor would have caused too much heat and too much electric consumption - and the additional cost would have made the product much less competitive. As processors advance, we upgrade to the new technology, become experts in the new architecture, and create improved product. Sometimes that means assembly. But the total assembly is always way less than 1% of the code.Khashishi said:Consider that in order to craft more optimized assembly than a compiler for a particular computer architecture, you need to be an expert at that particular architecture. And if you want it to run optimally on another computer, you'll have to find an expert to rewrite it for that computer. One of the best ways to improve the performance of a code is to run it on a faster system. If you hand craft it in assembly, you lose that option.
If you must get it to run as fast as possible, you should probably write it in FORTRAN or C.
TheOldFart said:I would argue that assembly language is *not* faster in anything other than perhaps the smallest microcontrollers.
Indeed. I used to work in the MS Windows Division, and had access to the Windows code base. I remember seeing some video driver code with a few lines of inline assembly, possibly for lighting up pixels in display memory (that was about 10 or so years ago, so was somewhere in the XP or Vista timeframe)..Scott said:Still, there are cases where a particular block of code needs to be executed as fast as possible - either because a very rapid response is needed or (more likely) that block of code is executed millions of times. In such cases, the first strategy is to devise an algorithm that is fast and allow certain optimizations, like placing functions inline to the main program and flatting loops. Many compilers will provide options for doing exactly this - and those optimizations can be applied specifically to the section of code that requires it.
But if all that is not enough, sometimes assembly code can be crafted that is substantially faster than compiler-generated assembly.
I think practically all the posts are talking about execution speed, not compilation speed. There may be an exception or two.ChrisVer said:Also one thing that seems unclear to me, is the speeding happening in the compilation time or for the program's runtime? In terms for an IDE during Building or during Running your code?
I agree. The time it takes to compile is of little concern--the goal usually is to get the program to run faster.FactChecker said:I think practically all the posts are talking about execution speed, not compilation speed.
First, no computer programmer is going to "dis" any potentially valuable tool. Assembly has huge disadvantages in the areas of maintainability and portability. In the example I gave, it was a multi-core processor, but even so the best product solution required assembly code.ChrisVer said:So far the inputs tend to dissing assembly over the usage of several cores for speeding up the process...? So ASM seems to be losing the privilege it's so proud of?
I've been following this thread closely, and to the best of my knowledge, no one is comparing assembly language and machine code.TMT said:What would be answer for "why we are using assembler and not using machine code?"
And even more, the analogy would be pretty pointless since assembly and machine are the SAME code whereas assembly vs higher level is a comparison of different languages. @TMT , I think you're off base on this one.Mark44 said:I've been following this thread closely, and to the best of my knowledge, no one is comparing assembly language and machine code.
I think both of you could not catch the idea by this example. I mean assembler may be count as high level languages if you consider a program (assembler) takes some line of instruction and create machine code. Same as high level language a program (compiler) takes lines of expression and (mostly) creates assembler (text code) than assembler creates machine code from it. Same pattern implemented. I'm telling that if a program (compiler) taken expression lines process and produce assembler text we can insert more intelligent logic producing assembler text. This logic will help us more.Mark44 said:The question being asked is "why would one choose assembly language over a high-level language?"
no my friend they are not same. One is text (ascii) while other is binaries expressed in numbers. Assembler is providing labels make life easier for addressing. you have to calculate address in machine code. I'm not offering to use machine code. I try to emphasis the design pattern on assembler and high level both aim to help programmerphinds said:ntless since assembly and machine are the SAME code whereas assembly vs higher level is a comparison of different languages. @TMT , I think you're off base on this one
That is NOT a reasonable use of the term "high level language". Assembly is specifically NOT a higher level language. For one thing, assembly is machine code which means there is no possibility of it being independant of the CPU it was written for. Higher level languages are not written for specific CPU's, they are written for humans.TMT said:I think both of you could not catch the idea by this example. I mean assembler may be count as high level languages if you consider a program (assembler) takes some line of instruction and create machine code.
You are completely missing the point. They are the same in that a line of assembly creates a line of machine code. A line of a higher level language can create THOUSANDS of lines of machine code.no my friend they are not same.
Assembly code might have been considered a "high-level" language back in the 1950s, before the advent of true high-level languages such as COBOL and Fortran, but no one today would consider any assembly language as "high level."TMT said:I think both of you could not catch the idea by this example. I mean assembler may be count as high level languages if you consider a program (assembler) takes some line of instruction and create machine code.
I'm going to disagree with you here, Paul, and side with TMT.phinds said:That is NOT a reasonable use of the term "high level language". Assembly is specifically NOT a higher level language. For one thing, assembly is machine code
sub esp,8
83 EC 08
phinds said:which means there is no possibility of it being independant of the CPU it was written for. Higher level languages are not written for specific CPU's, they are written for humans.
NO NOT assembler isphinds said:assembly is machine code
you can't run assembly program before assembling and linkage editing staff.phinds said:written for humans.
this is not true also simple branch is almost same with assembler code generation while using a macro line in assembler will produce several lines.phinds said:You are completely missing the point. They are the same in that a line of assembly creates a line of machine code. A line of a higher level language can create THOUSANDS of lines of machine code.
Which is exactly the point. They are not identical character by character obviously but they are identical in meaning. There is no such relationship between machine code and higher level languages. I know you understand this but it is not just semantics, it's an important distinction. In the early days there was what was widely known as "the principle of one to one correspondance" which stated that a line of assembly is exactly a line of machine code. The advent of macro assemblers began to blur that slightly but it was still close enough for government work.Mark44 said:Clearly they are different, but as you say, one assembly instruction corresponds to one chunk of machine code.
I'd try to give a few arguments to support TMT:phinds said:@TMT I see no point in arguing the point further. We clearly disagree with each other.
;i'm a comment translate to nothing
imalabel: ;translates to nothing
jmp imalabel ;there's some logic needed to translate this to machine code
db 1
db 2
db 3 ; translates to 1 chunk of machine code
It is. He was just making the fairly pointless point that the binary of the ASCII chars of assembly instructions are different than the binary characters of the resulting machine code.ChrisVer said:Wait, I am confused- why is jmp an example for not 1-to-1 correspondance between assembly and machine code?