Re: Asm programming capability?
- From: user923005 <dcorbit@xxxxxxxxx>
- Date: Wed, 10 Jun 2009 16:29:23 -0700 (PDT)
On Jun 10, 3:19 pm, "cr88192" <cr88...@xxxxxxxxxxx> wrote:
"Antoninus Twink" <nos...@xxxxxxxxxxxxxx> wrote in message
On 10 Jun 2009 at 17:47, cr88192 wrote:
inline asm is less of a hassle than external ASM, but then it is compiler
specific (and, in the GCC case, forces use of GAS syntax, ...).
To be honest, that one seemingly trivial difference is enough to make me
use externally assembled asm on the rare occasions I need it. Though I
vaguely remember reading somewhere that gcc is doing an increasingly
good job of accepting Intel syntax - I don't know if it's reached the
stage of being really usable yet?
I hadn't heard of it, I may go look into this...
now, if gcc's inline assembler was like Borland's or Microsoft's
inline ASM (AKA: much nicer looking, and Intel syntax), I would
probably use inline ASM...
Exactly. Not one of the GNU folks' better design decisions IMO.
oddly, my compiler doesn't really support inline ASM at present...
then again, if it did, I would probably use the Borland or MS style...
Inline assembly is (IMO) a pretty bad idea in general.
_asm mov ax, 0xf ; move 15 into the AX register of our 8086
_asm mov eax, 0xf; move 15 into the EAX register of our P4
_asm mov rax, 0xf; move 15 into the RAX register of our AMD 64
You will notice something strange about the above instructions which
all accomplish the same purpose. The names of the registers have
changed over time. So assembly code ages until it becomes useless.
Back in the bad old days, we had to calculate segments and offsets to
make an address. Now we have easier ways due to the larger address
space. So the techniques change over time. Also, the clever things
like XOR ax,ax to put a zero in ax fastest are not as clever as they
used to be since mov rax,0 is just as good now-days. And the
registers also widen over time. The ax register only held 16 bits.
In short, inline assembly is a mistake. It will obsolete your code
totally in a few years. And when the new whiz-bang chip comes out,
you will be doing a full rewrite.
Once in a great while, it is an evil necessity. But most of the time,
it is a choice you will rue in a few years if you decide to do it now.
- Prev by Date: Re: pointer
- Next by Date: Re: pointer
- Previous by thread: Re: Asm programming capability?
- Next by thread: Re: Asm programming capability?