Re: Learning to use PICS
From: Sergio Masci (sergio_at_NO.SPAM.xcprod.com)
Date: 11/27/04
- Next message: Wally: "Re: Multi-output regulated PSU"
- Previous message: Q-man: "frequency mixing : ~ns electrical pulse at 100kHz + 400MHz RF sinusoidal wave"
- In reply to: David Harper: "Re: Learning to use PICS"
- Next in thread: john jardine: "Re: Learning to use PICS"
- Reply: john jardine: "Re: Learning to use PICS"
- Messages sorted by: [ date ] [ thread ]
Date: Sat, 27 Nov 2004 15:03:57 -0000
David Harper <dave.harper@gmail.com> wrote in message
news:364fd697.0411241017.59f6c3e@posting.google.com...
> archilochus57@yahoo.com (Colubris) wrote in message
news:<b42cfb8e.0411231312.19522505@posting.google.com>...
> > dave.harper@gmail.com (David Harper) wrote in message
news:<364fd697.0411230747.559ea3c6@posting.google.com>...
> > > I'm interested in learning how to use PICS. I've done lots of
> > > advanced stuff with the Basic Stamps, but am starting to feel some
> > > speed, capacity, and temperature (low) limitations. I'm wondering if
> > > there are PICS out there that are more rugged, have more memory, and
> > > are considerably faster than BS modules. Not to mention, the prices
> > > I've seen are alot lower. :-)
> > >
> > > Thanks in advance for any suggestions, insight, or comments!
> > > Dave
> >
> > Hi Dave,
> > Since you're experienced with the BASIC Stamps, you might consider
> > PicBASIC (www.melabs.com) or one of the other BASIC compilers.
> > The commands are more-or-less the same, but you can buy your PIC
> > processors for a few dollars in the temp range that you need. You'll
> > need to build/buy a programmer.
> > I made a "picall" programmer, and use the free software for it:
> > www.picallw.com
> >
> > Not quite as fast or code-space efficient as assembly - but much
> > better than the Stamps.
> >
> > You can try out PicBASIC free at www.compilespot.com
> >
> > There are also a few BASIC compilers available free for the AVR's -
> > sorry, no links for those.
> >
> > Arch
>
> So those compilers allow standard PICS (from Microchip Technologies)
> to be programed in BASIC? How much slower is a PIC program in BASIC
> than assembly?
>
> Thanks!
> Dave
This depends on three things (1) the person doing the programming in
assembler,
(2) the BASIC compiler and (3) the complexity of the problem.
A good BASIC compiler WILL produce code that is within 10-20% of that
produced
by an experienced assembler programmer. If the assembler programmer is not
very
experienced then a good BASIC compiler WILL produce code that is MUCH more
efficient.
As the complexity of a problem increases so too does the ability of a good
compiler to outperform the assembler programmer. The compiler is a tool that
enables the computer to automatically perform hundreds of thousands of tests
on
your code. A good compiler will search for optimisations that an experienced
assembler programmer would find laborious and a non-experienced assembler
programmer would not even know about. Most importantly, the compiler can do
all
this work each and every time you make a change to your program. An
assembler
programmer would typically only look at a small part of the program when he
changes it.
Some compilers convert BASIC source code into a special internal form that
requires an interpreter to run. This internal code is downloaded into the
PIC
and then processed by an interpreter that is running on the PIC. Each
instruction in the BASIC program is effectively executed by the interpreter.
If
the instruction is executed 10 times in the BASIC source then it will be
executed 10 times by the interpreter.
Some compilers convert BASIC source code into machine code which is the same
stuff that assemblers produce. A mediocre compiler will generate several
machine
code instructions for each BASIC instruction. A good compiler will combine
multiple BASIC instructions and generate fewer machine code instructions.
Programs executed by an interpreter WILL run much (several hundred times)
slower
than an optimised machine code executable produced by a good compiler that
produces machine code.
The XCSB compiler will convert the following to just 6 machine code
instructions:
proc inline set_bit(ubyte *addr, ubyte id)
*addr = *addr | (1 << id)
endproc
proc inline clear_bit(ubyte *addr, ubyte id)
*addr = *addr & ~(1 << id)
endproc
proc inline ubyte test_bit(ubyte *addr, ubyte id)
return (*addr & (1 << id) != 0)
endproc
proc main()
ubyte a, b
if (test_bit(&a, 1) then
set_bit(&b, 2)
else
clear_bit(&b, 2)
endif
endproc
A 20MHz 16F876 can execute (aprox) 5,000,000 machine code instructions per
second.
Regards
Sergio Masci
http://www.xcprod.com/titan/XCSB - optimising PIC compiler
FREE for personal non-commercial use
- Next message: Wally: "Re: Multi-output regulated PSU"
- Previous message: Q-man: "frequency mixing : ~ns electrical pulse at 100kHz + 400MHz RF sinusoidal wave"
- In reply to: David Harper: "Re: Learning to use PICS"
- Next in thread: john jardine: "Re: Learning to use PICS"
- Reply: john jardine: "Re: Learning to use PICS"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|