Page 1 of 1

Rotate Right

Posted: Sat Dec 29, 2012 11:48 am
by Jan Lichtenbelt
Hi All,

I met the flowing declaration problem of variables in a rotation right. Let make the problem more clear:

1) take 2 variables A and B, which are declared as 1 byte variable each. Say A=0x01 and B=0x10.
2) I want to place bit 0 of A into bit 7 of B (and all other bits in B shifted to right)
3) The most easy way is in the assembler code like:
Asm
{
RRF A,F // which places bit 0 of A into the carry bit
RRF B,F // which places the carry bit into bit 7 of B
}


So far so good. But now in Flowcode 5:
4) The variable A and B will become gbl_FCV_A and gbl_FCV_A in the assembler code. But
asm
{
RRF gbl_FCV_A,F
RRF glb_FCV_B,F
}

gives an error that these variabales are unknown
5) The variable A and B will become FCV_A and FCV_A in the C-code. But
asm
{
RRF FCV_A,F
RRF FCV_B,F
}

give also the error that these variables are unknown.

In principle 4) is the right assembler code and should be used as such. But it is interpreted as a C-code with wrong variable names.

My question:
Is there and easy/simple solution?

Kind regards

Jan Lichtenbelt

Re: Rotate Right

Posted: Sat Dec 29, 2012 1:02 pm
by Enamul
asm
{
RRF gbl_FCV_A,F
RRF glb_FCV_B,F
}
this is not right according to Boostc manual

It should be following which compiles fine..

Code: Select all

asm
{
RRF _FCV_A,F
RRF _FCV_B,F
}
To refer to a C variable from inline assembly, simply prefix its name with an
underscore '_'.
// Example showing use of bit tests and labels in inline assembly
#include <system.h>
void foo()
{
unsigned char i, b;
i = 0;
b = 12;
asm
{
start:
btfsc _i, 4
goto end
btfss _b, 0
goto iter
iter:
movlw 0
movwf _b
end:
}
}

Re: Rotate Right

Posted: Sat Dec 29, 2012 4:03 pm
by Jan Lichtenbelt
Dear Enamul,

Thanks a lot. It works!


Jan Lichtenbelt