Check this one.
Modify as needed.
Code:
ReadMem VAR BYTE
Value VAR BYTE
Begin:
FOR ReadMem = 0 TO 128 'Scan eeprom
READ ReadMem, Value
IF Value <> $FF THEN Start
NEXT ReadMem
Start:
' your "value" variable gets a value here.
'..
'....
' when you want to save something into eeprom, goto "save".
GOTO Start
Save:
IF ReadMem = 128 THEN ' last eeprom location.
WRITE 0, Value ' thus, start from the beginning
WRITE 128, $FF ' assign $FF to last written eeprom location.
ELSE
WRITE ReadMem + 1, value 'save your value into eeprom after the current eeprom address.
WRITE ReadMem, $FF 'assign $FF to the current eeprom location.
ENDIF 'new eeprom location will be incremented,
GOTO Begin '...with the next eeprom scan.
Bookmarks