EmbeddedRelated.com
Forums
Memfault State of IoT Report

Warning in IAR when performing bitwise not on unsigned char (corrected)

Started by distantship101 April 3, 2012
On Thu, 26 Apr 2012 22:50:52 +0100, you wrote:

>> Actually, it is germane. One of the perennial topics that
>> comes up from time to time -- and I think you are guilty here
>> of making over-reaching comments in this regard (as are we
>> all on some subjects, I admit) -- is whether or not assembly
>> coding is "dead" or not.
>
> Assembly coding for small systems is alive and well; for
> large, complex systems, it is dead because the effort
> required to implement such a system in assembly code is
> simply not worthwhile.

Every system I work on that isn't trivial includes _some_
assembly, because I understand it well (obviously, if I
didn't, I would go to the ends of the Earth to avoid what I'm
ignorant of) and there are almost always certain points where
it makes vastly more sense in anything large enough. (Small,
trivial programs are often well-written in C without any
assembly.) If nothing else, it is trivial to set up a coop
switcher which greatly improves code readability.

However, Paul, I was addressing myself to David, not you. He
is far more likely (over the years I've watched) to make such
pronouncements. I never thought of you in that way. You are
more nuanced in view than he is, I imagine.

>> This kind of optimization is dead obvious for any assembly
>> coder who would, almost without thought about it, do the
>> promotion out of the loop (at some point -- not necessarily
>> as the first step in getting things working right.) If C
>> compilers cannot, in this day and age now, be trusted to do
>> such trivia then it leaves open many other questions.
>
> Compilers for x86 have a thankless task: there is no way
> that they will be able to, in general, predict execution of
> a program on the hardware so will need to take a "balanced
> view". Why expect Microsoft compilers to do a bang-up job?
> That's not what Microsoft does and it was Intel that got
> frustrated at MS for not improving their compilers.

But that misses my point, so we are already at cross
purposes. I'm not arguing anything about Microsoft's
motivations. I'm simply discussing the fact that I've been
working with C compilers since 1978 (Unix v6 kernel) and
perhaps imagined falsely that this kind of optimization was
easy enough (from my inexperienced view, but coming from
having at least written a parser/lexer for C and generated
simple code from it that worked fine) and so much an
ingrained part of the art that we were well past even asking
such questions.

This has opened my eyes. That's none of your business, since
your eyes have always been open. But it is news to me. I
anticipated that some would, some wouldn't. But you seem
(perhaps I'm getting this wrong, too) to be arguing that most
don't. And that is what is news to me.

> This isn't a QoI question, either. There are a whole lot of
> ways that the internals of a compiler works, a whole lot of
> issues with ABI specifications which get forced on
> compilers, and also what a programmer should expect of a
> compiler.

Well, as I said, your view is educated and nuanced. It's why
I respect everything you say here on the topic and read it
closely.

>> I will be looking over other compilers on this. I have a LOT
>> of old tools lying about. Metaware, for example, from the mid
>> 1980's is sitting on 5 1/4" floppies. Fran DeRemer and Tom
>> Pennello, despite some excessive Christian evangelism in
>> their technical documents, did take a different and
>> interesting direction in their compilers and I'm interested
>> to see how they behave here.
>
>Good luck. No such thing as "signed" in classic K&R C.

I'm simply not sure what Metaware implemented, though. Do
you? In any case, I have old tools kept year after year
since, as well. Lots of them from all kinds of sources.
Zortech C++, Lattice C (many versions), Microsoft C (many,
many versions), Borland, Whitesmiths, ... well, a lot. And
not only on x86, either. Uncountable version of Microchip C,
from back when their team was working prior to version 1 for
the PIC16 (not a terribly good compiler, but also working in
difficult circumstances too.)

>> I'm also still very interested in Paul's comments about
>> register coloring and I need to think (and refresh myself
>> about the algorithms again) about this more.
>
>http://en.wikipedia.org/wiki/Rematerialization
>
>> I just picked up
>> the newer Aho book and haven't had a chance to read it, yet.
>
> Yeah, don't bother. If you are burning personal time, this
> is better (but check the errata!)
>
>http://www.amazon.com/Advanced-Compiler-Design-Implementation-Muchnick/dp/1558603204/

Thanks, Paul. I'll get a copy now. I use this kind of thing
for relaxation in after-hours. I enjoy learning new things.
It's selfish, I admit.

>> So this might be a motivation to rummage through that, as
>> well.
>
>Like I said, don't bother. It's a bit of a yawn.

Oh, I'd do it for fun and nothng more.

>> Bottom line is -- this argues unfavorably (admittedly only
>> one data point and there remains many many counter arguments
>> as well) to those who say that there is no longer ANY reason
>> for assembly coding because of the supposed quality of modern
>> C compilers. If they can't handle this.... well.
>
>Compilers are tools: programmers must practice their craft.

We are allowed by you to relax and enjoy hobbies, I imagine?

Jon

Beginning Microcontrollers with the MSP430

>Assembly coding for small systems is alive and well; for large, complex
>systems, it is dead because the effort required to implement >such a system
>in assembly code is simply not worthwhile.

Keep spreading that myth, it makes it really hard for us to hire programmers
who can code in assembly, write code for spus/gpus/vector processors etc so
thanks!

It's very worthwhile, and its very dependent on which industry you're in.
I've been hearing the same thing said for decades, and apparently people are
starting to believe it ;)

On 26 Apr 2012, at 23:37, Charlie X Wallace wrote:

>> Assembly coding for small systems is alive and well; for large, complex
>> systems, it is dead because the effort required to implement >such a system
>> in assembly code is simply not worthwhile.
>
> Keep spreading that myth, it makes it really hard for us to hire programmers
> who can code in assembly, write code for spus/gpus/vector processors etc so
> thanks!
>
> It's very worthwhile, and its very dependent on which industry you're in.
> I've been hearing the same thing said for decades, and apparently people are
> starting to believe it ;)

