NO

Author Topic: Best way to "do" assembler in POIDE  (Read 9180 times)

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 1581
Re: Best way to "do" assembler in POIDE
« Reply #15 on: July 28, 2012, 09:36:31 AM »
I don't know what happen to my browser, but it removed the post from Tater.
I report it below.
Sorry.

Common Tater
Everybody want make programs, nobody want waste time studying basic concepts.....  :(

:D  Last week I couldn't spel progrimmer ... This week I are one!

Offline Vortex

  • Member
  • *
  • Posts: 484
    • http://www.vortex.masmcode.com
Re: Best way to "do" assembler in POIDE
« Reply #16 on: July 28, 2012, 09:46:10 AM »
[Pelle:] Mixing C and inline assembly code is almost always a bad idea; It will usually lead to the slowest and most bloated code. Using __declspec(naked) and writing the entire function body is better, but the best is to use a separate assembler.

Hi akko,

I guess you didn't interpret correctly Pelle's statement. Mixing C and inline is not recommended as this will degradate performance. The reason is that inline assembly will interfere with the C\C++ compiler's optimization engine.
Code it... That's all...

CommonTater

  • Guest
Re: Best way to "do" assembler in POIDE
« Reply #17 on: July 28, 2012, 10:11:57 AM »
I don't know what happen to my browser, but it removed the post from Tater.
I report it below.
Sorry.

Common Tater
Everybody want make programs, nobody want waste time studying basic concepts.....  :(

:D  Last week I couldn't spel progrimmer ... This week I are one!


No worries, I was just making a joke, it's not like anything important was lost.

JOE++

  • Guest
Re: Best way to "do" assembler in POIDE
« Reply #18 on: January 09, 2015, 06:25:08 AM »
I understand that Pelles C optimizer and new inliner can sometimes get "out of step" when it has to digest a chunk of asm statements. But when and how often is sometimes? What is the REAL penalty if you have just a few asm lines in your code? How do other C compilers behave?
Well, what do you REALLY gain using assembler?

Ralf

Have you programmed in serious assembly before?

Offline Bitbeisser

  • Global Moderator
  • Member
  • *****
  • Posts: 754
Re: Best way to "do" assembler in POIDE
« Reply #19 on: January 09, 2015, 07:01:17 PM »
I understand that Pelles C optimizer and new inliner can sometimes get "out of step" when it has to digest a chunk of asm statements. But when and how often is sometimes? What is the REAL penalty if you have just a few asm lines in your code? How do other C compilers behave?
Well, what do you REALLY gain using assembler?

Ralf

Have you programmed in serious assembly before?
Yes, ever since I got started with programming back in 1976. 6502, Z80, x86, 6809, 68k, ...

Ralf

JOE++

  • Guest
Re: Best way to "do" assembler in POIDE
« Reply #20 on: January 10, 2015, 01:58:17 AM »
Yes, ever since I got started with programming back in 1976. 6502, Z80, x86, 6809, 68k, ...

Ralf
[/quote]

Good for u. Then u should know programmers can GAIN a lot by doing some things in assembly. In fact, for the part where you said assembly is buggy, it is the other way around. C programmers often rely on assembly / debugger listing to find their hard-to-trace bugs. Not the other way around. My assembly library is strong enough to make my C program skip <stdio.h> and <math.h> entirely and I still get twice the speed and half the size of typical C program relying on those two standard headers. That's a big GAIN especially on embedded system.

It is not good to give people misleading statements when in the end C is compiled to machine binaries anyway.

Offline Bitbeisser

  • Global Moderator
  • Member
  • *****
  • Posts: 754
Re: Best way to "do" assembler in POIDE
« Reply #21 on: January 11, 2015, 06:18:09 AM »
Quote
Yes, ever since I got started with programming back in 1976. 6502, Z80, x86, 6809, 68k, ...

Ralf

Good for u. Then u should know programmers can GAIN a lot by doing some things in assembly.
As with a lot in life, "it depends"...
Quote
In fact, for the part where you said assembly is buggy, it is the other way around.
Please quote the sentence where I said that!
Quote
C programmers often rely on assembly / debugger listing to find their hard-to-trace bugs. Not the other way around. My assembly library is strong enough to make my C program skip <stdio.h> and <math.h> entirely and I still get twice the speed and half the size of typical C program relying on those two standard headers. That's a big GAIN especially on embedded system.
You are comparing apples and oranges here.
Yes, in some cases, you can gain some benefit from programming in assembler, for certain, limited use cases. And as far as embedded programming goes, I have done my fair share of this and rarely bother with assembler these days. For example, for the popular Arduino boards which use the 8bit Atmel AVR RISC micro-controllers, you barely gain anything by using assembler, as Atmel designed the chips and their instruction sets right from the start with view on allowing a C compiler to produce the most optimal code by consulting a C compiler developer company (IAR in Sweden) during the initial chip design phase. And the GCC based AVR compiler used by Arduino is producing pretty identically optimized code. Trying to get a couple of bytes here and there is a waste of time and energy in that case.
Quote
It is not good to give people misleading statements when in the end C is compiled to machine binaries anyway.
Why is it "misleading"? You use the best tool for the case. And in a lot of cases (and in case of Pelle's C, and that includes POIDE) when programming for Windows based code, you can rather gain a lot more by concentrating on your program concepts and the algorithms used rather than trying to do things in assembler. That applies to personal use cases and even more so for anything serious/professional.

It is rather a myth that assembler is always better/faster/more efficient...

Ralf

Offline jj2007

  • Member
  • *
  • Posts: 447
Re: Best way to "do" assembler in POIDE
« Reply #22 on: January 11, 2015, 10:35:27 AM »
It is rather a myth that assembler is always better/faster/more efficient...

- "faster": It is a myth that C compiler can produce code that is as fast as hand-crafted assembler code; in the Masm32 lab, we typically get a factor three on CRT routines. However, there are examples where the CRT can compete - and if you look under the hood, you may find out that the compiler found by accident exactly the same sequence as the experienced assembler programmer ;-)

- "better": Difficult to define, but code size is definitely much smaller. OTOH, maintenance is more difficult, unless it's your own code and it's well documented. Many people claim "portability" as an argument, but 1. x86 is everywhere nowadays, Mac and Linux included and 2. I have yet to see a truely portable hello world proggie that comes along with less than a megabyte for exe plus runtime/dll size.

- "more efficient": C programmers often claim that assembler takes a lot of time, but they judge by their own time, which is comparing apples and oranges. For myself, for example, it takes a lot of time to write a simple program in C, simply because I have a huge experience in assembler and little in C. For the great majority of coders, it's the other way round: huge experience in C but maybe only a few thousand lines in assembler. And obviously, for them C is "more efficient".

Besides, there is a bunch of idiots who insist that assembler must be the language that existed before Microsoft added macros to asm and called it MASM.

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 1581
Re: Best way to "do" assembler in POIDE
« Reply #23 on: January 11, 2015, 12:19:10 PM »
I would point-out that you are all right.  8)
As I said in a previous post the use of one language or another depends on the specific task. Using the motto borrowed from my americans collegues: "Use the right tool for the right job!".  ;D
JJ said that sometimes a compiler found the exact sequence that an experienced programmer would have used, this is not magic simply the process is the same for a human and the compiler: a well known code sequence have a well known assembly sequence. Who coded the compiler added the correct strategy for that case and that's all.  :)
Of course providing the compiler with all possible code variations optimized strategy is impossible, so maybe you want to consider the average...
The portability is an issue, consider the Linux OS, you can found kernels for almost whatever processor or hardware actually existing on the face of the earth. What if it would have been wrote all in assembler? Also in this case you'll find the demonstration that the assembler still is foundamental because some tasks cannot be done in 'C'. In fact looking at sources you'll discover many assembler modules. Of course that modules *must* be rewritten for each hardware they are intended to.

For the sake of portability some trials were made to create a 'portable' assembler, meta-assemblers that define an abstract instruction set that would be tailored to the target processor during compilation, but this is still a compilation and the result is not guaranted to be 1:1 with pure assembler.

Portability last frontier nowadays seems to be Java, that defines a virtual machine that runs on each platform.

Last we don't need to be foundamentalists of a language ... unfortunately there are too many of them out there ...  :-X
« Last Edit: January 11, 2015, 12:23:11 PM by frankie »

Offline jj2007

  • Member
  • *
  • Posts: 447
Re: Best way to "do" assembler in POIDE
« Reply #24 on: January 11, 2015, 02:35:38 PM »
JJ said that sometimes a compiler found the exact sequence that an experienced programmer would have used, this is not magic simply the process is the same for a human and the compiler: a well known code sequence have a well known assembly sequence. Who coded the compiler added the correct strategy for that case and that's all.  :)

Who coded the compiler ... translates C source code to assembler, so they must be excellent assembler programmers ;-)

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 1581
Re: Best way to "do" assembler in POIDE
« Reply #25 on: January 11, 2015, 03:04:38 PM »
Who coded the compiler ... translates C source code to assembler, so they must be excellent assembler programmers ;-)
You're absolutely right!  ;)
Maybe we can consider that without excellent assembler programmers is hard to have good compilers...  ;D ;D
« Last Edit: January 11, 2015, 03:06:11 PM by frankie »

czerny

  • Guest
Re: Best way to "do" assembler in POIDE
« Reply #26 on: January 11, 2015, 05:52:54 PM »
Btw. has meanwhile anyone answered the initial question 'Best way to "do" assembler in POIDE'?

Grincheux

  • Guest
Re: Best way to "do" assembler in POIDE
« Reply #27 on: March 19, 2015, 06:19:19 PM »
A good IDE : PELLES or RADASM and an assembler ML32 or ml64.
After a good debugger is important too, MS has the best.