Thank you for all the replies!
The b variable is indeed a temporary storage and the printBits() is working well I think. The malloc() really throws a warning so thanks for the tip.
The output section that feeds the inputs of the GAL works as a simple 10bit binary counter, I have chcecked the pins with LEDs and it seems to be ok.
I am worrying about the input section that receives the output from the GAL chip , maybe it has something to do with timing, because when I fiddle with the delay(0), the input is different for the same output. I am also not sure if the output and input is in sync, I mean line wise in the serial monitor (Serial.print() takes time?). Unfortunately I do not have enough LEDs right now to check if the real output/input on the pins corresponds to the line printed in the serial monitor.
Thanks,
Lukas