lefticus / 6502-cpp

The Unlicense
243 stars 44 forks source link

Feature request: calling disassembler and assembler for the user #5

Open xcvista opened 7 years ago

xcvista commented 7 years ago

This can be fairly convenient, as the user can input an executable file and this app can spit out another executable, ready to go. Example:

x86to6502 i8086-test-executable.com -o 6502-test-executable.bin

Or this:

i8086-gcc test.c -S -o - | x86to6502 -o 6502-test.bin
lefticus commented 7 years ago

A problem with your request is that I cannot really work with something that's already been linked into an executable - it has too much extra data in it. You really just need the compiled object file to pass through.

dr-m commented 7 years ago

x86to6502 translates from a subset of i80386 symbolic assembler, and not from i8086 at all. It is also a ‘lossy’ translator, translating 32-bit arithmetics into 16-bit arithmetics implemented in the 8-bit instructions of the 6502. Following the Unix philosophy, the suggested pipeline should be extended with two separate tools: an x86 disassembler whose output would be fed to x86to6502, and a 6502 assembler such as dasm, ca65, xa, or the ‘TMPx’ mentioned in make_file.sh. (Apparently, TMPx is Turbo Macro Pro cross-assembler, which appears to be aiming to be compatible with some assembler that was popular among some Commodore 64 programmers). A bigger problem is that the linked x86 executable would likely use some interfaces to the operating system and some hardware, making the input dependent on a particular operating environment. In its current form, the x86to6502 translator is operating system agnostic, only translating CPU instructions and not implementing any abstraction layers. If it was extended with some run-time library that would (for example) emulate some Win32 APIs, then this run-time library would have to be ported to each supported 6502 system (various Commodore models, Apple, Tangerine Oric, …), using the interfaces provided by the target operating system and hardware.