I was wondering if there is a way to store data in the data cache of a processor directly, rather than in main memory. I understand that the way caches work is to store the most frequently used data, however, it would make sense to have an assembly directive to do tell the processor, this is going to be a frequently used data. I am using the IA-32 assembly language.
Thanks!
Depending on the architecture, there are prefetching hints to move data directly into the cache. For ia32 this is the prefetch
instruction, which may move data to L1, L2.
On the other hand there are instructions which tell the processor to avoid using the cache, like moventdq
, which moves data directly from/to memory.
Edit: Additionally there are instructions to setup memory ranges for specific types of caching algorithms, like write back, write through, write combine or uncachable. See http://en.wikipedia.org/wiki/Memory_type_range_register.
No, you can't access the cache directly in assembly level. Because the cache is "hidden" (L1 and L2) in processor and maybe there's no cache at all.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With