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 10, 2005 at 10:36

Why with this instruction, appears 2 errors?

LD A, #HIGH(Buffer_0)

C5691 ''Instruction operand mismatch'' and C5686 ''undefined label 'HIGH'

HIGH is an additional operator of assembly AST7...but don't work..

When i compile the project the label ''HIGH'' is undefined....

what i can do for using this assembly operator??

I use the ST7VD with metrowerks toolchain...

please help me..

:-[

[ This message was edited by: liotro78 on 10-11-2005 16:44 ]

fggnrc
Associate II
Posted on November 11, 2005 at 04:05

try this:

LD A,#{HIGH Buffer_0}

EtaPhi

alfonso2
Associate II
Posted on November 11, 2005 at 07:53

the problem remaining....the label HIGH is unknow...

but there's an alternative method for extracting the high byte of a variable of 2 bytes?

fggnrc
Associate II
Posted on November 11, 2005 at 08:14

The ST7 core is big endian, i.e. the the most significative byte is stored first, then it is followed by the less significant ones.

When you define a 16bit variable, say Buffer_0, the high byte of its value is stored at Buffer_0, while the least significative byte is stored at Buffer_0+1.

HIGH is an assembler macro that returns the high address (i.e. page) of a label.

I Hope I was clear...

EtaPhi

wolfgang2399
Associate II
Posted on November 11, 2005 at 11:47

Hi liotro78,

in my opinion you make everything quite right - as you can compare with the Metrowerks assembler manual (Manual_Assembler_ST7.pdf) on page 206f.

HIGH Operator

 

Syntax

 

Byte: HIGH()

 

Description

 

This operator returns the high byte of the address of a memory location.

 

Example

 

Assume data1 is a word located at address $1050 in the memory.

 

LD A,#HIGH(data1)

 

This instruction will load the immediate value of the high byte of the address of data1

 

($10) in register A.

 

LD A,HIGH(data1)

 

This instruction will load the direct value at memory location of the higher byte of the address of data1 (i.e. the value in memory location $10) in register A.

I think, something else causes your error although I can't imagine what it is.

If all else fails why not contact the MetroWerks support?

Regards

WoRo

alfonso2
Associate II
Posted on November 11, 2005 at 12:04

My sfotware is this:

// Map user variables in BUFFER.

#pragma DATA_SEG BUFFER0_EP2_512

// RAM BUFFER

volatile char Buffer_0[512];

asm

{

LD A, #Buffer_0

LD pScan:1, A

LD A, #HIGH(Buffer_0) <---error

LD pScan, A

}

there are 2 errors :

ERROR C5691: Instruction operand mismatch

ERROR C5686: Undefined label 'HIGH'

I use the ST7VD and Metrowerks Codewarrior for ST7 V. 2.0 .

I asking you, do you know the code inside the macro HIGH() ?

For the Assembly manual i have not this pdf,and i don't find it in the ST site, i have only the ''ST7 Assembler-Linker User Manual'', can you attach this file?

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

alfonso2
Associate II
Posted on November 11, 2005 at 12:40

But Etaphi if the HIGH operator is don't know, if i overwrite this code:

asm

{

LD A, #Buffer_0

LD pScan:1, A

LD A, #HIGH(Buffer_0) <---error

LD pScan, A

}

with the next code, is exactly and similar with the previous HIGH operator?

asm {

LD A, #Buffer_0

LD pScan:1, A

LD A, #(Buffer_0)+1

LD pScan, A

}

this code is exactly?

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

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

fggnrc
Associate II
Posted on November 13, 2005 at 05:56

No, liotro78, the code does not the same thing.

From your code I understand that you want to copy the address of Buffer_0 into a pointer variable.

Therefore you need the HIGH operator.

I don't know why the Codewarrior toolchain complains, perhaps it is the space between the operands [try LD A,#HIGH(Buffer_0)], who knows...

However I suggest you to stick with C and use assembler only when there is a real need, such as in some reentrant interrupt handlers.

In this mixed setting you lose the C portability and abstraction from hardware without a real improvement in speed and size.

Regards,

EtaPhi

wolfgang2399
Associate II
Posted on November 14, 2005 at 07:25

Hi Liotro78,

you can download the Metrowerks manuals from the MetroWerks homepage. It is a quite long selfextracting file (33.3M) and contains a lot of manuals and technical notes. But I didn't find a way to download only the manuals.

To download the file go to MetroWerks' download page (click the following line):

http://www.metrowerks.com/MW/Develop/Embedded/STM/CWST7Mspecial.htm

and then select

Self-installing Manuals and Technical Notes

If you are a little familiar with C-programming, please try the C-code

pScan = &Buffer_0;

and then check the result by reading the .lst-file after compiling. It should be the same as your asm-code.

Regards

WoRo