Inline asm support and x64 development (Off Topic)

This example means nothing. It’s not that a single “asm” statement disables
optimization globally. It’s that “asm” statements force the compiler to
make extremely conservative assumptions when it is doing data-flow analysis
and call analysis, and also in register usage. A more meaningful example
would contain a function with a significant number of local variables, doing
non-trivial things, and would show that the compiler must assume that
registers *could* have been modified by the “asm” block, and will therefore
reload local variables into registers, etc.

– arlie

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Satya Das
Sent: Monday, October 03, 2005 3:05 PM
To: Kernel Debugging Interest List
Subject: RE: [windbg] Inline asm support and x64 development (Off Topic)

It seems some have expressed doubts about this ie. continue to believe that
introducing inline assembly basically disables optimization. So here is an
example just to demonstrate this. I compiled this in .NET
2003 -

int SimpleFunc(int param1, int param2)
{
if (2 > param1)
return param1-param2;
else
return param1;
}
int _tmain()
{
//_asm nop;
return SimpleFunc(5, 3);
}

Optimization disabled main looked like this (/Od and sans /Og)

_main:
00401016: 55 push ebp
00401017: 8B EC mov ebp,esp
00401019: 90 nop
0040101A: 6A 03 push 3
0040101C: 6A 05 push 5
0040101E: E8 DD FF FF FF call _SimpleFunc
00401023: 59 pop ecx
00401024: 59 pop ecx
00401025: 5D pop ebp
00401026: C3 ret

With optimization main looked like this

_main:
00401000: 6A 05 push 5
00401002: 58 pop eax
00401003: C3 ret

With inline assembly and optimizations main looked like this
_main:
00401000: 90 nop
00401001: 6A 05 push 5
00401003: 58 pop eax
00401004: C3 ret

Whole program optimization was turned off for this example. You can try more
inline assembly if you are enterprising. But the conclusion is this,
functions with inline assembly *do* get optimized.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Satya Das
Sent: Saturday, October 01, 2005 5:42 PM
To: Kernel Debugging Interest List
Subject: RE: [windbg] Inline asm support and x64 development (Off Topic)

Your statement about how optimizer behaves with functions with inline
assembly is wrong. In general, functions do get optimized even with inline
assembly. Optimizer in fact may not know in some platforms/tool versions
whether a function was partly inline assembly or not.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Don Burn
Sent: Saturday, October 01, 2005 3:54 AM
To: Kernel Debugging Interest List
Subject: Re:[windbg] Inline asm support and x64 development (Off Topic)

I’m not kidding, I used to be a compiler guy. When you go with inline
assembler the first thing the compiler recognizes is that it cannot safely
optimize. So that clever set of assembler instructions in the middle of the
function, makes the whole function unoptimized. Second, do you really know
the fastest approach for things? Good compilers work like crazy on this.

The scary thing on this is, I’ve been doing compilers and operating systems
for 30 years. I’ve had this argument that long, with the results when
someone REALLY CHECKED always being the same, get rid of the assembler.


Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting Remove StopSpam from the
email to reply

“Satya Das” wrote in message news:xxxxx@windbg…
You are kidding right ? I am sure the improvements were not because assembly
was used, but because of other factors. In any case there is a reason why
inline assembly was put in the language of C. As long as I have the choice I
am good.

>This is funny, every driver I’ve worked with that had assembler for
optimizations worked better and faster >once it was eliminated.

Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting Remove StopSpam from the
email to reply


You are currently subscribed to windbg as: xxxxx@appstream.com To
unsubscribe send a blank email to xxxxx@lists.osr.com


You are currently subscribed to windbg as: xxxxx@appstream.com To
unsubscribe send a blank email to xxxxx@lists.osr.com


You are currently subscribed to windbg as: unknown lmsubst tag argument:
‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com


You are currently subscribed to windbg as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

My point was to show that *an* optimization was still in effect with
inline assembly in the function. It is left to everyone to experiment
and find out what happens in your functions. I am not saying that this
is not trickier to achieve for the tools and yeah inline assembly is a
factor. I am just saying that the optimizer is not that dumb.

And I don’t want to hear functions are left unoptimized if there is
inline assembly.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Arlie Davis
Sent: Monday, October 03, 2005 12:14 PM
To: Kernel Debugging Interest List
Subject: RE: [windbg] Inline asm support and x64 development (Off Topic)

