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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

16 bit -> 32 bit translation

xor2003 opened this issue · comments

commented

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?

commented

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);
AFFECT_SF_(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.

commented

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.

commented

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

commented

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