Why do I have to use an absolute variable in the IF statement?

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Why do I have to use an absolute variable in the IF statement?

3,280件の閲覧回数
muskut
Contributor I
an example code;

...
if var1 == 5
jmp label1
else
jmp label2
endif
...

My question is when I use a variable (like var1) there is no problem if the variable is absolute. But if the variable is relocatable I have got an error message which is "complex relocatable expression not supported". Why do I have to use an absolute variable in the IF statement? (my MCU is RS08)
ラベル(1)
0 件の賞賛
返信
3 返答(返信)

1,039件の閲覧回数
rocco
Senior Contributor II
Hi, Mustafa:

I believe the IF statements in that context are conditional assembly statements, not program statements. But I'm not sure, because I don't know what programs you are using, and which program generated the error.

Assuming the context is assembly language, and not Basic or some other language then those statements mean the following:
If the address defined for 'var1' is equal to 5 then compile the assembler instruction 'jmp label1' into the object file, otherwise compile the assembler instruction 'jmp label2' into the object file.
So the only code that is generated is a single 'jmp' instruction, probably to label2.

The reason for the error is that, if 'var1' is relocatable, it doesn't yet have an address to test against. When the assembler evaluates 'var1==5', it realizes that 'var1' is not yet equal to anything, and generates an error.
0 件の賞賛
返信

1,039件の閲覧回数
peg
Senior Contributor IV

Hi Mustafa,

I believe rocco is on the right track here.

The important thing is that the value of the variable (var1 in your example) must be known to the assembler at assemble time.

And the other short answer is.....

Because the manual says so!

Regards David

 

Message Edited by peg on 2006-08-10 08:54 PM

0 件の賞賛
返信

1,039件の閲覧回数
muskut
Contributor I
thanks a lot for the answers. Nice points all
0 件の賞賛
返信