Bug in 4.0.0.2: Use of Constants within asm statement

General discussion on mikroPascal for AVR.
Post Reply
Author
Message
JohannesH
Posts: 68
Joined: 23 Apr 2007 07:51

Bug in 4.0.0.2: Use of Constants within asm statement

#1 Post by JohannesH » 20 Mar 2008 08:53

The following statements produces this messages:
==>> Successfully compiled unit "unit1"
==>> Argument out of range R24:xx.

The xx is some number which I dont understand.


unit unit1;
const const1 = 7; //define some constant
...
procedure proc1;
begin
asm
...
LDI R24,const1
...
end;
end;
...

program test;
uses unit1;

begin
proc1;
end.


Additional info:
It does make no difference where the constant is defined (global or local or within a device definition file).
If I change the asm statement to the pascal statement
"R24 := const1"
then it gets compiled correctly to the following assembly code:
"LDI R16,value of const1"
"MOV R24,R16".

So this is some kind of partial workaround (only uses 2 instructions instead of one) but it does not help with other instructions mainly with branch instructions:
...
const bitnr = 7;
...
asm
SBRS Rxx, bitnr //skip next instruction if bit "bitnr" is set
end;
This again leads to the error message.
It is an often used efficient construct when working with hardware modules and checking individual bits.
SBRS Rxx, 7 works ok
but one really wants to use symbolic constants in such situations.

Regards
Johannes

Post Reply

Return to “mikroPascal for AVR General”