Addressing ATmega registers by number

DDRB is a number, it's just been defined as a human-readable mnemonic.

port 0x04 for DDRB

Doesn't make sense, DDRB is one of the PORTB regs, there is no "port 0x04 for DDRB". Do you mean "pin 0x04"?

If you want to address ports using a number you could have an array of port addresses

byte ports [] = {DDRB, DDRA, PINx, PORTy...};

for (int i = 0, i < n; i++) {
    ports [i] = somevalue;

I think you should explain what you want to do not how you think it should be done.


Rob