Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How Ida to dosbox pseudo code is done? #49

Open
xor2003 opened this issue Jul 19, 2019 · 3 comments
Open

How Ida to dosbox pseudo code is done? #49

xor2003 opened this issue Jul 19, 2019 · 3 comments

Comments

@xor2003
Copy link

xor2003 commented Jul 19, 2019

I'm doing similar thing with my masm2c.
How did you converted ida/asm to dosbox pseudo instructions?

@Henne
Copy link
Owner

Henne commented Jul 19, 2019

Hi xOr,

this process has been done manually by me, since I know C and x86 assembly very well.
The code, I have translated, was not optimized by the compiler, so it was a straight forward process.
I also have the compiler, Borland C++ 3.1, which has been used to compile that binary.
So I did the following for each function separately of the original binary:

  1. analyze the code of the function
  2. write that code in C
  3. compile the C code again with Borland C++ 3.1
  4. compare the binary code of the rewritten function with the binary code of the original
  5. When they differ goto 1. When they are the same DONE.

There are no DOSBox pseudo instructions, a rewritten function is executed natively on the host processor.

I've hooked into the two call instructions of the software DOSBox-CPU.
If a function I have rewritten is called:

  1. I get the parameters from the stack
  2. call my rewritten function with the parameters
  3. place the return value of the function into register AX
  4. skip the emulation of that function call

Otherwise DOSBox emulates that function call.

But I think, that will not help you for masm2c, since you are doing something general with that.
I had only a special case.

I hope to find time next month to reactivate Bright-Eyes,
and I'll try out masm2c on one function which I did not managed to translate correctly.

Feel free to ask, if you want more details.

@xor2003
Copy link
Author

xor2003 commented Jul 21, 2019

Thanks mostly clear and interesting. I will try to prepare Borland C++ Dos as target of my translator.

@xor2003
Copy link
Author

xor2003 commented Jul 21, 2019

Testing resulting code on Dos might be easier before porting sound, graphics, etc to SDL.
The problem is reversed code is a code modification and no tests available.
Good solution for it is binary equality as in your case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants