How to reference sub-blobs in Squirrel

I’m using a 4K blob as temp buffer to read-modify-write an EEPROM 4K sector. The EEPROM gets written per page of 256 bytes hence there’s a need to do 16 page writes to ‘refres’ one single sector. (EEPROM needs erase before write and 4K is the smallest block that can be erased).
To do this in C I would use an array of 4K elements and have a pointer moving to the start of each page within that array. Then blast it out to the SPI from the pointer onwards. How can I do something similar in Squirrel ? The way I do it now is to copy a portion from the sector buffer blob to a temp page blob of 256 bytes, but this is painfully slow (about 16ms to copy).

Found an alternative which is already much faster (and much cleaner as well as it doesn’t require an additional temp buffer) :
original code:
for (i = 0; i < PAGESIZE; i++) EEPROMPageBuffer[i] = EEPROMSectorBuffer[(PageNr & 0xF)*256+i]; _SPIPort.write(EEPROMPageBuffer);

replaced by: * 0x100,'b'); _SPIPort.write(EEPROMSectorBuffer.readblob(PAGESIZE));

Technically, that is creating another temp buffer (readblob is creating one), but yeah, much neater and faster.

Thx. Just need to make sure not to forget changing all the constant values 0x100, 256 to PAGESIZE…Why else parametrise :slight_smile: Could become a nasty bug if I ever try to use the code on a device with different pagesize then 256.