Shop OBEX P1 Docs P2 Docs Learn Events
What methods do you use to debug PASM-code ? — Parallax Forums

What methods do you use to debug PASM-code ?

StefanL38StefanL38 Posts: 2,292
edited 2009-06-19 08:30 in Propeller 1
Hello,

most of the time I'm programming in SPIN.
But for one thing that needed raw speed I coded in PASM.
It was a lot of try and error.

Now I have a new thing where PASM is required

What methods do you use to debug PASM ?

best regards

Stefan

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-06-18 19:28
    I use spare pins with an oscilloscope. I don't mess with debuggers and emulators, since they can easily become a crutch and, in the long run, reduce productivity (IMO).

    -Phil
  • jazzedjazzed Posts: 11,803
    edited 2009-06-18 19:59
    To each their own debugger/methods Phil [noparse]:)[/noparse]

    I use Ariba's PASD in a pinch. It can usually do surprising things in addition to what it's supposed to do.

    There are limits though and I often forget how to set it up because I don't use it much.

    I do vividly remember PASD limits most of the time:
    • No breakpoints on self-modifying code instructions
    • you must add a dozen or so longs to your PASM so the debugger will work
    • the ORG label must have a space before it. i.e. " entry org 0"
    • you can not use single brace block comments { ... } that confuses PASD
    • the debug memory and cog windows are always on top with no option (very annoying)
    • you must respecify the com port every time you restart the application
    • in some circumstances given compile errors, the window positions will require terminating programs via taskbar
    • finally convenient toolbar buttons are not available
    • Added: also one file can not contain multiple sections of dat ... org ... and "res" variables in the middle.
    Aside from that list of details, PASD is really a great tool. Just memorize the list [noparse]:)[/noparse]


    Cluso99's PASM/SPIN debugger can be useful, but it requires manually tracking source lines.

    I've never bothered with POD beyond some simple tests.

    The GEAR emulator makes absolutely no sense to me.

    Also, avoid at all cost paying for a PASM debugger [noparse]:)[/noparse]

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    --Steve


    Propalyzer: Propeller PC Logic Analyzer
    http://forums.parallax.com/showthread.php?p=788230

    Post Edited (jazzed) : 6/18/2009 8:13:07 PM GMT
  • HarleyHarley Posts: 997
    edited 2009-06-18 20:05
    StefanL38,

    There is PASD. It allows me to initially single-step debug asm code to verify that SPIN variables are passed to the cog, and that the code is actually doing what's intended.

    Then I use ViewPort to 'scope' in logic analyzer mode to view the I/Os running at full speed. And using a spare or several spare I/Os to output a pulse at appropriate locations of the code, one can view the timing of a cog.

    These are the 'crutches' I've found useful. Of course, one needs spare cogs to use these; PASD uses 1 cog, ViewPort uses 2 cogs at 20 MHz sampling to 4 cogs at 80 MHz sampling. For my application, the 20 MHz speed is adequate, as I have few spare cogs with two Props. yeah.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Harley Shanko
  • CounterRotatingPropsCounterRotatingProps Posts: 1,132
    edited 2009-06-18 20:15
    Phil Pilgrim (PhiPi) said...
    I use spare pins with an oscilloscope.
    Wow Phil, that's pretty hardcore.·
    Better (or worse) than debugging Win programs using·only printf() statements. freaked.gif


    tongue.gif

    @Stefan: I've been using Viewport very recently for this, but if you are doing asm to do *really* fast stuff, it might not work for that... grab a 'real' scope or logic analyzer. (See contradiction above [noparse]:)[/noparse]

    cheers,

    - Howard

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "This device contains recyclable materials, which can be re-decomposed

    and re-integrated into brand new marvels... We strongly encourage you
    to contact the provided information and recycle yourself always. "
  • mikedivmikediv Posts: 825
    edited 2009-06-18 20:16
    Hey Jazzed I don't get gear either but I do appreciate the person taking the time to share it with us but I'm with you .. Jazzed can you tell us where to download the program I can never get the parallax search option to work worth a damn
  • RaymanRayman Posts: 14,838
    edited 2009-06-18 20:22
    I think the easiest way is the pass the address of some HUB RAM variable as a parameter and then us WRLONGs to that address to track position in the code...

    You can then use TV, VGA, or serial to monitor this HUB RAM variable...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    My Prop Info&Apps: ·http://www.rayslogic.com/propeller/propeller.htm
  • jazzedjazzed Posts: 11,803
    edited 2009-06-18 20:44
    mikediv said...
    ... Jazzed can you tell us where to download the program I can never get the parallax search option to work worth a damn
    Look here for PASD www.insonix.ch/propeller/prop_pasd.html

    I appreciate anyone taking time to produce a solution also ... especially if it's easy to understand/use.
    Forum search is just one of those other things you have to play with to learn how to make it useful.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    --Steve


    Propalyzer: Propeller PC Logic Analyzer
    http://forums.parallax.com/showthread.php?p=788230
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-06-18 21:00
    I don't mean to denigrate the efforts of those who've produced the great array of debugging tools now available to the Propeller. I just remember, when first programming the SX and seeing its debugging tool, thinking, "Wow! Now this is cool!" And it really is. But I found myself spending more time fiddling with the debugger than doing any actual debugging. The other problem was dealing with real time events. They occur on their own schedule, whether you're running at full speed or single stepping. That problem is only compounded when there are eight processors to keep track of at once. For me, it's just easier to attach a couple scope probes, add an or outa ... here, an andn outa ... there, and watch what happens in real time. It may be harder at first, but for me it's just quicker since it keeps me focused on the code and not on the tools.

    -Phil
  • LeonLeon Posts: 7,620
    edited 2009-06-18 21:37
    I find the lack of a decent debugging facility is the Propeller's biggest shortcoming. Although I got used to primitive debugging techniques with the early micro-controllers 30 years ago, I would have thought that Parallax would have provided something better in the 21st century. Most manufacturers use the industry-standard JTAG interface. Hopefully, the Propeller II will have something similar.

    Leon

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Amateur radio callsign: G1HSM
    Suzuki SV1000S motorcycle

    Post Edited (Leon) : 6/18/2009 9:54:04 PM GMT
  • RaymanRayman Posts: 14,838
    edited 2009-06-18 21:58
    I find the TV and VGA drivers make up for the missing JTAG interface... It's much easier to just see what's going on with a monitor...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    My Prop Info&Apps: ·http://www.rayslogic.com/propeller/propeller.htm
  • CounterRotatingPropsCounterRotatingProps Posts: 1,132
    edited 2009-06-18 22:03
    Leon said...
    I find the lack of a decent debugging facility is the Propeller's biggest shortcoming. Although I got used to primitive debugging techniques with the early micro-controllers 30 years ago, I would have thought that Parallax would have provided something better in the 21st century. XMOS has managed it with their much more complex chips, using an industry-standard JTAG interface. Hopefully, the Propeller II will have something similar.

    Leon

    Leon,

    the XMOS architecture is precisely what gives them the room for debugging tools·- after all, their primary core the XS1 is 32-bit, has registers, is threaded, has thread state identifiers ---·even the littlest one in·their pack·( XS1-G2 144BGA·)· has two xcores, 128k of SRAM·and runs 800 MIPs.·Althougth its perhaps not really a fair comp. to the Propeller I, I do agree that Parallax should have planned in some debugging hooks at the very least. As amazing as the Prop is, that's a surprising oversight, IMO.

    Even though JTAG is standard, I know many people who·dislike·using·it.· Perhaps Parallax will jump two leaps with the PropII by having a process-transparent debugger that is so good it sets a *new* industry standard for debugging. (Then, again, maybe we are putting too many hopes into the new Prop.!)

    just my 2 pence [noparse]:)[/noparse]

    - Howard



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


    Post Edited (CounterRotatingProps) : 6/19/2009 12:46:08 AM GMT
  • KyeKye Posts: 2,200
    edited 2009-06-18 22:28
    Vga works wonders. Since I never use the par register in my programs I can save it for debugging and just dump any value I want into whatever its pointing at.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nyamekye,
  • RossHRossH Posts: 5,512
    edited 2009-06-18 22:53
    @all,

    I used to use POD, but I can't use in when working on XMM code. Most of my really tricky PASM debuggging is done using the debug LED on the Hydra. I wrote some simple code that takes a long value and flashes it out on the debug LED in Hex.

    Surprisingly effective.

    Ross.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Catalina - a FREE C compiler for the Propeller - see Catalina
  • kuronekokuroneko Posts: 3,623
    edited 2009-06-18 23:08
    RossH said...
    Surprisingly effective.
    Seconded. If it gets hairy I usually use the demo board which can display an entire byte!
  • mikedivmikediv Posts: 825
    edited 2009-06-18 23:17
    Phil I still haven't quite grasped the idea of debugging in general, While I am a hardware guy trying to learn to program there really inst a good tutorial on the subject not one that I have found anyway.
    I can see the benefit but as an example I see everyone talk about doing just what you said adding an outa to an led or using the led on the hydra as a debugging aid but???????

    OK so I write a program but how does that help me in anyway? so if I can turn on an led doesn't that only mean that part of the programming is working? another example I see some of the code in the obex downloads
    a few of them have the fullduplexserial and keyboard in the code but commented out ?? I know they put them there for debugging but I just cant get my hands around the concept I would love a simple example or explanation
  • jazzedjazzed Posts: 11,803
    edited 2009-06-18 23:45
    I forgot to mention that I did most of my initial XMM code fetching bringup with Propalyzer [noparse]:)[/noparse] It's impossible to track nano-second LED state changes in real time with human eyes. Sorry guys, I keep forgetting to promote my product in my replies every chance I get [noparse]:)[/noparse]

    @mikediv,
    For me using a debugger is good for 2 things: 1) finding and fixing mistakes, and 2) verifying assumptions. With print statements and a serial port, you can accomplish a great deal, but there are limits. Using LED/pin states you can track the progress of your program or inspect variables. Rayman's approach to displaying PASM states with wrlong, etc... allows infinitely more flexibility than LEDs. You need a hook for that though.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    --Steve


    Propalyzer: Propeller PC Logic Analyzer
    http://forums.parallax.com/showthread.php?p=788230
  • CounterRotatingPropsCounterRotatingProps Posts: 1,132
    edited 2009-06-19 00:14
    jazzed said...
    ... Sorry guys, I keep forgetting to promote my product in my replies every chance I get [noparse]:)[/noparse]
    Well, Steve, at least you get FIVE stars for overlaying your propalyzer screen shot on top of Orion's Nebula ! yeah.gif
  • potatoheadpotatohead Posts: 10,261
    edited 2009-06-19 02:12
    GEAR is great for learning the prop concepts. It's no good for larger programs because it runs too slow. I did use it on the go, once or twice to work out display driver code for TV.

    Slow or not, it was actually ok for that.

    It's better now for having breakpoints. Good for understanding what little bits of code do.

    On the top of my to get list is a decent scope. I know I would lean toward the Phil method of just outputting to spare pins.

    Right now, I normally use a video display and write things to HUB memory. A simple 40x24 text screen with an ASCII font works great. Some people are either working on single pin NTSC monochrome drivers, or have them done. I'll jump on one of those when I get the chance. One single pin, with memory mapped video text can do a lot.

    I don't use the LED blinker idea much. When I'm working on the Prop, I've got a video capture device, which makes it easy to just write to the display. Making little movies isn't a bad idea either. Write a whole bunch of stuff, then trace back through, delete the large MPEG when done.

    Normally incorporating something like video is a problem, but not on the Prop. That is what is cool about the chip. Just include the video driver and point it at some area of HUB memory, then forget about it. Nice...

    One other thing I've done is just throw all of HUB memory onto a higher resolution display to see a sort of dynamic memory map. Helped to find a bad pointer writing to the wrong area of RAM once.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Propeller Wiki: Share the coolness!
    Chat in real time with other Propellerheads on IRC #propeller @ freenode.net
    Safety Tip: Life is as good as YOU think it is!
  • Mike GreenMike Green Posts: 23,101
    edited 2009-06-19 02:23
    For some of my PASM debugging, I've used the VGA HiRes Text object. It stores the text literally in the screen buffer rather than as tiles. It's easy to write short routines to display text or hexadecimal numbers at fixed locations on the screen. It's not too hard to do decimal output as well, but it takes more memory for the decimal conversion..
  • jazzedjazzed Posts: 11,803
    edited 2009-06-19 05:58
    CounterRotatingProps said...
    jazzed said...

    ... Sorry guys, I keep forgetting to promote my product in my replies every chance I get [noparse]:)[/noparse]
    Well, Steve, at least you get FIVE stars for overlaying your propalyzer screen shot on top of Orion's Nebula ! yeah.gif

    I've been nebulously expanding since 1999 [noparse]:)[/noparse]

    Good guess on the Nebula name, but it's actually the Carina Nebula's Keyhole Nebula between "God's middle finger" and the Dog-fish globule. See en.wikipedia.org/wiki/File:Keyhole_Nebula_-_Hubble_1999.jpg ... it's my windows wall-paper.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    --Steve


    Propalyzer: Propeller PC Logic Analyzer
    http://forums.parallax.com/showthread.php?p=788230
  • MagIO2MagIO2 Posts: 2,243
    edited 2009-06-19 08:30
    @mikediv:
    So, you're a hardware guy ... what do you do when your hardware does not work correctly? You measure at some points of interest to understand what might be wrong and for example in a signal path you try to spot the point where the signal starts getting wrong. You check the ins and outs whether they meet your expectation.

    That's exactly what debugging software is about. You want to see the ins and outs of the software. Simple blinking LED's can be used to track the path of the software for example if you have jumps which might be conditional. If you found out that the software ends in a branch of code where you did not expect it then you start watching the variables which are used to make the decision.

    Using 8 LEDs gives the possibility to show bytes of in or out variables.
    Using TV or Serial interface gives you more possibilities in showing what's going on, but needs more efford/changes of the original program.
Sign In or Register to comment.