Cross compile MASM-syntax assembly with mingw on Linux
You can install JWASM (a reasonably compatible MASM assembler) to assemble the 64-bit code. Get the source code with GIT, build and install it:
git clone https://github.com/JWasm/JWasm.git
cd JWasm
cmake .
cp jwasm /usr/local/bin
To install you may have to run the last command with sudo
on Ubuntu based distros.
To assemble your code to a 64-bit COFF object file (.o
) you use:
jwasm -win64 template_x64_windows.asm
Then build a Win64 PE executable using:
x86_64-w64-mingw32-gcc template_x64_windows.o -o file.exe
Has anyone gotten MASM Assembly Language working in Wine for Linux?
use DosBox
Difference between NASM, TASM, & MASM
TASM, MASM, and NASM are x86 assemblers.
Borland Turbo Assembler (TASM) and Microsoft Macro Assembler (MASM) are DOS/Windows-based, Netwide Assembler (NASM) is available for other platforms as well. TASM produces 16-bit/32-bit output, MASM and NASM also produce 64-bit output.
All of those assemblers take the x86 instruction set as input. That does not mean that assembler source files are identical and compatible, however.
Instruction syntax
Assemblers expect either the original syntax used in the Intel instruction set documentation - the Intel syntax - or the so-called AT&T syntax developed at the AT&T Bell Labs. AT&T uses mov src, dest
, Intel uses mov dest, src
, amongst other differences.
Windows assemblers prefer Intel syntax (TASM, MASM), most Linux/UNIX assemblers use AT&T. NASM uses a variant of the Intel syntax.
Assembler-specific syntax
Assemblers have their own syntax for directives affecting the assembly process, macros and comments. These usually differ from assembler to assembler.
Compatibility
TASM can assemble MASM sources in "MASM mode".
NASM can assemble TASM code in "TASM mode". So, in theory, you can take TASM code and assemble them using NASM on Linux using that mode. Of course, the code might still need adjustments. If the code have OS dependencies, these will require your attention as well as you move from Windows to Linux.
Related Topics
How to Access Raspberry Pi Qemu Vm via Network
How Can Beaglebone Black Be Used as Mass Storage Device
Principle of Qemu CPU Emulation
How to Check Character Encoding of a File in Linux
Ansible: Check If Service Is Listening on a Specific Port
Fork() and Stdout/Stderr to The Console from Child Processes
Implementing Basic File System
Does File ".Bash_History" Always Record Every Command I Ever Issue
What Is The Fastest Way to Display an Image in Qt on X11 Without Opengl
Why Use G++ Instead of Gcc to Compile *.Cc Files
Yocto Bitbake Script Not Displaying Echo Statement
Ssh Connection to Azure Vm with Terraform
Are System Calls on Windows Inherently Slower Than Linux
Unix Domain Sockets Not Accessable Across Users