![]() |
Stack Machine to Register Machine
1st of all i want to state that my question may be invalid in sense that the documents i am asking for doesnt exists at all. SO please correct me if you think so .
Can someone point to some documents on converting assembly from stack based architectures to register based architecture . Currently i am working on vmp vm which converts the x86 machine to stack based machines by replacing register locations intermediate stack locations . I have studied compiler documents on stack machines but so far i havent found any documents which guides me to convert the machine structure from one to another. Biggest issue i am facing is loss of intermediate register data . what i mean is right side registers are always converted into stack locations and then dont always link together. If we have something like this Code:
mov ebx,eaxCode:
load [sr1],[mem1]Code:
sr = stack registerCode:
mov eax,ebxCode:
//sample codeYou will see several intermediate stack locations cant be deducted and it is not safe to allocate any register to them randomly as this may corrupt the assembly . i am looking for expert advice in this area(specially people with compiler design knowledge) about how to map registers and what kind of knowledge do i need to solve this. |
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,ebxCode:
mov ebx,eaxOTOT, for what reason do you actually want to dos this anyway? Re-assemble VM code? |
Quote:
Thanks for your info anyway. I will look forward to have advice from more people involved in this area. |
Also see this discussion on hackernews on stack vs register machines and the corresponding article.
|
Quote:
PS:couldnt give a thanks for the help for not being a family member. |
Also see MS' JIT compiler which is now open source: https://github.com/dotnet/coreclr
|
| All times are GMT +8. The time now is 05:26. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2026, vBulletin Solutions, Inc.
Always Your Best Friend: Aaron, JMI, ahmadmansoor, ZeNiX