Shop OBEX P1 Docs P2 Docs Learn Events
[resolved][puzzle] PASM beginners only - Page 2 — Parallax Forums

[resolved][puzzle] PASM beginners only

2»

Comments

  • Beau SchwabeBeau Schwabe Posts: 6,569
    edited 2010-09-01 23:43
    jazzed,

    There is a way to do it without using any auxiliary constants that requires only three instructions.
  • jazzedjazzed Posts: 11,803
    edited 2010-09-02 00:00
    jazzed,

    There is a way to do it without using any auxiliary constants that requires only three instructions.
    I found one while you were posting :)
  • kuronekokuroneko Posts: 3,623
    edited 2010-09-02 00:27
    jazzed wrote: »
    I guess you're right. How about this instead?

    That's the one :)
  • ColeyColey Posts: 1,128
    edited 2010-09-02 01:38
    Thsi is exactly the sort of thread that would put off a newbie, especially a newbie in PASM.

    What started off as a request for beginners has now descended into a competition by the PASM experts.... Most of the PASM code snippets posted aren't commented, how are beginners going to learn anything from this???

    I think there is a large chasm that sits between SPIN and PASM, there's nothing to guide you across it at the moment.

    I hope you will take this constructive criticism as I believe the intention behind this thread was to help beginners (thanks kuroneko!), it all just looks like white noise now :shakehead:

    Regards,

    Coley
  • kuronekokuroneko Posts: 3,623
    edited 2010-09-02 02:21
    Coley wrote: »
    This is exactly the sort of thread that would put off a newbie, especially a newbie in PASM.

    @all: So what can be done better apart from commenting? I get the feeling that there are many people wanting too take the plunge (to learn PASM) but hardly anyone of them is prepared to participate in this kind of discussions. Why not? We don't eat participants :)

    The reason I started this thread was that the code fragment in question just looked wrong to me. I mean we have conditional execution and lots of exotic instructions so I went and found a solution which looked right to me. You don't learn this kind of stuff by reading tutorials (someone will disagree I'm sure). As it was simple enough I made it into a puzzle.

    So fire away!
  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2010-09-02 03:34
    As a newbie to PASM, I agree with Coley in part.
    Some of these examples are more confusing than helpful.

    But, I also agree with kuroneko in that "You don't learn this kind of stuff by reading tutorials" so I just skip over the abstract stuff for now and hope to explore it later.

    The way kuroneko helped me out with my ASM - Move a BYTE into a LONG? post http://forums.parallax.com/showthread.php?t=125346 was great and I really appreciate him taking time to help me understand!

    - Ron
  • jazzedjazzed Posts: 11,803
    edited 2010-09-02 07:44
    Coley wrote: »
    Most of the PASM code snippets posted aren't commented, how are beginners going to learn anything from this???
    There are different ways and things to learn. In this case hopefully a beginner will learn by pulling out the manual and trying to understand it themselves.

    People who don't like puzzles or don't have patience might seriously consider becoming some other kind of a beginner. Aligning one's goals with one's natural tendencies will be more satisfying in the end. Perpetuating excuses does not help people become satisfied.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-09-02 09:05
    I think the main take-away lesson from this puzzle for beginners is that they get to learn about a new instruction that doesn't exist in most microcontroller repertoires, namely the cmpsub instruction. What allows this instruction to shorten the code is that its effect on the carry flag is the opposite of other compares and subtracts, i.e., it is set when unsigned(D => S), not when unsigned(D < S). By specifying the nr (no result) modifier, it turns into a simple "reverse compare" operation, without the subtraction taking place. (BTW, if you look at the opcodes for cmp and sub, you'll see that they, too, are the same. The only difference is that cmp defaults to nr and sub defaults to wr.)

    Now, why does such an instruction even exist? It's main raison d'
  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2010-09-02 09:34
    Phil,
    The first instruction is supposed to be CMP (not CP) correct? :smilewinkgrin:
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-09-02 09:38
    Yup, fixed. Sorry!

    -Phil
  • SeariderSearider Posts: 290
    edited 2010-09-02 14:11
    I'm a PASM beginner and this thread does NOT put me off. I admit that I had to re-read parts and some parts went over the top but I learned something and I am a beginner so I think it was appropriate.

    thx
  • bill190bill190 Posts: 769
    edited 2010-09-02 16:55
    Searider wrote: »
    I'm a PASM beginner and this thread does NOT put me off. I admit that I had to re-read parts and some parts went over the top but I learned something and I am a beginner so I think it was appropriate.

    That's how I learn. Sometimes I need to read things 6 times.

    I used to be able to go buy a book by a different author about something and the explanations would be worded differently. So between two different books on the same subject, one or the other would make things "click".

    But lately there will be 10 books on the same subject and they are all just copies of the same exact wording used by the manufacturer's technical document (Not Parallax, others). Arrggg! (I'm buying the book because I don't understand the manufacturer's document...)
  • K2K2 Posts: 693
    edited 2010-09-02 22:43
    jazzed wrote: »
    People who don't like puzzles or don't have patience might seriously consider becoming some other kind of a beginner. Aligning one's goals with one's natural tendencies will be more satisfying in the end. Perpetuating excuses does not help people become satisfied.

    This is a very interesting point.

    I had a roommate in college who loved playing with his calculator. He'd spend hours studying its internal structure and disassembling its code. I was bored stiff with my own calculator unless I was using it to solve a physics or engineering problem, and then I adored it.

    Many people here find the Propeller captivating and wish to understand it thoroughly and exploit its unusual architecture in ever more creative ways. I think it was Dr. Acula who made a comparison between dissecting cadavers in medical school and discovering the Propeller.

    Then there are some of us who view the Propeller not as the patient but as the scalpel - a sharp tool that is a valuable aid in the exploration of something else. That's my circumstance. The Propeller is compelling to me primarily because it provides a very favorable MIPS/money ratio for some of my computationally intensive projects.

    I'm quick to get annoyed when unusual circumstances impede the timely deployment of code. And there have been many such circumstances with the Prop. There have also been many helpful individuals who have gone out of their way to make up the difference.

    One of these days I may want to play with the Prop. For now I just want it (them) to do a job. I wish to devote my puzzling time and attention to the real puzzle...the one that the Propellers are helping me solve.

    FWIW, everything is performing absolutely wonderfully. In a few more days, 64 additional cogs will join the quest. (multiplicative cogs arrive next year)
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-09-03 00:16
    K2,

    Play is an essential part of any learning process, even if you think that what you're learning is only the means to another end. By opening our minds to playfulness, process becomes an end in itself, rather than just another soul-sucking step in the quest to reach a "higher" goal. Focusing on the goal alone, rather than enjoying the process of getting there is what leads to frustration, despite any externalities one might wish to blame. But, by taking your eye off the goal -- if only momentarily -- and enjoying the scenery along the way, guess what happens? Right. You get there quicker and more refreshed.

    That's why puzzles like this are so important, even if you don't think you're the process-oriented type. Getting there can be at least half the fun -- if you let it.

    -Phil
  • K2K2 Posts: 693
    edited 2010-09-03 05:50
    Your comments ring a bit hollow, Phil. By your logic, we should never help a stranded motorist because we'd be denying him the opportunity to play.

    Just telling it like I see it.
  • Graham StablerGraham Stabler Posts: 2,510
    edited 2010-09-03 06:35
    I don't think that is a logical extension of what Phil said at all. Phil didn't at any point suggest that people shouldn't get help only that you can gain a lot through learning in a light-hearted, pressure-free and playful way.

    FWIW playing with a scalpel has actually made me quite good with one and making a small sword from solder made me quite good with that too. I also learnt several CAD packages through just having fun. On the other hand every time I sit down to learn something I really struggle to make any headway.

    Graham
  • K2K2 Posts: 693
    edited 2010-09-03 06:53
    You are right, Graham. Based solely on Phil's post, my comments seem out of place. At the risk of sounding mysterious, there's more to the picture.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-09-03 09:53
    My comment was based solely on the posts in this thread, nothing else. I should add, though, that some things should be designed to "just work" and stay out of our way the rest of the time. Automobiles and operating systems fall into this category; programming does not. Programming is more akin to having a set of oil paints than to owning a car. One can expect to drive directly from New York to L.A. and not have any problems along the way; but there is no straight path between picking up a brush and painting the Mona Lisa -- even for an experienced painter. Sketches have to be made and remade; vignettes get experimented with on canvas; even areas on the final work get painted over more than once; and, in the process, new techniques get discovered. My sole point is that one can choose to make this process of experimenting fun, and that doing so leads to reduced stress and, ultimately, greater productivity.

    -Phil
  • K2K2 Posts: 693
    edited 2010-09-03 12:38
    My comment was based solely on the posts in this thread, nothing else.

    Mine wasn't.
  • wjsteelewjsteele Posts: 697
    edited 2010-09-03 12:55
    Cool... I did my post on my phone, so I didn't have the luxury of looking up or testing it... would have driven me crazy had I tried to type it in, however... I always forget those silly little # symbols.

    I'm certaintly not a pro... but I guess I'm not a begininner either. :-)

    At Microsoft, we have 3 "developer personas." Mort, Elvis and Einstein. Mort is usually the beginner, Elvis the intermediate programmer and Einstein would be the Pro. (There are other definitions, but I'm going with these right now.)

    In PASM, I'm still in the Mort category and in SPIN, I'm right in the middle of Elvis.

    After you guys started talking about "another" way to solve it, I realized that CMPSUB must be the answer because I was doing both anyway, but I didn't figure it entirely out before you posted it.

    Very cool! Thanks for the challenge!

    Bill
Sign In or Register to comment.