This example means nothing. It’s not that a single “asm” statement
disables optimization globally. It’s that “asm” statements force the
compiler to make extremely conservative assumptions when it is doing
data-flow analysis and call analysis, and also in register usage. A
more meaningful example would contain a function with a significant
number of local variables, doing non-trivial things, and would show that
the compiler must assume that registers *could* have been modified by
the “asm” block, and will therefore reload local variables into
registers, etc.

– arlie

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Satya Das
Sent: Monday, October 03, 2005 3:05 PM
To: Kernel Debugging Interest List
Subject: RE: [windbg] Inline asm support and x64 development (Off Topic)

It seems some have expressed doubts about this ie. continue to believe
that introducing inline assembly basically disables optimization. So
here is an example just to demonstrate this. I compiled this in .NET
2003 -

int SimpleFunc(int param1, int param2)
{
if (2 > param1)
return param1-param2;
else
return param1;
}
int _tmain()
{
//_asm nop;
return SimpleFunc(5, 3);
}

Optimization disabled main looked like this (/Od and sans /Og)

_main:
00401016: 55 push ebp
00401017: 8B EC mov ebp,esp
00401019: 90 nop
0040101A: 6A 03 push 3
0040101C: 6A 05 push 5
0040101E: E8 DD FF FF FF call _SimpleFunc
00401023: 59 pop ecx
00401024: 59 pop ecx
00401025: 5D pop ebp
00401026: C3 ret

With optimization main looked like this

_main:
00401000: 6A 05 push 5
00401002: 58 pop eax
00401003: C3 ret

With inline assembly and optimizations main looked like this
_main:
00401000: 90 nop
00401001: 6A 05 push 5
00401003: 58 pop eax
00401004: C3 ret

Whole program optimization was turned off for this example. You can try
more inline assembly if you are enterprising. But the conclusion is
this, functions with inline assembly *do* get optimized.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Satya Das
Sent: Saturday, October 01, 2005 5:42 PM
To: Kernel Debugging Interest List
Subject: RE: [windbg] Inline asm support and x64 development (Off Topic)

Your statement about how optimizer behaves with functions with inline
assembly is wrong. In general, functions do get optimized even with
inline assembly. Optimizer in fact may not know in some platforms/tool
versions whether a function was partly inline assembly or not.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Don Burn
Sent: Saturday, October 01, 2005 3:54 AM
To: Kernel Debugging Interest List
Subject: Re:[windbg] Inline asm support and x64 development (Off Topic)

I’m not kidding, I used to be a compiler guy. When you go with inline
assembler the first thing the compiler recognizes is that it cannot
safely optimize. So that clever set of assembler instructions in the
middle of the function, makes the whole function unoptimized. Second,
do you really know the fastest approach for things? Good compilers work
like crazy on this.

The scary thing on this is, I’ve been doing compilers and operating
systems for 30 years. I’ve had this argument that long, with the
results when someone REALLY CHECKED always being the same, get rid of
the assembler.


Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting Remove StopSpam from
the email to reply

“Satya Das” wrote in message news:xxxxx@windbg…
You are kidding right ? I am sure the improvements were not because
assembly was used, but because of other factors. In any case there is a
reason why inline assembly was put in the language of C. As long as I
have the choice I am good.

>This is funny, every driver I’ve worked with that had assembler for
optimizations worked better and faster >once it was eliminated.

Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting Remove StopSpam from
the email to reply


You are currently subscribed to windbg as: xxxxx@appstream.com To
unsubscribe send a blank email to xxxxx@lists.osr.com


You are currently subscribed to windbg as: xxxxx@appstream.com To
unsubscribe send a blank email to xxxxx@lists.osr.com


You are currently subscribed to windbg as: unknown lmsubst tag argument:
‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com


You are currently subscribed to windbg as: unknown lmsubst tag argument:
‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com


You are currently subscribed to windbg as: xxxxx@appstream.com To
unsubscribe send a blank email to xxxxx@lists.osr.com

Frankly, I find your argument totally irrelevant. I really could care less
about optimization in, around, or through your hackery.

The real point is that if I go out and pay big bucks for a system dependent
on your kernel mode hackery, I don’t want to wait for you to get off your
ass and “fix” your hackery simply because your inline assembly hackery works
ONLY on one processor, and I now have requirements to use a processor
supported by the OS, but which will barf on your egomaniacal hicky.

Assembly code, whether inline or assembled and linked from separate source,
limits you to that processor family … period. That’s fine if you want
in-house code that will never ever see the shelf in a CompUSA. No one here
will argue with what you do to your own machines, just don’t try to sell it
to me in your next super whiz bang release.


