The 8051 isn’t as popular on this forum as other chips. However, it sounds like this is a variation of the classic LED blinking program, the “Hello, world!” of the embedded world. A Google of “8051 LED blinker” will get you started. You can use a simple brute force timing approach like the example below, or the timers in the 8051 if you feel more adventurous.
// psuedo code
set up your IO pins as desired (outputs, most likely)
loop: turn on the LEDs
call delay
turn off the LEDs
call delay
goto loop
delay: 500ms of nops
return