Issue
I have been messing around with the Flags while learning ARM assembly on my Raspberry PI. I have devised of ways only to set the zero flag, only the negative, and only the carry flag. However I can't think of a way to set only the overflow flag. Is it possible? Any help would be appreciated!
Edit: only setting the overflow flag with all the others zero/clear. Using only arithmetic or shifting. NZCV = 0001
Edit2: To clarify further, I would think multiple instructions would be needed to achieve this, and You can't write directly to the cpsr.
Solution
I don't see an obvious way with just one instruction, but you could do with combination. For example:
mov r0, #0x80000000
mov r1, #0x00000001
subs r2, r0, r1 ; C and V set
mov r3, #0x10
asrs r3, #1 ; C cleared, V not changed
Answered By - domen