4.4.8 Reading and writing memory

The semantics of reading memory are peek rather than bus read. The semantics of writing memory are poke rather than bus write.

Read data is transferred in the data member of the MemoryReadResult object returned by memory_read() and write data is transferred in the data argument of the memory_write() function. Both data fields use the same format to encode the data being transferred. For the format, see the documentation of memory_write() or MemoryReadResult.

Examples of packing various byteWidth elements into NumberU64 elements:

byteWidth=1
Reading 8 bytes with values 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88:
data[0] = 0x8877665544332211
byteWidth=2
Reading 4 16-bit words with values 0x1110, 0x2120, 0x3130, 0x4140:
data[0] = 0x4140313021201110
byteWidth=4
Reading 2 32-bit words with values 0x13121110, 0x23222120:
data[0] = 0x2322212013121110
byteWidth=8
Reading 1 64-bit word with value 0x8877665544332211:
data[0] = 0x8877665544332211
byteWidth=16
Reading 1 128-bit word with value 0x1f1e1d1c1b1a19181716151413121110:
data[0] = 0x1716151413121110, data[1] = 0x1f1e1d1c1b1a1918

All these examples are correct for big-endian and little-endian target memory and for big-endian and little-endian host memory. The representation is independent of the target or host endianness.

Non-ConfidentialPDF file icon PDF version101196_0100_00_en
Copyright © 2018 Arm Limited or its affiliates. All rights reserved.