Error concerning non-absolute arguments

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

Error concerning non-absolute arguments

跳至解决方案
2,745 次查看
jackabo
Contributor I
I had written a post before about getting an error when i used non-absolute arguments in certain instructions in my CW 5.1 for my MC9RS08KA2. However, I realized that I wasn't understanding what the error was saying. In the variable declaration section I have some variables that I declare by using "ds.b" For example,
 
SensorReading: ds.b 1
 
From what I understand, this clears one byte of space for this variable. However, when I then use this variable in an instruction such as "clr SensorReading", the compiler gives me and error and says that I can not do this with the -FA1 or -FA2 option. My question is if there is any way around this. Can I just say "SensorReading equ $00" and this would be the same? Thanks.
 
Jackabo
标签 (1)
标记 (1)
0 项奖励
回复
1 解答
1,512 次查看
CompilerGuru
NXP Employee
NXP Employee
Thanks bigmag, the $ was wrong, and there has to be at least a space or tab before every line except the labels.

Anyway my initial post was not that precise.
The point is that there has to be a ORG directive before every memory usage, and ds counts as such.

SO to reply to the original post, (I guess) the error was because the SensorReading label was in a relocatable area, and the reason why it was relocatable was the missing ORG before.

This derines SensorReading to be 0.
SensorReading EQU $00


 ORG $0
SensorReading: DS 1


With the ORG, SensorReading has the same value as when using the EQU, but in addition this also reserves/allocates one byte.

Daniel

在原帖中查看解决方案

0 项奖励
回复
3 回复数
1,512 次查看
CompilerGuru
NXP Employee
NXP Employee
In Absolute assembly mode (say with -FA1 or -FA2), its up to the user to define any address, nothing can be defined in the linker (simply because it is not called :smileyhappy:.
The point I want to make is that in order to reserve one byte with ds (or ds.b), you have to define the current absolute address first. Usually it looks like this (with better names and more reasonable content, I hope):


my_ram: EQU $1234 ; adapt :smileywink:
my_flash: EQU $8234 ; adapt :smileywink:
ORG $my_ram
Var0: DS 4 ; Var0 occupies 4 bytes
Var1: DS 1
....
ORG my_flash
StartHere:
CLR Var1
....

ORG $FFFE
DC.W StartHere

Daniel

PS: Have a look at a wizard generated, absolute assembly project. As starting point its better and more reasonable that my out of memory snippet :smileywink:
0 项奖励
回复
1,512 次查看
bigmac
Specialist III
Hello Daniel,
 
In the line -
ORG $my_ram
 
why the '$' symbol?  I am not familiar with this variation.
 
Also, it appears indentation has been lost when posting the code snippet.  It is my understanding that a pseudo-op (or instruction) cannot commence at the first position on the line.
 
Regards,
Mac
 
0 项奖励
回复
1,513 次查看
CompilerGuru
NXP Employee
NXP Employee
Thanks bigmag, the $ was wrong, and there has to be at least a space or tab before every line except the labels.

Anyway my initial post was not that precise.
The point is that there has to be a ORG directive before every memory usage, and ds counts as such.

SO to reply to the original post, (I guess) the error was because the SensorReading label was in a relocatable area, and the reason why it was relocatable was the missing ORG before.

This derines SensorReading to be 0.
SensorReading EQU $00


 ORG $0
SensorReading: DS 1


With the ORG, SensorReading has the same value as when using the EQU, but in addition this also reserves/allocates one byte.

Daniel
0 项奖励
回复