2

Say we want to find a shortest possible sequence of x86 instructions to move the $9^{th} - 16^{th}$ bit of the $eax$ register to the $24^{th} - 31^{th}$ bit of the $ebx$ register without changing the other bits of the $ebx$ register, where the least significant bit is defined to be the $0^{th}$ bit.

An obvious solution is:

ror eax, 1
rol ebx, 8
mov bl, ah
ror ebx, 8

But how do I prove this is the shortest possible? Is there a nice way to do it? If not, is there a nice piece of FOSS software to brute force it?

Alex Vong
  • 121
  • 3
  • If we're talking problems as easy and programs as small as this, just enumerate all shorter programs and check if the solve the problem. In general, the problem is, of course, not computable. – Raphael Nov 07 '17 at 11:12
  • Seems like you'd always have to start from a brute-force search, then use any trick you happen to know to optimize the search process. Exactly what "optimizing the search process" means is really implementation-subjective. – Nat Nov 07 '17 at 11:18
  • How interested are you in this problem? For example, was it a random thought that you wanted to explore, or is it a problem that you're seeking a good general solution for as part of, say, an optimizing compiler? – Nat Nov 07 '17 at 11:26
  • @Nat It is more like something to explore. – Alex Vong Nov 07 '17 at 11:35

0 Answers0