News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

In which programming language is MASM written in?

Started by RulerL0rd, September 01, 2016, 11:37:47 PM

Previous topic - Next topic

RulerL0rd

Greetings. I just started using MASM. We write assembly code in MASM.

What language was used to create MASM? It should be a low level, programming language correct?

jj2007

Good question! I've had a look at the disassembly and the import names, and can't see any typical C stuff. So probably MASM was coded in MASM 8)

Welcome to the Forum :icon14:

johnfound

But we can't be sure, because it is closed source. ;) Do someone tried to simply ask MS?

GoneFishing

Hi,
A long ago I read somewhere on the internet about leaked NT4 source code and there it was mentioned that MASM 5.NT.02 was written in C

P.S.: I think that earlier versions of MASM might be written entirely in assembly or contain large part of assembly code

P.P.S: What we're able to check are  MajorLinkerVersion /  MinorLinkerVersion fields of PE Optional headers  

RulerL0rd

Oh MASM is a closed system? You were kidding about MASM being coded in MASM right?

Yes C is the most likely option i believe. But we can't be sure. It may even be binary code but we don't know.

RulerL0rd

Quote from: GoneFishing on September 01, 2016, 11:52:56 PM
Hi,
A long ago I read somewhere on the internet about leaked NT4 source code and there it was mentioned that MASM 5.NT.02 was written in C

P.S.: I think that earlier versions of MASM might be written entirely in assembly or contain large part of assembly code

In order for the program to be written in assembly, then an other assembler was used to disassemble it, right, or am i confused?

GoneFishing

Quote from: RulerL0rd on September 02, 2016, 12:09:45 AM
...
In order for the program to be written in assembly, then an other assembler was used to disassemble it, right, or am i confused?

To learn the answer to your question you'd dive into the history of MASM and MS from DOS times :

http://bytepointer.com/masm/index.htm

Origins of MASM
:

Quote
After some guesswork as to the origins of MASM being possibly related to the 8086 Assembler created by Tim Paterson of SCP (Seattle Computer Products), I was able to contact him for his help in clearing things up. Tim Patterson, the original creator of DOS and the famous DEBUG.COM, wrote an 8086 assembler (ASM) to assemble 86-DOS, the prececessor to MS-DOS. Here is what he said:

MASM was written in Pascal by Marc McDonald (Microsoft employee #1, after Bill & Paul). Microsoft had been doing all their development on DEC computers, and the macro capability put in MASM was modeled after DEC assemblers. Because MASM was such a large macro assembler, one of the guys referred to it as "McDonald's big mac".
...
MASM does not have lineage back to M80. It was written specifically for the 8086 and attempted some level of compatibility with Intel's 8086 assembler. I remember it was different from what I was used to. When MS bought DOS from SCP I was at MS. After finishing up DOS 1.0, I translated DOS from SCP's assembler to MASM, and I needed Marc to explain some of the syntax to me.

He also had the following to say about his 8086 Assembler he wrote while at SCP:

The 8086 assembler I wrote originally was in Z80 assembly language and ran under CP/M. I believe it was distributed with the SCP 8086 CPU card as ASM86. I also wrote a translator that converted Z80 source code to inefficient but workable 8086 source code (Intel promoted this idea with a published translation table). This was called TRANS86 and was also written in Z80 assembly for CP/M. Once DOS was working, I applied the translator to ASM86 (and to itself) to create 8086 versions that ran under DOS. I do not have the change history in front of me (I see you deleted it from your history page), but I believe that versions >= 2 marked the translated (DOS) version. If any history shows version numbers < 2, that was the CP/M version.

Although the SCP 8086 Assembler was used to build early versions of DOS (86-DOS, MS-DOS 1.x), Microsoft's major rewrite of DOS 2.0 included changing the build system to use Microsoft's own assembler, MASM. More information about Tim's 8086 Assembler (ASM) can be found at the Computer History Museum's Microsoft MS-DOS early source code article. From here you may download the now freely available MS-DOS 1.1 and 2.0 source code which includes the source code to Tim's 8086 Assembler and the Z80 to 8086 translator.

jj2007

Microsoft's major rewrite of DOS 2.0 included changing the build system to use Microsoft's own assembler, MASM.

So DOS was written in MASM. Nice. Anyway, the disassembly of ML 6.14 didn't look like C, so it might as well be Pascal.

rrr314159

@RulerLOrd,

Just to clear up a point you might be confused about: it's entirely possible for a language to be written in itself. Obviously the first version can't be, but once that's working it's not at all uncommon to rewrite it using itself, and the same for all subsequent upgrades. You may have heard of HJWasm, an alternative to MASM which many of us use, which is (almost) 100% compatible, plus contains many improvements. It's written in C, but one of its developer's goals is to re-write it using itself. There's nothing odd or paradoxical about it.

I would have thought modern MASM was written with both C (++) and MASM, like most of Microsoft's code, but I don't know.
I am NaN ;)

GoneFishing

For better understanding of life read Microsoft 1978

Note EW ( estimated worth ) of Marc McDonald  the author of first MASM   



MichaelW

Looking at ML64 in an editor, it contains a list of CRT error messages, so I would assume that it was coded in C/C++, which is a reasonable guess for any sort of commercial software.
Well Microsoft, here's another nice mess you've gotten us into.

TWell

From here
Quote
Version 4.0 of the Microsoft Macro Assembler (MASM) has been optimized to improve performance. It now assembles code two to three times faster than any prior release. In addition, the input/output buffers and macro text have been moved out of the symbol space, allowing assembly of larger source files.

This was the first version of MASM written in Microsoft C as indicated in the Microsoft Languages Newsletter below. All previous versions (or at least some) were written in Pascal. A binary analysis of this version confirms this with evidence of linking with the C-Runtime libraries.


jj2007

Quote from: GoneFishing on September 02, 2016, 02:05:38 AM
Note EW ( estimated worth ) of Marc McDonald  the author of first MASM

He could sell his badge :P

hutch--

The answer to the original question is simple, MASM from version 6.00 onwards is written in C. If you ever bothered to look at the guts of any of the 32 bit versions you check how the stack entry and exit is done. It does look like some of the modules used in MASM were written in assembler and you can tell this from the LEAVE mnemonic on proc exit.