Skip to main content
Visitor II
November 21, 2005
Question

#HIGH assembly operator problem

  • November 21, 2005
  • 33 replies
  • 4808 views
Posted on November 21, 2005 at 16:22

#HIGH assembly operator problem

    This topic has been closed for replies.

    33 replies

    Visitor II
    November 17, 2005
    Posted on November 17, 2005 at 12:15

    liotro78,

    from your reply I see that my explanation was not clear...

    If the assembler does not accept LD A,#HIGH(Buffer_0), the workaround is to find in the C code the high byte of Buffer_0 address and store it somewhere (e.g. in Buffer_0H).

    The C macro HIGH is OK because it is similar to this one:

    #define HIBYTE(w) ((BYTE) (((WORD) (w) >> 8) & 0xFF))

    which is the one used by the Microsoft Visual C++.

    The compilation errors seems therefore strange.

    Perhaps they are due to the mix of languages; anyway if Buffer_0H is a valid label, there is no reason for the assembler to complain.

    If you look at the Woro listing, you can see that HIGH(Buffer_0) is 0x01 (A6 is the opcode for the loading of a constant in the accumulator).

    You can therefore replace LD A,HIGH(Buffer_0) with LD A,#1 which works as long as &Buffer_0[0] is located in page 1.

    EtaPhi

    BTW: your vectors are quite large. Are you sure that Buffer_0[1024] will fit in RAM? Few ST7 microcontrollers have so much memory...

    alfonso2Author
    Visitor II
    November 17, 2005
    Posted on November 17, 2005 at 15:30

    Etaphy i have used this code:

    #define HIGH(x) ((x) >> 8)

    const unsigned char Buffer_0H = HIGH(Buffer_0); <---ERRORS!!

    asm

    {

    LD A, #Buffer_0

    LD pScan:1, A

    LD A, Buffer_0H

    LD pScan, A

    }

    and appears 2 errors in constant declaration...

    ERROR C1826: Integer-expression expected

    ERROR C2207: Initializer must be constant

    I have sent a message at metrowerks support for resolving finaly the HIGH problem, because it's impossible that this operator is undefined, because i have the last version of CST7 and AST7 that allow this operator.

    [ This message was edited by: liotro78 on 18-11-2005 12:36 ]

    alfonso2Author
    Visitor II
    November 21, 2005
    Posted on November 21, 2005 at 16:22

    Probblem resolved:

    in the new codewarrior for ST7 the HIGH operator have changed from :

    HIGH(VAR)

    to:

    %HIGH(VAR)

    then the correctly code is:

    asm

    {

    LD A, #Buffer_0

    LD pScan:1, A

    LD A, #%HIGH(Buffer_0)

    LD pScan, A

    }