That looks like assembler to me... but it has interesting bits of a higer level langauge in it - .if .else .endif etc. As far as i can tell that is propiorty code going thats meant to be run on a dsp on a level 3 network switch or someting similar.
But in your case the << and >> will be bit shifters.
Code:
.set IPchecksum = IPchecksum + (IPVersionLength<<8) + IPTypeOfService
.set IPchecksum = IPchecksum + (IPTypeOfService<<8) + IPLength
This bit mearly turns two 8 bit words into a single 16 bit word, by moving IPVersionLength bits 8 bits up (same as multiplying by 256, but faster).
Code:
.MACRO UDPSendByte ;send to UDPport byte (given as parameter1)
.if ((@0 >> 0)&1)
out UDPPort,RegForUDP1
out UDPPort,RegForUDP0
.else
out UDPPort,RegForUDP0
out UDPPort,RegForUDP1
.endif
I'm a bit flumouxed by this bit. I think that the @0 is a pin number on the chip, but why bit shift it by 0 places? it does nothing. But it seems to signfy most/least signficant byte first.
Code:
in temp0, UDPPort ;load port state
cbr temp0, (1<<TxPlusPin)|(1<<TxMinusPin) ;clear TX+ and TX-
mov temp1,temp0 ;store the default state for recovering
out UDPPort,temp1 ;back to port as default state - no voltage between TX pins
sbr temp0, (1<<TxMinusPin) ;set TX- (TX+ was cleared)
mov RegForUDP0, temp0 ;and store as log0 state
Again this isn't how I would do it. Presumably both TxMinusPin and TxPlusPin are #defined somewhere, so why not just use their straight values instead of confusing matters with bit shifting?
The << and >> also work as bit shifters in C and C++.
A<<1 == A * 2
and
A>>1 == A /2 (rounded down).
You can also get some weird changing of the sign.
Try this proggie out, with an input of 65535.
Code:
#include <stdio.h>
#include <iostream>
int main()
{
int d, c;
cout << "Please enter a number between -2,147,000,000 and 2,147,000,000" << endl;
cin >> c;
cout << "Heres the number bit shifted up(l col), down(m col) and each bit (LSB first, r col)" << endl;
for(d=c; c|d;c<<=1, d>>=1)
printf("\n%13d%13d%2d", c, d, d&1);
return 0;
}