Shop OBEX P1 Docs P2 Docs Learn Events
Smallest PASM program possible? — Parallax Forums

Smallest PASM program possible?

HollyMinkowskiHollyMinkowski Posts: 1,398
edited 2010-07-21 02:09 in General Discussion
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 smile.gif
5 longs... Just an endless loop...

IYX8yTNp.jpeg

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.

6iXONtN1.jpeg


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

  • wjsteelewjsteele Posts: 697
    edited 2010-07-20 12:43
    Actually, why start out setting the clock? You can do that later.

    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
  • HollyMinkowskiHollyMinkowski Posts: 1,398
    edited 2010-07-20 12:58
    Yes of course!
    What was I thinking?

    For a program that does basically nothing, RCFAST
    is probably fast enough smile.gif

    POgUEsa.jpeg

    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 smile.gif


    But it simulates well in Gear smile.gif

    Mkll8t47.jpeg

    xFEEPlaN.jpeg

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    justasm.blogspot.com/

    Post Edited (HollyMinkowski) : 7/21/2010 1:31:38 AM GMT
  • John R.John R. Posts: 1,376
    edited 2010-07-20 14:20
    Setting the clock doesn't take up any space in the program (the endless loop is still 5 longs), and not including that bit of "housekeeping" could really set up a new user for problems in the long run.

    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
  • ratronicratronic Posts: 1,451
    edited 2010-07-20 17:31
    Holly - it's nice to point out not to forget the # when showing a jmp. Look at your last example.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ···································Fix it, if it ain't broke!


    D Rat

    Dave Ratcliff N6YEE
  • wjsteelewjsteele Posts: 697
    edited 2010-07-20 19:46
    John R. said...
    Setting the clock doesn't take up any space in the program (the endless loop is still 5 longs), and not including that bit of "housekeeping" could really set up a new user for problems in the long run.
    Actually, being a professional trainer (and developer,) I highly recommend against doing exactly that.
    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
  • John R.John R. Posts: 1,376
    edited 2010-07-20 20:04
    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
  • wjsteelewjsteele Posts: 697
    edited 2010-07-21 01:25
    Heck, it makes no difference if you teach them during the first blinky example anyway. wink.gif
  • HollyMinkowskiHollyMinkowski Posts: 1,398
    edited 2010-07-21 01:27
    @ratronic

    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 smile.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    justasm.blogspot.com/
  • SeariderSearider Posts: 290
    edited 2010-07-21 01:52
    Most likely it would jmp to a Parallax universe.cool.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

    Searider
  • wjsteelewjsteele Posts: 697
    edited 2010-07-21 02:06
    Oh gosh... parallel computing, parallel universe... and now parallax universe. My brain is getting all mushy, now... fuzzy, like string theory... or m-theory.

    BTW... this thread should really be over in the prop area! smile.gif That way we get all the propeller heads spinning over there! (Get the pun? :-D )

    Bill
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-07-21 02:09
    I still forget the "#" -- with depressing regularity. So now, after entering a block of code, I do a Find for "jmp" and "djnz" (I hardly ever use "tjz" or "tjnz") and check every instance, just in case. I've found that it's way quicker than trying to figure out why my program doesn't work.

    -Phil
Sign In or Register to comment.