The personal opinion of
Gary G. Little

“Satya Das” wrote in message news:xxxxx@windbg…
My point was to show that an optimization was still in effect with
inline assembly in the function. It is left to everyone to experiment
and find out what happens in your functions. I am not saying that this
is not trickier to achieve for the tools and yeah inline assembly is a
factor. I am just saying that the optimizer is not that dumb.

And I don’t want to hear functions are left unoptimized if there is
inline assembly.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Arlie Davis
Sent: Monday, October 03, 2005 12:14 PM
To: Kernel Debugging Interest List
Subject: RE: [windbg] Inline asm support and x64 development (Off Topic)

This example means nothing. It’s not that a single “asm” statement
disables optimization globally. It’s that “asm” statements force the
compiler to make extremely conservative assumptions when it is doing
data-flow analysis and call analysis, and also in register usage. A
more meaningful example would contain a function with a significant
number of local variables, doing non-trivial things, and would show that
the compiler must assume that registers could have been modified by
the “asm” block, and will therefore reload local variables into
registers, etc.

– arlie

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Satya Das
Sent: Monday, October 03, 2005 3:05 PM
To: Kernel Debugging Interest List
Subject: RE: [windbg] Inline asm support and x64 development (Off Topic)

It seems some have expressed doubts about this ie. continue to believe
that introducing inline assembly basically disables optimization. So
here is an example just to demonstrate this. I compiled this in .NET
2003 -

int SimpleFunc(int param1, int param2)
{
if (2 > param1)
return param1-param2;
else
return param1;
}
int _tmain()
{
//_asm nop;
return SimpleFunc(5, 3);
}

Optimization disabled main looked like this (/Od and sans /Og)

_main:
00401016: 55 push ebp
00401017: 8B EC mov ebp,esp
00401019: 90 nop
0040101A: 6A 03 push 3
0040101C: 6A 05 push 5
0040101E: E8 DD FF FF FF call _SimpleFunc
00401023: 59 pop ecx
00401024: 59 pop ecx
00401025: 5D pop ebp
00401026: C3 ret

With optimization main looked like this

_main:
00401000: 6A 05 push 5
00401002: 58 pop eax
00401003: C3 ret

With inline assembly and optimizations main looked like this
_main:
00401000: 90 nop
00401001: 6A 05 push 5
00401003: 58 pop eax
00401004: C3 ret

Whole program optimization was turned off for this example. You can try
more inline assembly if you are enterprising. But the conclusion is
this, functions with inline assembly do get optimized.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Satya Das
Sent: Saturday, October 01, 2005 5:42 PM
To: Kernel Debugging Interest List
Subject: RE: [windbg] Inline asm support and x64 development (Off Topic)

Your statement about how optimizer behaves with functions with inline
assembly is wrong. In general, functions do get optimized even with
inline assembly. Optimizer in fact may not know in some platforms/tool
versions whether a function was partly inline assembly or not.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Don Burn
Sent: Saturday, October 01, 2005 3:54 AM
To: Kernel Debugging Interest List
Subject: Re:[windbg] Inline asm support and x64 development (Off Topic)

I’m not kidding, I used to be a compiler guy. When you go with inline
assembler the first thing the compiler recognizes is that it cannot
safely optimize. So that clever set of assembler instructions in the
middle of the function, makes the whole function unoptimized. Second,
do you really know the fastest approach for things? Good compilers work
like crazy on this.

The scary thing on this is, I’ve been doing compilers and operating
systems for 30 years. I’ve had this argument that long, with the
results when someone REALLY CHECKED always being the same, get rid of
the assembler.


Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting Remove StopSpam from
the email to reply

“Satya Das” wrote in message news:xxxxx@windbg…
You are kidding right ? I am sure the improvements were not because
assembly was used, but because of other factors. In any case there is a
reason why inline assembly was put in the language of C. As long as I
have the choice I am good.

>This is funny, every driver I’ve worked with that had assembler for
optimizations worked better and faster >once it was eliminated.

Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting Remove StopSpam from
the email to reply


You are currently subscribed to windbg as: xxxxx@appstream.com To
unsubscribe send a blank email to xxxxx@lists.osr.com


You are currently subscribed to windbg as: xxxxx@appstream.com To
unsubscribe send a blank email to xxxxx@lists.osr.com


You are currently subscribed to windbg as: unknown lmsubst tag argument:
‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com