In general, it is not worthwhile to implement a complex system in assembly because the ROI is low to negative. If you have a complex system with a great ROI which must be coded to squeeze the best from specialist hardware, then you require somebody who can get the most out of your hardware, who may well not be an assembly programmer--just an excellent programmer--and can turn himself to programming such hardware.

Right now, we don't churn out "assembly programmers". I think that's a good thing. We should be turning out programmers that are generally useful and know about different aspects of programming, including low-level aspects. Unfortunately the dire state of ICT in the UK means we are up shit creek and have very little native technical resource, unless you need somebody to cook up some HTML or print a Word document.

Having done my fair share of coding in DSP assembly language for data broadcast and Eurofighter radar real time systems, I know that there is a place for assembly coding--but not the whole system, we just coded the absolutely time-critical parts in assembly code and the tie-it-all-together code was in Pascal, Modula-2, C or Ada.

-- Paul.

>In general, it is not worthwhile to implement a complex system in assembly
>because the ROI is low to negative. If you have a complex >system with a
>great ROI which must be coded to squeeze the best from specialist hardware,
>then you require somebody who can get the >most out of your hardware, who
>may well not be an assembly programmer--just an excellent programmer--and
>can turn himself to >programming such hardware.

In general, only works in general. Some things only work well when you code
for them in assembly ( or a variant thereof ) things like HAL/CL I'd
consider more assembly than C for instance. In general I find that the
programmers who come from an assembly background are much more useful in
these areas, at least this has been my experience in the games industry.

So in general at your regular coding company who's turning out average
performing software that’s really not going to gain much from assembler,
you're right. But we still have a need for the others.
>Right now, we don't churn out "assembly programmers". I think that's a
>good thing. We should be turning out programmers that are >generally
>useful and know about different aspects of programming, including low-level
>aspects. Unfortunately the dire state of ICT in >the UK means we are up
>shit creek and have very little native technical resource, unless you need
>somebody to cook up some HTML or >print a Word document.

I disagree, I think it’s a bad thing, but I'm basing it on my work
experience. Learning asm first gave me a greater insight into coding, most
of the programmers I know wouldn't be able to do look at the asm output from
the compiler as you did earlier to even know if its broken or generating
good code.

>Having done my fair share of coding in DSP assembly language for data
>broadcast and Eurofighter radar real time systems, I know that >there is a
>place for assembly coding--but not the whole system, we just coded the
>absolutely time-critical parts in assembly code and >the
>tie-it-all-together code was in Pascal, Modula-2, C or Ada.

I most do mostly graphics rendering related tasks (have done eurofighter sim
in the distant past), so in that field its very useful.

Agreed tie in the code in C/C+, but learn assembly, we do use it all the
time in our industry, If I post a job for a programmer, I get other
recruiters and companies calling me asking me to pass on the ones that we
pass on because everyone is hurting so bad, I can get common garden C++
people fairly easily, but they're useless when it comes to under the hood.
Quoting Colin Chapman, simplify, and add lightness. If he were a programmer,
I reckon he'd do it in asm ;)

