Changing the port values inside the loop (8051)
You may not be waiting long enough between 'button presses'. The HT12E always repeats each word packet (address bits + data bits) at least 4 times, even if transmission is only enabled momentarily. If you try to send too fast then some of the 'button presses' will be lost.  

At its recommended 3KHz oscillator frequency the HT12E takes about 70ms to send the 4 words, so you need to delay for longer than that (eg. 100ms) between transmissions.