Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ARM assembly puzzle

First of all, I'm not sure if solution even exists. I spent more than a couple of hours trying to come up with one, so beware.

The problem:

r1 contains an arbitrary integer, flags are not set according to its value. Set r0 to 1 if r1 is 0x80000000, to 0 otherwise, using only two instructions.

It's easy to do that in 3 instructions (there are many ways), however doing it in 2 seems very hard, and may very well be impossible.

like image 948
Ivan Tarasov Avatar asked Jun 02 '10 18:06

Ivan Tarasov


1 Answers

something like

SMMUL r0,r1,r1
MOV r0,r0,lsr #30
like image 122
Martin Avatar answered Oct 05 '22 22:10

Martin