Port Manipulation - Quick Question...

Is is correct to set registers like this

int i = 40;
PORTD = i;

if not how can i perform this operation during run time, should i perform bitmath and set pin by pin?

yes, you do need to do bit math.

To set a particular pin on port d you would do something like: PORTD |= 1 << pin ;
to turn the pin off: PORTD &= ~(1 << pin) ;

There is some information in the reference: http://www.arduino.cc/en/Reference/PortManipulation

Can I ask what it is you need to do that the usual Arduino commands don’t provide

I’m trying to send 8bit data from a temperature sensor to an holtek encoder. now i wanted to do it at one go. can’t i do PORTD = 87 or something? is it invalid?

// Trasmission of Temperature
  // First we send the Character 'T' (01010100) as a header for temperature data
  PORTD = B01010100;
  pulse_enc();
  delay(400);
  // Transmitting Temp Data
  PORTD = temp_val;
  pulse_enc();

You can set all 8 bits that way but remember that pins 0 and 1 of Port D are used by the serial port. On standard Arduino boards, there are no ports that have all 8 pins available. You may need to split across two ports. You may want to reconsider using digitalWrite – see LiquidCrystal.cpp (in the library directory) for an example of writing all 8 bits.
Also, don’t forget you need to set the pins as outputs.

Done. It works. Thanks a ton!