The memory has to be the exact same, and DUAL CHANNEL ram though, if not, it would not work correctly, to awnser your question is this:
If you have 2x 512, and 2x 256, Dual Channel RAM, then YES, but if no, it will not work as good.
As jervin said, if you have 2 memory pools, then make sure you put 1 512 stick and 1 256 stick in each pool and make sure they're in their respective slots. So, 512 in the first slot of the first pool, and 256 in the second slot, of the first pool. Then 512 in the first slot of the second pool, and 256 in the second slot, of the second pool.