cheers,
charlie

>> In general, it is not worthwhile to implement a complex system in assembly
>> because the ROI is low to negative. If you have a complex >system with a
>> great ROI which must be coded to squeeze the best from specialist hardware,
>> then you require somebody who can get the >most out of your hardware, who
>> may well not be an assembly programmer--just an excellent programmer--and
>> can turn himself to >programming such hardware.
>
> In general, only works in general. Some things only work well when you code
> for them in assembly ( or a variant thereof ) things like HAL/CL I'd
> consider more assembly than C for instance. In general I find that the
> programmers who come from an assembly background are much more useful in
> these areas, at least this has been my experience in the games industry.

OK, well as a child of the 60s, and growing up in the 70s with the micro revolution, I passed through FORTRAN IV to BASIC to 6502 assembly code to Z80 assembly code and then to Pascal and 68k assembly code I guess you haven't lived as a programmer unless you've written meaningful code at a low level. Personally I loved the built-in 6502 assembler of the Acorn Atom--absolutely stinking stroke of genius.

>
> So in general at your regular coding company who's turning out average
> performing software thats really not going to gain much from assembler,
> you're right. But we still have a need for the others.
>

Although I have had games published in the past, which I guess I am proud of as it got me through uni, I now have zero time for any sort of game. I should qualify this: I believe I have more years behind me than I have productive years ahead of me, and I want to squeeze the most that I can out of those remaining years. As much as I love writing code, and my sig shows you I still love writing software and creating Defender from scratch, I have no desire to play games. I find writing software so much more fulfilling.

>> Right now, we don't churn out "assembly programmers". I think that's a
>> good thing. We should be turning out programmers that are >generally
>> useful and know about different aspects of programming, including low-level
>> aspects. Unfortunately the dire state of ICT in >the UK means we are up
>> shit creek and have very little native technical resource, unless you need
>> somebody to cook up some HTML or >print a Word document.
>
> I disagree, I think its a bad thing, but I'm basing it on my work
> experience. Learning asm first gave me a greater insight into coding, most
> of the programmers I know wouldn't be able to do look at the asm output from
> the compiler as you did earlier to even know if its broken or generating
> good code.

Doesn't this simply come from experience? Given a normal distribution of programmers, I guess you really are interested in only the top one percent or better for your positions.

>
>> Having done my fair share of coding in DSP assembly language for data
>> broadcast and Eurofighter radar real time systems, I know that >there is a
>> place for assembly coding--but not the whole system, we just coded the
>> absolutely time-critical parts in assembly code and >the
>> tie-it-all-together code was in Pascal, Modula-2, C or Ada.
>
> I most do mostly graphics rendering related tasks (have done eurofighter sim
> in the distant past), so in that field its very useful.

This just comes down to squeezing the best you can out of what you have. To do that, no compiler will compete with a competent programmer for much of the intricate pieces of the jigsaw. State of the art is not quite there yet in compiler tech.

>
> Agreed tie in the code in C/C+, but learn assembly, we do use it all the
> time in our industry, If I post a job for a programmer, I get other
> recruiters and companies calling me asking me to pass on the ones that we
> pass on because everyone is hurting so bad, I can get common garden C++
> people fairly easily, but they're useless when it comes to under the hood.
>
>
> Quoting Colin Chapman, simplify, and add lightness. If he were a programmer,
> I reckon he'd do it in asm ;)

Wicked. :-) Did you know that happens to have special significance for me?

-- Paul.

On Thu, 26 Apr 2012 16:13:18 -0700, you wrote:

