Hi:
I am trying to save PORTB pin status on Power On Reset, then when power is restored the data will be the same there is my code:

start:
trisb=0
gosub update ' restore last portb value

mainlop:
portb = portb +1
gosub store_val 'update the value on rb to eeprom
pause 1000
goto mainlop


update:
read 0,last_val
PORTB= last_val
return

store_val:
last_val=portb
write 0,last_val
pause 10
return

is too simple, it means a loop where the portb is incremented once each second and then save the status on eeprom, but it doesn't work !
when I remove the power then I restore, th leds atached to the port b is a number different to the I can remember when the pic is shut off!

Ovbiously I init the eeprom data with a number before taht the pic can run on first time!
What I doing Wrong?
Thanks!