HM55B Compass Module ASM object problem?
rws-cst
Posts: 2
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?
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
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 +/- 29
I wish 20% of my students would proceed accordingly (rather than 5%)
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..
·
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