3 ms·
I think there is also the type of the data it points to, or maybe at least the length of the data it points to? I was wondering how come OS understands that say
by markus_zhang 4y ago
I think there is also the type of the data it points to, or maybe at least the length of the data it points to? I was wondering how come OS understands that say it only needs to grab 4 bytes for an int32_t, but 8 for an int64_t, I guess such information is included.
- ksherlock 4y agoGenerally, the CPU has instructions for loading memory into registers and storing registers into memory and they specify how much memory to read/write. eg: ARM (32) has LDR (32-bit), LDRH (16-bit), and LDRB (8-bit) 68K has MOVE.L (32-bit), MOVE.W (16-bit), MOVE.B (8-bit) There are also some architectures (early Alpha for example) where memory can only be read in aligned 32-bit chunks or aligned 64-bit chunks. If you want to read 8 bits... well the compiler will generate a 32-bit read and then shift/mask the data to get the 8-bits that you care about.
- markus_zhang 4y agoOh you are right, I absolutely forgot the translation part I read about tons of time.