You are currently subscribed to windbg as: unknown lmsubst tag argument:
‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com


You are currently subscribed to windbg as: xxxxx@appstream.com To
unsubscribe send a blank email to xxxxx@lists.osr.com

I’ve been reading this thread and getting a good chuckle every so often.
After reading Gary’s post, the following thoughts came to me. Thanks
to Gary for the colorful descriptions.

Fear and Propaganda:

  • Assembly Code = Hackery
  • Inline Assembly = Egomaniacal Hicky
  • Assembly limits compatibility more than C …period
  • Assembly will yield an unreliable product

Reality:

  • Poorly written code in any language = Hackery
  • Insistence on using poorly written code = Egomaniacal Hicky
  • Poorly designed code may limit compatibility (OS or HW)
  • Incompatible code may yield an unreliable product

The reliability of any driver is much more a function of design and
implementation than of language. Fight developer ignorance through
education, not fear and propaganda.

Proposed Education:

  • Assembly is almost always unnecessary for Windows driver development.
  • Assembly is more likely to enable the implementation of a poor design.
  • Successful assembly implementations require a much greater degree of
    knowledge than successful C implementations.
  • The benefits of using assembly vary rarely out way the effort required
    to ensure a successful implementation.
  • There may be rare occasions where the use of assembly is warranted
    and, if implemented properly will yield a perfectly reliable product.
  • If you believe that use of assembly is appropriate for a given
    problem, try consulting with your peers for alternatives. You may learn
    of a safer and easier method.

Regards,
Jim Allred

Gary G. Little wrote:

Frankly, I find your argument totally irrelevant. I really could care less
about optimization in, around, or through your hackery.

The real point is that if I go out and pay big bucks for a system dependent
on your kernel mode hackery, I don’t want to wait for you to get off your
ass and “fix” your hackery simply because your inline assembly hackery works
ONLY on one processor, and I now have requirements to use a processor
supported by the OS, but which will barf on your egomaniacal hicky.

Assembly code, whether inline or assembled and linked from separate source,
limits you to that processor family … period. That’s fine if you want
in-house code that will never ever see the shelf in a CompUSA. No one here
will argue with what you do to your own machines, just don’t try to sell it
to me in your next super whiz bang release.

I agree wholeheartedly. This discussion sounds more like religious war
than reasoned debate. Your response, Jim, is very well-written and I
don’t have much to add.

I would like to point out to the previous poster that writing a driver
in C does not make it “future-proof” any more than writing it in
assembler. You would still have to recompile your C driver for a new
processor before it would support the new features. Yes, I know that
recompiling a C driver is easier than rewriting assembler instructions
and I agree with the idea that assembler code in drivers is rarely
needed, but don’t stoop to such hyperbolic rhetoric in your posts.

Peter Waldschmidt

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Jim Allred
Sent: Tuesday, October 04, 2005 12:50 PM
To: Kernel Debugging Interest List
Subject: Re: [windbg] Inline asm support and x64 development (Off Topic)

I’ve been reading this thread and getting a good chuckle every so often.

After reading Gary’s post, the following thoughts came to me. Thanks
to Gary for the colorful descriptions.

Fear and Propaganda:

  • Assembly Code = Hackery
  • Inline Assembly = Egomaniacal Hicky
  • Assembly limits compatibility more than C …period
  • Assembly will yield an unreliable product

Reality:

  • Poorly written code in any language = Hackery
  • Insistence on using poorly written code = Egomaniacal Hicky
  • Poorly designed code may limit compatibility (OS or HW)
  • Incompatible code may yield an unreliable product

The reliability of any driver is much more a function of design and
implementation than of language. Fight developer ignorance through
education, not fear and propaganda.

Proposed Education:

  • Assembly is almost always unnecessary for Windows driver development.
  • Assembly is more likely to enable the implementation of a poor design.
  • Successful assembly implementations require a much greater degree of
    knowledge than successful C implementations.
  • The benefits of using assembly vary rarely out way the effort required

to ensure a successful implementation.

  • There may be rare occasions where the use of assembly is warranted
    and, if implemented properly will yield a perfectly reliable product.
  • If you believe that use of assembly is appropriate for a given
    problem, try consulting with your peers for alternatives. You may learn

of a safer and easier method.

Regards,
Jim Allred

Gary G. Little wrote:

Frankly, I find your argument totally irrelevant. I really could care
less
about optimization in, around, or through your hackery.

