Not sure I really understand your question.
It seems you're asking on how to reconstruct the original register based instructions? That is not possible, as that information is destroyed.
For example, given that stack based VM, you cannot distinguish
Code:
mov eax,ebx
mov ecx,eax
mov edx,ecx
from
Code:
mov ebx,eax
mov edx,ebx
mov ecx,edx
What you can do however, is what in compiler construction is called "register allocation". It basically means, that you start with arbitrarily many variables (in this case your stack variables from the stack machine) and find an allocation of assigning these variables to registers while at the same time trying to minimize the amount of register spills. Even a greedy algorithm should work sufficiently well in that case.
OTOT, for what reason do you actually want to dos this anyway? Re-assemble VM code?