>>In general, it is not worthwhile to implement a complex system in assembly
>>because the ROI is low to negative. If you have a complex >system with a
>>great ROI which must be coded to squeeze the best from specialist hardware,
>>then you require somebody who can get the >most out of your hardware, who
>>may well not be an assembly programmer--just an excellent programmer--and
>>can turn himself to >programming such hardware.
>
>In general, only works in general. Some things only work well when you code
>for them in assembly ( or a variant thereof ) things like HAL/CL I'd
>consider more assembly than C for instance. In general I find that the
>programmers who come from an assembly background are much more useful in
>these areas, at least this has been my experience in the games industry.
>
>So in general at your regular coding company who's turning out average
>performing software thats really not going to gain much from assembler,
>you're right. But we still have a need for the others.
>>Right now, we don't churn out "assembly programmers". I think that's a
>>good thing. We should be turning out programmers that are >generally
>>useful and know about different aspects of programming, including low-level
>>aspects. Unfortunately the dire state of ICT in >the UK means we are up
>>shit creek and have very little native technical resource, unless you need
>>somebody to cook up some HTML or >print a Word document.
>
>I disagree, I think its a bad thing, but I'm basing it on my work
>experience. Learning asm first gave me a greater insight into coding, most
>of the programmers I know wouldn't be able to do look at the asm output from
>the compiler as you did earlier to even know if its broken or generating
>good code.
>
>>Having done my fair share of coding in DSP assembly language for data
>>broadcast and Eurofighter radar real time systems, I know that >there is a
>>place for assembly coding--but not the whole system, we just coded the
>>absolutely time-critical parts in assembly code and >the
>>tie-it-all-together code was in Pascal, Modula-2, C or Ada.
>
>I most do mostly graphics rendering related tasks (have done eurofighter sim
>in the distant past), so in that field its very useful.
>
>Agreed tie in the code in C/C+, but learn assembly, we do use it all the
>time in our industry, If I post a job for a programmer, I get other
>recruiters and companies calling me asking me to pass on the ones that we
>pass on because everyone is hurting so bad, I can get common garden C++
>people fairly easily, but they're useless when it comes to under the hood.
>
>Quoting Colin Chapman, simplify, and add lightness. If he were a programmer,
>I reckon he'd do it in asm ;)
>
>cheers,
>charlie

Very well argued, Charlie. I can't find anything to even nit
pick over.

Jon
>OK, well as a child of the 60s, and growing up in the 70s with the micro
>revolution, I passed through FORTRAN IV to BASIC to 6502 >assembly code to
>Z80 assembly code and then to Pascal and 68k assembly code I guess you
>haven't lived as a programmer unless >you've written meaningful code at a
>low level. Personally I loved the built-in 6502 assembler of the Acorn
>Atom--absolutely stinking >stroke of genius.

I was zx80/zx81/c64/amiga and I still use 68K til this day, and only in asm

>Although I have had games published in the past, which I guess I am proud
>of as it got me through uni, I now have zero time for any >sort of game. I
>should qualify this: I believe I have more years behind me than I have
>productive years ahead of me, and I want to >squeeze the most that I can
>out of those remaining years. As much as I love writing code, and my sig
>shows you I still love writing >software and creating Defender from
>scratch, I have no desire to play games. I find writing software so much
>more fulfilling.

I rarely play games, I prefer making them. So its not uncommon. I like to
dabble in hardware and software. Initially I was interested in EE but when I
was 11 a company gave our school a wang 2020 and I never looked back.. But
now I since I co run a big hackerspace in los angeles, I get to teach
electronics and programming, which I enjoy very much.

I find the people with asm backgrounds just pick up the EE/HW faster and
they can debug problems. I'm sure thats no surprise though.

>Doesn't this simply come from experience? Given a normal distribution of
>programmers, I guess you really are interested in only the >top one percent
>or better for your positions.

Not in my experience, I've hired.interviewed a lot of people over the years
and there has just been a huge decline in the quality. Yes I am interested
in the higher end ones, but the gap between hi-end and we what I see in
resumes day to day is amazing.

>This just comes down to squeezing the best you can out of what you have.
>To do that, no compiler will compete with a competent >programmer for much
>of the intricate pieces of the jigsaw. State of the art is not quite there
>yet in compiler tech.

Absolutely, and this is why I prefer asm backgrounds, especially if you're
working with hardware thats new or you can best the compiler. We write our
compiler in house for the graphics arch and it bests the OEM's by upto 20%,
so thats an automatic boost from the competitimn, if they don't.

>Wicked. :-) Did you know that happens to have special significance for
>me?

Hmm I dunno, depends if you're an end user or work(ed) at Hethel. My 68K
comment from above goes hand in hand with Lotus... ;)

cheers,
charlie

On 27 Apr 2012, at 00:50, Charlie X Wallace wrote:

>
>> OK, well as a child of the 60s, and growing up in the 70s with the micro
>> revolution, I passed through FORTRAN IV to BASIC to 6502 >assembly code to
>> Z80 assembly code and then to Pascal and 68k assembly code I guess you
>> haven't lived as a programmer unless >you've written meaningful code at a
>> low level. Personally I loved the built-in 6502 assembler of the Acorn
>> Atom--absolutely stinking >stroke of genius.
>
> I was zx80/zx81/c64/amiga and I still use 68K til this day, and only in asm

I still have my Acorn Atom and its manuals. My latest project happens to recreate that part of my youth.

