AnsweredAssumed Answered

Byte or Bit Reference?

Question asked by BOB PAEHR on Sep 9, 2016
Latest reply on Nov 2, 2016 by ZhangJennie

In start08.c from my MC9S08SH8 Startup_Code folder, I found this code snippet (I've removed irrelevant comments and follow-on code):

 

static void Init(void) {

   int i;

  

   asm {

ZeroOut:

         LDA    _startupData.nofZeroOuts:1 ; /* nofZeroOuts */

        INCA

         STA    i:1 ; /* i is counter for number of zero outs */

         LDA    _startupData.nofZeroOuts:0 ; /* nofZeroOuts */

        INCA

        STA   i:0

         LDHX   _startupData.pZeroOut ; /* *pZeroOut */

        BRA   Zero_5

Zero_3:

.

.

}

 

What are the "i:0" and "i:1" references?  From the definition of "i" as an int, (a 16-bit, 2-byte value), they APPEAR to be low-byte and high-byte references, especially since the "STA" opcode is dealing with the 8-bit accumulator.  I can't see that there is any reference to a structure or bitfield since "i" is defined locally.

It appears that

   "STA  i:1"

means

      "store the entire 8-bit accumulator in the high byte of variable 'i' ".

It doesn't make any sense if I try to look at it from the individual bits.  Am I correct?

Bob

Outcomes