Shop OBEX P1 Docs P2 Docs Learn Events
HM55B Compass Module ASM object problem? — Parallax Forums

HM55B Compass Module ASM object problem?

rws-cstrws-cst Posts: 2
edited 2008-02-10 03:42 in Propeller 1
I'm reviewing the shared module HM55B Compass Module Asm.spin, downloaded from the shared object repository. The portion of the code I'm questioning involves the conversion of the 11-bit input values to properly signed 32-bit values. In part the code is:

test x_, TestMask wz
if_nz or x_, NegMask

test y_, TestMask wz
if_nz or y_, NegMask

...

TestMask long %00000000_00000000_00000010_00000000
NegMask long %11111111_11111111_11111100_00000000


Now, it seems to me that if I've just read an 11-bit sign-extended integer from the HM55B, I should be testing bit 11 to look for the sign and OR-ing in the negative mask if it's set. It looks to me like this code is testing bit 10, not bit 11. That is, I think the TestMask should be defined as follows:

TestMask long %00000000_00000000_00000100_00000000

Am I missing something else here?

Comments

  • deSilvadeSilva Posts: 2,967
    edited 2008-02-09 17:42
    Your reasoning is correct.
    IF there are 11 bits input - we shall have to take a look.
    On the other hand this bug could have been overlooked for a long time, as it works well within +/- 29smile.gif
  • rws-cstrws-cst Posts: 2
    edited 2008-02-09 18:10
    re 2**9: my thoughts exactly, which is (even if I'm correct) why this code probably works as-is. I'm trying to figure out SPIN and ASM by carefully tracing the code, which is why I noticed.
  • deSilvadeSilva Posts: 2,967
    edited 2008-02-09 18:32
    rws-cst said...
    I'm trying to figure out SPIN and ASM by carefully tracing the code
    This is an extreme good thing to do and cannot be esteemed highly enough!

    I wish 20% of my students would proceed accordingly (rather than 5%) smile.gif
    It not only furthers your own understanding, but teaches you "best practices" and even widens your horizon from time to time.

    Not to forget it helps detect hidden bugs or leads to unexpected optimization proposals...


    But back to the issue. Of course there are 11 bits delivered and transfered. And the test of bit 11 is called for rather than bit 10.

    I expect Beau will fix that soon..
  • Beau SchwabeBeau Schwabe Posts: 6,559
    edited 2008-02-10 03:42
    rws-cst·and deSilva,
    ·
    I am just returning from being out of town, but I will·look into it and try to make the change this weekend.
    Not that I'm trying to make any excuses, but when I wrote that object, I had some help and there was a certain portion of it that I did not do.· As a result·this error was missed.


    Edit FIXED:
    http://obex.parallax.com/objects/48/




    ·
    ·

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.

    Post Edited (Beau Schwabe (Parallax)) : 2/10/2008 5:08:33 AM GMT
Sign In or Register to comment.