>
>> Although I have had games published in the past, which I guess I am proud
>> of as it got me through uni, I now have zero time for any >sort of game. I
>> should qualify this: I believe I have more years behind me than I have
>> productive years ahead of me, and I want to >squeeze the most that I can
>> out of those remaining years. As much as I love writing code, and my sig
>> shows you I still love writing >software and creating Defender from
>> scratch, I have no desire to play games. I find writing software so much
>> more fulfilling.
>
> I rarely play games, I prefer making them. So its not uncommon. I like to
> dabble in hardware and software. Initially I was interested in EE but when I
> was 11 a company gave our school a wang 2020 and I never looked back.. But
> now I since I co run a big hackerspace in los angeles, I get to teach
> electronics and programming, which I enjoy very much.

I don't think our backgrounds and outlooks are so very different.

>> Wicked. :-) Did you know that happens to have special significance for
>> me?
>
> Hmm I dunno, depends if you're an end user or work(ed) at Hethel. My 68K
> comment from above goes hand in hand with Lotus... ;)

Well, I am most certainly an end user. I wanted a Lotus ever since I first saw the Esprit, and the JPS Specials also did a lot for me too. I contracted for a stint at Rover Group developing the K series ECU (no tittering at the back). It's amazing how management can crush the life from great engineers.

-- Paul.

>I still have my Acorn Atom and its manuals. My latest project happens to
>recreate that part of my youth.

Indeed, I spend a lot of time on ARM, having had had BBC Micro's at school,
no surprise.

>I don't think our backgrounds and outlooks are so very different.

Seems like it. Just try to encourage at least some asm people ;) I
desperately need hires, though might take a while to filter in!

>Well, I am most certainly an end user. I wanted a Lotus ever since I first
>saw the Esprit, and the JPS Specials also did a lot for me too. I
> >contracted for a stint at Rover Group developing the K series ECU (no
>tittering at the back). It's amazing how management can crush >the life
>from great engineers.

Heh, yeah.. Tell me about it. I had a dream job at Disney Imagineering
doing mostly pure RnD and the non engineering mgmt made it a horrible place
to work, no amount of tools and robots could make it worthwhile, better to
get your own.

A long time ago (it feels like) I developed aftermarket tuning packages for
the S2 elises / exiges T4/T4e ECUs after reversing them and
supercharger/turbocharger kits.. Been a Lotus person all my life, my dad was
too. I started off with the M100 and S1 in the UK and I still have my S2
exige/M100 here..

Anyway probably gone off the beaten track just a tad.

cheers,
charlie

On 27/04/2012 01:31, Paul Curtis wrote:
>>> In general, it is not worthwhile to implement a complex system in
>>> assembly because the ROI is low to negative. If you have a
>>> complex>system with a great ROI which must be coded to squeeze
>>> the best from specialist hardware, then you require somebody who
>>> can get the>most out of your hardware, who may well not be an
>>> assembly programmer--just an excellent programmer--and can turn
>>> himself to>programming such hardware.
>>
>> In general, only works in general. Some things only work well when
>> you code for them in assembly ( or a variant thereof ) things like
>> HAL/CL I'd consider more assembly than C for instance. In general I
>> find that the programmers who come from an assembly background are
>> much more useful in these areas, at least this has been my
>> experience in the games industry.
>
> OK, well as a child of the 60s, and growing up in the 70s with the
> micro revolution, I passed through FORTRAN IV to BASIC to 6502
> assembly code to Z80 assembly code and then to Pascal and 68k
> assembly code I guess you haven't lived as a programmer unless
> you've written meaningful code at a low level. Personally I loved
> the built-in 6502 assembler of the Acorn Atom--absolutely stinking
> stroke of genius.
>

I never used the Atom, but assuming it's assembler was similar to that
of the BBC Micro then I agree. What I found particularly cool was how
well you could mix Basic and Assembly. BBC Basic was probably the best
Basic I ever used. And in addition you could use the A%, X% and Y% fast
integer variables in Basic to pass data back and forth between assembly
snippets. You could also call OS functions easily from assembly.

But you haven't done /real/ programming until you have hand-assembled
code for a ZX spectrum (Z80 processor), typed it all into a Basic loader
program on the chewing-gum keyboard, and done your debugging based on
the sound made by the power supply. Of course, if it hangs you pull the
plug and start again (or load from a tape recorder, if you are lucky).
It encouraged careful thought and accurate programming, rather than "try
it and see" coding!

Memfault State of IoT Report