M-HT / SR

A project to statically recompile following games to create Windows or Linux (x86 or arm) versions of the games - Albion, X-Com: UFO Defense (UFO: Enemy Unknown), X-Com: Terror from the Deep, Warcraft: Orcs & Humans, Septerra Core: Legacy of the Creator, Battle Isle 3: Shadow of the Emperor
305 stars 17 forks source link

16 bit -> 32 bit translation #47

Closed xor2003 closed 2 years ago

xor2003 commented 2 years ago

Hello, I have wrote a tool for source to source translation for 16 bit games with segment model into C++ fake-asm. https://github.com/xor2003/masm2c And for each 16 bit assembler instruction I have precise copy implemented in C++. The instructions are checked while running game in dosbox. https://github.com/xor2003/libdosbox We are thinking of binary translation of 16 bit instructions into 32 bit to use usual decompilers. https://www.youtube.com/watch?v=MzK9RVgeWGM Do you know some information which can help?

xor2003 commented 2 years ago

I am emulating assembler instructions using C++ inline functions like: template<class D, class S> MYINLINE void ADD_(D &dest, const S &src, m2c::eflags &m2cflags) { D result = dest + (D) src; AFFECT_CF(result < dest); const D highestbitset = (1 << (m2c::bitsizeof(dest) - 1)); AFFECT_OF(((dest ^ src ^ highestbitset) & (result ^ src)) & highestbitset); dest = result; AFFECT_ZFifz(dest); AFFECTSF(dest, dest); } You have experience with LLVM and LR. Is it possible to tell compiler to use frow away the above flag emulation and use hardware flags results? So we could use 32 decompiler on it.

M-HT commented 2 years ago

Is it possible to tell compiler to use frow away the above flag emulation and use hardware flags results?

No, to use hardware flags results you would have to emit assembler instructions instead of c/c++ code.

xor2003 commented 2 years ago

Thank you. Trying it already https://godbolt.org/z/fdcza8E7f

xor2003 commented 2 years ago

Thank you. Trying it already https://godbolt.org/z/fdcza8E7f