How to change PORTx register in other place of program?(Codevision & AVR-GCC)

I have a question related to AVR microcontrollers using AVR-GCC and CodeVision:
Normally we set the port related registers inside the main function using DDRx/PORTx registers, for example like this:

DDRB = 0x00;
PORTB = 0x00;


How can I change the content of these registers in other places of the program?

And another question, is it wise to set DDRx and PORTx registers using the following way:

DDRB.0=0;
PORTB.0=1;

• This question would take too much introductory material to explain since you don't even understand this is a processor-specific question. Jul 29 '13 at 11:07
• What introductory material? Jul 29 '13 at 16:20
• Exactly. ------ Jul 29 '13 at 18:15

Exactly the same way; there is no intrinsic difference between performing the assignment at any point in your code.

I have no experience with Codevision, but I can't imagine that performing a bitfield assignment that way would not be translated to the appropriate opcodes, the same way as if one were to perform a bitwise operation against the entire register in C.