The real point is that if I go out and pay big bucks for a system
dependent
on your kernel mode hackery, I don’t want to wait for you to get off
your
ass and “fix” your hackery simply because your inline assembly hackery
works
ONLY on one processor, and I now have requirements to use a processor
supported by the OS, but which will barf on your egomaniacal hicky.

Assembly code, whether inline or assembled and linked from separate
source,
limits you to that processor family … period. That’s fine if you
want
in-house code that will never ever see the shelf in a CompUSA. No one
here
will argue with what you do to your own machines, just don’t try to
sell it
to me in your next super whiz bang release.


You are currently subscribed to windbg as: xxxxx@waldschmidt.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

Well put Jim. I agree with you on all counts.

Gary, I was mostly responding to Don Burn’s “So that clever set of
assembler instructions in the middle of the function, makes the whole
function unoptimized.” which is incorrect. Again if you don’t need it
that’s fine. Those who need it, use it and do wonders. Of course it can
be misused and so can everything else. Also chances are very high that
you are running some product that has inline assembly, I would leave it
to you to guess which product that is.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Jim Allred
Sent: Tuesday, October 04, 2005 9:50 AM
To: Kernel Debugging Interest List
Subject: Re: [windbg] Inline asm support and x64 development (Off Topic)

I’ve been reading this thread and getting a good chuckle every so often.

After reading Gary’s post, the following thoughts came to me. Thanks
to Gary for the colorful descriptions.

Fear and Propaganda:

  • Assembly Code = Hackery
  • Inline Assembly = Egomaniacal Hicky
  • Assembly limits compatibility more than C …period
  • Assembly will yield an unreliable product

Reality:

  • Poorly written code in any language = Hackery
  • Insistence on using poorly written code = Egomaniacal Hicky
  • Poorly designed code may limit compatibility (OS or HW)
  • Incompatible code may yield an unreliable product

The reliability of any driver is much more a function of design and
implementation than of language. Fight developer ignorance through
education, not fear and propaganda.

Proposed Education:

  • Assembly is almost always unnecessary for Windows driver development.
  • Assembly is more likely to enable the implementation of a poor design.
  • Successful assembly implementations require a much greater degree of
    knowledge than successful C implementations.
  • The benefits of using assembly vary rarely out way the effort required
    to ensure a successful implementation.
  • There may be rare occasions where the use of assembly is warranted
    and, if implemented properly will yield a perfectly reliable product.
  • If you believe that use of assembly is appropriate for a given
    problem, try consulting with your peers for alternatives. You may learn
    of a safer and easier method.

Regards,
Jim Allred

Gary G. Little wrote:

Frankly, I find your argument totally irrelevant. I really could care
less about optimization in, around, or through your hackery.

The real point is that if I go out and pay big bucks for a system
dependent on your kernel mode hackery, I don’t want to wait for you to

get off your ass and “fix” your hackery simply because your inline
assembly hackery works ONLY on one processor, and I now have
requirements to use a processor supported by the OS, but which will
barf on your egomaniacal hicky.

Assembly code, whether inline or assembled and linked from separate
source, limits you to that processor family … period. That’s fine if

you want in-house code that will never ever see the shelf in a
CompUSA. No one here will argue with what you do to your own machines,

just don’t try to sell it to me in your next super whiz bang release.


You are currently subscribed to windbg as: xxxxx@appstream.com To
unsubscribe send a blank email to xxxxx@lists.osr.com

Mathiematical background? Hogwash. The absolute WORSE code I have ever seen came from a doctorate in mathematics.


Gary G. Little
“Guy Bonneau” wrote in message news:xxxxx@windbg…
Don,

I would agree with you that most of the time assembler code doesn’t help very much at kernel level. As you probably observed yourself adding a few line of assembler code inside C code rarely improve performance.

I am not talking about a few lines of inline assembler instruction. But I am talking about a few hundred and sometime thousand of lines of assembler code. I would say that it is not worthwhile trying to write assembler code unless you develop an expertise in computer architecture and have a very good understanding of OOO (Out Of Order) processor scheduling. Beside you need to have a strong mathematical background to understand how to fit the algorithm you are working at with the set of instructions the processor uses.

A good example could be the use of the CMOV instruction. Not a long time ago I remember when the C compiler of Microsoft couldn’t even use a CMOV conditional instruction to remove a conditional branching.

I could also point to those who write assembler code for security issues at kernel level playing with DR registers and writing “virus-like” assembler code trying to stop hackers.

