AVR "OUT" function. addressing port without constant
All IO registers are also available as memory mapped. Just use ST instead of OUT, and you can simply load e.g. X register contents from a variable in memory and so X will then point to correct memory address for the port you have chosen with the variable. But do note that OUT and ST have a different base so you need to convert the IO port address to memory address and such macros should be readily available.