The code shown from the data sheet will "Refresh" the entire EEPROM space.
It's a procedure that should only be done once every couple month/years in order to meet the 40 year data retention spec. I don't think that's what you're looking for

But in that code, you can also see the required Write Sequence that involves setting 3 bits in EECON1, writing 55h AAh to EECON2, before setting the WR bit in EECON1 which actually initiates the write.

The sequence was designed to prevent any unintentional writes, and it's unlikely that writes to EEPROM on power-up are due to PIC registers not being set properly. And, like Bruce says, that sequence is already included in PBP's WRITE command, so there's no need to do it separately in ASM.

However, there is a minimum voltage requirement for EEPROM writes. And if you are trying to write to EEPROM immediately on power-up to record the number of times it's been powered on/off for instance, then Large capacitors on the power rail may not have fully charged by the time it starts trying to write. This could cause unpredictable results.

The current Brown-out detector settings in your config are ...

_BOREN_NOSLP_2L ; Brown-out Reset enabled in hardware only and disabled in Sleep mode (SBOREN is disabled)

Using the "No Sleep" BOR mode, implies that you may be using Sleep Mode on your board. Perhaps there's a battery backup that keeps it running when there's no power?

If that's the case, then BOR will be disabled, and when main power is restored, it may try to write before the voltage is above the minimum.

_BORV_1_2L ; second highest voltage setting

The "second highest voltage setting" can switch anywhere between 4.11 and 4.55V. If that particular chip switches at the low end of the range, it could also be writing with a low voltage.

If any of this is actually relevant to your problem, then a simple pause 1000 (or less) at the beginning should take care of it. Or, any other method that insures voltage is sufficient, before attempting to write.

HTH,