Is there any speed advantage?

clockwork

Member
I have just read the thread "Picaxe based Segway project". I noticed that a Picaxe chip may not be fast enough to operate
this project.

I am aware that the Programming Editor has the capability to compile code to assembler and that Tech Supplies list the BAS800 Pic Programmer.

So it appears possible to perfect a program in Basic, test it out on a Picaxe, and after correcting any errors to compile the program into Assember
and program a PIC chip. Is this correct?

If this is the case (and assuming the PIC chip and Picaxe chip are the same basic chip) will there be any speed advantage in using the PIC chip.
I am assuming that both run a simple program that just switches a port on and off repeatedly to provide a square wave output for example.

Is the PC chip running the assembled hex code faster in operation than the Picaxe chip running its interpreted program. If this is correct is it possible to say
how much faster a PIC chip could theoretically operate at?

I am interested to see what the forum members have to say.


Many thanks Clockwork
 

nick12ab

Senior Member
I am aware that the Programming Editor has the capability to compile code to assembler and that Tech Supplies list the BAS800 Pic Programmer.

So it appears possible to perfect a program in Basic, test it out on a Picaxe, and after correcting any errors to compile the program into Assember
and program a PIC chip. Is this correct?
No, because the BASIC compiler for PIC chips has only a limited set of instructions.

Is the PC chip running the assembled hex code faster in operation than the Picaxe chip running its interpreted program.
Yes, about 100-250 times faster.
 

srnet

Senior Member
And there are a number of compilers out there that will take a program written in Basic, C or Pascal and compile it into assembler for downloading into a PIC. These too are faster than PICAXE basic, but not as fast as writing code direct in assembler.
 

hippy

Ex-Staff (retired)
The general case is that compiled code is faster than interpreted code, but not always by such a great amount as might be expected.

For a simple case of toggling a specific I/O pin then it would be reasonable to expect speed gains of 250-fold, for an I/O pin specified by a variable perhaps 100-fold, but for complicated maths you could get considerably less.

It all depends upon how the compiler converts code, how it is designed and whether optimising for speed, for code size, or even for ease of producing the compiler product itself. There are compilers which don't actually "compile" in the usual sense of the meaning but actually generate an interpreter to do the job and there'd be far less speed gain there.

The BAS800 Basic to Assembler converter is an educational tool with only limited command support, as nick12ab notes, designed to illustrate that translation capability and is not optimised for speed.
 
Top