It would be the same.Quote:
Originally Posted by Laserve
No, it's a C idiom that I figured was not widely recognized, but I didn't know how much.Quote:
Originally Posted by jafet
I first saw it about a decade or so ago, and I've come to read it as a "move bit to LSB" "operator". Mentally I picture it something like this:
So upon inspection, I can more easily tell that this is doing what is expected like this:Code:0100:0000 -> 0000:0001, 0000:0000 -> 0000:0000
than like thisCode:#define UART_RX 0x40
const volatile unsigned char *UartStatus = (const volatile unsigned char *)0x38;
volatile unsigned char UartRxData;
/* interrupt */ void UartReceive(void)
{
UartRxData <<= 1; /* shift current value to make room for new LSB */
UartRxData |= !!(*UartStatus & UART_RX); /* add new bit in LSB */
}
or other variants. YMMV.Code:#define UART_RX 0x40
const volatile unsigned char *UartStatus = (const volatile unsigned char *)0x38;
volatile unsigned char UartRxData;
/* interrupt */ void UartReceive(void)
{
UartRxData <<= 1; /* shift current value to make room for new LSB */
UartRxData |= (*UartStatus & UART_RX) != 0; /* add new bit in LSB */
}
Related discussions:
:rolleyes:Quote:
Originally Posted by manutd
Apparently the point of this thread is not what I thought.