What happens in the CPU if I pop / push all the stack?

120 Views Asked by At

I am doing an energy profile of an ARM processor for an academic project. I managed to measure the power consumption of several assembly instructions by running them in a ~200 insts loop, e.g.:

.rept 200  
add r1, r2, r3
.endr

However, when coming to stack instructions, I wondered: what happens if I do something like this?

.rept 200  
pop {r1}
.endr

Notice that the control flow isn't affected, since the loop uses an absolute jump at the end, and the code is running bare metal, without an OS.

What happens when the stack finishes? Does the sp simply overflow and wrap around, going to 0x00000000 and starting popping from there?

My power sensor doesn't see anything strange; it is a constant power drain like any other instruction. Then, the question also arises: what if I keep pushing instead?

0

There are 0 best solutions below