why is writing to eeprom is as fast as writing to RAM?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Gilad_Raz
Posted On:   Monday, September 9, 2002 02:24 AM

why is writing to eeprom is as fast as writing to RAM? hello I wrote an applet that checks the speed of writing operations to EEPROM and writing operation to RAM and I received the same result for both which is wierd. My check was on 2 cards: 1. schlumberger cyberflex access 32k developer 2. gemples gemexpresso 211pkIS. the results were almost the same. I added the applet main code here: public class AES extends Applet { final static byte AES_CLA = (byte) 0xB0; final static byte AES_INS_Check1 = (byte)0x7; final static byte AES_INS_Check2 = (byte)0x8; // both presistent object static byte arrEEPROM[]; sta   More>>

why is writing to eeprom is as fast as writing to RAM?

hello I wrote an applet that checks the speed of writing operations to EEPROM and
writing operation to RAM and I received the same result for both which is wierd.

My check was on 2 cards:
1. schlumberger cyberflex access 32k developer
2. gemples gemexpresso 211pkIS.

the results were almost the same.

I added the applet main code here:

			
public class AES extends Applet
{
final static byte AES_CLA = (byte) 0xB0;
final static byte AES_INS_Check1 = (byte)0x7;
final static byte AES_INS_Check2 = (byte)0x8;

// both presistent object
static byte arrEEPROM[];
static byte arrRAM[]; // will be a presisten reference to a traient object

protected AES(byte[] buffer, short offset, byte length)
{
.
.
.


arrEEPROM = new byte[(byte)16];
}

public boolean select()
{
// create an array of 16 bytes inside the RAM.
arrRAM = JCSystem.makeTransientByteArray((byte)16,
(byte)JCSystem.CLEAR_ON_DESELECT);

return true;
}
.
.
.
public void process(APDU apdu)
{
byte buffer[] = apdu.getBuffer();
byte cla = buffer[ISO7816.OFFSET_CLA];
byte ins = buffer[ISO7816.OFFSET_INS];

if (cla == ISO7816.CLA_ISO7816 && ins == ISO7816.INS_SELECT)
{
// After (byte)e're selected, the JCRE passes us the SELECT APDU
// that (byte)as sent to the smart card. There's nothing special
// (byte)e (byte)ant to do here.
return;
}

if (cla != AES_CLA)
ISOException.throwIt(ISO7816.SW_CLA_NOT_SUPPORTED);

switch (ins)
{
case AES_INS_Check2:
Check2(apdu);
return;
case AES_INS_Check1:
Check1(apdu);
return;
default:
ISOException.throwIt(ISO7816.SW_CLA_NOT_SUPPORTED);
}
}




private void Check1(APDU apdu)
{
byte buffer[] = apdu.getBuffer();
byte p1 = buffer[ISO7816.OFFSET_P1];
byte p2 = buffer[ISO7816.OFFSET_P2];
short x;
short sLoopTimes = Util.makeShort(p2,p1);
//byte bytesRead = (byte)(apdu.setIncomingAndReceive());

try
{
for (short i=0; i
{
arrEEPROM[0] = 0;
arrEEPROM[1] = 1;
arrEEPROM[2] = 2;
arrEEPROM[3] = 1;
arrEEPROM[4] = 1;
arrEEPROM[5] = 1;
arrEEPROM[6] = 1;
arrEEPROM[7] = 2;
arrEEPROM[8] = 3;
arrEEPROM[9] = 4;
arrEEPROM[10] = 5;
arrEEPROM[11] = 6;
arrEEPROM[12] = 7;
arrEEPROM[13] = 8;
arrEEPROM[14] = 8;
arrEEPROM[15] = 7;
}
}
catch (ArrayStoreException ArrayRef)
{
ISOException.throwIt(ISO7816.SW_FILE_NOT_FOUND);
}

}

private void Check2(APDU apdu)
{
byte buffer[] = apdu.getBuffer();
byte p1 = buffer[ISO7816.OFFSET_P1];
byte p2 = buffer[ISO7816.OFFSET_P2];
short sLoopTimes = Util.makeShort(p2,p1);

for (short i=0; i
{
arrRAM[0] = 0;
arrRAM[1] = 1;
arrRAM[2] = 2;
arrRAM[3] = 1;
arrRAM[4] = 1;
arrRAM[5] = 1;
arrRAM[6] = 1;
arrRAM[7] = 2;
arrRAM[8] = 3;
arrRAM[9] = 4;
arrRAM[10] = 5;
arrRAM[11] = 6;
arrRAM[12] = 7;
arrRAM[13] = 8;
arrRAM[14] = 8;
arrRAM[15] = 7;
}
}



I run Check1 command and Check2 command for 4096 (sLoopstimes=4096) and received it
takes 35 seconds for check1 and check2.

that mean that writing to RAM is the same speed as writing to EEPROM. and with that I've
heard about javacard writing to RAM should be 1000 times faster.

why is that? please help.

Thanks alot,

Gilad Raz.    <<Less

Re: why is writing to eeprom is as fast as writing to RAM?

Posted By:   Paul_Szulc  
Posted On:   Tuesday, October 15, 2002 11:01 AM

Keep in mind that optimisations are made when compiling and converting the Java code to a CAP file.



Second point is that when the same value is already present on a particulair place in an array it will not be written again as the same value is already present.



The above mentioned causes that it seems that both RAM and EEPROM writing consumes the same amount of time.
About | Sitemap | Contact