Almost 30 years after MASM 6.0, It is still being used for educational purposes worldwide.
The 16 bit MASM is what is being taught.
I use linux and am quite pained that not a single MASM assembler is available.
1.Wine does not work
2.DOSBOX does not run the linker
3.I don't have an windows XP cd to run in a VM
4.My only windows computer is windows 8.1, which does not support MASM
People suggest NASM but the syntax is not same as a 16 bit MASM assembler.
Is it illegal to make a MASM for linux, or any windows 7 and above??
I was thinking about coding a simple one for educational purposes myself.
Related
Can somebody explain the differences between: masm, tasm, & nasm?
Why can't I run tasm code on linux? Are they different languages?
I thought that assembly language was unique for all systems.
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.
I am teaching myself/reading up about assembly. Most of the books on assembly refer to x86- all the register names in the code begin with "e" and not "r" (as they would in x86-64). However, I use 64-bit Linux and I was wondering if these books have any value because they are not referring to x86-64.
So in short- is it really worth me using these resources to learn x86-64. Or reworded differently, besides the difference in register naming convention- are there any other differences between the two which could make learning from x86 materials difficult?
64 bit Linux allows running 32bit applications, so you still can create 32 bit applications on your computer. This way, the books and example 32 bit code are fully useful.
The only single problem you might have is if the assembly application dynamically link to some 32 bit shared library. In order to fix this you should install 32 bit compatibility layer.
The assembly programs that use only Linux system calls works fine without this layer, which is actually set of shared libraries compiled for 32 bit.
BTW, in my opinion, writing 32 bit code is still better if you want your programs to be useful for more people. There are still many 32 bit computers around and they will not disappear soon.
It's indeed a bit easier to learn assembly on 32bit since the calling conventions and stack management are simpler.
On 64bit you need to worry about ABI. Not only that but the conventions are not the same for every OSes. For instance, the ABI rules on Mac OS X are different than those on Windows (the registers are not the same and on Windows it only uses 4 registers).
You can compile your assembly code using -arch i386 with the assembler (as). With clang or gcc you can use -m32 (at least on Mac OS X, since I haven't used it on Linux proper). You won't be able to link modules that have different bitness (32bit vs 64bit).
Once you're ready to switch or compile your program for 64bit you will have to make sure that when you handle the stack you need to push 64bit words instead of 32bit ones but that kinda goes with saying.
I'm going to port a large C++-Project to x64 (some parts of it are written about 15 years ago) and I found that the 64-bit compiler does not support inline assembly, so I have to change the code. I would like to know if there are more differences or incompatibilities between both compilers. Or the better question would be are there parts of 32-compiler which 64-compiler does not suport.
Relevant articles:
The forgotten problems of 64-bit programs development
Seven Steps of Migrating a Program to a 64-bit System
Collection of Examples of 64-bit Errors in Real Programs
I am interested in programming assembler for Intel x86 architecture and on Linux. After some initial research this lead me to believe out of FASM, NASM and MASM I wanted NASM.
From this point on, how easy is it to write a NASM assembler "text file" on Linux and execute it? Is it relatively simple? What packages (gcc etc) do I need to ensure are installed? Does anyone know any walkthrough guides? I havent been able to find anything yet. Does it matter which linux distro?
You don't say what flavor of Linux. On Ubuntu, install is as simple as sudo apt-get install nasm. After that, you might start at the NASM Project's links page, which will lead you to approximately a zillion tutorials.
The best one that I have found on the web, is John Carter's PC Assembly. It aim NASM, it's comprehensive, yet conscious and also it aims at Linux and Nasm.
All you need to know to start, can be found in first few chapters. Also it's been published under GPL licence .
Is there a way that I use MASM under Linux. Even tough NASM is quite popular under Linux, it still differs for some instruction style on code.
Wiki says
The MASM32 EULA does not allow its usage in the development of open source software, and only allows it to be run in Windows operating systems.
so it is a no.
I use DosBox and it does work fine for me.
Details here
You should be able to run MASM under Wine.
MASM dont run with WINE, im running MASM under Virtual Box
Personally I prefer the NASM style, but you can probably run MASM under Wine (or failing that, in a VM). After all it shouldn't need any exotic API calls.
I've been able to run the Win32 NASM binary under Wine on Linux without any problems [long story, no net connection].
If you want to convert Microsoft's OMF binary format to ELF then you should be able to do so using objcopy, but you may need to compile in support for the right object formats.
Run MASM under Wine or see at the wiki that MASM can only run at Windows.
Regards.
An alternative to MASM is UASM.
UASM is a free MASM-compatible assembler based on JWasm.
It works for creating general Linux binaries.
However, shared objects requiring the -fPIC option is not possible with UASM.