I need to convert the following PIC assembly code (below) to an 8051 assembly. It is an inline assembly code. Actually, I intend to convert it to C. I am not familiar with the PIC MCU so I do not understand much of what happens. If I can an understanding of each instruction, I will try and input the equivalent assembly. Or better still, I will appreciate if I can get an equivalent 8051 assembly code of it. "toRotate" is a 32 bit variable. Thanks
_asm
movlb toRotate
bcf STATUS,0,0
btfsc toRotate+3,7,1
bsf STATUS,0,0
rlcf toRotate+0,1,1
rlcf toRotate+1,1,1
rlcf toRotate+2,1,1
rlcf toRotate+3,1,1
_endasm
This is the entire code below.....I really want to know what is done here. My intention is to convert it to C language.
DWORD leftRotateDWORD(DWORD val, BYTE bits)
{
BYTE i, t;
DWORD_VAL toRotate;
toRotate.Val = val;
for(i = bits; i >= 8u; i -= 8)
{
t = toRotate.v[3];
toRotate.v[3] = toRotate.v[2];
toRotate.v[2] = toRotate.v[1];
toRotate.v[1] = toRotate.v[0];
toRotate.v[0] = t;
}
for(; i != 0u; i--)
{
_asm
movlb toRotate
bcf STATUS,0,0
btfsc toRotate+3,7,1
bsf STATUS,0,0
rlcf toRotate+0,1,1
rlcf toRotate+1,1,1
rlcf toRotate+2,1,1
rlcf toRotate+3,1,1
_endasm
}
return toRotate.Val;
}
