Complex relocatable expression not supported

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Complex relocatable expression not supported

1,125 次查看
Brax02
Contributor III

XDEF offset

DataSec1: SECTION SHORT

DataLbl1: DS.B 10

DataSec2: SECTION SHORT

DataLbl2: DS.W 15

offset: EQU DataLbl2 - DataLbl1



I need to do something like that but it's generated the error (Complex relocatable expression not supported ).

 

Somebody knows how to do that ?

 

Or it's not possible ??

标签 (1)
0 项奖励
回复
7 回复数

920 次查看
rocco
Senior Contributor II

Hi Bertrand,

What you have is not possible. Since the placement of sections won't occur until link-time, the assembler can't know where either "DataLbl2" or "DataLbl1" will be, and therefore can't calculate their offset.

Your options are:

1) Put both "DataLbl2" and "DataLbl1" in the same section.

2) Calculate the offset at run-time.

I would use the first option, myself.

0 项奖励
回复

920 次查看
Brax02
Contributor III

Hello Mark,

Tanks for your answer !

And if I would like to know the offset between a Variable (RAM) and a constant (FLASH). The only option is to calculate the offset in run time because we can't put them in the same section ..?

0 项奖励
回复

920 次查看
rocco
Senior Contributor II

Hi Bertrand,

Yes, you are correct, you can't directly calculate the offset between ram and flash when using relocatable assembly language. However, I have never found a need to do that. Can you give an example of what you are doing? Maybe there's a better way.

Edward's (kef's) technique will work, but you need to be aware of its fragility. R0 and F0 would need to be defined in the assembler source file as the start of the segments, and they need to be defined also in the .PRM file to the same addresses. If the segment locations in the .PRM file should change, as they might if you ported to a different MCU, no errors would be reported and the code would simply not work. Explicit comments at both locations would help to minimize the risk.

0 项奖励
回复

920 次查看
Brax02
Contributor III

I send constant saved in FLASH by SPI (8bytes by frames). In the same time i want receive and save the datas on miso pin. So I would like to add or substract an offset beteween the addres of my table in flash and the adress in RAM.

But you are right there is probably a best way to do that.


0 项奖励
回复

920 次查看
rocco
Senior Contributor II

Hi Bertrand,

I do similar buffer management, as is pretty necessary with the SPI. The way I usually do it is with the H:X register as an index, and then having the address to each buffer specified as an offset in the MOV instruction. Here is an example:

Well, this new board pretty much sucks. I can't find a way to insert code. I never thought I would miss the old Lithium board.

I will post back when I find a way to insert code.

EDIT: Well, there seems to be no way to post code in a window. There also seems to be no way to request help from a moderator. And also no topic to discuss the board itself. Yes, I'm starting to miss that crappy old Lithium board.

So I will simply attach the source file:

AAARRGG: This board turned it into a ZIP file !

0 项奖励
回复

920 次查看
Brax02
Contributor III

Hi Mark,

Thanks for you example.

From my point with your algorithm the last byte is send after the end of the routine. So it's not very good if you have different SPI communication with several slaves or several communications with the same slave.

I do something like that (family MC9S08)

pastedImage_3.png

With this method you only send the constant table GET1DATA0A (OutBuffer). I have to do something with the possibility to choose the constant table.

0 项奖励
回复

920 次查看
kef
Specialist I

Betrand,

You may have some variable or label V0 at start of RAM section. You may have some constant/label C0 at start of FLASH section dedicated to constants. Since you know where each section starts, you may try something like this:

offset = (V1-V0) - (C1-C0) + (R0-F0)

Where V1-V0 is compile time constant variable offset relative to start of section.

C1-C0 - also compile time constant

R0 - known linker address of RAM section, F0 - known linker address of constants section. R0 == V0, F0 == C0

0 项奖励
回复