Smallest PASM program possible?
HollyMinkowski
Posts: 1,398
I was just sitting here at my bench thinking about
what to post on my blog as the absolute minimal PASM
program that would compile and run. I came up with this
and it compiles and runs (at least in gear on my laptop)
My thinking is to start at the bare minimum and build up
from there.
Surely I can explain how each line of this snip of code works
5 longs... Just an endless loop...
Next would be the minimal program that would actually
do something. This one is 7 longs and turns on an LED
by setting pin0 high....then proceeds to an endless loop.
Next I would post a program that turns on an LED in
a proper fashion.
Then one that flashes it.
Then one that turns on an LED if you press a button.
etc..etc..etc
Just thought I'd post these 2 as a curiosity.
It's a slow afternoon here while a test is being made.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
justasm.blogspot.com/
what to post on my blog as the absolute minimal PASM
program that would compile and run. I came up with this
and it compiles and runs (at least in gear on my laptop)
My thinking is to start at the bare minimum and build up
from there.
Surely I can explain how each line of this snip of code works
5 longs... Just an endless loop...
Next would be the minimal program that would actually
do something. This one is 7 longs and turns on an LED
by setting pin0 high....then proceeds to an endless loop.
Next I would post a program that turns on an LED in
a proper fashion.
Then one that flashes it.
Then one that turns on an LED if you press a button.
etc..etc..etc
Just thought I'd post these 2 as a curiosity.
It's a slow afternoon here while a test is being made.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
justasm.blogspot.com/
Comments
Also, I might consider an XOR instruction right away inplace of the second MOV, because it would "flash" the LED in the same amount of code. Then you can introduce the WAITCNT and JMP #A·to slow it down to a visible blink.· Just a thought.
Bill
Post Edited (wjsteele) : 7/20/2010 12:51:55 PM GMT
What was I thinking?
For a program that does basically nothing, RCFAST
is probably fast enough
xor outa, #1
That's a good thought, but just moving something is easier
for the total newbie to grasp. xor is just a bit more exotic
But it simulates well in Gear
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
justasm.blogspot.com/
Post Edited (HollyMinkowski) : 7/21/2010 1:31:38 AM GMT
Yes, it's two lines of code to explain, but without them, anything requiring good timing (like serial communication with the PST for debugging, etc.) will not work.
Why not start a new user on the right foot, even if all you explain is that "These two lines sets the clock speed, and will be explained in more detail at a latter time."
Just my opinion...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
John R.
Click here to see my Nomad Build Log
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
···································Fix it, if it ain't broke!
D Rat
Dave Ratcliff N6YEE
People (especially developers)·are too curious and it will simply distract them if they sit and try to figure that out while you are trying to teach them some other concept.
My suggestion is to leave it out, and then maybe introduce that clocking concept right after you do the flashing, that way they can see the result and benefit, but you don't want to distract from them learning the other concepts first.
Bill
While I understand your point, and also understand that for some people saying "the set the clock speed, and we'll learn more latter" won't fly. BUT, how many programs don't NEED to have those statements?
I think we might end up agreeing to disagree.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
John R.
Click here to see my Nomad Build Log
Thanks for spotting that.
I'm always forgetting and leaving off the # arrrrgh!
And it's a really great way to send your PASM code off
into the unknown, maybe it jumps over to a parallel
universe
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
justasm.blogspot.com/
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Searider
BTW... this thread should really be over in the prop area! That way we get all the propeller heads spinning over there! (Get the pun? :-D )
Bill
-Phil