I would say his doctorate in math is a waste if he sits down cramming intel spec sheets in the name of optimization and inline assembly:-) Again I have encountered lots of ego fattened systems programmers with years of experience that know all the cool tricks for A GIVEN CHIP fall flat when it comes to basic principles of software engineering (read good code). Not to say thats wrong cause its called division of labour! One man cant be good for everything or can he?

banks

“Gary G. Little” wrote in message news:xxxxx@windbg…
Mathiematical background? Hogwash. The absolute WORSE code I have ever seen came from a doctorate in mathematics.


Gary G. Little
“Guy Bonneau” wrote in message news:xxxxx@windbg…
Don,

I would agree with you that most of the time assembler code doesn’t help very much at kernel level. As you probably observed yourself adding a few line of assembler code inside C code rarely improve performance.

I am not talking about a few lines of inline assembler instruction. But I am talking about a few hundred and sometime thousand of lines of assembler code. I would say that it is not worthwhile trying to write assembler code unless you develop an expertise in computer architecture and have a very good understanding of OOO (Out Of Order) processor scheduling. Beside you need to have a strong mathematical background to understand how to fit the algorithm you are working at with the set of instructions the processor uses.

A good example could be the use of the CMOV instruction. Not a long time ago I remember when the C compiler of Microsoft couldn’t even use a CMOV conditional instruction to remove a conditional branching.

I could also point to those who write assembler code for security issues at kernel level playing with DR registers and writing “virus-like” assembler code trying to stop hackers.

I’m not sure I have been successful trying to explain my thought. In all
what has been said there is some true! Yes some with a doctorate in
mathematics might write really bad software code. But I’ve seen quite badly
written software code from people having a degree in software engineering
too.

I have the same conviction that inline asm should be avoided as much as
possible. Especially at kernel level.

BUT

There are rare cases when it is needed. And does a mathematic background
might help? Well my guessing is that Intel introduced the SSE3 instruction
set to help solve engineering problems that use complex numbers. And I don’t
think software coders are likely to use them unless involved in solving
engineering problem using complex number. I am also guessing that when they
created the SSE3 instruction set they probably listen more to software coder
having a strong mathematic background complaining about the lack of
specialized instructions to support algorithm using complex numbers. And
there are no straightforward ways to use them in straight C++ code unless
using intrinsic Macro or asm inline code.

In 25 years of software engineering I haven’t seen often a coder trying to
use inline asm to boast it ego. What I have seen is that most of those
trying to use inline asm are only trying to solve software problems to the
best of their knowledge. And I believe that this is what this email list is
all about. People trying to solve software problems and helping each other.

I’m only grateful that Jason understood my pain and forwarded my email to
the Compiler team. He is doing is job. Helping us doing our job.

Thanks

Guy


From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of bank kus
Sent: Wednesday, October 05, 2005 11:33 PM
To: Kernel Debugging Interest List
Subject: Re:[windbg] Inline asm support and x64 development (Off Topic)

I would say his doctorate in math is a waste if he sits down cramming intel
spec sheets in the name of optimization and inline assembly:-) Again I have
encountered lots of ego fattened systems programmers with years of
experience that know all the cool tricks for A GIVEN CHIP fall flat when it
comes to basic principles of software engineering (read good code). Not to
say thats wrong cause its called division of labour! One man cant be good
for everything or can he?

banks

“Gary G. Little” wrote in message news:xxxxx@windbg…
Mathiematical background? Hogwash. The absolute WORSE code I have ever seen
came from a doctorate in mathematics.


Gary G. Little
“Guy Bonneau” wrote in message news:xxxxx@windbg…
Don,

I would agree with you that most of the time assembler code doesn’t help
very much at kernel level. As you probably observed yourself adding a few
line of assembler code inside C code rarely improve performance.

I am not talking about a few lines of inline assembler instruction. But I am
talking about a few hundred and sometime thousand of lines of assembler
code. I would say that it is not worthwhile trying to write assembler code
unless you develop an expertise in computer architecture and have a very
good understanding of OOO (Out Of Order) processor scheduling. Beside you
need to have a strong mathematical background to understand how to fit the
algorithm you are working at with the set of instructions the processor
uses.

A good example could be the use of the CMOV instruction. Not a long time ago
I remember when the C compiler of Microsoft couldn’t even use a CMOV
conditional instruction to remove a conditional branching.

I could also point to those who write assembler code for security issues at
kernel level playing with DR registers and writing “virus-like” assembler
code trying to stop hackers.


You are currently subscribed to windbg as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com