Exact match. Not showing close matches.
PICList
Thread
'[PIC]/[EE] Small microcontroller with GCC support?'
2007\06\29@042309
by
Peter Bindels
Hello,
I was thinking. I have been using PICs for a few times before, and I'm
professionally speaking a software guy (up to the edge of hardware,
but hobbyist beyond). For myself a simple processor with very advanced
software support and easy hardware interfacing (as in, electrically)
would be the ideal solution. That rules out any devices I can't solder
(BGA, TQFP), devices with near-none software support (BASIC stamps)
and devices with complex hardware interfacing (FPGA's with softcores).
The only problem I have with SDCC (which I've used up to now) is that
it doesn't support C++ or anything similar.
I'm expressly not out to somebody telling me C++ in a 512 byte device
is bollocks, I know that you can make C++ act like a pig but I also
know that you can make it work like a fairy.
What kind of device would I be best off with?
Regards,
Peter
2007\06\29@045713
by
wouter van ooijen
> I was thinking. I have been using PICs for a few times
> before, and I'm professionally speaking a software guy (up to
> the edge of hardware, but hobbyist beyond).
Same for me (at least by eduction, I earn most of my living now in
hardware, so maybe I qualify as a hardware professional).
> For myself a
> simple processor with very advanced software support and easy
> hardware interfacing (as in, electrically) would be the ideal
> solution. That rules out any devices I can't solder (BGA,
> TQFP), devices with near-none software support (BASIC stamps)
> and devices with complex hardware interfacing (FPGA's with
> softcores).
DSpic and its derivatives use a GCC compiler, but it was
modified/augmented by Microchip, so I dunno whether it could succesfully
do C++.
ARM (or MSP430?) would be ideal, except for the packaging. Shout after
me: "Why can't anybody make an ARM chip in a DIP with 5V I/O and decent
I/O drive?" (single-5V supply would be nice too).
Note that there are lots of ARM evaluation boards around, and soldering
an 48 or even 64 pin package is not that bad. I (and probably lots of
other sources) sell SMD-to-DIP adpater boards, so you can fit an ARM
into a solderless beradboard if you want.
> I'm expressly not out to somebody telling me C++ in a 512
> byte device is bollocks, I know that you can make C++ act
> like a pig but I also know that you can make it work like a fairy.
in 512 bytes RAM? I don't see the problem. 512 bytes FLASH would be a
bit small for using fancy inheritance, but C++ is (also) a better C, so
it is
still usefull.
> What kind of device would I be best off with?
My current choice is ARM, but I admit the packaging (and electrical
interface) is still a big problem.
Wouter van Ooijen
-- -------------------------------------------
Van Ooijen Technische Informatica: http://www.voti.nl
consultancy, development, PICmicro products
docent Hogeschool van Utrecht: http://www.voti.nl/hvu
2007\06\29@054037
by
Michael Rigby-Jones
|
{Quote hidden}>-----Original Message-----
>From:
spam_OUTpiclist-bouncesTakeThisOuT
mit.edu [
.....piclist-bouncesKILLspam
@spam@mit.edu]
>On Behalf Of Peter Bindels
>Sent: 29 June 2007 09:23
>To: Microcontroller discussion list - Public.
>Subject: [PIC]/[EE] Small microcontroller with GCC support?
>
>
>Hello,
>
>I was thinking. I have been using PICs for a few times before,
>and I'm professionally speaking a software guy (up to the edge
>of hardware, but hobbyist beyond). For myself a simple
>processor with very advanced software support and easy
>hardware interfacing (as in, electrically) would be the ideal
>solution. That rules out any devices I can't solder (BGA,
>TQFP), devices with near-none software support (BASIC stamps)
>and devices with complex hardware interfacing (FPGA's with
>softcores). The only problem I have with SDCC (which I've used
>up to now) is that it doesn't support C++ or anything similar.
>
>I'm expressly not out to somebody telling me C++ in a 512 byte
>device is bollocks, I know that you can make C++ act like a
>pig but I also know that you can make it work like a fairy.
>
>What kind of device would I be best off with?
The Atmel AVR has good GCC support, so you might want to look there. I'd be interested to see what kind of small embedded application would actualy benefit from being coded in C++ though.
Regards
Mike
=======================================================================
This e-mail is intended for the person it is addressed to only. The
information contained in it may be confidential and/or protected by
law. If you are not the intended recipient of this message, you must
not make any use of this information, or copy or show it to any
person. Please contact us immediately to tell us that you have
received this e-mail, and return the original to us. Any use,
forwarding, printing or copying of this message is strictly prohibited.
No part of this message can be considered a request for goods or
services.
=======================================================================
2007\06\29@055357
by
Tamas Rudnai
2007\06\29@055632
by
wouter van ooijen
> The Atmel AVR has good GCC support, so you might want to look
> there. I'd be interested to see what kind of small embedded
> application would actualy benefit from being coded in C++ though.
exception handling => safety critical stuff
templates => flexible libraries (reduces development costs)
"better C part of C++" => less coding errors
etc
Wouter van Ooijen
-- -------------------------------------------
Van Ooijen Technische Informatica: http://www.voti.nl
consultancy, development, PICmicro products
docent Hogeschool van Utrecht: http://www.voti.nl/hvu
2007\06\29@063511
by
Russell McMahon
Have a look at GCC for the AVR processors and see if their products
fit your requirements.
Russell
> I was thinking. I have been using PICs for a few times before, and
> I'm
> professionally speaking a software guy (up to the edge of hardware,
> but hobbyist beyond). For myself a simple processor with very
> advanced
> software support and easy hardware interfacing (as in, electrically)
> would be the ideal solution.
2007\06\29@065928
by
Peter Bindels
|
On 29/06/07, Michael Rigby-Jones <.....Michael.Rigby-JonesKILLspam
.....bookham.com> wrote:
> The Atmel AVR has good GCC support, so you might want to look there. I'd be interested to see what kind of small embedded application would actualy benefit from being coded in C++ though.
int main() {
EventHdl handler;
Channel serial_out(handler, uart_info);
Button left(handler, serial_out, ...), right(handler, serial_out,
...), confirm(handler, serial_out, ...);
handler.process();
}
instead of recoding the glue logic everytime I want a new device with
three analog inputs, a matrix keypad and an LCD screen. This takes me
1 minute to write and think up, including making all handling
asynchronous, polling-based or such. Writing that in C is a lot more
error prone and allows less abstraction, in particular having
functions that "belong" to a given struct are useful for keeping stuff
ordered.
I have a concept for dynamically distributing information on a
hardware system that I intend to test using this, but it's highly C++
specific and complex in implementation. When compiled for a leaf node,
though, it could be substantially reduced in size by its limitations,
but that would require C++ support or I'd have to recode everything in
a variant of C, keeping both code bases synchronized.
Using something like this plus a cheap kind of microcontroller would
allow me to add a new one to an existing design for nearly no expense
in terms of development time - you configure the device in a few
minutes, you compile & install the output application and don't think
about it anymore.
Thanks for the helpful replies, though.
2007\06\29@072330
by
Xiaofan Chen
On 6/29/07, wouter van ooijen <EraseMEwouterspam_OUT
TakeThisOuTvoti.nl> wrote:
>
> DSpic and its derivatives use a GCC compiler, but it was
> modified/augmented by Microchip, so I dunno whether it could succesfully
> do C++.
C++ is not supported by GCC based C30 for dsPIC. Please refer to the
following thread.
http://forum.microchip.com/tm.aspx?m=262180
> ARM (or MSP430?) would be ideal, except for the packaging. Shout after
> me: "Why can't anybody make an ARM chip in a DIP with 5V I/O and decent
> I/O drive?" (single-5V supply would be nice too).
>
dsPICs do have the features you need (DIP and 5V I/O) except C++.
AVRs have good GCC support and has DIP and 5V I/O. There are some
limited C++ support as well.
MSP430s have good GCC support (I think C++ is not really supported).
By the way, IAR seems to support embedded C++ for
dsPIC/AVR/MSP430/ARM but it is not free. There are limitted kickstart
edition though.
There are single 5V supply ARMs available from companies like ST
(STR7 ARM7) but no DIP.
Personally I think 3V operation is not a problem. DIP package can be a
problem but there are prototype boards available just as you mentioned.
In a world, dsPIC/AVR/MSP430/ARM are some of the options.
Xiaofan
2007\06\29@073408
by
Peter Bindels
On 29/06/07, Xiaofan Chen <xiaofanc
spam_OUTgmail.com> wrote:
> dsPICs do have the features you need (DIP and 5V I/O) except C++.
>
> AVRs have good GCC support and has DIP and 5V I/O. There are some
> limited C++ support as well.
>
> MSP430s have good GCC support (I think C++ is not really supported).
>
> By the way, IAR seems to support embedded C++ for
> dsPIC/AVR/MSP430/ARM but it is not free. There are limitted kickstart
> edition though.
>
> There are single 5V supply ARMs available from companies like ST
> (STR7 ARM7) but no DIP.
>
> Personally I think 3V operation is not a problem. DIP package can be a
> problem but there are prototype boards available just as you mentioned.
>
> In a world, dsPIC/AVR/MSP430/ARM are some of the options.
If I interpret that fairly correctly, that means no chips below $5-10?
2007\06\29@082549
by
Alan B. Pearce
>C++ is not supported by GCC based C30 for dsPIC.
>Please refer to the following thread. ...
However this does not stop you using a C++ preprocessor that generates C,
surely.
2007\06\29@082623
by
wouter van ooijen
> > In a world, dsPIC/AVR/MSP430/ARM are some of the options.
>
> If I interpret that fairly correctly, that means no chips below $5-10?
http://www.findchips.com/ "LPC201"
Wouter van Ooijen
-- -------------------------------------------
Van Ooijen Technische Informatica: http://www.voti.nl
consultancy, development, PICmicro products
docent Hogeschool van Utrecht: http://www.voti.nl/hvu
2007\06\29@094855
by
Peter P.
> > application would actualy benefit from being coded in C++ though.
>
> exception handling => safety critical stuff
exception handling => race condition on small micro
> templates => flexible libraries (reduces development costs)
flexible libraries with C++ calling conventions => huge memory and code
overhead, high library porting and maintenance cost
> "better C part of C++" => less coding errors
worse C++ expands C => the temptation to use automatic strings on a micro with
limited RAM, the temptation to use inheritance and object collection on same,
the temptation to call by reference in a non-memory protected environment
Also code footprint 30% to 300% of optimized C code.
Other than that, you are right, the main() program is easier to write in C++.
Peter P.
2007\06\29@101322
by
Xiaofan Chen
On 6/29/07, Peter Bindels <@spam@dascandyKILLspam
gmail.com> wrote:
> >
> > In a word, dsPIC/AVR/MSP430/ARM are some of the options.
>
> If I interpret that fairly correctly, that means no chips below $5-10?
> --
All of them have parts below $5.
2007\06\29@102425
by
Peter Bindels
|
Hi Peter,
On 29/06/07, Peter P. <KILLspamplpeter2006KILLspam
yahoo.com> wrote:
> > exception handling => safety critical stuff
>
> exception handling => race condition on small micro
How do you generate race conditions using exceptions in the first
place? They have no relation at all.
> > templates => flexible libraries (reduces development costs)
>
> flexible libraries with C++ calling conventions => huge memory and code
> overhead, high library porting and maintenance cost
In the case of templates, probably smaller code and memory overhead
since you decide per type what to store, instead of for a generic
type, less porting (as c++ remains c++) and maintenance cost of near
zero, since it's portable code as you're not using compiler specifics
to make it work properly.
> > "better C part of C++" => less coding errors
>
> worse C++ expands C => the temptation to use automatic strings on a micro with
> limited RAM, the temptation to use inheritance and object collection on same,
> the temptation to call by reference in a non-memory protected environment
>
> Also code footprint 30% to 300% of optimized C code.
I wouldn't use strings, vectors or any STL on a micro in any case. The
most code overhead you receive from properly written C++ code is the
overhead C code would've generated, except that you commonly forget to
check those boundaries.
If you're tempted to pretend you're working on a home computer, your
code will be slow anyway, even if you program in C. I have seen worse
C code, every bit of code making their own small buffer, the whole
using half the memory as buffer not being able to use more than 2% of
it at any time because there's only one thread running at all.
Making C++ code work properly is possibly easier than making the
corresponding C code work properly. I've tried to make a few small
demos indicating how much overhead your code has when it doesn't do
much. In most cases, turning on any optimization optimized away /the
entire program/. I'll dare you to beat that with C.
Regards,
Peter
2007\06\29@113214
by
wouter van ooijen
Maybe I should not react to this, but here I go...
>> exception handling => safety critical stuff
>
> exception handling => race condition on small micro
a "race" condition is something very important indeed.
But I assume you meant "rare"? You did a lot of automibile, military,
nuclear, and space projects? Ever programmed for ESA?
Ever programmed in a language that had exception handling, so you could
appreciate it?
> > templates => flexible libraries (reduces development costs)
>
> flexible libraries with C++ calling conventions => huge
> memory and code overhead, high library porting and maintenance cost
I dunno about C++ calling conventions (multiple?), C++ can call by C
convention if you want.
Did you ever actually use templates? Using it can actually *save* code
compared to a (roughly) equaly flexible C library.
> > "better C part of C++" => less coding errors
>
> worse C++ expands C => the temptation to use automatic
> strings on a micro with limited RAM, the temptation to use
> inheritance and object collection on same, the temptation to
> call by reference in a non-memory protected environment
Temptation to use 'general' memory allocation/deallocation is easily
handled by not linking agains memory allocation. This 'tempation' is
available in C too, but I admit it is more visible there.
Inheritance is actualy very useable, and static (not dynamic)
inheritence cost *nothing* more than a C call. Dynamic inhertance can -
when used properly, like all tools - save a lot of code. It can aslo be
misused. Which tool can't?
> Also code footprint 30% to 300% of optimized C code.
If you mean 0.3 .. 3.0 times the footprint of C code you are not saying
very much, except that C++ can be better (and can be worse).
If you meanr 0.3 to 3.0 times *more*: bullocks. Take your C code, pass
it through a C/C++ compiler in C++ mode and get the same assembly as in
C mode. After that, see what could be done better with C++ constructs
and start saving code.
Wouter van Ooijen
-- -------------------------------------------
Van Ooijen Technische Informatica: http://www.voti.nl
consultancy, development, PICmicro products
docent Hogeschool van Utrecht: http://www.voti.nl/hvu
2007\06\29@132141
by
Michael Dipperstein
2007\06\29@170421
by
William Chops Westfield
On Jun 29, 2007, at 4:34 AM, Peter Bindels wrote:
>> AVRs have good GCC support and has DIP and 5V I/O. There are some
>> limited C++ support as well.
>> In a world, dsPIC/AVR/MSP430/ARM are some of the options.
>
> If I interpret that fairly correctly, that means no chips below $5-10?
>
ATmega168 is about $4 in ones from digikey, and less than $3 if you buy
25. Arduino (using mega8 or mega168 and gcc) claims to support some
c++.
I'd be worrying about runtime environments for C++ in deeply embedded
systems. Some of the features people are talking about (exception
handling?) rely on an OS-like thing as well as the language.
BillW
2007\06\29@173752
by
Peter Bindels
On 29/06/07, William Chops Westfield <TakeThisOuTwestfwEraseME
spam_OUTmac.com> wrote:
> ATmega168 is about $4 in ones from digikey, and less than $3 if you buy
> 25. Arduino (using mega8 or mega168 and gcc) claims to support some
> c++.
I noticed for the first few tryouts that Wouter sells them too, for
about $10 including a 48-pin tsop to DIP converter PCB, which is very
practical. I'm thinking it'll be the lpc2101 then.
> I'd be worrying about runtime environments for C++ in deeply embedded
> systems. Some of the features people are talking about (exception
> handling?) rely on an OS-like thing as well as the language.
Exception handling is compiler specific and can (for GCC) probably be
cloned/extracted from the standard libsupc++ delivered with gcc
itself. I'm not sure how exception handling works on an ARM but I
suspect that for all devices in my area of interest they'll give an
exceptional overhead that I'm not willing to add.
2007\06\29@174445
by
wouter van ooijen
> I'd be worrying about runtime environments for C++ in deeply
> embedded systems. Some of the features people are talking
> about (exception
> handling?) rely on an OS-like thing as well as the language.
exception handling requires OS support? I don't doubt it *can* be done
with OS support, but in most cases it is done totally without. Think for
yourself: it is not difficult to transform a program that uses
C-with-exception-handlers in to a plain C program.
which other features would you be worried about?
Wouter van Ooijen
-- -------------------------------------------
Van Ooijen Technische Informatica: http://www.voti.nl
consultancy, development, PICmicro products
docent Hogeschool van Utrecht: http://www.voti.nl/hvu
2007\06\29@180257
by
Peter Bindels
On 29/06/07, wouter van ooijen <RemoveMEwouter
TakeThisOuTvoti.nl> wrote:
> exception handling requires OS support? I don't doubt it *can* be done
> with OS support, but in most cases it is done totally without. Think for
> yourself: it is not difficult to transform a program that uses
> C-with-exception-handlers in to a plain C program.
At link time, yes, but not at compile time. Add to that that the
linker doesn't know about exceptions and you do have a problem that
needs handling, in particular having something that manages types and
that "knows" when to stop unwrapping the stack. Search for
__gxx_personality and find a bunch. Not to mention the actual stack
unwinding, which is iirc also a library function, not a compiler-added
bit of logic.
2007\06\29@181535
by
Mark Rages
2007\06\29@182936
by
Gerhard Fiedler
Mark Rages wrote:
>> exception handling => safety critical stuff
>
> Exceptions considered harmful:
> http://www.joelonsoftware.com/items/2003/10/13.html
While I think he has a point, I also think he kind of takes it away when he
says:
"A better alternative is to have your functions return error values when
things go wrong, and to deal with these explicitly, no matter how verbose
it might be."
This is not any different than dealing with any exceptions explicitly, and
a lot more ugly. If you deal with all exceptions explicitly, his points are
moot. And IMO it's better readable (i.e. fewer errors) than the return code
method.
Gerhard
2007\06\29@193501
by
Peter P.
|
wouter van ooijen <wouter <at> voti.nl> writes:
> Maybe I should not react to this, but here I go...
>
> >> exception handling => safety critical stuff
> >
> > exception handling => race condition on small micro
>
> a "race" condition is something very important indeed.
A race appears when an exception is thrown and interrupts are on, if there is
more than one path to the exception handler and/or there are unguarded
variables used by the throw mechanism. There is no inherent mechanism in the
try/throw/catch paradigm that guarantees it to work other than in a single
threaded environment. Either that or the task must be fully reentrant and that
requires a full stack frame of usually large size. Afaik no such thing exists
on PICs (excepting on the largest ones).
> But I assume you meant "rare"? You did a lot of automibile, military,
> nuclear, and space projects? Ever programmed for ESA?
No, not at all. Are any PICs used in European missiles ? ;-)
> Ever programmed in a language that had exception handling, so you could
> appreciate it?
Yes, C++ and a little of others. But I did not feel like abusing it.
> > > templates => flexible libraries (reduces development costs)
> >
> > flexible libraries with C++ calling conventions => huge
> > memory and code overhead, high library porting and maintenance cost
>
> I dunno about C++ calling conventions (multiple?), C++ can call by C
> convention if you want.
C++ allows full virtual methods as you know. These need to be instantiated at
runtime i.e. a good part of the linker must be compiled into the program. And
it has to be fully reentrant and thread-safe in an interrupted environment with
no memory protection. I don't even want to think about what that would look
like, although I'm sure it can be done.
> If you meanr 0.3 to 3.0 times *more*: bullocks. Take your C code, pass
> it through a C/C++ compiler in C++ mode and get the same assembly as in
> C mode. After that, see what could be done better with C++ constructs
> and start saving code.
I think that C++ excels precisely at what is 'forbidden' on micros due to
limited resources. Other than that, you are right. So basically you's use C++
without most convenient C++ features. Whatever is good for you.
Peter P.
2007\06\30@023304
by
wouter van ooijen
> Exceptions considered harmful:
> http://www.joelonsoftware.com/items/2003/10/13> .html
That's an interesting article that totally misses an importnat point. It
is not the 'goto' that is (was) considered most harmfull, but the label
it jumps to. When you read code you can easily spot a goto, note the
label, and see where it will jump to: when you found the label you are
done. The reverse is not true: when you see a lable, you will have to
search the total scope op that label and find *all* goto's that use this
label. This asymmetry could be worded as 'come-from considered
harmfull'.
Maybe I should check Dijkstra's grave to see whether he turns areound in
anger (I am not sure this Dutch proverb translates to english?).
Oh, and for the 'add an extra parameter and check that' argument: how do
you add an extra parameter to a diadic infix operator, and how do you
check that value in the middle of an expression?
Wouter van Ooijen
-- -------------------------------------------
Van Ooijen Technische Informatica: http://www.voti.nl
consultancy, development, PICmicro products
docent Hogeschool van Utrecht: http://www.voti.nl/hvu
2007\06\30@032213
by
Peter Bindels
|
On 30/06/07, Mark Rages <RemoveMEmarkragesEraseME
EraseMEgmail.com> wrote:
> On 6/29/07, wouter van ooijen <RemoveMEwouterspam_OUT
KILLspamvoti.nl> wrote:
> > > The Atmel AVR has good GCC support, so you might want to look
> > > there. I'd be interested to see what kind of small embedded
> > > application would actualy benefit from being coded in C++ though.
> >
> > exception handling => safety critical stuff
>
> Exceptions considered harmful:
> http://www.joelonsoftware.com/items/2003/10/13.html
Whilst he has a point, I'm at the moment working in an environment
that works with return values that you have to check at every point.
This is a lot worse - you not only have to check for any return value,
but even if you know that if something is wrong in the subfunction and
you just want your caller to know that (which is fairly common
indirection, and that happens a lot on our systems) you have to
explicitly pass that value up any number of times. Moreso, if you do
not have an exceptional state, you wouldn't get an exception but you
do get a return value that you must check.
Exceptions can be programmed with. Return values cause a lot of code
bloat that doesn't add any values. Solution: /learn/ to program with
exceptions, don't reject them outright.
Oh, and "Considered Harmful considered harmful",
http://meyerweb.com/eric/comment/chech.html .
Back to the original question, thanks for the replies and I'm going to
get a small ARM sometime soon.
Regards & thanks,
Peter
2007\06\30@033202
by
Mark Rages
On 6/30/07, wouter van ooijen <RemoveMEwouterTakeThisOuT
spamvoti.nl> wrote:
> > Exceptions considered harmful:
> > http://www.joelonsoftware.com/items/2003/10/13> .html
>
> That's an interesting article that totally misses an importnat point. It
> is not the 'goto' that is (was) considered most harmfull, but the label
> it jumps to. When you read code you can easily spot a goto, note the
> label, and see where it will jump to: when you found the label you are
> done. The reverse is not true: when you see a lable, you will have to
> search the total scope op that label and find *all* goto's that use this
> label. This asymmetry could be worded as 'come-from considered
> harmfull'.
>
But it seems to me that exceptions are more like "come-from" than
"go-to". That is, you see clearly where the exception is handled, but
you don't know where it is thrown.
Regards,
Mark
markrages@gmail
--
Mark Rages, Engineer
Midwest Telecine LLC
EraseMEmarkragesspam
spamBeGonemidwesttelecine.com
2007\06\30@051829
by
wouter van ooijen
> > a "race" condition is something very important indeed.
>
> A race appears when an exception is thrown and interrupts are
> on, if there is more than one path to the exception handler
> and/or there are unguarded
> variables used by the throw mechanism. There is no inherent
> mechanism in the try/throw/catch paradigm that guarantees it
> to work other than in a single threaded environment.
I don't understand that. There is nothing in the t/t/c mechnism either
that prevents working in a multi-threaded environment.
> Either
> that or the task must be fully reentrant and that requires a
> full stack frame of usually large size. Afaik no such thing exists
> on PICs (excepting on the largest ones).
I don't see a problem on 12-bit, larger 14-bit, or 16-bit cores. And who
said this discussion was exclusively about PICs anyway?
> > Ever programmed in a language that had exception handling, so you
> > could appreciate it?
>
> Yes, C++ and a little of others. But I did not feel like abusing it.
It sounds like in your idea abusing == using. At least you have
experience with a language that has execptions, but I'd give your
opinion more weight if you had actualyy used exceptions for a year or so
and then decided it was not a good concept.
> C++ allows full virtual methods as you know. These need to be
allows yes, but you are not forced to use them unless you want to use a
construct that is not available in C. so if you just want what can be
done in C there is no added disadvantage in C++.
> C++ instantiated at
> runtime i.e. a good part of the linker must be compiled into
> the program.
Bullocks. virtual functions can be implemented by a single VFT per
class, a pointer to this VFT in each instance, and an extra indirection
for each (virtual!) function call. The linker need not be aware of this
at all.
> And
> it has to be fully reentrant and thread-safe in an
> interrupted environment with no memory protection.
What has to be "fully reentrant and thread safe"?
> I think that C++ excels precisely at what is 'forbidden' on
> micros due to limited resources. Other than that, you are
> right. So basically you's use C++ without most convenient C++
> features. Whatever is good for you.
As an example: classes with non-virtual member functions add zero
overhead.
And what is limited? The smallest LPC ARM (LPC2101) costs 1.96 (Digikey
@ 100). It has 1k RAM and 8k FLASH (or better: 2k ARM instructions or 4k
Thumb instructions). That is plenty for a small program using a lot of
C++ features. I don't say that is always a wise way to do things, but
when development cost outweights unit cost it might well be.
Wouter van Ooijen
-- -------------------------------------------
Van Ooijen Technische Informatica: http://www.voti.nl
consultancy, development, PICmicro products
docent Hogeschool van Utrecht: http://www.voti.nl/hvu
2007\06\30@052446
by
wouter van ooijen
> Back to the
> original question, thanks for the replies and I'm going to
> get a small ARM sometime soon.
If you do so, consider making a web page. We could do with some
alternatives to "my first 16c84 project"!
Wouter van Ooijen
-- -------------------------------------------
Van Ooijen Technische Informatica: http://www.voti.nl
consultancy, development, PICmicro products
docent Hogeschool van Utrecht: http://www.voti.nl/hvu
2007\06\30@052446
by
wouter van ooijen
> But it seems to me that exceptions are more like "come-from"
> than "go-to". That is, you see clearly where the exception
> is handled, but you don't know where it is thrown.
In an abstract but important way you do know: within the scope of the
catch block. (Or by a fucntion called from within, but that is
essentially the same.) A lot of things (unwidning, freeing up
recsources) can be done between the throw and the catch. If you feel
like you need to know exactly where the exception was thrown then the
construct was used badly.
Wouter van Ooijen
-- -------------------------------------------
Van Ooijen Technische Informatica: http://www.voti.nl
consultancy, development, PICmicro products
docent Hogeschool van Utrecht: http://www.voti.nl/hvu
2007\06\30@052954
by
wouter van ooijen
> And what is limited? The smallest LPC ARM (LPC2101) costs
> 1.96 (Digikey @ 100). It has 1k RAM and 8k FLASH (or better:
> 2k ARM instructions or 4k Thumb instructions). That is plenty
> for a small program using a lot of
> C++ features. I don't say that is always a wise way to do things, but
> when development cost outweights unit cost it might well be.
sorry, 2k RAM.
Wouter van Ooijen
-- -------------------------------------------
Van Ooijen Technische Informatica: http://www.voti.nl
consultancy, development, PICmicro products
docent Hogeschool van Utrecht: http://www.voti.nl/hvu
2007\06\30@094057
by
Gerhard Fiedler
wouter van ooijen wrote:
>> And it has to be fully reentrant and thread-safe in an interrupted
>> environment with no memory protection.
>
> What has to be "fully reentrant and thread safe"?
In this context, probably the exception mechanism and the handlers of
exceptions that are used in both mainline code and inside of an interrupt
handler. (Unless you of course don't use exceptions in interrupts, which
may be a reasonable restriction.)
Gerhard
2007\06\30@124743
by
wouter van ooijen
> > What has to be "fully reentrant and thread safe"?
>
> In this context, probably the exception mechanism and the
> handlers of exceptions that are used in both mainline code
> and inside of an interrupt handler. (Unless you of course
> don't use exceptions in interrupts, which may be a reasonable
> restriction.)
OK, then why should that be more problematic than any other code that
must be reentrant?
Wouter van Ooijen
-- -------------------------------------------
Van Ooijen Technische Informatica: http://www.voti.nl
consultancy, development, PICmicro products
docent Hogeschool van Utrecht: http://www.voti.nl/hvu
2007\06\30@132512
by
Gerhard Fiedler
wouter van ooijen wrote:
>>> What has to be "fully reentrant and thread safe"?
>>
>> In this context, probably the exception mechanism and the handlers of
>> exceptions that are used in both mainline code and inside of an
>> interrupt handler. (Unless you of course don't use exceptions in
>> interrupts, which may be a reasonable restriction.)
>
> OK, then why should that be more problematic than any other code that
> must be reentrant?
Maybe his thought was that this is more hidden. I don't know.
Gerhard
2007\06\30@162051
by
Peter P.
|
Gerhard Fiedler <lists <at> connectionbrazil.com> writes:
> Maybe his thought was that this is more hidden. I don't know.
I think that the throw mechanism uses the error handler and any unwinding done
to reach it in flat mode, like longjmp() in C. longjmp() is one of the things
one is expressly warned not to use in an interrupted environment. As you know,
it uses a static data structure (or several). The C++ throw mechanism very
likely uses the same paradigm but in addition to longjmp the structure is hidden
from the programmer so he cannot guard it against a concurrent task. There is no
way to know whether the time between when throw occurs and when the handler is
executed affords any protection to the variables and to the stack involved. If
an interrupt occurs in the same thread and the interrupt thread does anything
related to the throw context (such as, initializing the throw data block upon
entry into the try segment), then really bad things will happen. So unless throw
is specifically thread safe in a compiler I don't think that it can be used in
an interruptible environment.
As I wrote before, you are right, C++ or ADA or whatever is the best for the
project to be used should be used. However I usually deal with very small micros
where this cannot be justified. This reflects my point of view. Additionally,
from what I know about Linux and other embedded kernel code, C++ is avoided like
the plague in a kernel/tight timing etc context by developers. Or has been until
very recently. I think that several of the constructs that make C++ easier to
write create hidden things that interfere with operation on the 'bare metal'
with concurrent issues (as above).
Peter P.
2007\06\30@162506
by
Peter P.
wouter van ooijen <wouter <at> voti.nl> writes:
> If you do so, consider making a web page. We could do with some
> alternatives to "my first 16c84 project"!
How about 'my first PDP11 clone project, using 1MB Flash and 1MB RAM', fully
programmable in tiny ADA.
Peter P.
2007\06\30@175822
by
Peter P.
|
Peter Bindels <dascandy <at> gmail.com> writes:
> int main() {
> EventHdl handler;
> Channel serial_out(handler, uart_info);
> Button left(handler, serial_out, ...), right(handler, serial_out,
> ...), confirm(handler, serial_out, ...);
>
> handler.process();
> }
#include <CRIT.h>
#include <kbd.h.>
#include <rs232.h>
#include <timer.h>
volatile int errors = 0;
volatile int keycode = 0;
void Rs232txd {
CRITA
if((rs232->status & RS232_TXEMPTY) && keycode) {
rs232->txd = keycode;
keycode = 0;
}
CRITZ
}
void ButtonsToSerial(void) {
CRITA
if(keycode) { // overrun
errors |= TXD_OVERRUN; // NOT throw(), oops
CRITZ // !!!
return;
}
keycode = kbd->keycode;
kbd->status & ~KEY_DOWN;
CRITZ
Rs232txd;
}
int main() {
timer_init();
rs232_init();
kbd_init();
timer_setup(0, TICKS); // needed by kbd for debouncing
rs232->speed = RS232_SPEED;
rs232->txcallback = Rs232txd;
rs232_poll();
kbd->debounce = DEBOUNCE_CONSTANT;
kbd->callback = ButtonsToSerial;
kbd_poll();
idle:
goto idle;
}
Yes, I know that you described an event driven model and I a timer driven aided
one, but this illustrates just a little bit of what you need to implement to
make your 'beautiful' main() work (20-50 more lines of code missing, to do the
timer interrupts, the keyboard, and the serial and baud generator init). You or
someone who implements it (the libraries) for you. And isn't it dercandy ?
Anyway the main() is about as terse as yours.
Peter P.
'[PIC]/[EE] Small microcontroller with GCC support?'
2007\07\01@064231
by
wouter van ooijen
> I think that the throw mechanism uses the error handler and
> any unwinding done to reach it in flat mode, like longjmp()
> in C.
Which error handler are you talking about and what is 'flat mode'? ARe
you referring to a specific implementation of exception handling? If so,
remeber: the existence of a bad or broken implementation of a concept is
no proff against that conecpt!
> longjmp() is one of the things one is expressly warned
> not to use in an interrupted environment. As you know, it
> uses a static data structure (or several).
No, I don't know, because I never usef setjmp/longjmp.
> There is no way to
> know whether the time between when throw occurs and when the
> handler is executed affords any protection to the variables
> and to the stack involved.
Sorry, his makes no sense at all.
> If an interrupt occurs in the same
> thread and the interrupt thread does anything related to the
> throw context (such as, initializing the throw data block
> upon entry into the try segment),
An interrupt executes on its own stack or on an extension of the
interrupted stack. the exception throwing/hndling/catching mechanism can
(and should) be implemented fully reentrant, so there will be no problem
at all.
> So unless throw is specifically thread safe in a
> compiler I don't think that it can be used in an
> interruptible environment.
Of course, anything that is not 'reentrant'-safe can not be used in both
main and interrupts. But throw/catch can and should be fully reentrant.
Wouter van Ooijen
-- -------------------------------------------
Van Ooijen Technische Informatica: http://www.voti.nl
consultancy, development, PICmicro products
docent Hogeschool van Utrecht: http://www.voti.nl/hvu
2007\07\01@065200
by
Peter Bindels
|
On 30/06/07, Peter P. <RemoveMEplpeter2006KILLspam
yahoo.com> wrote:
> Gerhard Fiedler <lists <at> connectionbrazil.com> writes:
> > Maybe his thought was that this is more hidden. I don't know.
>
> I think that the throw mechanism uses the error handler and any unwinding done
> to reach it in flat mode, like longjmp() in C. longjmp() is one of the things
> one is expressly warned not to use in an interrupted environment. As you know,
> it uses a static data structure (or several). The C++ throw mechanism very
> likely uses the same paradigm but in addition to longjmp the structure is hidden
> from the programmer so he cannot guard it against a concurrent task.
The structure is the one that stores where to longjmp to; exceptions
most certainly don't have a longjmp-style target but rather have
exception handler frames (.ehframe) sections in the executable that
contain this information on a per-function basis, in a non-modifiable
and hence reentrant way.
Regards,
Peter
2007\07\01@065926
by
Peter Bindels
|
On 30/06/07, Peter P. <plpeter2006STOPspam
spam_OUTyahoo.com> wrote:
{Quote hidden}> #include <CRIT.h>
> #include <kbd.h.>
> #include <rs232.h>
> #include <timer.h>
>
> volatile int errors = 0;
> volatile int keycode = 0;
>
> void Rs232txd {
> CRITA
> if((rs232->status & RS232_TXEMPTY) && keycode) {
> rs232->txd = keycode;
> keycode = 0;
> }
> CRITZ
> }
>
> void ButtonsToSerial(void) {
> CRITA
> if(keycode) { // overrun
> errors |= TXD_OVERRUN; // NOT throw(), oops
> CRITZ // !!!
> return;
> }
> keycode = kbd->keycode;
> kbd->status & ~KEY_DOWN;
> CRITZ
> Rs232txd;
> }
>
> int main() {
> timer_init();
> rs232_init();
> kbd_init();
>
> timer_setup(0, TICKS); // needed by kbd for debouncing
>
> rs232->speed = RS232_SPEED;
> rs232->txcallback = Rs232txd;
> rs232_poll();
>
> kbd->debounce = DEBOUNCE_CONSTANT;
> kbd->callback = ButtonsToSerial;
> kbd_poll();
>
> idle:
> goto idle;
> }
>
> Yes, I know that you described an event driven model and I a timer driven aided
> one, but this illustrates just a little bit of what you need to implement to
> make your 'beautiful' main() work (20-50 more lines of code missing, to do the
> timer interrupts, the keyboard, and the serial and baud generator init). You or
> someone who implements it (the libraries) for you.
Which is most likely heavily unportable since you use constants and
the internal structure of these modules in your main code, you use a
goto at the end where you should've just used while(1); or for(;;);
which have the same effect but don't include a goto in the code and
your drivers seem to be unable to handle more than one given device,
which would be a problem on the aforementioned LPC2101 which has two
UARTs.
These kinds of problems are exactly why I would not want to use C as
it inspires and practically promotes this kind of structures.
> Anyway the main() is about as terse as yours.
It's about 4x as long, a lot more involved with the drivers in
question and requires a lot more care from the writer to not forget
initializing a module before use or to initialize all modules before
use just to be done with it.
> And isn't it dercandy ?
Probably. The actual nickname would be Candy but gmail requires at
least 6 characters. Not to mention that Candy is usually taken.
2007\07\01@095816
by
Gerhard Fiedler
wouter van ooijen wrote:
>> So unless throw is specifically thread safe in a compiler I don't think
>> that it can be used in an interruptible environment.
>
> Of course, anything that is not 'reentrant'-safe can not be used in both
> main and interrupts. But throw/catch can and should be fully reentrant.
I think Peter's point is that if you use a compiler in such an environment,
you better make sure that what you need is explicitly specified as
reentrant. It's just too easy for an implementation to use some static or
global variable somewhere behind the scenes to manage something -- and not
have it properly secured.
The exception mechanism is probably one of those possible problem spots,
because by definition it has one single (global) exit point -- it usually
ends up in main() if an exception doesn't get caught. So where does that
leave the not caught interrupt exception?
Gerhard
2007\07\01@105148
by
wouter van ooijen
> I think Peter's point is that if you use a compiler in such
> an environment, you better make sure that what you need is
> explicitly specified as reentrant.
That is essentially a strawman argument: bad implementations exist (or
could exist), so the language feature is bad.
> The exception mechanism is probably one of those possible
> problem spots, because by definition it has one single
> (global) exit point -- it usually ends up in main() if an
> exception doesn't get caught. So where does that leave the
> not caught interrupt exception?
I am not familiar with the semantics of propagating an exception out of
the exception handler, but if from your interrupt hndler you will use
anything that can throw an exception you'd better include an appropriate
handler - and at least for debugging one at the top that flashes some
aleam if and exception propagates up to there!
Wouter van Ooijen
-- -------------------------------------------
Van Ooijen Technische Informatica: http://www.voti.nl
consultancy, development, PICmicro products
docent Hogeschool van Utrecht: http://www.voti.nl/hvu
2007\07\01@133238
by
Gerhard Fiedler
|
wouter van ooijen wrote:
>> I think Peter's point is that if you use a compiler in such an
>> environment, you better make sure that what you need is explicitly
>> specified as reentrant.
>
> That is essentially a strawman argument: bad implementations exist (or
> could exist), so the language feature is bad.
I don't think it's necessarily a strawman argument. It's difficult to get
anything guaranteed by any software vendors these days; most things are
specified as "it's working unless it doesn't" :) The more complex a
language is, the more difficult is it to make sure for yourself, and the
more complex it may be to find out when something doesn't work as specified
(which actually happens occasionally :).
IMO this is one of the reasons why C has been around for so long in the
area of small embedded systems: it's a workable compromise. (Which is not
to say that other such compromises, and better ones for many situations,
exist.)
>> The exception mechanism is probably one of those possible problem spots,
>> because by definition it has one single (global) exit point -- it
>> usually ends up in main() if an exception doesn't get caught. So where
>> does that leave the not caught interrupt exception?
>
> I am not familiar with the semantics of propagating an exception out of
> the exception handler, ...
If I were using a compiler that supports exceptions, I would want to know
how my compiler handles this. I think if I need to be sure that exceptions
are thread-safe, I need to know how they work (internally,
implementation-wise, not how they are specified to work). Or have, for one
reason or another, a lot of confidence in the word of others (usually in
the form of good and proven documentation).
> ... but if from your interrupt hndler you will use anything that can
> throw an exception you'd better include an appropriate handler
Exceptions may be thrown for any number of reasons, and not all have
necessarily been thrown by your code (like division by 0 or stuff like
this). Unless you can trust the compiler vendor's documentation 100% (or
your own evaluation of the compiler's source code), you probably need a
catch-all exception handler in any thread or independent interrupt code
line if your compiler may throw exceptions -- even if your code doesn't
explicitly throw any exceptions.
One thing I have learned to appreciate when working with exceptions is a
complete documentation of all exceptions that may be thrown (or re-thrown,
or passed through) by any method (or operator, which is just a semantic
form of a method). But this is not always given. (This is the same as with
the code itself: often the documentation of the exceptions is three times
more than the documentation of the method core function. Which is probably
also the reason why it is so often incomplete...)
(FWIW, I'm not arguing against the use of exceptions -- just in case :)
Gerhard
2007\07\01@144530
by
Peter Bindels
|
On 01/07/07, Gerhard Fiedler <spamBeGonelistsSTOPspam
EraseMEconnectionbrazil.com> wrote:
{Quote hidden}> wouter van ooijen wrote:
>
> >> I think Peter's point is that if you use a compiler in such an
> >> environment, you better make sure that what you need is explicitly
> >> specified as reentrant.
> >
> > That is essentially a strawman argument: bad implementations exist (or
> > could exist), so the language feature is bad.
>
> I don't think it's necessarily a strawman argument. It's difficult to get
> anything guaranteed by any software vendors these days; most things are
> specified as "it's working unless it doesn't" :) The more complex a
> language is, the more difficult is it to make sure for yourself, and the
> more complex it may be to find out when something doesn't work as specified
> (which actually happens occasionally :).
>
> IMO this is one of the reasons why C has been around for so long in the
> area of small embedded systems: it's a workable compromise. (Which is not
> to say that other such compromises, and better ones for many situations,
> exist.)
The sole reason why C is abundant in embedded systems programming is
because C was abundant in embedded systems programming. Did you ever
try to convince somebody to NOT do the tread path and to try something
new? You should try - it gives you a whole new perspective on why
Windows is used everywhere, why people keep using C for embedded
systems and why people keep driving SUV's. The main answer is the
Prisoners Dilemma, which (in short) says that you have to do
everything that you could do to gain an advantage, and if you do
something different you most likely have a disadvantage.
People use C because they have code in C, people don't switch to
Pascal because of their C code base. The only difference would be in
startups - and notably startups have a high failure rate that isn't
related to the language. Which leads to statistics showing that using
C gives your project a low chance of failure (in a noncausal relation)
causing all managers to flock to C. Again.
As I've been sure of for 20 years (and given my age, that's an awful
long time for me) people use what's known to work and if you're the
one that produces what's known to work you only have to make your
application sufficient. If people accept 10 crashes per day - so be
it. The entire concept of brands and product lines never appealed to
me but unfortunately I appear to be a strong minority in that. I'm for
change if I see the results being better than before, even if I'm not
sure that the results will be better.
Apologies for the rant.
Regards,
Peter
2007\07\01@162143
by
wouter van ooijen
> The sole reason why C is abundant in embedded systems
> programming is because C was abundant in embedded systems
> programming.
> (snip)
> Apologies for the rant.
But it is IMHO still true. But a mediocre standard is sometimes still
better than no standard. If I learn my students some C that is very
probably what they will need in their jobs. They have a hard time
learning just C, I don't want to think of learning them CLU, Eiffel, a
few Ada versions, C++, a bunch of pascal-with-objects, Modula 2,
Haskell, Ruby, and a few more that I don't even know of.
Wouter van Ooijen
-- -------------------------------------------
Van Ooijen Technische Informatica: http://www.voti.nl
consultancy, development, PICmicro products
docent Hogeschool van Utrecht: http://www.voti.nl/hvu
2007\07\01@193218
by
William Chops Westfield
On Jul 1, 2007, at 11:45 AM, Peter Bindels wrote:
> People use C because they have code in C...
I don't think your argument hold up very well. Wasn't the original
Apple OS written in pascal? Wasn't ADA going to be required for all
government-funded projects? Was not PL/1 going to be THE language
for anything IBM? I don't recall C being heavily used in embedded
projects 20 years ago; I recall it being barely available for computers
as large as the IBM/PC of the day.
I think C succeeded because it was one of the few languages that
didn't include a library or run-time environment specification
that was too big for embedded systems; it was easy to SHRINK.
Eventually there were standards for C libraries, but that came
LATER...
I think you'd have a really hard time finding a set of C++
libraries and run-time environment that will work in the 4k
memory environment of even relatively large 8 to 16 bit micros.
It's pretty questionable for the single-chip ARMs with 64k or
less. Our "embedded" systems allocate at 4k to 8k for each
process or interrupt level stack (3 or 4 times that on RISC
cpus, cause of the the potentially heftier context saving),
and that's still for C. We have relatively frequent arguments
about C++, with the nay-sayers harping on just how easy it is
to suddenly use up much more of one resource or another than
you thought you were using. To use C++ on a mid-sized
microcontroller, you'd probably end up needing to restrict
yourself to a subset of features and classes that not many
people would still consider to be C++...
(How's that defined embedded subset/version of java that Sun
was pushing (javame?)? A little searching shows Sun bragging
that their CLDC JavaME implementation is targeted to devices
with "as little as 192KB of total available memory", and that
their javaSE for embedded systems has a reduced footprint of
"only 30MB." That doesn't make ME feel very warm and fuzzy.)
BillW
2007\07\01@213027
by
Gerhard Fiedler
William ChopsWestfield wrote:
> On Jul 1, 2007, at 11:45 AM, Peter Bindels wrote:
>
>> People use C because they have code in C...
>
> I don't think your argument hold up very well. Wasn't the original
> Apple OS written in pascal? Wasn't ADA going to be required for all
> government-funded projects? Was not PL/1 going to be THE language for
> anything IBM? I don't recall C being heavily used in embedded projects
> 20 years ago; I recall it being barely available for computers as large
> as the IBM/PC of the day.
I think the first popular compiler/IDE combo for the PC was Turbo Pascal.
Still alive and well (not that much so, it seems, in the USA) in the form
of its successor Delphi.
I think if you look at the details, you'll find a number of reasons why C
is actually a rather flexible compromise for the small micro area, a
flexibility that most other languages don't seem to have.
Gerhard
2007\07\01@233447
by
John Chung
|
I love assembly. It was the language I really started
to know what the computer was doing. The problem was
asm is not being used extensively in business section
and many other portions in developent. Same goes with
C, the Unix kernel uses assembly and C. Peter was
right to state that each language has their own
strengths. Imagine that the program you are
maintaining is HTML or written in Java. You just have
to use back the same technology to get it working.
Again, if the senario was written in C, you could use
assembly to rewrite portions of it BUT the developer
would miss out the reusability of the current code. I
personally do encourage all sort of languages for any
dev. work but it has to be within reason. Can the rest
of your team read your code?
John
--- Peter Bindels <KILLspamdascandyspamBeGone
gmail.com> wrote:
{Quote hidden}> On 01/07/07, Gerhard Fiedler
> <
EraseMElists
EraseMEconnectionbrazil.com> wrote:
> > wouter van ooijen wrote:
> >
> > >> I think Peter's point is that if you use a
> compiler in such an
> > >> environment, you better make sure that what you
> need is explicitly
> > >> specified as reentrant.
> > >
> > > That is essentially a strawman argument: bad
> implementations exist (or
> > > could exist), so the language feature is bad.
> >
> > I don't think it's necessarily a strawman
> argument. It's difficult to get
> > anything guaranteed by any software vendors these
> days; most things are
> > specified as "it's working unless it doesn't" :)
> The more complex a
> > language is, the more difficult is it to make sure
> for yourself, and the
> > more complex it may be to find out when something
> doesn't work as specified
> > (which actually happens occasionally :).
> >
> > IMO this is one of the reasons why C has been
> around for so long in the
> > area of small embedded systems: it's a workable
> compromise. (Which is not
> > to say that other such compromises, and better
> ones for many situations,
> > exist.)
>
> The sole reason why C is abundant in embedded
> systems programming is
> because C was abundant in embedded systems
> programming. Did you ever
> try to convince somebody to NOT do the tread path
> and to try something
> new? You should try - it gives you a whole new
> perspective on why
> Windows is used everywhere, why people keep using C
> for embedded
> systems and why people keep driving SUV's. The main
> answer is the
> Prisoners Dilemma, which (in short) says that you
> have to do
> everything that you could do to gain an advantage,
> and if you do
> something different you most likely have a
> disadvantage.
>
> People use C because they have code in C, people
> don't switch to
> Pascal because of their C code base. The only
> difference would be in
> startups - and notably startups have a high failure
> rate that isn't
> related to the language. Which leads to statistics
> showing that using
> C gives your project a low chance of failure (in a
> noncausal relation)
> causing all managers to flock to C. Again.
>
> As I've been sure of for 20 years (and given my age,
> that's an awful
> long time for me) people use what's known to work
> and if you're the
> one that produces what's known to work you only have
> to make your
> application sufficient. If people accept 10 crashes
> per day - so be
> it. The entire concept of brands and product lines
> never appealed to
> me but unfortunately I appear to be a strong
> minority in that. I'm for
> change if I see the results being better than
> before, even if I'm not
> sure that the results will be better.
>
> Apologies for the rant.
>
> Regards,
> Peter
> --
2007\07\01@233629
by
John Chung
|
--- Gerhard Fiedler <@spam@lists@spam@
spam_OUTconnectionbrazil.com>
wrote:
{Quote hidden}> wouter van ooijen wrote:
>
> >> I think Peter's point is that if you use a
> compiler in such an
> >> environment, you better make sure that what you
> need is explicitly
> >> specified as reentrant.
> >
> > That is essentially a strawman argument: bad
> implementations exist (or
> > could exist), so the language feature is bad.
>
> I don't think it's necessarily a strawman argument.
> It's difficult to get
> anything guaranteed by any software vendors these
> days; most things are
> specified as "it's working unless it doesn't" :)
> The more complex a
> language is, the more difficult is it to make sure
> for yourself, and the
> more complex it may be to find out when something
> doesn't work as specified
> (which actually happens occasionally :).
>
> IMO this is one of the reasons why C has been around
> for so long in the
> area of small embedded systems: it's a workable
> compromise. (Which is not
> to say that other such compromises, and better ones
> for many situations,
> exist.)
>
>
> >> The exception mechanism is probably one of those
> possible problem spots,
> >> because by definition it has one single (global)
> exit point -- it
> >> usually ends up in main() if an exception doesn't
> get caught. So where
> >> does that leave the not caught interrupt
> exception?
> >
> > I am not familiar with the semantics of
> propagating an exception out of
> > the exception handler, ...
>
> If I were using a compiler that supports exceptions,
> I would want to know
> how my compiler handles this. I think if I need to
> be sure that exceptions
> are thread-safe, I need to know how they work
> (internally,
> implementation-wise, not how they are specified to
> work). Or have, for one
> reason or another, a lot of confidence in the word
> of others (usually in
> the form of good and proven documentation).
>
> > ... but if from your interrupt hndler you will use
> anything that can
> > throw an exception you'd better include an
> appropriate handler
>
> Exceptions may be thrown for any number of reasons,
> and not all have
> necessarily been thrown by your code (like division
> by 0 or stuff like
> this). Unless you can trust the compiler vendor's
> documentation 100% (or
> your own evaluation of the compiler's source code),
> you probably need a
> catch-all exception handler in any thread or
> independent interrupt code
> line if your compiler may throw exceptions -- even
> if your code doesn't
> explicitly throw any exceptions.
>
> One thing I have learned to appreciate when working
> with exceptions is a
> complete documentation of all exceptions that may be
> thrown (or re-thrown,
> or passed through) by any method (or operator, which
> is just a semantic
> form of a method). But this is not always given.
> (This is the same as with
> the code itself: often the documentation of the
> exceptions is three times
> more than the documentation of the method core
> function. Which is probably
> also the reason why it is so often incomplete...)
>
> (FWIW, I'm not arguing against the use of exceptions
> -- just in case :)
>
> Gerhard
>
I agree on this matter. When it comes to
undocumented "features" reading asm listing is the
best way!
John
____________________________________________________________________________________
Pinpoint customers who are looking for what you sell.
http://searchmarketing.yahoo.com/
2007\07\02@001742
by
Nate Duehr
|
On Jul 1, 2007, at 5:32 PM, William Chops Westfield wrote:
> I think C succeeded because it was one of the few languages that
> didn't include a library or run-time environment specification
> that was too big for embedded systems; it was easy to SHRINK.
> Eventually there were standards for C libraries, but that came
> LATER...
I thought early C was well accepted because of the underlying fact
that it was a way to make Unix systems have "source code
portability". Whether or not that really was true, is debatable, but
that was the original goal.
Generally,
Unix = Source is portable, recompile on new target
Windows = Binary portability
And that's seriously over-simplified, I know -- Just trying to
explain the above point.
> I think you'd have a really hard time finding a set of C++
> libraries and run-time environment that will work in the 4k
> memory environment of even relatively large 8 to 16 bit micros.
Me too. ARM and other larger chips are not getting popular for no
reason. Price drops, processor has more horsepower and ability to do
things like your example... natural progression... but
microcontrollers will remain popular in low-power requirement
applications, probably forever... although FPGA's sure are shaking
things up, too.
{Quote hidden}> It's pretty questionable for the single-chip ARMs with 64k or
> less. Our "embedded" systems allocate at 4k to 8k for each
> process or interrupt level stack (3 or 4 times that on RISC
> cpus, cause of the the potentially heftier context saving),
> and that's still for C. We have relatively frequent arguments
> about C++, with the nay-sayers harping on just how easy it is
> to suddenly use up much more of one resource or another than
> you thought you were using. To use C++ on a mid-sized
> microcontroller, you'd probably end up needing to restrict
> yourself to a subset of features and classes that not many
> people would still consider to be C++...
The "higher level"/newer the language is... *generally* the less the
designers paid any serious attention to resource utilization, it
seems. It also seems that many of those developers also seem to have
been so disconnected throughout their formative/educational years
from how the hardware actually works (no emphasis or requirement to
ever learn any Assembly or ever work "close" to the hardware at the
bit-twiddling level).
Not saying that people don't still learn it, but the majority of
"Computer Science" majors coming out of colleges, don't seem to
really understand the architectures they work on, it's all abstracted
for them, and they've maybe had one class covering low-level hardware
design/operation and maybe one semester of Assembly.
Whether or not this is "good" or "bad", I find a boring discussion --
it just "is". For those who study the low-level stuff, and work in
industry that needs to squeeze all the performance out of a tiny 8-
bit micro they can, those people find themselves more and more
valuable these days.
> (How's that defined embedded subset/version of java that Sun
> was pushing (javame?)? A little searching shows Sun bragging
> that their CLDC JavaME implementation is targeted to devices
> with "as little as 192KB of total available memory", and that
> their javaSE for embedded systems has a reduced footprint of
> "only 30MB." That doesn't make ME feel very warm and fuzzy.)
Java's a freakin' resource pig, no matter how you slice it. Ugggh...
--
Nate Duehr
spamBeGonenate
KILLspamnatetech.com
2007\07\02@015611
by
Nate Duehr
|
On Jul 1, 2007, at 9:34 PM, John Chung wrote:
> I love assembly. It was the language I really started
> to know what the computer was doing. The problem was
> asm is not being used extensively in business section
> and many other portions in developent.
Me too. 6809. (And of course, PIC - for fun now.) Those were the
days.
The worst commercial/production code I ever saw and had to fix bugs
in, was a CGI interface in the early HTML days, written as a state-
machine in C++. Someone designing it didn't quite "get" the whole
HTML/CGI thing being "stateless" back then, and JavaScript or
anything browser-side was still just a twinkle in Netscape's eye...
that code was NASTY.
That was just plain ugly to debug (imagine the fun of hitting the
back button in the browser a few times when the back-end was coded as
a state-machine that really only knew how to go "forward" at first)
and fixing it was a huge pain. It also turned me off of coding for a
living, completely -- clear back in what... um... 1997? I stuck to
system integration, support, and found that having coded for a while,
it makes it very easy to "see" why something that's broken is likely
to be broken. You can almost intuitively figure out the Engineer's
assumptions after you see the symptoms of the bug.
Since I can also read (but not write to) our internal CVS tree for
the products I work on, I can usually confirm it too -- if I have
time -- but they say in our system that isn't my job... I just try to
document the behavior and add notes to the engineering trouble ticket
with as much info as I can glean from the source tree in a quick
look. Mostly digging through source code for anything these days is
either a) not for work, or b) just a mental exercise at work to see
if I can find it before the Engineer does.
Supporting the systems doesn't pay as well, and has much worse hours
than most of the Engineers have, and the clueful ones "get it" when
you're forced to call at 2AM with a serious/disastrous problem either
happening or brewing.
But it's definitely (to me) more satisfying than the time I spent
staring at a monitor full of someone else's hideous C++ code, with
the mandate to only spend enough time on it to fix promised features
that weren't working right in the first revision... the product line
was being killed as quickly as possible, and only one major "bug fix"
release was ever going to be allowed to be done on it.
--
Nate Duehr
.....natespam_OUT
natetech.com
2007\07\02@201607
by
Rich Satterlee
|
Peter Bindels wrote:
> Wasn't the original Apple OS written in pascal?
I wonder if you were thinking of the very popular UCSD p-SYSTEM where the
"native" compiler was Pascal? I believe that much of the OS was written in a
pascal language and then run interpretive on the "p-system". A very popular
platform for this were the Apple II's. This was circa early 80's or so.
Cheers,
Rich S.
---- Original Message ----
From: Gerhard Fiedler
Date: Sun 7/1/07 18:40
To: TakeThisOuTpiclist.....
TakeThisOuTmit.edu
Subject: Re: [PIC]/[EE] Small microcontroller with GCC support?
William ChopsWestfield wrote:
{Quote hidden}> On Jul 1, 2007, at 11:45 AM, Peter Bindels wrote:
>
>> People use C because they have code in C...
>
> I don't think your argument hold up very well. Wasn't the original
> Apple OS written in pascal? Wasn't ADA going to be required for all
> government-funded projects? Was not PL/1 going to be THE language for
> anything IBM? I don't recall C being heavily used in embedded projects
> 20 years ago; I recall it being barely available for computers as large
> as the IBM/PC of the day.
I think the first popular compiler/IDE combo for the PC was Turbo Pascal.
Still alive and well (not that much so, it seems, in the USA) in the form
of its successor Delphi.
I think if you look at the details, you'll find a number of reasons why C
is actually a rather flexible compromise for the small micro area, a
flexibility that most other languages don't seem to have.
Gerhard
2007\07\06@092815
by
Walter Banks
Rich Satterlee wrote:
{Quote hidden}> Peter Bindels wrote:
> > Wasn't the original Apple OS written in pascal?
>
> I wonder if you were thinking of the very popular UCSD p-SYSTEM where the
> "native" compiler was Pascal? I believe that much of the OS was written in a
> pascal language and then run interpretive on the "p-system". A very popular
> platform for this were the Apple II's. This was circa early 80's or so.
>
> Cheers,
>
> Rich S.
The original mac os was written in compiled pascal.
The apple][ software was written in asm. For a very interesting
piece of asm software look for Woz's floating point package
(the source is on the net in a bunch of places). To add to the
confusion it was written to accommodate a 6502 that did not
have a unconditional branch.
w..
2007\07\06@102057
by
Walter Banks
|
wouter van ooijen wrote:
{Quote hidden}> > The sole reason why C is abundant in embedded systems
> > programming is because C was abundant in embedded systems
> > programming.
> > (snip)
> > Apologies for the rant.
>
> But it is IMHO still true. But a mediocre standard is sometimes still
> better than no standard. If I learn my students some C that is very
> probably what they will need in their jobs. They have a hard time
> learning just C, I don't want to think of learning them CLU, Eiffel, a
> few Ada versions, C++, a bunch of pascal-with-objects, Modula 2,
> Haskell, Ruby, and a few more that I don't even know of.
>
> Wouter van Ooijen
C has had a lot of University promotion starting with the wide free
distribution of unix from Bell labs for all of the PDP-11's that were
common at the time and followed by GCC. There is a huge gap
between what is being taught and what the embedded industry
needs.
Wouter you don't mention it specifically but many students would
benefit from some exposure to functional languages. (Haskell, Logo
ML) Programming in a functional language changes the way
problems are organized and separates much more clearly problem
and implementation. Engineers generally are encouraged to treat
functional languages as toys (because some of them are) They never
get to the point they see them as engines capable effectively solving
some very complex non linear control problems.
Peter has raised some import points about how we organize problems
implemented on the Microchip PIC and other small processors. I as
a tool provider am very interested in finding out what cannot be
practically expressed. If we put just a fragment of the effort we have
used to optimize our current implementations in C and asm to
encapsulating applications what would the effect on the generated
code standard as an industry. All of us have to fight off inbred
prejudices and conventional wisdoms.
I was part of the ill-fated embedded C++ discussions and standards
that failed in part because it did not identify what was actually needed
in embedded applications. We need to separate out exception handling,
encapsulation, templates software reliability and event driven
programming (being introduced in all new releases of our C compiler
tools) and ee how each are needed in the various applications we are
implementing.
Language is about how we express the problem, without the words
and grammar we are speechless.
My inhibitors didn't hold...
What is actually needed in embedded applications?
What is hard to express in our tools?
Walter Banks
--
Byte Craft Limited
Tel. (519) 888-6911
http://www.bytecraft.com
TakeThisOuTwalterKILLspam
spambytecraft.com
2007\07\06@160704
by
wouter van ooijen
> Wouter you don't mention it specifically but many students
> would benefit from some exposure to functional languages.
I agree, but I would empahasizae *lazy* functional language. Eager
functional programming can be done in almost any language, including C.
> Engineers generally are
> encouraged to treat functional languages as toys (because
> some of them are) They never get to the point they see them
> as engines capable effectively solving some very complex non
> linear control problems.
But the problem is timing. Timing of (L)F languages is difficult to
analyse (if possible at all), and handling of state, andtime-depenent
input and output, which are very important in typical engineering work,
are cumbersome (at least last time I looked, maybe 8 y ago).
> I as a tool provider am very interested in
> finding out what cannot be practically expressed.
timing? stack level use? efficient booleans?
One of the things I wanted to do in Jal but never got around to (I could
not even find the suitable source language constructs) is controlled
timing. Just think of a software UART transmit routine, at let's say ~
10 instructions per baud. Not difficult to do by hand in assembler, but
it gets messy when you add banking and paging instructions (vary by PIC
type) and output shadow registers (12 and 14 bit cores). Why can't I
just specify that between this line and that line exactly x ms must
elaps, and the compiler takes care of this (up to the resolution of a
single instruction). When it is in a loop the compiler can do an overall
resolution of 1 instruction / iterations. And this must be done over
various clock ferquencies, PIC architectures etc. A real cahllenge would
be to do this on an ARM (with a much less predicatble instruction
timing).
> Language is about how we express the problem, without the
> words and grammar we are speechless.
Unfortunately the reverse is also true: once we have words they shape
our thoughts. The pen is mightier than the sword.
Wouter van Ooijen
-- -------------------------------------------
Van Ooijen Technische Informatica: http://www.voti.nl
consultancy, development, PICmicro products
docent Hogeschool van Utrecht: http://www.voti.nl/hvu
2007\07\07@081059
by
Walter Banks
|
wouter van ooijen wrote:
> But the problem is timing. Timing of (L)F languages is difficult to
> analyse (if possible at all), and handling of state, andtime-depenent
> input and output, which are very important in typical engineering work,
>
I am seeing more and more control problems being implemented as
a layered system with the top layer dealing with control approach
and the lower layer I/O specific often spread over multiple
processors. (L)F on the top layer has possibilities. Your point
about timing is well taken. I also don't know of any serious attempt
to create functional languages for embedded work on small systems.
The only small commercial application I know that was implemented
with a functional language approach was "furby". There was nothing
special about the hardware requirements it could have been done
on a 14 bit PIC.
> > Language is about how we express the problem, without the
> > words and grammar we are speechless.
>
> Unfortunately the reverse is also true: once we have words they shape
> our thoughts. The pen is mightier than the sword.
The Japanese expression "Language is culture" comes to mind
w..
2007\07\10@181713
by
olin piclist
Walter Banks wrote:
> What is actually needed in embedded applications?
A decent language. I use mostly assembler for lots of reasons having
nothing to do with the high level language tools available. We have pushed
toward somewhat higher level programming by use of the MPASM macro
capability and by features created ourselves with our PREPIC PIC assembler
preprocessor. The few times I might have used a real compiler I didn't
because:
1 - They're all (mostly) in C. Standards are good in the right
circumstances, but unfortunately also become a refuge for the unimaginative
and lazy. Your own company is guilty of this too. C is by far the worst
programming language to ever get widespread use. There are just too many
things broken in the C definition that I would never chose C for any project
of my own accord. I have used C on PICs because the customer insisted on it
or I received code in C that would have been too expensive to re-develop.
I'm rarely concerned with portability of my PIC code to other platforms, so
I'd much rather see a decent language that aids in responsible programming
and that was designed for the PIC or small systems in general than something
"standard" and ugly like C. The silly thing is that by the time you add the
stuff to make C useable on a PIC you've left the standard behind anyway.
That means you end up with the worst of both worlds, a awful language that
still isn't well suited to the PIC environment.
2 - They don't integrate well with MPASM/MPLAB. I'm always going to have
some assembler, so a compiler that doesn't play nice with my large existing
library of MPASM code is useless to me. At least with Microchip C18 it is
possible to create a mixed MPASM/C18 project, but it's nowhere near as easy
as they would have you believe. This is partly due to them making some
downright stupid choices for things like FSR use, stack conventions, and
subroutine linkage conventions. Of course it can be done and we've done it,
but it's not that "nice". We have a C18COMP switch in our assembler
facilities and in the build scripts that switches things into the less
efficient C18 compatibility mode.
Other compilers are even worse than C18 in that you have to use their
assembler. That ain't gonna happen.
3 - Aside from C being a awful language in general, it lacks features
important on small systems like PICs. There is no seamless integration with
assembler (It should be able to read MPASM include files, and the assembler
should be able to read the HLL include files. If done properly both would
be a single translator.), no understanding of multiple address spaces each
with their own limitations and pointer types, no instruction-level timing
capability, no built in data types of explicit width (int8u_t, int16u_t,
etc), etc. For example, 24 bit floating point makes a lot of sense on PIC
16 and PIC 18, assuming you need the dynamic range. One part in 65K is
plenty for intermediate calculations when your inputs are 10 bit A/D
readings and outputs are 8 bit PWM duty cycles. 32 bit IEEE standard
floating point is just silly in the vast majority of such applications, but
yet that's the common floating point format for PIC 16 and PIC 18 compilers.
4 - The few compilers that aren't C have so little use that I don't trust
them. Compilers for small systems are buggy enough that I want as many
other people using the same compiler as possible. I don't want to be a test
pilot, so I'll leave the niche compilers (no matter how nice the language)
to others.
In the end I'm going to stick to my PIC development environment and MPASM.
I can crank out PIC projects using that environment quickly and reliably
with very few bugs. Some who don't really understand the issues always say
they can develop a project more quickly in a HLL than in assembler. But
they are usually comparing artificial projects and not using expert level
assembler programmers with a large pile of tested reusable code all within a
consistent framework already sitting on the disk. They also usually compare
the more algorithmic code where a HLL really does win. But look at most PIC
projects and you will see that this kind of non-IO pure number crunching
code is very rare. The real work of a PIC project is to first design the
architecture to use the PIC capabilities effectively, and then most of the
code is in some way related to PIC-specific peripherals or other PIC
specific limitations. Something like solving a quadratic equation, for
example, is a very very small part of overall PIC code. Even if that part
becomes free, you haven't gained much. You'll gain a lot more by embracing
the PIC architecture instead of trying to get your tools to work around it,
and by getting really good at learning how to use it effectively.
I'll probably continue to enhance PREPIC as I wish I had a feature. For
those willing to look at PREPIC, you can see that most of its features are
not aimed at the kinds of things HLLs generally solve for you on a micro,
but mostly at allowing good coding practises that reduce the chance of human
error and make it easier and more reliable to change global parameters,
while not getting in the way of regular MPASM programming. IN other words,
things a really good assembler would have built in. Frankly, everybody
should be using PREPIC for assembler projects, if only for the /INBIT and
/OUTBIT commands.
********************************************************************
Embed Inc, Littleton Massachusetts, http://www.embedinc.com/products
(978) 742-9014. Gold level PIC consultants since 2000.
2007\07\12@094255
by
Rikard Bosnjakovic
2007\07\12@100408
by
wouter van ooijen
> > There are just too many things broken in the C definition
> that I would
> > never chose C for any project of my own accord.
>
> Broken things, like what?
I am no C basher, but I can think of a LOT of things! just a few:
- struct tag in a different namespace
- array/pointer different yet the same
- condition / character / integer are all the same
- old/new style function decalarations
- if(a>b); (etc) is allowed
- if(a=b) is allowed
- is a char signed or unsigned?
- type declaration syntax
- small things pass by value, arrays pass by reference (structs?)
- arithemetic evaluation rules are not 8-bit friendly
Wouter van Ooijen
-- -------------------------------------------
Van Ooijen Technische Informatica: http://www.voti.nl
consultancy, development, PICmicro products
docent Hogeschool van Utrecht: http://www.voti.nl/hvu
2007\07\12@104552
by
Nicola Perotto
2007\07\12@115902
by
Rich Satterlee
|
Walter Banks wrote:
>> What is actually needed in embedded applications?
------------------------<snip>------------------------------------------------
>1 - They're all (mostly) in C. Standards are good in the right
>circumstances, but unfortunately also become a refuge for the unimaginative
>and lazy.
Yep. That's me. Lazy. I've had to learn too many programming languages already
and I am loath to learn yet another one. YADL (yet another darned language).
I evaluated C in the early 80's. A mixed compiler/assembler output for a 68000
showed me that I should add C to my toolbox in addition to my assembly language
stuff because:
1. It produced pretty tight/effecient code, allbeit not as tight as a well thought
out assembly language routine, but still pretty darned good. After all, if they
could make a fairly fast operating system, mainly composed of C code and that seemed
to be portable....
2. It was a "dirty" language. I found the "weaknesses" of C actually an asset when
dealing with low level, I/O wiggling stuff.
3. It was getting popular by that time.
4. It "fit" a certian class of solutions mainly:
a. gather some data
b. run through some sort of algorithm, maybe with floating point numbers
c. output some state/value according to the results of b.
d. go back and do it again.
So, I bought a copy of Aztec C for C/PM and loaded it up on my S100 machine.
The proof of the pudding is that I'm still programming ARM chips in C. Still have
to learn assembly language, but........
Cheers,
Rich S.
------------------------<snip>------------------------------------------------
2007\07\12@123010
by
Neil Baylis
Olin wrote:
> C is by far the worst programming language to ever get widespread use. There are just too many things broken in the C definition that I would never chose C for any project of my own accord.
It's not broken. There are clearly things you don't like about it, but
that doesn't make it broken. The very fact that it is in such
widespread use is strong evidence that C does in fact enable folks to
get a great deal of useful work done.
Whether it's the best choice for a small device like a PIC.. well
that's a different proposition.
2007\07\12@145027
by
Peter Bindels
|
On 12/07/07, wouter van ooijen <spamBeGonewouter@spam@
spam_OUTvoti.nl> wrote:
> I am no C basher, but I can think of a LOT of things! just a few:
>
> - struct tag in a different namespace
Is a problem. Fixed in C++ as you can't fix it in C without breaking
significant backward compatibility.
> - array/pointer different yet the same
Array is treated differently to allow a few things that you otherwise
couldn't do (sizeof in particular). For the rest it's equal.
> - condition / character / integer are all the same
Depends on your view of the language whether that's bad. IMO it's good
as, at least, the x86 processor evaluate that way too, making it
pretty efficient on checking for null pointers etc.
> - old/new style function decalarations
Fixed in C++.
> - if(a>b); (etc) is allowed
With warnings, usually. Disabling/not enabling warnings is pretty
stupid. The language allows you to say pretty much everything but it
should warn you about stuff you really should only do if you know
pretty damn sure that that's what you want.
> - if(a=b) is allowed
Same.
> - is a char signed or unsigned?
Neither, for purposes of overloading. A char is used for only ASCII
text which is only 7-bit so there's no difference either way. The most
efficient for the particular device can be chosen by the implementers.
If you want a signed char or an unsigned char, say so.
> - type declaration syntax
What part of it?
> - small things pass by value, arrays pass by reference (structs?)
Completely untrue. All pass by value unless you pass a pointer, in
which case the pointer passes by value. There's a good reason why you
shouldn't pass a struct in a parameter list as it's very likely not
efficient. You can pass whole C++ objects by value if you like (and
it's commonly done too).
> - arithemetic evaluation rules are not 8-bit friendly
Which rules?
2007\07\12@154457
by
John Temples
On Thu, 12 Jul 2007, Peter Bindels wrote:
>> - old/new style function decalarations
> Fixed in C++.
It's been officially obsolescent in C for 8 years, and I can't see how
it's a problem anyway.
--
John W. Temples, III
2007\07\12@195409
by
James Newtons Massmind
> What is actually needed in embedded applications?
The biggest complaint I have about high level languages is that they don't
generate readable ASM code. No matter how hard the compiler writer tries,
there is always some bug, some problem, or just some misunderstanding
between what I wrote in the HLL and what it produced in ASM. So I need to be
able to see that, and when necessary, comment out the line in the HLL and
inline MY assembly so I can get the freaking job done.
I have to agree with Olin that any HLL for the PIC should work with MPASM.
Including macros.
I'm currently working with IAR systems C/C++ for the MSP430. It does ok, but
the only real way to see what it put out is in the debugger. Then I have to
figure out why it generated THAT instead of what I expected and go tweak
pragmas, pour through pages of options, or whatever until I get it to do as
I wish. It feels like I'm riding a wild bull; I have no control of the
thing. Makes me nuts.
Why not put the options in the code editor? So after a compile, if there are
three ways to generate ASM from a line of C code, show a mark and if the
user clicks it, the compiler can offer up the options that relate to that
code. I pick the one I like and the appropriate pragma gets dropped in at
that point.
> What is hard to express in our tools?
Time has already been mentioned and I totally fail to see why it is so darn
hard for a compiler to pad code or call a delay routine so that the
generated ASM takes the specified number of cycles OR through an error if it
can't figure out how to code it in that.
Another thing that is hard to express is more efficient code: Hand coded ASM
can sometimes (not always) be tighter than the C compiler. When I need that,
I want it put in. Why can't I build up MY library of divide code for
different sized operators and have the compiler drop it in automatically
when it needs it? Try some generic library code first, and then look at my
"database of known magically good code" and see if there isn't a better one
in there. If so, use that instead.
Finally, it's probably just me, but I would like to be able to describe the
hardware in the source code file. Potentially, a simulator could then
include hardware simulation of the circuit at the same time it was
simulating the software. That HAS been done, but not terribly well:
http://www.feertech.com/misim/screens.html
---
James Newton: PICList webmaster/Admin
TakeThisOuTjamesnewtonspam
piclist.com 1-619-652-0593 phone
http://www.piclist.com/member/JMN-EFP-786
PIC/PICList FAQ: http://www.piclist.com
2007\07\12@231638
by
John Chung
|
I have used C and ASM. Most of the time exclusively.
Yes there is all those magic thingsss with C can do
and will not do adequately. Still there are strengths
to it's use. Example:
1) I don need to know the asm for the uC. *Okay this
is rather bad but at least I do take time learning
about the architecture of the uC....*
2) When I was developing on the PC I assumed that
the C compiler was adequate on most things. But then
came PIC and blew away how code generation was
done.....
3) Namespace I can live without it. Just use more
meaningful names in your identifiers.
4) More ppl know C which "allows" code
maintenance...
All in all C has it's place. I can blame C++ which is
quite badly implemented but can do NEAT things. Still
there are flaws to each language. Assembly is more
usable thanks to MACROS but without them would be
frightening.
John
--- Nicola Perotto <nicolaEraseME
nicolaperotto.it> wrote:
> This is a hoax but very amusing:
> http://www.gnu.org/fun/jokes/unix-hoax.html
> and wikipedia is also intersting:
>
en.wikipedia.org/wiki/Criticism_of_the_C_programming_language
{Quote hidden}>
>
> Rikard Bosnjakovic wrote:
> > On 7/11/07, Olin Lathrop
> <
RemoveMEolin_piclistEraseME
spam_OUTembedinc.com> wrote:
> >
> >
> >> There are just too many things broken in the C
> definition that I would never chose
> >> C for any project of my own accord.
> >>
> >
> > Broken things, like what?
> >
> >
> >
> --
2007\07\13@071742
by
Gerhard Fiedler
|
James Newtons Massmind wrote:
> Why not put the options in the code editor? So after a compile, if there
> are three ways to generate ASM from a line of C code, show a mark and if
> the user clicks it, the compiler can offer up the options that relate to
> that code. I pick the one I like and the appropriate pragma gets dropped
> in at that point.
This sounds nice :)
> Try some generic library code first, and then look at my "database of
> known magically good code" and see if there isn't a better one in there.
> If so, use that instead.
I think with most C compilers, this is partly possible. You can write your
own libraries, and link them in. The compiler will then give preference to
your libs, substituting the routines provided by the compiler mfr with your
own ones. Of course this only works with routines that are in libs, and in
the granularity that the libs have.
Other than that, it seems awfully difficult for arbitrary code snippets to
be used automagically.
> Finally, it's probably just me, but I would like to be able to describe
> the hardware in the source code file. Potentially, a simulator could
> then include hardware simulation of the circuit at the same time it was
> simulating the software. That HAS been done, but not terribly well:
> http://www.feertech.com/misim/screens.html
For integrated hardware/firmware simulation, Proteus
<http://www.labcenter.co.uk> does a quite good job. But it's not a hardware
description inside the firmware sources, it's plugging the firmware sources
into a model of a component of a hardware simulation. (You probably can
write the SPICE sources as text, which would then be closer to "describe
the hardware in the source code", but it may be too close :)
Gerhard
2007\07\14@070329
by
Walter Banks
|
There have a been a bunch of good points raised. I need to add
one more tools companies need to communicate what they
do better.
For processors like the PIC there needs to be a way to work with
assembler. As much as I will argue that assembler isn't needed
http://www.bytecraft.com/C_versus_Assembly
there are that places where assembler can and should be used.
Libraries of debugged assembler functions,
small sequences of specific instruction and
James's case of getting the freaking job done.
For compatibility with MPASM you have to be able to use
MPASM not the current MPASM but the version of
MPASM you have.
This is where communication comes in on tool vendors part.
At least for MPC you can assemble a library of routines in
MPASM (Or any tool) into machine code and write a
header file and access those routines directly from C. The
extensions to the header syntax allows arguments to be passed
scatter gather so C will interface to the machine code in
however the code passes arguments. The C compiler
doesn't touch the code it doesn't "optimize it" The compiler
interfaces to the execution image directly. If the MPASM
code needs full control of some system resource like a
block of the processor registers then telling the compiler
is all that is needed.
> small sequences of specific instruction and
> James's case of getting the freaking job done.
Why not be able to do this? Part is communication.
Assemblers in C compilers should be different from
standalone assemblers. Assemblers in C compilers
need to reference C variables by name (No addition
of underscore or other transformation).
Assemblers in C compilers need to be able to use
C macros or asm macros. ASM labels and variables
need to be referenced from C by name. This
is important to support Olin's point that asm header
files need to be read into a C compiler and referenced.
One thing that has come out of this discussion is
Byte Craft will make processing the MPASM inc
files a release requirement for new releases of MPC.
Inline asm gets applied unoptimized as written.
Walter Banks
--
Byte Craft Limited
Tel. (519) 888-6911
http://www.bytecraft.com
@spam@walterRemoveME
EraseMEbytecraft.com
James Newtons Massmind wrote:
{Quote hidden}> > What is actually needed in embedded applications?
>
> The biggest complaint I have about high level languages is that they don't
> generate readable ASM code. No matter how hard the compiler writer tries,
> there is always some bug, some problem, or just some misunderstanding
> between what I wrote in the HLL and what it produced in ASM. So I need to be
> able to see that, and when necessary, comment out the line in the HLL and
> inline MY assembly so I can get the freaking job done.
>
> I have to agree with Olin that any HLL for the PIC should work with MPASM.
> Including macros.
>
2007\07\14@090403
by
Walter Banks
|
James Newtons Massmind wrote:
> > What is hard to express in our tools?
>
> Time has already been mentioned and I totally fail to see why it is so darn
> hard for a compiler to pad code or call a delay routine so that the
> generated ASM takes the specified number of cycles OR through an error if it
> can't figure out how to code it in that.
Delays are reasonable well covered. Specify delay in usec msec or
sec and that is about it.
Constant execution time has two open problems.
How to specify the constraint.
What to do about run time dependent code sequences. (variable dependent
execution time in a PC for example)
> Another thing that is hard to express is more efficient code: Hand coded ASM
> can sometimes (not always) be tighter than the C compiler. When I need that,
> I want it put in.
> Why can't I build up MY library of divide code for
> different sized operators and have the compiler drop it in automatically
> when it needs it?
You can in most cases. What may be missing is the library calling
sequences the compiler uses (Documentation) All our libraries
are shipped with sources and users can replace or modify them
> Finally, it's probably just me, but I would like to be able to describe the
> hardware in the source code file. Potentially, a simulator could then
> include hardware simulation of the circuit at the same time it was
> simulating the software. That HAS been done, but not terribly well:
> http://www.feertech.com/misim/screens.html
There have been many attempts at this. BCDirect in the .cod file is a
generic messaging system that creates reports. These reports can
be used to preset break points, reference regression tests for each
of the used library functions, pass setup information for debuggers
and simulators, or reference hardware detail.
Think generic messages with address context created from
messaging pragma directives in source code (including PIC).
A surprising number of applications are multiprocessor. Most are
heterogeneous (not the expected homogeneous sharing the task for
bandwidth). We are seeing compiler messaging as a way to tie
these multiprocessor systems together. A single make will
generate all of the code used by the system of multiprocessors.
Compiler messaging will create a report with details from one
processor that is included in the build of code for a second
processor.
This same mechanism is a way to create inter operability between
several code generation tools on a single processor. In practical
terms one tool can export a list of the remaining processor
resources (RAM registers ROM) and interface to generated
code. The report can be as simple as a header file with
defined constants and function prototypes. It could include code
images as well.
This kind of stuff is happening a lot in the automotive industry
where there has been a strong focus on inter operability between
tool sets.
Walter Banks
--
Byte Craft Limited
Tel. (519) 888-6911
http://www.bytecraft.com
EraseMEwalter
@spam@bytecraft.com
2007\07\14@093817
by
olin piclist
Walter Banks wrote:
> For compatibility with MPASM you have to be able to use
> MPASM not the current MPASM but the version of
> MPASM you have.
I'm not sure what you are saying, but this sounds like a non-issue to me.
First, MPASM is backward compatible to a high degree so it shouldn't much
matter which (recent) version you are using. Second, the latest version of
MPASM is always freely available, so I don't see the problem telling a user
they have to upgrade. If a new compiler release only works with specific
MPLAB versions just say so. Then people can judge on their own if they want
to use it and can't complain when it doesn't work with a different version.
By the way, it is the MPLAB version that should be stated, not the MPASM,
MPLINK, etc, version. Only the MPLAB version is easily known, and all the
tools of differing version numbers are bundled in it.
> At least for MPC
You're acting like we're supposed to know what MPC is, but you haven't
defined that term.
********************************************************************
Embed Inc, Littleton Massachusetts, http://www.embedinc.com/products
(978) 742-9014. Gold level PIC consultants since 2000.
2007\07\14@100953
by
olin piclist
Walter Banks wrote:
> Constant execution time has two open problems.
> How to specify the constraint.
Probably a special block for that purpose:
fixedtime 10 us begin
blah
blah
blah
end
> What to do about run time dependent code sequences.
The block must have a single entry and exit. If/then/else may be allowed
and you pad the shorter case to match the longer case. Loops are not
allowed. If any branch exceeds the time without padding then you get a
compile time error.
There is no need to solve all problems for all cases. You can see how I
handle this in assembler by looking at the WAITxxx macros in STD.INS.ASPIC
at http://www.embedinc.com/pic. They still require some counting of
instruction cycles to use, but at least you can specify a fixed delay time
and the right number of extra instruction cycles are inserted automatically
depending on the instruction rate. You can change the oscillator speed and
rebuild, and the delays will still be correct in absolute time.
A compiler could do basically the same, except it counts the fixed
instruction cycles instead of the programmer supplying the count.
Actually now that I think about this more, I'm not sure this makes sense for
a compiler. The usual case for needing this kind of timing is you want two
hardware operations performed a fixed time apart, like when wiggling a
serial output line from software UART code. Since there is no guarantee how
many cycles a HLL source line compiles to, and where within those cycles the
critical operation takes place, specifying a fixed execution time for a
sequence of HLL source lines isn't useful. For example, a compiler might
have to set the bank before some operation in some cases but not in others,
and it might implement some things as library calls and others as in-line
code, and even a mixture of the two per source line. How is the compiler to
know the critical moment in time within the sequence of instructions
generated by a source line that the user considers the single action of that
source line?
I think this argument gets back to HLLs are good for certain things and
shouldn't try to solve all problems. Use a decent syntax for your HLL that
encourages good programming, maximizes the chance of catching likely errors,
and generally makes the code readable so someone not familiar with the
language can still get a basic idea what's going on.
You want instruction level timing? Use assembler.
********************************************************************
Embed Inc, Littleton Massachusetts, http://www.embedinc.com/products
(978) 742-9014. Gold level PIC consultants since 2000.
2007\07\14@173137
by
Peter Bindels
On 14/07/07, Walter Banks <@spam@walterspam_OUT
.....bytecraft.com> wrote:
> What to do about run time dependent code sequences. (variable dependent
> execution time in a PC for example)
That's a common problem in encryption, where it's possible for some
decryptors to decipher a bit of the key if you know how long it took
to decrypt something - the solution is to time-pad the checker. This
would also be best off in a microcontroller as they have much easier
instruction timings - usually X cycles per instruction. That's easy to
fix up.
Inlining code sequences in asm should be specified in a header and
then inserted in a highly optimized way. I tend to make asm calls
defines because function call overhead would be significant (both in
code size, execution time and debugging lines on my asm-level
debugger).
2007\07\15@071206
by
Walter Banks
|
Olin Lathrop wrote:
{Quote hidden}> Walter Banks wrote:
> > Constant execution time has two open problems.
> > How to specify the constraint.
>
> Probably a special block for that purpose:
>
> fixedtime 10 us begin
> blah
> blah
> blah
> end
>
> > What to do about run time dependent code sequences.
>
> The block must have a single entry and exit. If/then/else may be allowed
> and you pad the shorter case to match the longer case. Loops are not
> allowed. If any branch exceeds the time without padding then you get a
> compile time error.
This topic has come up on comp.arch.embedded a couple times. In one
of those discussions I looked at the problem with a quite a bit of detail
and was startled to find how many cases where execution timing was
data dependent. For example a multiple and other library calls. (I know
a multiply can be written with constant time) These can be detected in the
compiler, the real question is at what point does the compiler tell the
application developer that a sequence cannot be constant timed.
{Quote hidden}>
> There is no need to solve all problems for all cases. You can see how I
> handle this in assembler by looking at the WAITxxx macros in STD.INS.ASPIC
> at
http://www.embedinc.com/pic. They still require some counting of
> instruction cycles to use, but at least you can specify a fixed delay time
> and the right number of extra instruction cycles are inserted automatically
> depending on the instruction rate. You can change the oscillator speed and
> rebuild, and the delays will still be correct in absolute time.
>
> A compiler could do basically the same, except it counts the fixed
> instruction cycles instead of the programmer supplying the count.
A compiler in general does a good job at accounting and this is an
accounting problem. A compiler has both control and data flow
information that makes the implementation task relatively easy.
> Actually now that I think about this more, I'm not sure this makes sense for
> a compiler. The usual case for needing this kind of timing is you want two
> hardware operations performed a fixed time apart, like when wiggling a
> serial output line from software UART code.
At high baud rates (10's of instructions per bit) might make a good
example test case.
> I think this argument gets back to HLLs are good for certain things and
> shouldn't try to solve all problems. Use a decent syntax for your HLL that
> encourages good programming, maximizes the chance of catching likely errors,
> and generally makes the code readable so someone not familiar with the
> language can still get a basic idea what's going on.
We are on the same page on this one
> You want instruction level timing? Use assembler.
The current choice is inline asm for tight constant length sequences.
At some point I would like to create a constraint based syntax in
a HLL and at the same set realistic expectations for what the
compiler can do.
Walter Banks
--
Byte Craft Limited
Tel. (519) 888-6911
http://www.bytecraft.com
spamBeGonewalterEraseME
bytecraft.com
2007\07\15@082623
by
olin piclist
Walter Banks wrote:
> At high baud rates (10's of instructions per bit) might make a good
> example test case.
That's not "high" baud rate. I once did a 9600 baud UART in a PIC with a
160KHz clock. That comes out to 4.2 instructions per bit time. Assembly
time calculations added extra NOPs as needed for correct timing, including
taking care of the cumulative error.
Again, I see nothing wrong with saying this is a inappropriate requirement
on a HLL. I'd be impressed if you can show me a HLL that can do this. On
the other hand, I'd be very reluctant to use it for this case. This kind of
code is at least as easy to write in assembler, and I'd worry about compiler
bugs in such a fringe feature. So I'd break even or only slightly lose (I
may feel obligated to check the compiler's output) at best by using a HLL.
A single compiler bug in 100 cases puts this in the solid loss column for
the HLL. No thanks.
This really gets back to what HLLs are good for on small systems (no OS,
frequently up against resource constraints, always need to be aware or
hardware details). Legitimate reasons are:
- Complicated data structures.
- High level relatively hardware-independent control code.
- Math beyond what the native instruction set provides.
Abuse of HLL reasons are:
- Don't want to learn instruction set
- Don't want to learn hardware peripheral details
People that won't or can't learn low level details of such systems don't
belong there no matter what language they use. The right answer is to tell
them to find something else to do. Note that speed of implementation is not
in either group above, because this is a small advantage in some areas and a
hinderance in other to those with good proficiency in the low levels. It
would be less of a hinderance with some better HLL than C, but that's the
only real choice currently.
However I understand as a compiler vendor you can't do that since I suspect
the majority of your customers fall into the second catagory. And Microchip
can't do that either because they like to pretend that using PICs is easy
("only 35 instructions!"), and besides even the clueless may put together
projects that result in significant sales of chips. In otherwords, as in
the rest of life, lazy or incompetent people are profitable to sell to. The
corrolary is that the lazy and incompetent with their large purchasing power
get to define the products we all end up having to use.
So this is all a long winded way of saying to forget about it. The lazy or
incompetent will only shoot themselves in the foot with HLL level timing
and/or eat up all your profits with support costs. The experts aren't going
to use it anyway. So this has been a nice theoretical discussions, but
alas, pointless.
********************************************************************
Embed Inc, Littleton Massachusetts, http://www.embedinc.com/products
(978) 742-9014. Gold level PIC consultants since 2000.
2007\07\15@100858
by
wouter van ooijen
> This topic has come up on comp.arch.embedded a couple times.
> In one of those discussions I looked at the problem with a
> quite a bit of detail and was startled to find how many cases
> where execution timing was data dependent. For example a
> multiple and other library calls. (I know a multiply can be
> written with constant time) These can be detected in the
> compiler, the real question is at what point does the
> compiler tell the application developer that a sequence
> cannot be constant timed.
When the programmer specifies contant time and the compiler can't
fulfill that it should issue an error at the point where the constant
time is specified, identifying the exact reason. Maybe or maybe at the
call that causes it, with a reference to the constant-time request (like
for a double declaration).
But in a lot of cases a compiler might be able to choose a constant-time
alternative. The user wanted constant-time, so that's what the compiler
must do, even at the expense of extra code etc.
> A compiler in general does a good job at accounting
That is exactly where a compiler shines compared to a human. The human
should do the creative part, the compiler the accounting.
Wouter van Ooijen
-- -------------------------------------------
Van Ooijen Technische Informatica: http://www.voti.nl
consultancy, development, PICmicro products
docent Hogeschool van Utrecht: http://www.voti.nl/hvu
2007\07\15@124057
by
Xiaofan Chen
On 7/15/07, Olin Lathrop <olin_piclistspamBeGone
embedinc.com> wrote:
>
> This really gets back to what HLLs are good for on small systems (no OS,
> frequently up against resource constraints, always need to be aware or
> hardware details). Legitimate reasons are:
>
> - Complicated data structures.
>
> - High level relatively hardware-independent control code.
>
> - Math beyond what the native instruction set provides.
I think HLL like C is also easier to maintain than assembly code. The
speed of the development also plays a part. Thiese two reasons are
important for choosing the HLL over commercial project.
Your programming environment is already at a level higher than
pure assembly. And I think it is still much more difficult for people to
understand your code (say the EasyProg Firmware which is not
big at all) than it is if you write it in a decent C compiler (say Hitech PICC).
> Abuse of HLL reasons are:
> - Don't want to learn instruction set
> - Don't want to learn hardware peripheral details
>
This is not the problem for HLL but the problem of the people
who are using it. Embedded firmware developers in the
area you defined need to know the underline hardware anyway.
With MCUs like PIC18F/dsPIC and ARMs coming out, I believe
HLL like C will be more and more useful even in the small
system small you defined (no OS, frequently up against resource
constraints, always need to be aware or hardware details).
Example: you write the USB code in assembly for PIC18F2550.
But the majority of the people will use MPLAB C18 or other
C compiler.
Xiaofan
2007\07\15@132616
by
Bob Blick
Olin Lathrop wrote:
> So this is all a long winded way of saying to forget about it. The lazy or
> incompetent will only shoot themselves in the foot with HLL level timing
> and/or eat up all your profits with support costs. The experts aren't going
> to use it anyway. So this has been a nice theoretical discussions, but
> alas, pointless.
Your entire email was funny, but this last part had me laughing. I
suppose if one is operating in a bubble, it might be possible to
consider this a serious position, but to the rest of us, it's hilarious.
High level languages make it possible for me to be agile, pick the best
processor for the job, and code up a working program in an hour.
I'm not stuck using PICs because I've got too much invested in assembler
to dare switch.
Both you and Walter are smart guys, but Walter sees the big picture, and
has thought about ways to make C better. I say "more power to him".
Cheerful regards,
Bob
2007\07\15@133836
by
wouter van ooijen
> - Don't want to learn instruction set
Why is that an abuse? I have done a few 18F projects with the C18
compiler. I know the instruction set a little bit, but I have no desire
to learn it better. What is wrong with that?
> - Don't want to learn hardware peripheral details
That has nothing to do with HLL, everything with use of a library versus
using the peripheral directly (at the register level). In the same 18F
projects I used the library when I felt like it. It allowed me to finish
the project faster. What's wrong with that?
Wouter van Ooijen
-- -------------------------------------------
Van Ooijen Technische Informatica: http://www.voti.nl
consultancy, development, PICmicro products
docent Hogeschool van Utrecht: http://www.voti.nl/hvu
2007\07\15@184500
by
Walter Banks
|
Olin Lathrop wrote:
{Quote hidden}> Walter Banks wrote:
> > At high baud rates (10's of instructions per bit) might make a good
> > example test case.
>
> That's not "high" baud rate. I once did a 9600 baud UART in a PIC with a
> 160KHz clock. That comes out to 4.2 instructions per bit time. Assembly
> time calculations added extra NOPs as needed for correct timing, including
> taking care of the cumulative error.
>
> I'd be impressed if you can show me a HLL that can do this.
This is an interesting paragraph that adds a lot of information to the
constraint timing requirements. Cumulated and sequential timing is
important as well as per bit timing. The next step is how to describe
the timing requirements.
The test case now becomes 9600 baud UART on a PIC initially
running at 160Khz compared to asm code.
The tests are how cleanly can the code generation change when
the clock speed is changed to 200Khz, 4 Mhz and processor
changes between architectures from 12,14,16 bit.
As soon as we start computing fractions of an instruction it
opens the question of should we be taking advantage of the
instruction transfer edges to reduce jitter.
Walter Banks
--
Byte Craft Limited
Tel. (519) 888-6911
http://www.bytecraft.com
RemoveMEwalter@spam@
spamBeGonebytecraft.com
2007\07\15@191831
by
olin piclist
Walter Banks wrote:
> As soon as we start computing fractions of an instruction it
> opens the question of should we be taking advantage of the
> instruction transfer edges to reduce jitter.
I'm not sure what you mean by instruction transfer edges, but any one
section of code can of course only take a integer number of instruction
cycles. The user may need to be a little clever to eliminate long term
error, but this can still be done with abutting sections of specified
execution time.
In my case I wanted a average of 4.2 cycles per code section. The low level
assembler macro just guaranteed some number of instruction cycles since a
label, assuming one address meant one instruction cycle, which was true in
my case. Higher level assembly time logic in the top level source code did
the figuring of how many instruction cycles to specify for each bit. This
same higher level logic could be applied on top of a HLL facility that
provided fixed timing for a block.
But again, do you really want to do this?
********************************************************************
Embed Inc, Littleton Massachusetts, http://www.embedinc.com/products
(978) 742-9014. Gold level PIC consultants since 2000.
2007\07\16@041721
by
Peter Bindels
|
On 16/07/07, Olin Lathrop <.....olin_piclist@spam@
EraseMEembedinc.com> wrote:
> But again, do you really want to do this?
Considering the idea, I find it a particularly challenging target to
hit with a compiler code generator - static interleaving of functions
so that one receives as much computing time as it can and the other
can perform one instruction per N. I'm not going to do it as I would
say - just use a second PIC for that part and make a simpler
connection between them. Maintaining a program with such constraints
is pretty much impossible, especially if you didn't write it.
Did you realise that any construction you make in your assembler to
match these constraints can also be applied in a HLL compiler, with
equal effectiveness? In other words, there's nothing you can do in
assembler that you can't also do in a HLL, given the ability to adjust
the compiler in a generic way.
Walter,
Is it possible to make something akin to plugins or loadable code
generation hints that allow the compiler to match a given code
sequence with constraints and to replace it with another? This would
have to be before the timing checker, but I do think this would be
very useful; if you know something the compiler doesn't, tell it
(specific version of my mantra "fix problems where they are, not where
the symptoms show").
2007\07\16@073234
by
Gerhard Fiedler
wouter van ooijen wrote:
>> - Don't want to learn instruction set
>
> Why is that an abuse? I have done a few 18F projects with the C18
> compiler. I know the instruction set a little bit, but I have no desire
> to learn it better.
Exactly. There's a big difference between having a passive knowledge of the
instruction set (i.e. being able to understand the compiler-generated code
when needed, possibly with the help of an instruction table :) and having
an active knowledge of it (required to actually write code).
Then there's what Xiaofan wrote: Olin doesn't program in (pure) assembler,
he programs in ASPIC. Which is probably as difficult to learn as C (and for
me and many others it would be much more difficult to learn).
Gerhard
2007\07\16@081130
by
Russell McMahon
> Then there's what Xiaofan wrote: Olin doesn't program in (pure)
> assembler,
> he programs in ASPIC. Which is probably as difficult to learn as C
> (and for
> me and many others it would be much more difficult to learn).
Real men write in pure machine code :-)
By that definition I stopped being a real man long ago - I'm pleased
to say.
After that almost anything else is easier :-).
The MC6800 was especially well suited to it as it grouped it's bit
fields in a very consistent manner. Many processors scatter the bits
for various fields in various locations and even in "incorrect" orders
within the program words making hand compilation and code reading far
far harder.
Russell
Some things burn in (variably accurately) forever:
86 44 (1000 0110 0100 0100) **
B7 4044 ( ...
B6 4088
26 03
CE 2956
...
** 206 104 ......... aaaaagh!!! No.
2007\07\16@083106
by
wouter van ooijen
> Real men write in pure machine code :-)
Those are the stupid beef eaters. REAL men write their own compiler, and
enter it either using toggle switches or a hand-punched paper tape.
(note: I am a vegetarian, so I don't qualify for 'real man' anyway)
> Some things burn in (variably accurately) forever:
I think I can still read some Z80 hex, but I am sure I can't write it
any more :(
Wouter van Ooijen
-- -------------------------------------------
Van Ooijen Technische Informatica: http://www.voti.nl
consultancy, development, PICmicro products
docent Hogeschool van Utrecht: http://www.voti.nl/hvu
2007\07\16@085302
by
Dario Greggio
wouter van ooijen wrote:
>>Real men write in pure machine code :-)
>
> Those are the stupid beef eaters. REAL men write their own compiler, and
> enter it either using toggle switches or a hand-punched paper tape.
I did write one in 1989, for Acorn Archimedes... using their Basic!
Have been porting it to C/C++ later, and still worked on it as of 2001.
> I think I can still read some Z80 hex, but I am sure I can't write it
> any more :(
I can read 6502 ASM well enough... I know it's much simpler :)))
--
Ciao, Dario
2007\07\16@101802
by
Russell McMahon
|
>> Real men write in pure machine code :-)
> Those are the stupid beef eaters. REAL men write their own compiler,
> and
> enter it either using toggle switches or a hand-punched paper tape.
You don't need a compiler when you write machine code in directly from
your head :-).
Long long ago (uphill both ways snow no shoes etc) I had an impressive
enough trick with a Motorola 'D2' kit. This had an ?6? digit 7
segment display plus a hex keypad. Usually 4 digits were 16 bit
address and 2 digits were 8 bit data but you could address the display
under program control. So, turn on power and spend several minutes
entering data with the hex keypad. Then press "RUN" and, if I'd done
it correctly" a moving message display with a readable enough
alphanumeric message (with a bit of care re what characters were used)
would scroll across the 6 digit display. This required entry of the
message data, delay routine, load message, shift display left and misc
housekeeping. Not overly hard but more impressive for those who knew a
little about what was involved than for the totally uninitiated. While
some people I knew could probably have done this by rote memory it was
easier for me to remember the program functions and actually code them
as I went - presumably (memory fades) in the same order each time so
the code was probably identical).
I haven't done anything approaching that level of (apparent)
programming arcanery for quite some while.
Russell
2007\07\16@112936
by
Rich Satterlee
|
Yet another walk down memory lane.
Anybody remember the Signetics 8X300?
Now there, I *DID* program in machine language. It had 8 instructions, all single
16 bit words. Well grouped too. The most significant bits were the op code, there
were mostly 2 register operands following that. No exclusive or instruction, no
stack, 16bit program bus and 8 bit data bus. Octal representation of it's program
word on it's ICE system.
It was actually faster to patch the ICE with an instruction or two. One could
do a jump to an unused bit of program store, put in the patch and jump back to
the post patch jump+1. In the mid 70's, we had a time share that we had to run
to get to the assembler. Let's see. a 6 was an XMIT (load) instruction and I
think a 7 was a jump...
AND IT HAS A HARVARD ARCHITECTURE! Where have I seen that recently......
Cheers,
Rich S.
---- Original Message ----
From: wouter van ooijen
Date: Mon 7/16/07 5:43
To: 'Microcontroller discussion list - Public.'
Subject: RE: [PIC]/[EE] Small microcontroller with GCC support?
> Real men write in pure machine code :-)
Those are the stupid beef eaters. REAL men write their own compiler, and
enter it either using toggle switches or a hand-punched paper tape.
(note: I am a vegetarian, so I don't qualify for 'real man' anyway)
> Some things burn in (variably accurately) forever:
I think I can still read some Z80 hex, but I am sure I can't write it
any more :(
Wouter van Ooijen
-- -------------------------------------------
Van Ooijen Technische Informatica: http://www.voti.nl
consultancy, development, PICmicro products
docent Hogeschool van Utrecht: http://www.voti.nl/hvu
2007\07\16@113447
by
Alan B. Pearce
>Real men write in pure machine code :-)
<VBG> One machine I worked on the assembler was called 'Real' - stood for
'Relocatable Assembly Language'.
2007\07\16@114649
by
Walter Banks
|
Olin Lathrop wrote:
{Quote hidden}> Walter Banks wrote:
> > As soon as we start computing fractions of an instruction it
> > opens the question of should we be taking advantage of the
> > instruction transfer edges to reduce jitter.
>
> I'm not sure what you mean by instruction transfer edges, but any one
> section of code can of course only take a integer number of instruction
> cycles. The user may need to be a little clever to eliminate long term
> error, but this can still be done with abutting sections of specified
> execution time.
Some processors do the actual transfer in and out of an I/O bit
on different clock edges depending on the instruction. I haven't
checked the Microchip PIC execution flows yet to see if this
is possible. A friend of mine sent me some communication
code about a year ago for a processor that he was the architect
on that he reduced jitter by clever use of instruction selection. In his
example ReadModifyWrite instructions wrote on a different
cycle than Write instructions (The instructions were the same
length). He had written a small program that tracked the clock
edges. We might do similar tricks by setting and clearing read and
write bits. This is the kind of thing that we might be able to achieve
sub instruction I/O timing.
Walter Banks
--
Byte Craft Limited
Tel. (519) 888-6911
http://www.bytecraft.com
.....walterRemoveME
bytecraft.com
2007\07\16@115208
by
Alan B. Pearce
>Anybody remember the Signetics 8X300?
As I recall it, that was a bipolar bit slice unit with instruction decode
and register set in it, is that correct?
Sort of fell by the wayside when the AMD2900 4 bit wide unit came out with
lower power consumption and expandable to 4n bits wide, where n could be
almost any number of chips. I think the 2900 was also faster (100nS cycle
for the earliest units IIRC, later ones were faster).
Part of my last job in NZ was repairing processors made from 2900 bit slice
units. The later 2nd source chips were even faster and lower power.
2007\07\16@122455
by
Rich Satterlee
|
Right you are! My first real job out of college was with Scientific Micro Systems,
which used to be Signetics Memory Systems and they developed the 8X300. So,
there was a vested interest in using that chip.
Yep it is/was bipolar. Low power Schottky. Sucked up a ton of power. We had
to use fusible link proms to program them with too. I think we used nibble wide
proms for production. Seems like we tried to reuse the once programmed proms with
patching so we didn't have to throw away a full set of proms for a patch.
I also remember some of the "system" multi chip modules we used to do. These included
seperate modules on a ceramic header with CPU and I/O modules on them.
It was a strange critter.
Cheers,
Rich S.
---- Original Message ----
From: Alan B. Pearce
Date: Mon 7/16/07 9:08
To: Microcontroller discussion list - Public.
Subject: Re: [PIC]/[EE] Small microcontroller with GCC support?
>Anybody remember the Signetics 8X300?
As I recall it, that was a bipolar bit slice unit with instruction decode
and register set in it, is that correct?
Sort of fell by the wayside when the AMD2900 4 bit wide unit came out with
lower power consumption and expandable to 4n bits wide, where n could be
almost any number of chips. I think the 2900 was also faster (100nS cycle
for the earliest units IIRC, later ones were faster).
Part of my last job in NZ was repairing processors made from 2900 bit slice
units. The later 2nd source chips were even faster and lower power.
2007\07\16@124655
by
olin piclist
Walter Banks wrote:
> Some processors do the actual transfer in and out of an I/O bit
> on different clock edges depending on the instruction.
I think all PICs write the bit on the third Q cycle, but it's been a while
since I looked at that. In my UART code I didn't take this into account,
but I probably used the same instruction to write the I/O bit anyway, so it
wouldn't have mattered.
********************************************************************
Embed Inc, Littleton Massachusetts, http://www.embedinc.com/products
(978) 742-9014. Gold level PIC consultants since 2000.
2007\07\21@073639
by
Howard Winter
On Mon, 16 Jul 2007 16:34:36 +0100, Alan B. Pearce wrote:
> >Real men write in pure machine code :-)
>
> <VBG> One machine I worked on the assembler was called 'Real' - stood for
> 'Relocatable Assembly Language'.
LOL! I remember hearing about that one - and about "English", so-called because it was supposedly as easy to write a program as to say what you
wanted it to do. It was nothing but marketing drivel, of course - the instructions were all recognisable words, but it was no easier than any other
language to learn and use.
Cheers,
Howard Winter
St.Albans, England
More... (looser matching)
- Last day of these posts
- In 2007
, 2008 only
- Today
- New search...