Skip to content
x86 assembler (MASM syntax) to C translator
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
asmTests Trying to fix test Jul 20, 2019
asm_emu in the middle2 Mar 11, 2017
qemu_tests fix colors. add unimplemented Jun 9, 2018
tasm Trying to fix test Jul 20, 2019
IPLAY.CFG Fix several segement specificator, but not in translator May 25, 2019
IPLAY.EXE Add leading underscores Feb 26, 2017
ISETUP.EXE add iplay setup Jul 23, 2014
README.md Update README.md Jul 11, 2019
_ida_to_tasm.sh Update and add nasm version Jul 23, 2014
_masm61.pg Implement indirect jmp, call. Numerical extentions May 22, 2018
_tasm_to_nasm.sh Update and add nasm version Jul 23, 2014
alink.exe add build script Jan 26, 2013
asm.cpp
asm.h
build Fix carry flag calculation May 27, 2018
build_masm.bat Fix scasb May 29, 2018
build_mingw.bat Trying to fix test Jul 20, 2019
build_nasm.bat improve tasm recover. add asm_emu Mar 7, 2017
build_t2.bat Fix scasb May 29, 2018
build_tasm.bat improve tasm recover. add asm_emu Mar 7, 2017
error.h
iplay.asm Update and add nasm version Jul 23, 2014
iplay.idc Minor changes and renames Jun 16, 2019
iplay.pct first commit Jan 26, 2013
iplay.png first commit Jan 26, 2013
iplay_masm.asm Minor changes and renames Jun 16, 2019
iplay_masm_.asm Minor changes and renames Jun 16, 2019
iplay_masm_.cpp Fix ncurses. Simplify variable access Jul 2, 2019
iplay_masm_.h Fix ncurses. Simplify variable access Jul 2, 2019
iplay_masm_ida.c Added inertia build instructions. Added optimized C functions file Jun 14, 2019
iplay_nasm.asm Fix ncurses. Simplify variable access Jul 2, 2019
iplay_nasm_override.patch
iprintf.asm Add qemu tests Jun 5, 2018
lzasm.exe add build script Jan 26, 2013
masm-recover Rename tasm-recover to masm-recover Dec 19, 2018
masm61.g4 Trying antlr4 May 21, 2018
mcb.h Adding BC++ 5 target support #2 Jul 19, 2019
memmgr.cpp Adding BC++ 5 target support #3 Jul 19, 2019
memmgr.h Fix unit separated compilation. Improve logging Jun 24, 2019
nomyso.pl Update and add nasm version Jul 23, 2014
test-i386.asm fix colors. add unimplemented Jun 9, 2018
test-i386.cpp Trying to fix test Jul 20, 2019
test-i386.h Trying to fix test Jul 20, 2019
test-i386_or.asm Adding qemu x86 tests Jun 3, 2018

README.md

MASM x86 to C translator 0.8

Translator may be used to port your DOS assembler code to SDL C. Since there is no working decompiler for 16 bit DOS code yet. Your porting path: DOS binary 16 bit real or 32 bit protected modes -> IDA Pro (disassembly) -> export assembler (masm format) -> Tasmx to compile (dosbox debugger to fix) -> this MASM to C translator -> C SDL source.

Optionally you can recompile resulting C to 32 bits with optimization and recompile to get cleaner C code without dead code and flags update.

Key features:

  • Most of x86 instructions (except FPU) are supported (well tested with QEMU tests). flags: Carry, Zero, Sign are supported for most of x86 instructions.
  • Segment memory model and 16bit offsets.
  • Some BIOS/DOS Int 10h, 21h interrupts are supported. Also DOS memory manager and stack.
  • CGA text mode is supported using Curses (PDcurses or NCurses).
  • VGA 320x200x256 support (partial)

3 party code used: ASM2C (x86 instruction emulation), tasm-recover (from SCUMMVM project; highly modified), QEMU x86 test suit, FreeDOS memory manager.

License: GPL2.

Sure ASM2C have cleaner code and good parser but it written on Swift and less instructions supported, also only protected mode.

TODO:

  • equ out of segment/proceedure
  • macros support
  • full VGA/EGA
  • better parser based on Masm EBNF
  • proper SB emulation or use DOSBOX as library
  • add FPU instructions support
  • better keyboard

Also to easier disassembling (exe to asm) need to collect run-time information from dosbox or other emulator to annotate IDA disassembly. Maybe modify dosbox debugger tracing mechanism to collect:

  • current instruction is code
  • access to memory (which segment), offset which segment
  • segement register value

To build resulting disassembly I use uasm(jwasm)/masm6, link5/tlink. See uasm\Samples\Dos\ for examples.

See list of DOS games with debug information http://bringerp.free.fr/forum/viewtopic.php?f=1&t=128

Execute to convert your masm 16 bit source to C:

masm-recover <some.asm>

(Some small resulting source code modification will be also required to build)

IDA Pro Free https://www.scummvm.org/news/20180331/

Inertia Player 1.22 source code

Famous reverse engenerred MOD, S3M player. Currently platform DOS (ASM), SDL2 (C++) There is source code for MASM, TASM Ideal and Nasm, gcc which can be built and running

TODO: fix sound on SDL, finish porting (keyboard, graphics mode,...)

Binary is available on releases page

Building Inertia for SDL from source:

  1. get PDCurses or other curses library+headers, SDL2, mingw32
  2. build_mingw.bat
  3. execute: iplay_masm.exe HACKER4.S3M
You can’t perform that action at this time.