Shop OBEX P1 Docs P2 Docs Learn Events
Multiple Watch Directives — Parallax Forums

Multiple Watch Directives

pjvpjv Posts: 1,903
edited 2005-01-28 00:02 in General Discussion
Hello All;

In some earlier versions of the SX assembler one could have more than one WATCH directive referincing the same variable. This was useful to observe simulaneously the value in binary as well as in hex. Sometime during the upgrade process this nice feature has gone away; an error now occurs if two WATCHes reference a same variable.

Is it possible to get this feature restored ????....· Please???

Peter
·

Comments

  • PJMontyPJMonty Posts: 983
    edited 2005-01-26 07:58
    Peter,

    Hard to say, as this one is definitely a Parallax decision. The way SASM builds its symbol table doesn't lend itself to allowing multiple definitions of the same symbol. While it would be possible (anything is possible in software) to modify SASM to allow multiple symbol definitions for WATCH directives, itt's not an easy task due to the way SASM was originally architected.
      Thanks, PeterM
  • dkemppaidkemppai Posts: 315
    edited 2005-01-26 13:47
    It seems to me that I had found a clever way around
    this problem...·· ...I'll have to look into how I did it.

    Seem to me that I had made some temporary variables,
    referencing the same locations as the real ones that
    I wanted to watch twice...

    -Dan
    ·
  • pjvpjv Posts: 1,903
    edited 2005-01-26 15:15
    Thanks Peter and Dan;

    Peter, by your response, I'm not sure I adequately explained what has gone missing. It is simply watching the same RAM variable name twice or more times simultaneously, not multiple different names for the same RAM location. So I suspect it does not require an assembler change.

    This feature existed previously, but just now I can't recall in what version. If it helps, I will try to go though my archives to find out at what point it disappeared.

    Example:

    watch flagbyte,8,ubin
    watch flagbyte,8,uhex
    watch flagbyte,8,udec

    Hope this makes it clearer.

    Thanks,

    Peter
  • Guenther DaubachGuenther Daubach Posts: 1,321
    edited 2005-01-26 16:27
    Peter,

    Dan's tip is a good workaround, for example:

    flagbyte DS 1
    flagbyte1 = flagbyte
    flagbyte2 = flagbyte

    watch flagbyte,8,ubin
    watch flagbyte1,8,uhex
    watch flagbyte2,8,udec

    passes the assembler without error. I did not check it with the debugger but I'm pretty sure that it should work.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Greetings from Germany,

    G
  • pjvpjv Posts: 1,903
    edited 2005-01-26 17:24
    Hi Peter, Guenther and Dan;

    I just tried your (now obvious) solution, and the debugger is also happy with that.

    Wonder why I hadn't thought of that. I guess I was looking for the feature previously available.

    With only slightly more inconvenience, this aliasing idea works, and is an adequate solution.

    Thanks for the help.

    Peter
  • PJMontyPJMonty Posts: 983
    edited 2005-01-27 07:58
    Peter,

    Actually, I understood your problem exactly. The problem is that SASM use a binary tree for storing the symbol table. While you can store more than one item with the same name, the problem is when you go looking for it. In order to find an item, you have to start at the root node and then search node to node (using the next node pointers) until you find the item. If you find it, you terminate the search.

    If you have more than one item with the same name, it means you always have to search throught the entire tree in case you have more than one item with the same name but a different type. This is much less efficient than stopping the search when you find the item. This is why I said it would require some real work on SASM to allow this feature.

    Of course, the alias ability makes it a somewhat moot point.
      Thanks, PeterM
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-01-27 17:04
    Theres a way to speed that up, by using a hash with multiple entries per bin, the bin selection takes a fixed amount time. Then a linear search of the bin for all matching elements is also a fixed time, if you keep the bin depth relatively small this linear search time is small as well. Though this typically requires a backup bin tree to catch any elements that overfill a bin but a properly designed hash algorithm will minimize its use.

    Alternatively the hash bin can just point to a bin tree, while this still requires searching the entire tree, the hashing algorithm automatically subdivides the entire tree into N subtrees (N being the number of bins) and that subtree is gauranteed to contain all instances of an identically named symbol,·subdividing the amount of time required to search the tree for all instances by N for only a small fixed cost (the computation time of the hashing algorithm). But like you said this would require modification, and the need for it is somewhat limited. After all, when computing the upperbound of the number of symbols for 4KB of code yeilds a fairly small number, especially when you consider the average program doesn't come close to that upperbound.

    These approaches only become nessesary when your number of symbols are in the many thousands, or if your search time has a real-time constraint.

    Paul

    Post Edited (Paul Baker) : 1/27/2005 5:09:47 PM GMT
  • pjvpjv Posts: 1,903
    edited 2005-01-27 17:28
    Thanks Peter and Paul (where's Mary?)

    Not being a "big systems" or "heavy duty" programmer at heart, I have only the faintest idea of what you two are talking about. And that's a good thing, as I have no real interest in that side of the business. Embedded processors and hardware on the other hand, ........ I can't get enough of them.

    So thanks again for your responses, I will leave it alone now that the only slightly less convenient alias approch does what I need.

    Peter
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-01-27 17:40
    I first learned about hashes in CIS102 as part of my programming curriculum of my computer engineering degree (1/2 CIS, 1/2 EE). But I didn't fully understand their use and application until I started my patent examiner job, where they are used extensively in various caching schemes and database retreival (I don't do database stuff but if the database uses a cache to reduce searching time, it comes my way).
  • Guenther DaubachGuenther Daubach Posts: 1,321
    edited 2005-01-27 18:41
    Paul,

    a loooooong time ago, when Wordstar was the word processor software on CP/M machines, I wrote a spell checking software with extensive use of hash coding, binay trees (balanced or not), etc. These techniques worked out great speedwise on such machines. clocked at 1 to 4 MHz.

    Today, with computers clocked far above UHF TV frequencies, searching a symbol table with just - maybe - several hundred entries for an SX program should not really be a timing concern - even a KISS linear search would do the job fast enough.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Greetings from Germany,

    G
  • Guenther DaubachGuenther Daubach Posts: 1,321
    edited 2005-01-27 18:46
    pjv,

    I did not see Mary eiter here...

    As a matter of fact, my aunt's first name is Mary, and she's only 10 years older than I am - thanks to my grand parents with their "late success". They did not only "create" Mary but Helen as well at the same time, IOW Mary and Helen are twins smile.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Greetings from Germany,

    G
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-01-27 18:53
    My aunt's name is Mary and her son's name is Peter. At one of our familiy reunions we sang "Puff the Magic Dragon", with my aunt dressed in green and a paper machet dragon head, with her chimney boxing a cigarette, much to the delight of the rest of our family (that side of my family is pretty wacky and has a bizarre sense of humor).
  • Guenther DaubachGuenther Daubach Posts: 1,321
    edited 2005-01-27 23:55
    Paul,

    so you are the "Paul" in this story ???

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Greetings from Germany,

    G
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-01-28 00:02
    A-yup I think I was 15 at the time, my cousin Peter was 4ish, he kept singing "Puk da madik dwagon, dwived BYDA dee" and sang "la-la-la" to the melody for most of the verse, it was as close as we could get him to sing the lyrics. I think this, combined with my aunt getting dizzy from smoking the cigarette so fast that had my family splitting thier sides in laughter.
Sign In or Register to comment.