![]() |
|
#1
|
|||
|
|||
|
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,eax mov ebx,ecx Code:
load [sr1],[mem1] store [mem2],[sr1] load [sr1],[mem3] store [mem4],[sr1] Code:
sr = stack register mem = stack memory , i.e. scratch memory in stack mem1 = mapped as eax mem2 = intermediate memory which was suppose to be ebx mem3 = mapped as ecx mem4 = mapped in output as ebx Code:
mov eax,ebx mov ecx,eax mov edx,ecx Code:
//sample code MOV EAX,EBX MOV ECX,EAX MOV EDX,ECX MOV EDX,EBP MOV EAX,0x539 MOV EAX,EDX //transformed stack based machine code loc=00000030 (EBX) -> [sr1] [sr1] -> loc=00000000 (missing) loc=00000000 -> [sr1] [sr1] -> loc=00000004(ECX) loc=00000004(ECX) -> [sr1] [sr1] -> loc=00000008 (missing) loc=00000038(EBP) -> [sr1] const 539 -> [sr2] [sr2] -> loc=00000020(missing) [sr1] -> loc=0000003C(EDX) loc=0000003C(EDX) -> [sr1] [sr1] -> loc=0000001C(EAX) You 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. Last edited by mr.exodia; 03-01-2015 at 18:15. Reason: fixed |
| The Following User Gave Reputation+1 to Conquest For This Useful Post: | ||
ahmadmansoor (03-01-2015) | ||
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Sentinel SHK Virtual Machine | phroyt | General Discussion | 4 | 07-05-2022 23:51 |
| You do not have a Codewizard for C++ 4.3 license for this machine | matrowang | General Discussion | 0 | 05-10-2004 15:19 |
| Softice rebooting my machine | Mok | General Discussion | 4 | 09-07-2003 00:01 |