0

I am currently working on a project, where i inject bitflips (0 -> 1, or 1 -> 0) in memory or registers. Now i have to think about some special cases.

Here is my question:
Can there be cases, where there is a memory access on a certain memory location and shortly after, there is a memory access on the same location with smaller or wider access size?

Example:

1:    ld.B    D15, [A15]
2:    ld.W    D15, [A15]

In line 1 the memory is accessed via the pointer in the addressregister A15 and it's content is stored in dataregister D15. The access size is a byte (.B). In line 2 it's the same as in line 1, but with the access size word (.W)(32-Bit).

So the access sizes would be something like this:

[A15]  ------XX  -> line 1
[A15]  XXXXXXXX  -> line 2

Where X is a hexdecimal.

Is this possible, that the compiler would do something like this? And what would be an example case for this?

I have no idea if this question is stupid or not. I am sorry! :D

AndiYo
  • 43
  • 6
  • Narrow stores and a wide reload (or vice versa) could easily happen in an endian-conversion function that compiled inefficiently. A compiler could plausibly generate a byte load and a word load from the same value, maybe for `x` and `x&0xff`, but not to the same destination register without having used it first. Most compilers would normally prefer to use an ALU instruction like AND or a bit-field extract / zero-extend instruction to use one load result two ways, though. With `volatile` you could certain construct C that compiled to separate loads if you wanted to. – Peter Cordes Sep 11 '18 at 20:03
  • Very nice, thank you for your information! I am going to try to create a case like this! – AndiYo Sep 12 '18 at 15:23

0 Answers0