PSoC >> PSoC Mixed-Signal Array

Filippo - ELMARC
stranger


Reged: Apr 17 2008
Posts: 5
BUG BUG BUG!!! in array index operation
      Wed Apr 23 2008 04:57 AM

look this code:

;input_drv.c: 513: SM.Output.LedStatus = ManualTest_Led_Table[SM.ProgramStatus.PhaseStepIndex];
51 20 mov a, [(_SM+10)^0]
64 asl a
01 00 add a, <_ManualTest_Led_Table
5C mov x, a
50 1E mov a, >_ManualTest_Led_Table
08 push a
28 romx

ManualTest_Led_Table is defined as follow:
const u_int16 ManualTest_Led_Table[]
and as you can see is placed at 0x1E00

then we want substract 1 in the table index index:

;input_drv.c: 515: else SM.Output.LedStatus = ManualTest_Led_Table[(SM.ProgramStatus.PhaseStepIndex - 1)];
51 20 mov a, [(_SM+10)^0]
64 asl a
01 FE add a, <(_ManualTest_Led_Table+-2)
5C mov x, a
50 1D mov a, >(_ManualTest_Led_Table+-2)
08 push a
28 romx

The MSB of ManualTest_Led_Table is always 0x1D and is wrong!

if we try to cast the result:

;input_drv.c: 515: else SM.Output.LedStatus = ManualTest_Led_Table[(u_int08) (SM.ProgramStatus.Phase
StepIndex - 1)];
51 20 mov a, [(_SM+10)^0]
64 asl a
01 FE add a, <(_ManualTest_Led_Table+254)
5C mov x, a
50 1E mov a, >(_ManualTest_Led_Table+254)
08 push a
28 romx

that is wrong with SM.ProgramStatus.PhaseStepIndex = 0

Post Extras Print Post   Remind Me!     Notify Moderator


Entire topic
Subject Posted by Posted on
* BUG BUG BUG!!! in array index operation Filippo - ELMARC Wed Apr 23 2008 04:57 AM
. * * Re: BUG BUG BUG!!! in array index operation clydeAdministrator   Thu May 01 2008 06:01 AM

Extra information
2 registered and 1 anonymous users are browsing this forum.

Moderator:  ndouglas, Dan Henry, jtemples, jeff, Andrew L, mikerj, dave g, meisty, josh stevo 



Forum Permissions
      You cannot start new topics
      You cannot reply to topics
      HTML is enabled
      UBBCode is enabled

Rating:
Thread views: 937

Rate this thread

Jump to

Contact Us | Privacy statement HI-TECH Software

Powered by UBB.threads™ 6.5.5