Hello Sary,
First, let's confirm the hardware connections you are using. The code would be based on the following 'HC595 pins:
Pin 14 (device 1 only) = CPU_LED_DATA
Pin 13 (all devices) = CPU_LED_ENABLE
Pin 12 (all devices) = CPU_LED_LATCH
Pin 11 (all devices) = CPU_LED_SRCLK
Pin 10 (all devices) = tied to Vdd
Pin 9 (device 1) -> Pin 14 (device 2)
Pin 9 (device 2) -> Pin 14 (device 3)
On power-up, the shift register and latches may have arbitrary output state, so you will need to initialise by pulsing pin10 (SCLR) low, and then strobing pin 12 (RCK) to zero the output latches. Alternatively, you might simply update the LEDs in the normal way, using a value of 0x000000, which should also zero the output latches (and presumably turn all LEDs off).
Now I am assuming that the LEDs states are not changing as the data is serial shifted into the register, but change only as a result of a positive transition of the CPU_LED_ LATCH signal, after the data shifting is complete. The code does rely on the fact that the RCK pin is edge triggered, and would require some modification for transparent latch type.
Regards,
Mac