int addr = StringUtil.readHexValue(i, 8);
// read the length if it exists
int length = 1;
if ( StringUtil.peekAndEat(i, ',') )
length = StringUtil.readHexValue(i, 8);
State s = simulator.getState();
StringBuffer buf = new StringBuffer(length*2);
if ( (addr & MEMMASK) == MEMBEGIN ) {
// reading from SRAM
addr = addr & (~MEMMASK);
for ( int cntr = 0; cntr < length; cntr++ ) {
byte value = s.getDataByte(addr+cntr);
buf.append(StringUtil.toHex(value & 0xff, 2));
}
} else {
// reading from program memory
for ( int cntr = 0; cntr < length; cntr++ ) {
byte value = s.getProgramByte(addr+cntr);
buf.append(StringUtil.toHex(value & 0xff, 2));
}
}
sendPacketOK(buf.toString());