cancel
Showing results for 
Search instead for 
Did you mean: 

#HIGH assembly operator problem

alfonso2
Associate II
Posted on November 21, 2005 at 16:22

#HIGH assembly operator problem

33 REPLIES 33
alfonso2
Associate II
Posted on November 17, 2005 at 11:49

Etaphy your codes generate two errors.

But Buffer_0H must be a pointer variable....and the shift is good with 16bit variable?, buffer_0 is declared in 16bits memory address.

Woro my compiler is 2.0 version and the HIGH operator don't work, but why in my list file don't appears the translation in assembly language of the C instruction pScan=Buffer_0??????

What's the option of the compiler exactly? i have used the -lasm option for creating .lst file, but the C instructions is not translate?there is an option for activate this translation?

[ This message was edited by: liotro78 on 17-11-2005 16:21 ]

fggnrc
Associate II
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...

alfonso2
Associate II
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 ]

alfonso2
Associate II
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

}