"Shift in" operator?

Technical questions regarding the XTC tools and programming with XMOS.
Hagrid
Active Member
Posts: 44
Joined: Mon Jul 29, 2013 4:33 am

"Shift in" operator?

Post by Hagrid »

I have been adapting the "Simple/FAST UART Receiver" IP block to a more specialised use case.

While the code is functioning perfectly, I remain a little confused about *why* it works.

The main working loop looks like this:

Code: Select all

        for(int i = 0; i < 8; i++) {
            pIn @ t :> >> data;
            t += dt;
        }
From a C programmer's perspective, the line "pIn @ t :> >> data;" would read as "shift the value (pIn @ t :> ) to the right by (data) bits. But then without an lvalue, the result would be discarded.

So, xC is treating ">>" as something semantically different in this context, as some kind of shift-in operator.

I have been unable to find documentation on this operator.

Can someone point me to the right manual for this and any other operators that vary from C semantics?


User avatar
Bianco
XCore Expert
Posts: 754
Joined: Thu Dec 10, 2009 6:56 pm

Post by Bianco »

shift data with port width bits to the right, then write the input to the port width msb bits of data.
Or you can see it as shifting the input into data from the right. It corresponds with the following instruction:
INSHR
Input and shift right
Inputs a value from a port, and shifts the data read into the most significant bits of the
destination register. The bottom
port-width
bits of the destination register are lost